Great article, Ron!
ICD, DSM, SNOMED, and other classifiers on Coruscant must be crazy.
- Log in to post comments
Great article, Ron!
ICD, DSM, SNOMED, and other classifiers on Coruscant must be crazy.
I think projecting as an attribute is enough. Here's an example:
Class Utils.Message Extends (%RegisteredObject, %XML.Adaptor)
{
Parameter XMLNAME = "ID";
Property scope As %String(XMLPROJECTION = "ATTRIBUTE");
}DTL:
Class Utils.DTL Extends Ens.DataTransformDTL
{
XData DTL [ XMLNamespace = "http://www.intersystems.com/dtl" ]
{
<transform sourceClass='Ens.Request' targetClass='Utils.Message' create='new' language='objectscript' >
<assign value='"Message"' property='target.scope' action='set' />
</transform>
}
/// do ##class(Utils.DTL).Test()
ClassMethod Test()
{
set source = ##class(Ens.Request).%New()
#dim target As Utils.Message
set sc = ..Transform(source, .target)
do target.XMLExportToString(.xml)
w xml, !
}
}Results in:
>do ##class(Utils.DTL).Test()
<ID scope="Message"></ID>My recommended approach is to call routines in a silent mode if at all possible, or to do minimal modifications to add silent mode. But here's how you can work with read using input redirection:
ClassMethod Test() [ ProcedureBlock = 0 ]
{
set tOldIORedirected = ##class(%Device).ReDirectIO()
set tOldMnemonic = ##class(%Device).GetMnemonicRoutine()
set tOldIO = $io
try {
set str=""
//Redirect IO to the current routine - makes use of the labels defined below
use $io::("^"_$ZNAME)
//Enable redirection
do ##class(%Device).ReDirectIO(1)
set x = ..MyLegacyRoutine()
} catch ex {
do ex.Log()
}
//Return to original redirection/mnemonic routine settings
if (tOldMnemonic '= "") {
use tOldIO::("^"_tOldMnemonic)
} else {
use tOldIO
}
do ##class(%Device).ReDirectIO(tOldIORedirected)
w !,"x is: ",x,!
w "Routine wrote to device: ", str
//Labels that allow for IO redirection
//Read Character
rchr(time) quit "a"
//Read a string
rstr(len,time) quit "xyz"
//Write a character - call the output label
wchr(s) do output($char(s)) quit
//Write a form feed - call the output label
wff() do output($char(12)) quit
//Write a newline - call the output label
wnl() do output($char(13,10)) quit
//Write a string - call the output label
wstr(s) do output(s) quit
//Write a tab - call the output label
wtab(s) do output($char(9)) quit
//Output label - this is where you would handle routine device output.
//in our case, we want to write to str
output(s) set str=str_s quit
}
ClassMethod MyLegacyRoutine()
{
read "Input x: ",x
write "Hello!"
return x
}
}It outputs:
x is: xyz
Routine wrote to device: Input x: Hello!February 31st?
The easiest way would be to run on the first day of a month and send results for a previous month.
Another way you can do it is to create a schedule which runs 9:00 am to 9:30 am every day (or 28-31) and checks if this is a last day of a month before doing anything.
Schedule is limited to Max String length, so you can also generate a very long schedule once. For example this code would produce a schedule for the next 10 years:
/// date - start date. Must be the last day of the month.
/// months - how many months to generate
ClassMethod Test(date = "2024-09-30", months = 120)
{
while $i(months,-1)>=0 {
set year = $system.SQL.DATEPART("year", date)
set month = $tr($j($system.SQL.DATEPART("month", date), 2), " ", 0)
set day = $system.SQL.DATEPART("day", date)
write $$$FormatText("START:%1-%2-%3T09:00:00,STOP:%1-%2-%3T09:30:00,", year, month, day)
set date = $system.SQL.DATEADD("day", -1, $system.SQL.DATEADD("month", 1, $system.SQL.DATEADD("day", 1, date)))
}
}Schedule
If you're okay with February 28th for leap years a schedule can be simplified to 12 entries with * in the year.
If all of the above is not an option create a separate Business Service which runs on a first day of a month, calculates last day of a month and sets a correct schedule for BO.
$System.OBJ.Load() your installation routine?
WQM is a recommended and preferred approach, but here's an article which might be helpful to you.
Congratulations, Benjamin!
While I agree that ideally you'd run two IRIS nodes in two geographically close but fully separate datacenters, running IRIS in a mirror with both servers in the same datacenter still provides protection from:
In addition to that datacenters often allow users to specify placement strategy. Select spread placement strategy to avoid hosting both servers on the same underlying hardware if possible.
So mirroring in this scenario still provides a lot of advantages.
Sure, you have two approaches:
XMLPROJECTION=NONE for the properties you want to skip%ShowContents method for your message class to skip some of the properties (check Ens.Util.MessageBodyMethods for a sample implementation).What BO are you using?
Done
In that case you need to implement REST API and call that.
Are you in the interop context? If yes, SendSync/SendAsync should be available for you.
If not, check this article.
Use %Classname(1) method?
Can you copy FOP to two places (or each job at a start copies FOP to it's own dir) and call it in parallel after that. Would that work?
I recommend using embedded python and boto3.
I agree that
[ CodeMode = objectgenerator ]is certainly outside of this code golf conditions (method signature should not be changed), but it's still a creative example.
^IRIS.Msg("EnsColumnsNAMESPACENAME,"en"Can be mapped to your DB, so you won't lose the changes on update (and also you won't need to make ENSLIB RW).
*i is a great idea.
There are to valid ways to solve this code golf:
Both approaches are valid, sample solution uses approach 1.
"Print out" is any output the program produces so if you for example add 1/0 at the end it might save you a few characters.
Well, in that case you might as well do this (down to 41):
ClassMethod ascii() [ CodeMode = objectgenerator ]
{
f i=0,27,0:1:94 d %code.Write($c(i+32))
}I am very interested how compilation flags help you with this.
it's like cheating
Reflective programming is not cheating!
42 characters so far.
Pinging @Stefan Wittmann
Class methods are recommended for use in all cases.
While classes provide an overhead, this is usually negligible.