Question
· Jul 6, 2016

Any examples of DTL where create='existing'?

Hi,

Does anyone have a sample that demonstrates how to use the Data Transformation option create='existing', in order to update an existing object by its ID?  My use-case is that I have an HL7 message coming in which contains data on a patient that may or may not already exist in a (non-HL7) table.  I want to use the PatientID from the (source) HL7 message, check if that patient exists in the (target) object, and if so, insert some new data into the existing patient, or if not, create a new patient.

 

I believe that to use create='existing', I need to provide the DTL with the PatientID as a parameter.  Can I call the transform from a Routing Rule with a parameter, or do I need to use BPL?

 

Thanks,

Steve

Discussion (3)0
Log in or sign up to continue

Hi Steve,

I have done something like you describe. I used BPL, and at the time tried to keep away from using bits of code, but it got complex and in retrospect I'm not sure it was the best way. The diagrams are nice, but I think a bit of well written code might have been easier to follow!

First I created a "TempStore" class with an "MRN" (Medical Records Number) property and no permanent storage. This is used as the target class for a transform that pulls out the patient id and puts it in that property.

In the BPL Process I added an instance of the TempStore class to the BPL context object, and the first activity in the diagram is the transform with Source of "request" and Target "context.TempStore".

With the MRN found, I then use code like the following in the Value of an "assign" activity to put the target stored object into another context property of "context.BNetEpisode" already set to the same class.

##class(...).MRNIndexOpen(context.TempStore.MRN,4)

An "if" activity with a Condition like "$IsObject(context.BNetEpisode)" is used to see if anything was found, and create a new one if required by setting the "context.BNetEpisode.MRN" property equal to "context.TempStore.MRN".

The "context.BNetEpisode" property is then be used as the Target for "transform" activities later on with Create = "existing" used. Ensemble does a save automatically when the Process completes.

I hope this makes sense. (I cannot provide the full code as it belongs to the customer, and anyway it gets a lot more complex as there are 3 types of inbound message, one of which was an HL7 v3 document, and it was actually using an xml document inside the stored object to hold much of the data - but that's another story).

Mike

I saw one of these recently.  The programmer was using a target class which had a collection property.  His DTL had a loop that was passing the entire target object to a subtransform to have elements added to the collection property, and the result was stored back into target.  That subtransform DTL needed to have create=existing to avoid wiping out the target before appending to the collection.