`4F2MSH0\Ec:\tempHL7#7g #7g|~FR#7g^S#7g&T HL7$qKH(&8$qKH(&8Y4FV6& LabResultE53TE53T9'MSH52Field SeparatorcSTCb3Value String Data52Encoding Characters52Sending ApplicationcHDCb3 Namespace IDcISCb3Value#Coded Value For User-defined TablesCb3 Universal IDCb3Universal ID TypecIDCb3ValueCoded Values For Hl7 TablesHierarchic Designator52Sending Facility 52Receiving Application 52Receiving Facility 52Date/Time of MessagecDTMCb3ValueTrDateTime !0 DTM DateTime Date/Time52Security52 Message TypecMSGCb3 Message CodeCb3 Trigger EventCb3Message Structure Message Type52Message Control ID52 Processing IDcPTCb3 Processing IDCb3Processing ModeProcessing Type52 Version IDcVIDCb3 Version IDCb3Internationalization CodecCWE Cb3 IdentifierCb3TextCb3Name of Coding SystemCb3Alternate IdentifierCb3Alternate TextCb3Name of Alternate Coding SystemCb3Coding System Version IDCb3"Alternate Coding System Version IDCb3 Original TextCoded with ExceptionsCb3International Version ID'Version Identifier52Sequence NumbercNMCb3ValueNumeric52Continuation Pointer52Accept Acknowledgment Type52Application Acknowledgment Type52 Country Code52 Character Set52Principal Language Of Message'52'Alternate Character Set Handling Scheme52Message Profile IdentifiercEICb3Entity IdentifierCb3 Namespace ID Cb3 Universal IDCb3Universal ID TypeEntity Identifier52 Sending Responsible OrganizationcXON Cb3Organization NameCb3Organization Name Type Code Cb3 ID Number3Cb3Identifier Check Digit3Cb3Check Digit SchemeCb3Assigning Authority Cb3Identifier Type CodeCb3Assigning Facility Cb3Name Representation CodeCb3Organization IdentifierCExtended Composite Name and Identification Number for Organizations52"Receiving Responsible OrganizationC52Sending Network Address 52Receiving Network Address Message HeaderMessageORUx#R01x# LabResultUnsolicited Observation Message,C 3 '= $cXADCb3Street AddresscSADCb3Street or Mailing AddressCb3 Street NameCb3Dwelling NumberStreet AddressCb3Other DesignationCb3CityCb3State or ProvinceCb3Zip or Postal CodeCb3CountryCb3 Address TypeCb3Other Geographic DesignationCb3County/Parish Code Cb3 Census Tract Cb3Address Representation CodeCb3Address Validity RangecDRCb3Range Start Date/TimeCb3Range End Date/TimeDate/Time RangeCb3Effective DateCb3Expiration DateCb3Expiration Reason'Cb3Temporary IndicatorCb3Bad Address IndicatorCb3 Address UsageCb3 AddresseeCb3CommentCb3Preference Order3Cb3Protection Code'Cb3Address Identifier=Extended AddressbScDTCb3ValueTrDateDT DateDatecSICb3Value Sequence IDcXPNCb3 Family NamecFNCb3SurnameCb3Own Surname PrefixCb3 Own SurnameCb3"Surname Prefix from Partner/SpouseCb3Surname from Partner/Spouse Family NameCb3 Given NameCb32Second and Further Given Names or Initials ThereofCb3Suffix (e.g., JR or III)Cb3Prefix (e.g., DR)Cb3Degree (e.g., MD) Cb3Name Type CodeCb3Name Representation CodeCb3 Name Context'Cb3Name Validity RangebCb3Name Assembly OrderCb3Effective DateCb3Expiration DateCb3Professional SuffixExtended Person NamewcJCCCb3Job Code Cb3 Job Class Cb3Job Description TextcTXCb3Value Text DataJob Code/ClasscCX Cb3 ID NumberCb3Identifier Check DigitCb3Check Digit SchemeCb3Assigning Authority Cb3Identifier Type CodeCb3Assigning Facility Cb3Effective DatepCb3Expiration DatepCb3Assigning Jurisdiction'Cb3Assigning Agency or Department'&Extended Composite ID with Check DigitcXTNCb3Telephone NumberCb3Telecommunication Use CodeCb3 Telecommunication Equipment TypeCb3Communication AddressCb3 Country Code3Cb3Area/City Code3Cb3 Local Number3Cb3 Extension3Cb3Any TextCb3Extension PrefixCb3Speed Dial CodeCb3Unformatted Telephone numberCb3Effective Start DateCb3Expiration DateCb3Expiration Reason'Cb3Protection Code'Cb3#Shared Telecommunication Identifier=Cb3Preference Order3!Extended Telecommunication NumbercPRLCb3Parent Observation Identifier'Cb3!Parent Observation Sub-identifierCb3#Parent Observation Value DescriptorParent Result LinkcTQ Cb3QuantitycCQCb3Quantity3Cb3Units'Composite Quantity with UnitsCb3IntervalcRICb3Repeat Pattern Cb3Explicit Time IntervalRepeat IntervalCb3DurationCb3Start Date/TimeCb3 End Date/TimeCb3PriorityCb3 ConditionCb3TextCb3 ConjunctionCb3Order SequencingcOSD Cb3Sequence/Results FlagCb3&Placer Order Number: Entity IdentifierCb3!Placer Order Number: Namespace ID Cb3&Filler Order Number: Entity IdentifierCb3!Filler Order Number: Namespace ID Cb3Sequence Condition ValueCb3Maximum Number of Repeats3Cb3!Placer Order Number: Universal IDCb3&Placer Order Number: Universal ID TypeCb3!Filler Order Number: Universal IDCb3&Filler Order Number: Universal ID TypeOrder Sequence DefinitionCb3Occurrence Duration'Cb3Total Occurrences3Timing QuantitycEIPCb3Placer Assigned Identifier=Cb3Filler Assigned Identifier=Entity Identifier PaircCNE Cb3 IdentifierCb3TextCb3Name of Coding SystemCb3Alternate IdentifierCb3Alternate TextCb3Name of Alternate Coding SystemCb3Coding System Version IDCb3"Alternate Coding System Version IDCb3 Original TextCoded with No ExceptionscXCNCb3 ID NumberCb3 Family NamewCb3 Given NameCb32Second and Further Given Names or Initials ThereofCb3Suffix (e.g., JR or III)Cb3Prefix (e.g., DR)Cb3Degree (e.g., MD) Cb3 Source Table Cb3Assigning Authority Cb3Name Type CodeCb3Identifier Check DigitCb3Check Digit SchemeCb3Identifier Type CodeCb3Assigning Facility Cb3Name Representation CodeCb3 Name Context'Cb3Name Validity RangebCb3Name Assembly OrderCb3Effective DateCb3Expiration DateCb3Professional SuffixCb3Assigning Jurisdiction'Cb3Assigning Agency or Department'1Extended Composite ID Number and Name for PersonscMOCCb3Monetary AmountcMOCb3Quantity3Cb3 DenominationMoneyCb3 Charge Code'Money and CodecSPSCb3Specimen Source Name or Code'Cb3 Additives'Cb3Specimen Collection MethodCb3 Body Site'Cb3 Site Modifier'Cb3Collection Method Modifier Code'Cb3 Specimen Role'Specimen SourcecNDL Cb3NamecCNN Cb3 ID NumberCb3 Family NameCb3 Given NameCb32Second and Further Given Names or Initials ThereofCb3Suffix (e.g., JR or III)Cb3Prefix (e.g., DR)Cb3Degree (e.g., MD Cb3 Source Table Cb3$Assigning Authority - Namespace ID Cb3#Assigning Authority - Universal IDCb3(Assigning Authority - Universal ID Type'Composite ID Number and Name SimplifiedCb3Start Date/timeCb3 End Date/timeCb3 Point of Care Cb3Room Cb3Bed Cb3Facility Cb3Location Status Cb3Patient Location Type Cb3Building Cb3Floor Name with Date and LocationcCDCb3Channel IdentifiercWVICb3Channel Number3Cb3 Channel NameChannel IdentifierCb3Waveform SourcecWVSCb3Source One NameCb3Source Two NameWaveform SourceCb3Channel Sensitivity and UnitscCSUCb3Channel Sensitivity3Cb3Unit of Measure IdentifierCb3Unit of Measure DescriptionCb3Unit of Measure Coding SystemCb3$Alternate Unit of Measure IdentifierCb3%Alternate Unit of Measure DescriptionCb3'Alternate Unit of Measure Coding SystemChannel Sensitivity and UnitsCb3Channel Calibration ParameterscCCPCb31Channel Calibration Sensitivity Correction Factor3Cb3Channel Calibration Baseline3Cb3Channel Calibration Time Skew3Channel Calibration ParametersCb3Channel Sampling Frequency3Cb3Minimum and Maximum Data ValuescNRCb3 Low Value3Cb3 High Value3 Numeric RangeChannel Definition/&5"cPL Cb3 Point of Care Cb3Room Cb3Bed Cb3Facility Cb3Location Status Cb3Person Location Type Cb3Building Cb3Floor Cb3Location DescriptionCb3!Comprehensive Location Identifier=Cb3 Assigning Authority for Location Person LocationcDLNCb3License NumberCb3 Issuing State, Province, Country Cb3Expiration DatepDriver's License Number9'NK1'52 Set ID - NK1s52Nameu52 Relationship'52AddressQ52 Phone Number52Business Phone Number52 Contact Role'52 Start Datep52End Datep52*Next of Kin / Associated Parties Job Title52/Next of Kin / Associated Parties Job Code/Class520Next of Kin / Associated Parties Employee Number52Organization Name - NK1C52Marital Status'52Administrative Sex 52Date/Time of Birth52Living Dependency 52Ambulatory Status 52 Citizenship'52Primary Language'52Living Arrangement 52Publicity Code'52Protection Indicator52Student Indicator 52Religion'52Mother's Maiden Nameu52 Nationality'52 Ethnic Group'52Contact Reason'52Contact Person's Nameu52!Contact Person's Telephone Number52Contact Person's AddressQ52*Next of Kin/Associated Party's Identifiers52 Job Status 52Race'52Handicap 52%Contact Person Social Security Number52Next of Kin Birth Place52 VIP Indicator Next of Kin / Associated Parties9'OBR252 Set ID - OBRs52Placer Order Number=52Filler Order Number=52Universal Service Identifier'52Priority52Requested Date/Time52Observation Date/Time #52Observation End Date/Time #52Collection Volume *52Collector Identifier *52Specimen Action Code *52 Danger Code'52Relevant Clinical Information52Specimen Received Date/Time52Specimen Source52Ordering Provider52Order Callback Phone Number52Placer Field 152Placer Field 252Filler Field 1 +52Filler Field 2 +52%Results Rpt/Status Chng - Date/Time +52Charge to Practice +52Diagnostic Serv Sect ID52Result Status +52Parent Result +52Quantity/Timing52Result Copies To52Parent52Transportation Mode52Reason for Study'52Principal Result Interpreter +52Assistant Result Interpreter +52 Technician +52Transcriptionist +52Scheduled Date/Time +52Number of Sample Containers *352)Transport Logistics of Collected Sample *'52Collector's Comment *'52$Transport Arrangement Responsibility'52Transport Arranged52Escort Required52!Planned Patient Transport Comment'52Procedure Code52Procedure Code Modifier52'Placer Supplemental Service Information'52'Filler Supplemental Service Information'52.Medically Necessary Duplicate Procedure Reason'52Result Handling 52#Parent Universal Service Identifier'Observation Request9'OBX52 Set ID - OBXs52 Value Type52Observation Identifier'52Observation Sub-ID52Observation Value52Units'52References Range52Abnormal Flags 52 Probability352Nature of Abnormal Test52Observation Result Status52!Effective Date of Reference Range52User Defined Access Checks52Date/Time of the Observation52 Producer's ID'52Responsible Observer52Observation Method'52Equipment Instance Identifier=52Date/Time of the Analysis52Observation Site'52Observation Instance Identifier=52 Mood Code52Performing Organization NameC52Performing Organization AddressQ52(Performing Organization Medical DirectorObservation/Result9'ORC52 Order Control52Placer Order Number=52Filler Order Number=52Placer Group Number=52 Order Status52 Response Flag52Quantity/Timing52Parent52Date/Time of Transaction52 Entered By52 Verified By52Ordering Provider52Enterer's Location852Call Back Phone Number52Order Effective Date/Time52Order Control Code Reason'52Entering Organization'52Entering Device'52 Action By52 Advanced Beneficiary Notice Code'52Ordering Facility NameC52Ordering Facility AddressQ52Ordering Facility Phone Number52Ordering Provider AddressQ52Order Status Modifier'52+Advanced Beneficiary Notice Override Reason'52(Filler's Expected Availability Date/Time52Confidentiality Code'52 Order Type'52Enterer Authorization Mode52#Parent Universal Service Identifier' Common Order9'PID'52 Set ID - PIDs52 Patient ID52Patient Identifier List52Alternate Patient ID - PID52 Patient Nameu52Mother's Maiden Nameu52Date/Time of Birth52Administrative Sex 52 Patient Aliasu52Race'52Patient AddressQ52 County Code 52Phone Number - Home52Phone Number - Business52Primary Language'52Marital Status'52Religion'52Patient Account Number52SSN Number - Patient52!Driver's License Number - PatientD52Mother's Identifier52 Ethnic Group'52 Birth Place52Multiple Birth Indicator52 Birth Order352 Citizenship'52Veterans Military Status'52 Nationality'52Patient Death Date and Time52Patient Death Indicator52Identity Unknown Indicator52Identity Reliability Code 52Last Update Date/Time52Last Update Facility 52 Species Code'52 Breed Code'52Strain52Production Class Code'52Tribal Citizenship'Patient Identificationr MACHINEIDCODEMSHMSHdefaultORUx#MSHR01x#MSHASCIIASCIIvalue = 'MSH' + value .(<77< ,   WE< :c  P<Pimport xml.dom.minidom import time #Helpers def v3Indent(i): return i * '\t' def getText(nodelist): rc = "" for node in nodelist: if node.nodeType == node.TEXT_NODE: rc = rc + node.data return rc def getElement(Parent, Property): PropertyTag = Parent.getElementsByTagName(Property)[0] return getText(PropertyTag.childNodes) def getItem(DomMessage, TableName, Index, ColumnName): Table = DomMessage.getElementsByTagName(TableName)[Index] ColumnTag = Table.getElementsByTagName(ColumnName)[0] return getText(ColumnTag.childNodes) def getTableElement(DomMessage, TableName, Index, ColumnName): Table = DomMessage.getElementsByTagName(TableName)[Index] ColumnTag = Table.getElementsByTagName(ColumnName)[0] return Table, getText(ColumnTag.childNodes) #Functions that generate the different parts of the CDA document def BeginDocument(): value = '\n' value += '\n' return value def Header(): value = '\n' return value def typeID(): value = '\n' return value def id(): value = '\n' return value def code(): value = '\n' return value def effectiveTime(): value = '\n' return value def confidentialityCode(): value = '\n' return value def recordTarget(FirstName, LastName): value = '\n' value += v3Indent(1) + '\n' value += v3Indent(2) + '\n' value += v3Indent(2) + '\n' value += v3Indent(3) + '\n' value += v3Indent(4) + '' + FirstName + '\n' value += v3Indent(4) + '' + LastName + '\n' value += v3Indent(4) + '' + 'Senior' + '\n' value += v3Indent(3) + '\n' value += v3Indent(3) + '\n' value += v3Indent(3) + '\n' value += v3Indent(2) + '\n' value += v3Indent(2) + '\n' value += v3Indent(3) + '\n' value += v3Indent(2) + '\n' value += v3Indent(1) + '\n' value += v3Indent(0) + '\n' return value def author(): value = '\n' value += v3Indent(1) + '\n' return value def custodian(): value = '\n' value += v3Indent(1) + '\n' value += v3Indent(2) + '\n' value += v3Indent(3) + '\n' value += v3Indent(2) + '\n' value += v3Indent(1) + '\n' value += '\n' return value def Body(): value = '\n' value += '\n' value += v3Indent(1) + '\n' value += v3Indent(2) + '\n' value += v3Indent(3) + '
\n' value += v3Indent(4) + '\n' value += v3Indent(4) + 'History of Present Illness\n' value += v3Indent(4) + '\n' value += v3Indent(5) + 'Henry Levin, the 7th\n' value += v3Indent(5) + 'is a 67 year old male referred for further asthma management.\n' value += v3Indent(5) + 'Onset of asthma in his twenties\n' value += v3Indent(5) + 'teens.\n' value += v3Indent(5) + 'He was hospitalized twice last year, and already twice this year.\n' value += v3Indent(5) + 'He has not been able to be weaned off steroids for the past several\n' value += v3Indent(5) + 'He was hospitalized twice last year, and already twice this year.\n' value += v3Indent(5) + 'months.\n' value += v3Indent(4) + '\n' value += v3Indent(3) + '
\n' value += v3Indent(2) + '
\n' value += v3Indent(1) + '
\n' value += v3Indent(0) + '
\n' return value def EndDocument(): value = '
\n' return value def V2toCDA(PlainDataXml): InMsg = xml.dom.minidom.parseString(PlainDataXml) v3 = BeginDocument() v3 += Header() v3 += typeID() v3 += id() v3 += code() v3 += effectiveTime() v3 += confidentialityCode() v3 += recordTarget(getItem(InMsg, "Patient", 0, "PatientFirstName"), getItem(InMsg, "Patient", 0, "PatientLastName")) v3 += author() v3 += custodian() v3 += Body() v3 += EndDocument() return v3 value = V2toCDA(value[3:]) ASCIITABLE - Short Tags'2'