Julian Matthews · Sep 6, 2023 go to post

This is a rather subjective based on the skill level of the intended audience.

You could add a comment to the ClassMethod to provide context to what is being done and why. For example:

/// This ClassMethod takes a delimited String from System-X that consists of sets of Questions and Answers. 
/// The Sets are delimited by a pipe "|" and then the questions and answers are delimeted by a colon ":"
/// The response from this ClassMethod is a %Library.DynamicArray object containing the questions and answers
ClassMethod createResponse(data As %String(MAXLEN="")) As %Library.DynamicArray
{
    ;1.- Questions splitted by "|"
    Set listQuestions 			= $LISTFROMSTRING(data, "|")
    Set items 			= []
    Set questionNumber 	= 0
    ;2.- Iterate
    For i=1:1:$LISTLENGTH(listQuestions) {
        Set questionAnswer = $LISTGET(listQuestions, i)
        ;3.- Update variables
        Set questionNumber 	= questionNumber + 1
        Set question 		= $PIECE(questionAnswer, ":", 1)
        Set answer 		    = $ZSTRIP($PIECE(questionAnswer, ":", 2), "<W") //Get rid of initial whitespace
        ;4.- Generate item
        Set item 			= 									
        {
        "definition": ("question "_(questionNumber)),
        "text": (question),
        "answer": 
        [
            {
                "valueString": (answer)
            }
        ]
        }
        Do items.%Push(item)
    }	
    Quit items
}

Or you could go one step further and be more descriptive with your comment at each action within your code. So, instead of:

;2.- Iterate

You could write something like:

;2.- Iterate through the list of Questions and Answers

If your intended audience is not familiar with ObjectScript, then you may want to introduce them to features in stages. For example, you could use $ZSTRIP on both the question and answer in your For loop, but only nest it for the answer and use comments to describe it all. Something like:

// Retrieve the question from the delimited entry
Set tQuestion = $PIECE(questionAnswer, ":", 1)

// Strip any whitespace from the start of the question
Set question = $ZSTRIP(tQuestion, "<W")

// It is also possible to nest functions, so below we will retrieve the answer and remove the whitespace in a single line.
Set answer = $ZSTRIP($PIECE(questionAnswer, ":", 2), "<W")
Julian Matthews · Jul 1, 2023 go to post

If you were to use the Parenthesis () Syntax in your routing rule, you could simply make your rule something like:

The reason this works is that using the parenthesis syntax to access repeating values from a message will return all of the entries in the repeating segment as a *delimited string, and you can then check the string contains the - character using the contains function.

*Do make sure that the delimiter isn't the character you're looking for. Maybe throw in a trace when you first test this and check how it's returned.

Julian Matthews · Jun 26, 2023 go to post

Hey Guillaume.

Funnily enough - it's one of your github repos where I located the demo I'm trying use as a jumping off point (but from https://github.com/grongierisc/InstallEnsDemoHealth/blob/master/src/CLS/Demo/DICOM/Process/WorkList.cls)

Basically, I'm stuck trying to work out if I should scrap the wakeup calls etc, and just call the external data when I get a C-FIND-RQ message and then call "CreateIntermediateFindResponse" for each result set entry, or if it's necessary to use the wakeup calls and somehow hold the result set in context and move to the next result set entry on each Ens.AlarmResponse received.

ETA: The approach taken was to use the initial message as a trigger to call off to an external db, and write the results into a local table, and then use the Ens.AlarmResponse as the trigger to grab the top entry from the local table and return this to the calling system. This then allows for a cancel to come in and interrupt the process (the cancel will trigger a deletion of the appropriate rows in the local table)

Julian Matthews · Jun 6, 2023 go to post

Hey Michael.

A good use of a lookup table would be when working with an integration between two systems that use differing codes for the same values.

For example, you could have System A that records Sex as 1 for Male, 2 for Female, 0 for Not Known, and 9 for Not Specified, whereas System B uses M for Male, F for Female, and O for Other.

You could have a winding If/Else in a transform, or you could simply reference a lookup table in your DTL using the ..Lookup() function:

and then build up your lookup table to look like this:

As you can see, System A has more values than System B so the values for Not Known and Not Specified are being added as Other in my example.

Another example could be you needed to filter messages in a router based on a code within the HL7 message. You could add the codes to a lookup table as the key and a description as the value, and then use the Exists() function within your routing rule:

 

Which becomes:

Julian Matthews · May 17, 2023 go to post

Hey Jon.

One option could be to change the permissions for the source directory to be read only for the account running Ensemble/Healthshare? This way, the adapter will copy the file from the directory but will then be unable to delete it from the directory, while also keeping track of what files it has copied.

The log for the passthrough service will be a bit messy at first. but you'll end up with something like:

However, if the directory you're going to be checking for documents will be an ever growing list of a large number of documents, then your own suggestion of copying the files into a secondary working directory before being picked up by ensemble might actually be the best option as there's a bit of an overhead for the adapter when it's scanning a directory that contains a large number of files.

Depending on how soon after the files creation you need it for onward processing, you could create a scheduled task that copies all files from the previous day into your working directory and then sends an email if that fails for any reason?

Julian Matthews · Apr 19, 2023 go to post

Hey Kurro.
I'm not sure of a built in function for this, but if you wanted to have your own:

Class Demo.FunctionSets.Example
{

ClassMethod Format(InputString As %String, Params... As %String) As %String
{
	Set OutputString = InputString
	For i = 1 : 1 : $GET(Params, 0){
		Set OutputString = $Replace(OutputString,"{"_i_"}",Params(i))
	}
	
	Quit OutputString
}

}

And then:

Write ##Class(Demo.FunctionSets.example).Format("My name is {1} and I'm {2} years","Kurro","18")
My name is Kurro and I'm 18 years
Julian Matthews · Apr 19, 2023 go to post

StackOverflow suggests using svglib and reportlab to achieve this with python:

from svglib.svglib import svg2rlg
from reportlab.graphics import renderPM
drawing = svg2rlg("my.svg")
renderPM.drawToFile(drawing, "my.png", fmt="PNG")
Julian Matthews · Apr 13, 2023 go to post

I would recommend approaching this in three parts:

  1. Create a custom message class for your target system.
  2. Use a DTL to transform your HL7 into your custom message class
  3. Use a custom File Operation to write the file output based on your custom message class

For #1, this could be as basic as:

Class Demo.Messages.SystemX.CustomBody Extends Ens.Request
{

Property Param1 As %String;

Property Param2 As %String;

Property Param3 As %String;

Property Etc As %String;

}

For #2, your transform would then be something like:

And then for #3, your file operation would be something along the lines of:

Class Demo.Operations.SystemX.FileWriter Extends Ens.BusinessOperation
{

Parameter ADAPTER = "EnsLib.File.OutboundAdapter";

Property Adapter As EnsLib.File.OutboundAdapter;

Parameter INVOCATION = "Queue";

Method OnMessage(pRequest As Demo.Messages.SystemX.CustomBody, Output pResponse As Ens.Response) As %Status
{

	Set Line1 = pRequest.Param1_"|"pRequest.Param2
	Set Line2 = pRequest.Param3_"|"pRequest.Param4
	Set Line3 = pRequest.Param5_"|"pRequest.Param6
	Set outString = Line1_$C(13)_$C(10)_Line2_$C(13)_$C(10)_Line3_$C(13)_$C(10)
	
	Set fileName = "Filename"
	Set sc = ..Adapter.PutString(fileName_".dat",outString)
	Quit sc
}

}

Please note that the above is a super rough draft - there's no error handling, and you'd need to consider how you'd make the filename unique per message, but I'm hoping this gets you on the right path.

Julian Matthews · Mar 27, 2023 go to post

Hi @Evgeny Shvarov 

I don't have anything immediately to hand as I still feel that the reuse of code in Step 3 from the original class method is not best practice, although I do have this running in a live production for 2-3 operations where this was needed.

I will try and see if I can get something put together that can be exported and put onto the Open Exchange. Just a warning, I'm not one for Docker, so it'll be a Production deployment export smiley

Julian Matthews · Mar 21, 2023 go to post

Hey Yuri.

The users are held within the SQL table "Security.Users" in the %SYS namespace, so you could use embedded sql to return the information, however as you're unlikely to be executing your code directly from the %SYS namespace, I'd suggest creating a function that you pass the email address, and it returns the username.

Something like:

Class Demo.Utils.General.Users
{

ClassMethod UserFromEmail(Email As %String, Output Username As %String) As %Status
{
	//Initially set this to null, as we want to return it empty when we get no results
	Set Username = ""
	//Hold the Namespace within a variable so we can use the variable to set the namespace back once the SQL has been run.
	Set CurrNamespace = $NAMESPACE
	//Change NameSpace to %SYS
	Set $NAMESPACE = "%SYS"
	//Run query to get the Username based on the email address - note the use of the UPPER function to remove issues with case sensitivity
	&SQL(
	Select ID into :Username
	FROM Security.Users
	WHERE UPPER(EmailAddress) = UPPER(:Email)
	)
	
	//Set namespace back to the namespace the function was run from
	Set $NAMESPACE = CurrNamespace
	
	//Evaluate SQLCODE for result
	//Less than 0 is an error.
	If SQLCODE <0{
		WRITE "SQLCODE="_$SYSTEM.SQL.Functions.SQLCODE(SQLCODE)
		QUIT 0
		}
	
	//Greater than 0 can really only mean Code 100, which is no results found.
	If SQLCODE > 0 {
		QUIT 1 //No Result Found
		}
	Else {
		QUIT 1 //Result Found
		}
}

}
DEMO> WRITE Class(Demo.Utils.General.Users).UserFromEmail("YuriMarx@ACME.XYZ",.Output)
1

DEMO> WRITE Output
YMARX

This is by no means perfect as I have thrown it together for the example - please forgive the messy if/else's! smiley

Julian Matthews · Mar 14, 2023 go to post

There's a few "gotchas" when it comes to Character Encoding. But the key thing in you case is understanding the character encoding being used by the receiving system. This should be something specified in the specification of the receiving system, but many times it's not.

If I had to guess, it's most likely that the receiving system is using UTF-8 simply because latin1/ISO-8859-1 encodes the pound symbol as hex "A3" whereas UTF-8 encodes to  "C2 A3". As there's no solitary "A3" in UTF-8, there's nothing to print, which is why you get the ? instead. I'm sure there's other character sets where this can happen, but I would start there.

Julian Matthews · Jan 18, 2023 go to post

Hey Joe.

To quickly answer your second question: you will want to take a look at the table Ens.MessageHeader which contains the Session ID, and then the Ens.MessageBody which is linked to the Ens.MessageHeader on the field "MessageBodyId".

Julian Matthews · Jan 13, 2023 go to post

Hi Thomas.

Are you trying to connect to the same API endpoint from Test and Live?

Is it possible that the end point is performing IP filtering so your request from the Live server is being rejected?

Julian Matthews · Nov 16, 2022 go to post

Hey Andy.
When you're copying the router from your production, it will continue to reference the same rules class in the settings as per:

After you have copied the Router, you will want to hit the magnifying glass and then use the "Save As" option in the Rule Editor. After you have done this, you can then go back to your Production and then change the rule assigned to your Router via the drop down to select the new rule.

Just make sure you create a new alias for your Rule on the "general" tab on the rule page. 

Julian Matthews · Nov 9, 2022 go to post

Hey William.

I'm pretty sure you just need to query the table Ens.MessageHeader.

This should give you the process by way of the column SourceConfigName, and the status of the discarded messages.

For example:

SELECT *
FROM Ens.MessageHeader
WHERE SourceConfigName = 'ProcessNameHere' AND Status = 'Discarded'

You may want to consider including a time range depending on the size of the underlying database.

Julian Matthews · Oct 28, 2022 go to post

I ended up extending EnsLib.HL7.Operation.TCPOperation and overwriting the OnGetReplyAction method.

From there, I coped the default methods content but prepended it with a check that does the following:

  • Check pResponse is an object
  • Loop through the HL7 message in hunt of an ERR segment
  • Checks value of ERR:3.9 against a lookup table

If any of the above fail, the response message is passed to the original ReplyCodeAction code logic, otherwise it quits with the result from the Lookup Table.

The use of the Lookup Table then makes adding/amending error actions accessible to the wider team rather than burying it within the ObjectScript, and having the failsafe of reverting to the original ReplyCodeAction logic keeps the operation from receiving an unexpected error and breaking as it has the robustness of the original method.

Julian Matthews · Oct 25, 2022 go to post

Hey Patty.

If you just simply need the empty NTE to be added in using the DTL, you can set the first field to an empty string to force it to appear.

For example:

Will give this:

Note that my example is simply hardcoding the first OBX repetition of every first repeating field with no care for the content. You will likely need to do a for each where you evaluate if the source NTE:1 has a value, and then only set to an empty string if there is no content in the source.

Julian Matthews · Oct 21, 2022 go to post

Hey Kev.

The main way to build upon this would be to use something like Prometheus and Grafana to pull data out and then display it in a human readable way, and it has been covered on the forums a few times.

However, if you were to upgrade past IRIS 2020, you should find that you are able to utilise System Alerting and Monitoring (SAM) in your environment.

Julian Matthews · Oct 19, 2022 go to post

Mainly major version jumps unless something is problematic in the version that has ended up in our production environment.

Last jump was 2019.1 to the current 2022.1 and I'm blaming the pandemic on no upgrades between those two releases smiley

Julian Matthews · Oct 19, 2022 go to post

Seeing as I just completed a production upgrade yesterday:

  • What InterSystems products + versions are you running? ($zv is ideal.) 
    • IRIS for Windows (x86-64) 2022.1 (Build 209U) Tue May 31 2022 12:16:40 EDT [Health:3.5.0]
  • What makes you decide to upgrade?
    • New features + security fixes
  • ​​​​​​​What are your blockers to upgrading?
    • ​​​​​​​Bugs in new releases + being limited to the non-CD releases due to current configuration
  • What is your process for evaluating and planning a possible upgrade?
    • ​​​​​​​Install in our NPE and use the new version, run tests against the most heavily used elements
  • What documentation resources do you use?
    • ​​​​​​​Release notes + any upgrade guides that explicitly call out versions you can/can't upgrade from
  • ​​​​​​​What gaps/issues do you see in our existing documentation around upgrades?
    • ​​​​​​​It's a small thing, but a link to the release notes from the online distribution page on WRC would be greatly received alongside the release in question.
  • What would make your InterSystems software upgrade process better?
    • ​​​​​​​One step that always bothers me is the need to do a recompile post upgrade, as it's not been made quite clear to me at what stage this needs to be done when working in a mirrored environment. This could be a step handled by the installer given that it should happen with any major version change.​​​​​​​
  • What has made an upgrade fail?
    • Not to hammer on at the same point, but I did have an upgrade "fail" due to a miscommunication about if the version change was major or minor, and we hadn't run the recompile of all namespaces.
  • When have you had to roll-back?
    • Never had to fully roll back, but have had to fall back to a secondary mirror after noting the upgraded mirror was having issues (see above). Otherwise we aim for a "fix forward" approach to issues found following an upgrade.
Julian Matthews · Sep 28, 2022 go to post

So upon further review, it seems that the first ACK is being generated by the Operation, and the second one is the body of the HTTP Response.

Basically, the operation will attempt to parse the http response into a HL7 message, and if that doesn't happen, it will then "generate" an ack and write the http response data at the end of the generated ack.

In my case, although there is a HL7 message in the response, it's not being parsed for some reason, so the code moves onto generating its own ack, followed by the http response body, which is the second ack I was seeing.

I'm now replicating the HTTP operation and attempting to pin down exactly where it's falling down, and failing that I will likely reach out to WRC as it seems to be an issue deeper than I can dive.

Julian Matthews · Sep 27, 2022 go to post

Hey Lionel.

I did write an article about this a little while ago which I hope can walk you through what you're looking to achieve, with the difference being to pivot from using the ORCGrp counts like I had, and instead using RXCgrp and then setting the transform to have a source and target class of RDE O11.

If you do ty to follow this approach, I'm more than happy to answer any questions you have.

Julian Matthews · Sep 21, 2022 go to post

Hey Marc.

Thank you for sharing this - I have no idea how I have yet to come across this!

Julian Matthews · Sep 21, 2022 go to post

If you have a record map configured and have the generated class, then the next step would be to use this generated class in a transform as your source. From there, you can transform the data into the SDA class you have set in your target for transform.

Once you have this SDA message, you can send it wherever your requirements need you to send them.

Julian Matthews · Sep 20, 2022 go to post

If you're working with a CSV, then you could look at the Record Mapper or Complex Record Mapper depending on the input format. From there, you could then create a transform that uses the generated class from the record mapper as your source, and then the appropriate SDA class as your destination.

However, if you're working with an actual xls/xlsx file, then I'm out of ideas.

Julian Matthews · Sep 20, 2022 go to post

Hey Marc.

Firstly, thank you for sharing this. This does seem to closely follow what I had intended to use, with a slight variation or two.

Would you mind giving some insight on this line "set tReadLen=..#CHUNKSIZE" as I'm not familiar with the use of the # symbol in this way. Is this acting as a modulo in this context?