Skip to main content


class HS.Gateway.HL7.HL7ToSDA3 extends %Library.RegisteredObject

Convert an HL7 message into SDA3 XML

Method Inventory


parameter HSDEPLOY = 1;


classmethod ACC()
classmethod AIL()
classmethod AIP()
classmethod AIS()
classmethod AL1()
classmethod By(tag As %String, bclosetag As %Boolean = 1, table As %String, codingstandard As %String, code As %String, last As %String, first As %String, middle As %String = "", prefix As %String = "", suffix As %String = "", profsuffix As %String = "", nametypecode As %String = "", idtypecode As %String = "")
Make a 'By' tag from the supplied fields for User, CareProvider, ReferralDoctor J2 PJH - Allow NameSuffix, ProfSuffix, remove close tage to be a boolean option and closer in parameter list
classmethod DB1()
classmethod DG1()
classmethod DRG()
classmethod DummyEncounters()
No longer used, as any type can now be encounter-less.
classmethod EVN()
classmethod EncounterLocation(locationDetailCode As %String, physicalTypeCode As %String, priorLocation As %Boolean)
classmethod EncounterParticipant(participantType As %String)
classmethod EndEncounters()
classmethod EndOrder(order As %String = "*LAST*")
End an order, and possibly its enclosing elmement
classmethod FormatPhone(country As %String, area As %String, number As %String, extension As %String) as %String
Format a Phone Number from the 4 fields supplied
classmethod GT1()
classmethod GenerateEncounterNumber() as %String
Generate an encounter number when none is provided
classmethod GetData()
classmethod GetSDA(pRequest As EnsLib.HL7.Message, Output pXML As %Stream.GlobalCharacter, pLogAlerts As %Boolean = 1, pObservationMode As %Boolean = 0, pMultiLineOBXCompatibilityMode As %Boolean = 0, pKeepDuplicateOBXIdentifiers As %Boolean = 0) as %Status
Input: One HL7 message in EnsLib.HL7.Message Output: SDA3 XML string
classmethod HL7ToHorolog(dt As %String) as %String
Convert an HL7 timestamp to horolog ($H) format
classmethod IAM()
classmethod IN1()
classmethod IN2()
classmethod IN3()
classmethod MRG(mode As %String)
classmethod MSH()
classmethod MessageHeader()
classmethod NK1()
classmethod NTE()
classmethod OBR(mode As %String)
classmethod OBX(mode As %String, pReplace As %String = "")
classmethod ORC(mode As %String)
classmethod OnAllergy()
Callback method for custom processing of Allergy streamlet
classmethod OnAppointment()
Callback method for custom processing of Appointment streamlet
classmethod OnBeforeEndContainer()
Callback method to enable addition of custom streamlets and streamlets from non-standard segments to SDA
classmethod OnDiagnosis()
Callback method for custom processing of Diagnosis streamlet
classmethod OnDocument()
Callback method for custom processing of Document streamlet
classmethod OnEncounter()
Callback method for custom processing of Encounter streamlet
classmethod OnLabOrder()
Callback method for custom processing of LabOrder streamlet
classmethod OnMedication()
Callback method for custom processing of Medication streamlet
classmethod OnObservation()
Callback method for custom processing of Observation streamlet
classmethod OnOtherOrder()
Callback method for custom processing of OtherOrder streamlet
classmethod OnPatient()
Callback method for custom processing of Patient streamlet
classmethod OnProblem()
Callback method for custom processing of Problem streamlet
classmethod OnProcedure()
Callback method for custom processing of Procedure streamlet
classmethod OnRadOrder()
Callback method for custom processing of RadOrder streamlet
classmethod OnVaccination()
Callback method for custom processing of Vaccination streamlet
classmethod PD1()
J2 PJH - Added Publicity Code and Immunication Registry Info
classmethod PDA()
classmethod PID()
classmethod PR1()
classmethod PRB()
classmethod PV1() as %Status
classmethod PV2()
classmethod ParseADDSegs(pDoc As EnsLib.EDI.Document, pValSpec As %String, Output pStatus As %Status) as %Boolean
This method is meant to be called by the OnValidate method of any Ensemble HL7 Service that expects to receive messages with ADD segments. Per the HL7 spec, it takes the content of each ADD segment and appends it to the end of the preceding segment, then removes the ADD segment.

The arguments to this method are the same as those to OnValidate. Also note that for the OnValidate method to be called, the Validation property of the class has to be set to a non-null value.
classmethod PhonesAndEmail(s As %Integer, field As %Integer, ByRef phone As %String, ByRef mobile As %String, ByRef email As %String, ByRef fax As %String, ByRef workphone)
Examine the (repeating) Phone & Email field for Home, Work, Mobile and Fax Phone number(s) and Email address(es) Note that Fax is only stored for OBR-17/ORC-14

The workphone parameter was added for ROL-12 since this field can contain both home and work numbers. For other fields this parameter is unused. (JLD035)
classmethod ROL(mode As %String, tag As %String)
mode has 2 possible values: "CareProvider" and "User", corresponding to which HS.SDA.CodeTableDetail class this segment should map to. tag is the name of the element this ROL segment maps to in SDA.
classmethod RXA(mode As %String)
classmethod RXC()
classmethod RXE()
classmethod RXO()
classmethod RXR()
classmethod RXRAdminSite()
classmethod RemoveOrder(mode As %String, type As %String)
Delete or inactivate an order
classmethod SCH()
classmethod SFT()
classmethod SPM()
J2 PJH - Added in SPM
classmethod SourceFormat()
classmethod StartEncounters() as %Status
classmethod StartOrder()
Start an order, possibly with enclosing element
classmethod TQ1()
classmethod TXA()
classmethod UB1()
classmethod UB2()
classmethod WriteEncounterNumber(pEncNum)
Add encounter number to encounter-related data stored at the same level as the encounter
classmethod adta01()
classmethod adta02()
classmethod adta03()
classmethod adta05()
classmethod adta09()
classmethod adta18()
classmethod adta21()
classmethod adta30()
classmethod adta39()
classmethod adta45()
classmethod adta50()
classmethod adta60()
classmethod barp12()
classmethod end(seg As %String)
Output closing if it was opened
classmethod formatname(last As %String, first As %String, middle As %String, prefix As %String) as %String
If both last and first are given, returns the name as last_", "_first
Else if last is given, returns last
Else if first is given, returns first
Else returns ""
classmethod gettext(segment As %String, fieldnum As %Integer, segment2 As %String, fieldnum2 As %Integer) as %String
Get text from value (optionally followed by NTE())
classmethod idtype(value As %String) as %String
Patient Number Identifier Codes
classmethod mdmt01()
classmethod mdmt02()
classmethod message() as %Status
classmethod occ(field As %String, occ As %Integer) as %Integer
Get next occurence (after occ, if any) that has any data for the field, else ""
classmethod ompo09()
classmethod orderstatus(value As %String) as %String
Order Status Codes
classmethod ormo01()
classmethod orur01()
classmethod pprpc1()
classmethod rdeo11()
classmethod sius12()
classmethod start(seg As %String, tag As %String)
Output if this is the first occurrence of
classmethod unescape(text As %String) as %String
Unescape HL7 escape sequences found in text. This will not unescape anything to a carat (^) as that is used as a delimiter internally. The HL7 escape sequences are used to encode the HL7 field separator and encoding characters, which are defined in MSH-1 and -2 and can vary from message to message. This method will unescape to the characters used in the current message. Also note that the character used to denote escape sequences (usually "\") is one of the encoding characters that can vary from message to message. This method will look for the escape character defined for the current message.

The supported HL7 escape sequences are (assuming "\" is the escape character):
\F\ - Field separator (usually "|")
\S\ - Component separator (usually "^")***
\R\ - Repetition separator (usually "~")
\E\ - Escape character (usually "\")
\T\ - Subcomponent separator (usually "&")
\.br\ - line break (CRLF)

***Note that, as stated above, this method will not unescape anything to a carat (^), so if the component separator is "^", we will not unescape "\S\" to that. However this method will unescape "\S\" if another character is used. The same is true for the other escape sequences.
classmethod vxuv04()
classmethod write(s As %String)
Add to XML buffer, and possibly write it to the output stream
classmethod writeCodeTableTranslated(pTag As %String, pCode As %String = "", pDescription As %String = "", pCodingStandard As %String = "", pCodeSystemVersion As %String = "", pPriorCode As %String = "", pPriorDescription As %String = "", pPriorCodeSystem As %String = "", pPriorCodeSystemVersion As %String = "", pOriginalText As %String = "")
J2 Write out a Code Table Translated
classmethod writeMedicalDirector() as %Boolean
J2 If OBX-25 - Performing Organization Medical Director is valued
Writes out as a CareProvider
for the Result and LabResultItem property PerformedAt/MedicalDirector.
classmethod writePerformedAt()
J2 Writes out the PerformedAt tags associated with Result and LabResultItem
PerformedAt property.
If OBX-15 and OBX-23 are valued they should match.
If valued OBX-23 is used over OBX-15
otherwise default to OBX-15.
If OBX-24 Performing Organization Address is found that will be written out also.
classmethod writecdata(tag As %String, segment As %String, fieldnum As %Integer, segment2 As %String, fieldnum2 As %Integer)
Output value as CData (optionally with NTE())
classmethod xml(text As %String) as %String
XML-escape all data when fetched
classmethod xmltimestamp(dt As %String) as %String
Convert HL7 date to XML date

Inherited Members

Inherited Methods

FeedbackOpens in a new tab