From: <fre...@sk...> - 2004-06-24 14:52:32
|
Tripp, Bryan a =E9crit : >Hi Fr=E9d=E9ric,=20 > >Thank you, that's a very nice introduction to openadaptor. =20 > >The only part I didn't understand was what underlies the XML element >MapToHL7. Did you write that component or is it part of openadaptor? W= here >does the Terser-like syntax come from?=20 > MapToHL7 is an AliasingPipeSegment component, which is described at=20 http://openadaptor.openadaptor.org/pg/transforming_components.htm#Aliasin= g.=20 In fact, I don't use the standard class provided by *openadaptor* but a=20 slightly modified version. But it is pure openadaptor code, not related=20 to HL7 at all. The objective is to transform a dataobject from one=20 structure to another. In my previous example, MapToHL7 transforms each dataobject built from=20 the SQL result set, for instance: <Admission> <patientID>M07869D</patientID> <firstName>FREDERIC</firstName> <lastName>DUBRU</lastName> <sex>M</sex> <birthDate>1970-10-04T00:00:00 @Europe/Paris</birthDate> ... </Admission> into another dataobject with a HL7-like structure: <ADT_A01> <PID> <PID_2>M07869D</PID_2> <PID_5> <PID_5_1>DUBRU</PID_5_1> <PID_5_2>FREDERIC</PID_5_2> </PID_5> <PID_7>1970-10-04T00:00:00 @Europe/Paris</PID_7> <PID_8>M</PID_8> ... </PID> ... </ADT_A01> This XML piece is only the XML representation of the transformed=20 dataobject; it's not HAPI XML. Then, the HL7StringWriter encodes this dataobject into an HL7 message,=20 with the following pseudo-code, using the HAPI classes: Instantiate an Message after the name of the dataobject type (ADT_A01) For each attribute (nested dataobject) of this dataobject (EVN, PID, PV1). Create a Segment after the name of this attribute For each attribute of this nested dataobject (PID_2, PID_5, etc.) Create a Type after the index in the name of this attribute If it is a simple attribute Set the value of this attribute into this primitive type Else if it is a composite attribute (nested dataobject) For each attribute of this nested dataobject (PID_5_1, PID_5_2, etc.) ... Create or complete the MSH segment Encode the message Surely it would have been easier to use a Terser, rather than build all=20 the HAPI structures by hand, but the Terser didn't exist yet at the time=20 I wrote the code. Fr=E9d=E9ric |