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

Hi

Lets assume you have an Ensemble request message with the following properties:

MyRequestMessage as Ens.Request

{

Property Action as %String(VALUELIST=",Add,Update,Delete";

Property HL7Message as EnsLib.HL7.Message;

Property Patient as ?;

}

// Assume I have received or created an HL7 Message in tHL7Message and I want to send the message to a Business Process  and the BP will perform the specified action on my Patient based on the content of the HL7 message (bear in mind that this is just an example and you probably wouldn't do this in real life so this is for illustration purposes only)

set tRequest=##class(MyRequestMessage).%New(),tRequest.Action="Add",tRequest.HL7Message=tHL7Message

set tSC=..SendRequestSync("My Business Process",tRequest,.tResponse)

The question is whether to open the Patient Object and pass it in the request message or rather send the Patient ID rather

i.e.

Property Patient as MyPackage.Patient; or

Property Patient as %String;

If you pass the patient as an object you have to take into consideration the following factors:

How long will the request message sit in the BP queue before it gets processed.?

Once it is linked to the request message it will remain linked to the message until the message is purged

If another request comes along that wants to delete that Patient then you will run into a referential integrity problem an %DeleteId() will probably fail as the patient is linked to the request message. (You can get around this by setting tRequest.Patient = "" in the BP once you have finished processing the request message but if at some point in the future you want to see which patient was modified by that request message you wont be able to tell as the property is now null.

Likewise if some other Business Process or classmethod elsewhere in your application wants to update that patient then you will run into concurrency issues where either the other process will not be able to update the patient as it has been modified by your process or visa versa.

So my recomendation is that you pass the Patient RowId in the Patient Property and then in your BP open the Patient, do your update it and save the change and then when your BP method quits the patient object will be released.

I have been caught out in the past by passing objects by reference in Ensemble Productions in the past and it took me ages to work out why the object was not getting updated  or why another part of the application was unable to update the patient because it was effectively locked elsewhere in the application (i.e. in the BP processing the request message)

Nigel