Dan

there are lots of ways of doing this. I find thta building the segment data into strings is often the easiest way to do it because you can see what you have and mistakes are easier to avoid.

The example below builds strings with random data but you could be pulling it form a database. 

If you want to be more sophistcated you could use the SetValueAt() method of an HL7 Segment.

As Stefan says, looking at the generated code for a data transform can often give you good ideas.

Dave

 

 
//random values. These could be pulled from an application
set PID1=(1+$r(9))_$r(9999999)
set PID2=(1+$r(9))_$r(9999999)
set PID3=(1+$r(9))_$r(9999999)
set PID4=(1+$r(9))_$r(9999999)
set CID=(1+$r(9))_$r(9999999)
set PAC=(1+$r(9))_$r(9999999)

set firstname=##class(%PopulateUtils).FirstName()
set lastname=##class(%PopulateUtils).LastName()

set hl7=##class(EnsLib.HL7.Message).%New()
set hl7.DocType="2.5:ADT_A01"


set tSeg1=##class(EnsLib.HL7.Segment).ImportFromString("MSH|^~\&|HQ|A|||20070222140835||ADT^A01|1"_$r(99999999)_"R"_$R(99999999)_"|D|2.2||||||||||2.2b")


set tSeg2=##class(EnsLib.HL7.Segment).ImportFromString("EVN|A01|200702221400||ADM|MPACPB")
set tSeg3=##class(EnsLib.HL7.Segment).ImportFromString("PID|1|"_PID1_"|"_PID2_"^^^A^MR~"_PID3_"^^^B^PI~"_PID4_"^^^C^PI||"_lastname_"^"_firstname_"||20010101|U||W|122 BIRDSEED ROAD^^SKOKIE^IL^60077^US^^COOK|COOK|(847)676-2211||ENG|S|NON|3000018947054|111-11-1111|||||||||||N||||||||||||||||||||N")

set tSeg4=##class(EnsLib.HL7.Segment).ImportFromString("PD1|||||||O")
set tSeg5=##class(EnsLib.HL7.Segment).ImportFromString("PV1|1|I|E3E^3404^01^E|U|||000764^LERNER^DAVID JOSEPH^^MD^DR|||MED||||R|||000764^LERNER^DAVID JOSEPH^^MD^DR|I|7054|5^20070223|||||||||||||||||||E|||||200702221400|||||||A||000764^LERNER^^^MD^DR")
set tSeg6=##class(EnsLib.HL7.Segment).ImportFromString("PV2||P")
set tSeg7=##class(EnsLib.HL7.Segment).ImportFromString("DG1|1|FF|^OOO^FF||20050101|A|||||||||0||O")
set tSeg8=##class(EnsLib.HL7.Segment).ImportFromString("GT1|1|300001894^^^A^PI|BOOBOO^POOPOO||122 BIRDSEED ROAD^^SKOKIE^IL^60077^US^^COOK|(847)676-2211||20010101|U||P|111-11-1111||||001000^NONE|^^^^^US|||N")
set tSeg9=##class(EnsLib.HL7.Segment).ImportFromString("ZPI|1|N|||||||||20070220|N||^C|001000^NONE|^^^^^US")
set tSeg10=##class(EnsLib.HL7.Segment).ImportFromString("ZPV|1||||||||||N||||O||")
set tSeg11=##class(EnsLib.HL7.Segment).ImportFromString("ZP2|1|x|dgcode|")


set tsc=hl7.SetSegmentAt(tSeg1,1)

set tsc=hl7.InsertSegmentAt(tSeg2,2)
set tsc=hl7.InsertSegmentAt(tSeg3,3)

set tsc=hl7.InsertSegmentAt(tSeg4,4)
set tsc=hl7.InsertSegmentAt(tSeg5,5)
set tsc=hl7.InsertSegmentAt(tSeg6,6)
set tsc=hl7.InsertSegmentAt(tSeg7,7)
set tsc=hl7.InsertSegmentAt(tSeg8,8)
set tsc=hl7.InsertSegmentAt(tSeg9,9)
set tsc=hl7.InsertSegmentAt(tSeg10,10)
set tsc=hl7.InsertSegmentAt(tSeg11,11)

Andreas

I don't think there is an easy way to do what you are asking for in a single SQL statement. Mapping Ens.MessageHeader data from different databases into one namespace isn't really possible.

I think you will have to run a query per namespace and merge the results. 

The new activity statistics capability will centralize statistics for many namespaces so you can run a single query, but that isn't available until 2016.1.

 

Dave

Robert

when database encryption was first introduced it was determined that for a particular application that  was very I/O intensive (5,000  block read or writes per second) , encryption would add about 4% to the CPU usage and it can add a tiny amount to disk block latency. 

That is an extreme case, so it is probably an upper bound  for any considerations.

In my experience, very few Ensemble solutions are at all IO intensive, with more time spent on network traffic or CPU usage. So I would be surprised if it is possible to measure the difference in your case.

I don't know about disk encryption.

 

dave

Scott

what type of messages are they? I guess since you are using a routing rule they are HL7 v2  or X12 messages, but perhaps not.

If you want to block or route a message based on a field in the message and you are dealing with more than a very small number of customers then I would use a lookup table as you suggest that maps customer identifiers to 0 or 1 so it is easy to reference them in a routing rule.

For a small number of customers that don't change, you could use an In(...) function but I am guessing that is not the case.