`4F2MSH0\Ec:\tempHL7Hz*0 W@#7g #7g|~FR#7g^S#7g&T ~HL7]Z$[Me6SrUMY5EFX(n`#cTable0_#cY4FV6&ADTA31E53TE53T9'MSH52Field SeparatorcSTCb3ValueString52Encoding Characters52Sending ApplicationcEICb3Entity IdentifierCb3 Namespace IDcISCb3Value#Coded value for user-defined tablesCb3 Universal IDCb3Universal ID TypecIDCb3IDCoded values for HL7 tablesEntity Identifier52Sending Facility 52Receiving Application 52Receiving Facility 52Date/Time of MessagecTSCb3ValueTr Time Stamp !0(YYYY[MM[DD[HH[MM[SS[.SSSS]]]]]][+/-ZZZZ] Time stamp52Security52 Message TypecCM_MSHCb3EventCb3TypeMSH Event-Type Composite52Message Control ID52 Processing IDcPTCb3Processing TypeCb3Processing ModeProcessing Type52 Version ID52Sequence NumbercNMCb3ValueNumeric52Continuation Pointer52Accept Acknowledgement Type52 Application Acknowledgement Type52 Country Code52 Character Set52Principal Language of MessagecCECb3 IdentifierCb3TextCb3Name of coding systemCb3Alternate IdentifierCb3Alternate TextCb3Name of Coding System Coded ElementMessage HeaderMessageADTx#ADTA31 Person UpdateY4FV6& LabMessageE53TE53TMessage6ORUx# LabMessageLab result message cXCNCb3 ID NumberCb3 Family NameCb3 Given NameCb3Middle Initial or NameCb3SuffixCb3PrefixCb3DegreeCb3 Source Table Cb3Assigning authoritycHDCb3 Namespace Cb3 Universal IDCb3 Universal IDHierarchic DesignatorCb3Name type codeCb3Identifier check digitCb30Code identifying the check digit scheme employedCb3Identifier type code Cb3Assigning FacilityB%Extended composite ID number and nameBcSICb3Value Sequence ID.cCXCb3IDCb3 Check DigitCb30Code Identifying the check digit scheme employedCb3Assigning AuthorityBCb3Identifier Type Code Cb3Assigning FacilityB&Extended composite ID with check digitcXONCb3Organization NameCb3Organization name type code Cb3 ID Number&Cb3 Check Digit&Cb3 Code Identifying the Check DigitCb3Assigning AuthorityBCb3Identifier Type Code Cb3Assigned FacilityB%Extended composite name and ID number&cXAD Cb3Street AddressCb3Other DesignationCb3CityCb3State or ProvinceCb3Zip or postal codeCb3CountryCb3 Address typeCb3Other geographic designationCb3Country/parish code Cb3 Census Tract Extended AddresscXPNCb3 Family NameCb3 Given NameCb3Middle Initial or NameCb3SuffixCb3PrefixCb3DegreeCb3Name Type CodeExtended person namecXTN Cb3NumberCb3Telecommunications use codeCb3!Telecommunications equipment typeCb3 Email AddressCb3 Country Code&Cb3Area/City Code&Cb3 Phone Number&Cb3 Extension&Cb3Any Text"Extended telecommunications numbercDTCb3ValueTrDate (YYYY[MM[DD]]DatecCMCb3Field1Cb3Field2Cb3Field3Cb3Field4Cb3Field5Cb3Field6Composite - discouragedcCPCb3PricecMOCb3Quantity&Cb3 DenominationMoneyCb3 Price TypeCb3 From Value&Cb3To Value&Cb3 Range Units.Cb3 Range TypeComposite PricecJCCCb3Job code Cb3 Job class Job code/class !cDLNCb3License NumberCb3Issuing province, country Cb3Expiration DatezDriver's License NumbercPL Cb3 Point of Care Cb3Room Cb3Bed Cb3FacilityBCb3Location Status Cb3Person Location Type Cb3Building Cb3Floor Cb3Location DescriptionPerson locationcFCCb3Financial classCb3Effective dateFinancial classcFTCb3ValueFormatted textcCQCb3Quantity&Cb3Units.Composite Quantity with UnitscTQ Cb3QuantityCb3IntervalCb3DurationCb3Start Date/timeCb3 End Date/timeCb3PriorityCb3 ConditionCb3TextcTXCb3Value Text dataCb3 ConjunctionCb3Order sequencingTiming/quantity9'EVN52Event Type Code52Recorded Date/Time52Date/Time Planned Event52Event Reason Code 52 Operator ID852Event Occurred Event Type9'IN1152 Set ID - IN1K52Insurance Plan ID.52Insurance Company IDM52Insurance Company NameT52Insurance Company Address]52Insurance Co. Contact Personh52Insurance Co Phone Numberp52 Group Number52 Group NameT52Insured's Group Emp IDM52Insured's Group Emp NameT52Plan Effective Datez52Plan Expiration Datez52Authorization Information}52 Plan Type 52Name of Insuredh52!Insured's Relationship to Patient 52Insured's Date of Birth52Insured's Address]52Assignment of Benefits 52Coordination of Benefits 52Coord of Ben. Priority52Notice of Admission Flag52Notice of Admission Datez52Rpt of Eligibility Flag52Rpt of Eligibility Datez52Release Information Code 52Pre-Admit Cert (PAC)52Verification Date/Time52Verification By852Type of Agreement Code 52Billing Status 52Lifetime Reserve Days&52Delay Before L. R. Day&52Company Plan Code 52 Policy Number52Policy Deductible52Policy Limit - Amount52Policy Limit - Days&52Room Rate - Semi-Private52Room Rate - Private52Insured's Employment Status.52 Insured's Sex 52Insured's Employer Address]52Verification Status52Prior Insurance Plan ID 52 Coverage Type 52Handicap 52Insured's ID NumberM Insurance9'IN2H52Insured's Employee IDM52 Insured's Social Security Number52Insured's Employer Name852Employer Information Data 52Mail Claim Party 52Medicare Health Ins Card Number52Medicaid Case Nameh52Medicaid Case Number52Champus Sponsor Nameh52Champus ID Number52Dependent of Champus Recipient.52Champus Organization52Champus Station52Champus Service 52Champus Rank/Grade 52Champus Status 52Champus Retire Datez52Champus Non-Avail Cert on File52 Baby Coverage52Combine Baby Bill52Blood Deductible52Special Coverage Approval Nameh52Special Coverage Approval Title52Non-Covered Insurance Code 52Payor IDM52Payor Subscriber IDM52Eligibility Source 52Room Coverage Type/Amount}52Policy Type/Amount}52Daily Deductible}52Living Dependency 52Ambulatory Status 52 Citizenship 52Primary Language.52Living Arrangement 52Publicity Indicator.52Protection Indicator52Student Indicator 52Religion 52Mothers Maiden Nameh52 Nationality.52 Ethnic Group 52Marital Status 52Insured's Employment Start Datez52Insured's Employment Stop Datez52 Job Title52Job Code/Class52 Job Status 52Employer Contact Person Nameh52$Employer Contact Person Phone Numberp52Employer Contact Reason 52Insureds Contact Persons Nameh52)Insureds Contact Person Telephone Numberp52Insureds Contact Person Reason 52&Relationship To The Patient Start Datez52%Relationship To The Patient Stop Datez52Insurance Co. Contact Reason 52!Insurance Co Contact Phone Numberp52 Policy Scope 52 Policy Source 52Patient Member NumberM52#Guarantors Relationship To Insured 52!Insureds Telephone Number - Homep52#Insureds Employer Telephone Numberp52Military Handicapped Program.52 Suspend Flag52Copay Limit Flag52Stoploss Limit Flag52 Insured Organization Name And IDT52)Insured Employer Organization Name And IDT52Race 52$HCFA Patient Relationship to Insured. Insurance Additional Information9'NK1%52 Set ID - NK1K52Nameh52 Relationship.52Address]52 Phone Numberp52Business Phone Numberp52 Contact Role.52 Start Datez52End Datez52(Next of Kin/Associated Parties Job Title52-Next of Kin/Associated Parties Job Code/Class52.Next of Kin/Associated Parties Employee NumberM52Organization Name-NK1T52Marital Status 52Sex 52Date/Time of Birth52Living Dependency 52Ambulatory Status 52 Citizenship 52Primary Language.52Living Arrangement 52Publicity Indicator.52Protection Indicator52Student Indicator 52Religion 52Mothers Maiden Nameh52 Nationality.52 Ethnic Group 52Contact Reason.52Contact Persons Nameh52!Contact Persons Telephone Numberp52Contact Persons Address]52*Next of Kin/Associated Partys IdentifiersM52 Job Status 52Race 52Handicap 52%Contact Person Social Security NumberNext of Kin/Associated Parties9'PID52 Set ID - PIDK52Patient ID (External ID)M52Patient ID (Internal ID)M52Alternate Patient ID - PIDM52 Patient Nameh52Mother's Maiden Nameh52Date/Time of Birth52Sex 52 Patient Aliash52Race 52Patient Address]52 County Code 52Phone Number - Homep52Phone Number - Businessp52Primary Language.52Marital Status 52Religion 52Patient Account NumberM52SSN Number - Patient52Driver's Licence Number-Patient52Mother's IdentifierM52 Ethnic Group 52 Birth Place52Multiple Birth Indicator52 Birth Order&52 Citizenship 52Veterans Military Status.52 Nationalty.52Patient Death Date and Time52Patient Death IndicatorPatient Identification9'PV1452 Set ID - PV1K52 Patient Class 52Assigned Patient Location52Admission Type 52Preadmit NumberM52Prior Patient Location52Attending Doctor852Referring Doctor852Consulting Doctor852Hospital Service 52Temporary Location52Preadmit Test Indicator 52Readmission Indicator 52 Admit Source 52Ambulatory Status 52 VIP Indicator 52Admitting Doctor852 Patient Type 52 Visit NumberM52Financial Class52Charge Price Indicator 52 Courtesy Code 52 Credit Rating 52 Contract Code 52Contract Effective Datez52Contract Amount&52Contract Period&52 Interest Code 52Transfer to Bad Debt Code 52Transfer to Bad Debt Datez52Bad Debt Agency Code 52Bad Debt Transfer Amount&52Bad Debt Recovery Amount&52Delete Account Indicator 52Delete Account Datez52Discharge Disposition 52Discharged to Location}52 Diet Type 52Servicing Facility 52 Bed Status 52Account Status 52Pending Location52Prior Temporary Location52Admit Date/Time52Discharge Date/Time52Current Patient Balance&52 Total Charges&52Total Adjustments&52Total Payments&52Alternate Visit IDM52Visit Indicator 52Other Healthcare Provider8 Patient Visit9'ZPI9'ZP19'ZPS9'ZPX9'ZCS9'ZEN9'PR152 Set ID - PR1K52Procedure Coding Method 52Procedure Code.52Procedure Description52Procedure Date/Time52Procedure Functional Type 52Procedure Minutes&52Anesthesiologist852Anesthesia Code 52Anesthesia Minutes&52Surgeon852Procedure Practitioner852 Consent Code.52Procedure Priority&52Associated Diagnosis Code. Procedures9'NTE52 Set ID - NTEK52Source of Comment52CommentNotes and Comments9'OBR+52 Set ID - OBRK52Placer Order Number 52Filler Order Number 52Universal Service ID.52Priority52Requested Date/Time52Observation Date/Time52Observation End Date/Time52Collection Volume52Collector Identifier852Specimen Action Code52 Danger Code.52Relevant Clinical Info.52Specimen Received Date/Time52Specimen Source}52Ordering Provider852Order Callback Phone Numberp52Placer Field 152Placer Field 252Filler Field 152Filler Field 252#Results Rpt/Status Chng - Date/Time52Charge To Practice}52Diagnostic Serv Sect ID52 Result Status52 Parent Result}52Quantity/Timing52Result Copies To852 Parent Number}52Transportation Mode52Reason For Study.52Principal Result Interpreter}52Assistant Result Interpreter}52 Technician}52Transcriptionist}52Scheduled Date/Time52Number Of Sample Containers&52'Transport Logistics Of Collected Sample.52Collectors Comment.52$Transport Arrangement Responsibility.52Transport Arranged52Escort Required52!Planned Patient Transport Comment.Observation Request9'OBX52 Set ID - OBXK52 Value Type52Observation Identifier.52Observation Sub-ID52Observation Value52Units.52References Range52Abnormal Flags52 Probability&52Nature of Abnormal Test52Observ Result Status52Date Last Obs Normal Values52User Defined Access Checks52Date/Time of the Observation52 Producer's ID.52Responsible Observer852Observation Method.Observation/Result9'ORC52 Order Control52Placer Order Number 52Filler Order Number 52Placer Group Number 52 Order Status52 Response Flag52Quantity/Timing52Parent}52Date/Time of Transaction52 Entered By852 Verified By852Ordering Provider852Enterer's Location52Call Back Phone Numberp52Order Effective Date/Time52Order Control Code Reason.52Entering Organization.52Entering Device.52 Action By8 Common Order| MACHINEIDCODEMSHMSHPif value == 'A31': value = 'A08' elif value == 'A28': value = 'A01' Mvalue = value + '\\' + subfield(environment, 1, 0) clearfield(environment) if subfield(environment, 1, 0) == 'A31': setsubfield(environment, 1, 0, 'A08') if subfield(environment, 1, 0) == 'A28': setsubfield(environment, 1, 0, 'A01') f# TODO # make a function which allows us to say # do not pass this segment through if value <> '1' value = 'N' + value "value = get_clean_phone(value) Pid31 = value Blah = subfield(environment, 2, 0) setsubfield(environment, 3, 0, Blah) setsubfield(environment, 5, 0, Blah) setsubfield(environment, 2, 0, '') `# This code will replace all occurances of / with -. value = string.replace(value, '/', '-') 0if subfield(environment, 0, 0) == '': value = '""' if subfield(environment, 1, 0) == '': setsubfield(environment, 1, 0, '""') if subfield(environment, 2, 0) == '': setsubfield(environment, 2, 0, '""') if subfield(environment, 4, 0) == '': setsubfield(environment, 4, 0, '""') value = get_clean_phone(value) value = get_clean_phone(value) H# Need to copy PID.3.1 and prepend it with an 'E' value = 'E' + Pid31 # Get the assigning facility from here Blah = subfield(environment, 3, 0) setsubfield(environment, 5, 0, Blah) setsubfield(environment, 3, 0, '') # clear the original field defaultNew Configuration2MSH0\Ec:\tempHL7Hz*0 W@#7g #7g|~FR#7g^S#7g&T ~HL7]Z$[Me6SrUMY5EFX(ncIDCb3IDCoded values for HL7 tablescTSCb3ValueTr Time Stamp !0(YYYY[MM[DD[HH[MM[SS[.SSSS]]]]]][+/-ZZZZ] Time stampcISCb3Value#Coded value for user-defined tablescXCNCb3 ID NumbercSTCb3ValueStringCb3 Family Name%Cb3 Given Name%Cb3Middle Initial or Name%Cb3Suffix%Cb3Prefix%Cb3Degree%Cb3 Source Table!Cb3Assigning authoritycHDCb3 Namespace!Cb3 Universal ID%Cb3 Universal IDHierarchic DesignatorCb3Name type codeCb3Identifier check digit%Cb30Code identifying the check digit scheme employed%Cb3Identifier type code!Cb3Assigning Facility/%Extended composite ID number and name%/cSICb3Value Sequence IDcCECb3 Identifier%Cb3Text%Cb3Name of coding system%Cb3Alternate Identifier%Cb3Alternate Text%Cb3Name of Coding System% Coded ElementcCXCb3ID%Cb3 Check Digit%Cb30Code Identifying the check digit scheme employedCb3Assigning Authority/Cb3Identifier Type Code!Cb3Assigning Facility/&Extended composite ID with check digitcXONCb3Organization Name%Cb3Organization name type code!Cb3 ID NumbercNMCb3ValueNumericCb3 Check DigitLCb3 Code Identifying the Check DigitCb3Assigning Authority/Cb3Identifier Type Code!Cb3Assigned Facility/%Extended composite name and ID numberLcXAD Cb3Street Address%Cb3Other Designation%Cb3City%Cb3State or Province%Cb3Zip or postal code%Cb3CountryCb3 Address typeCb3Other geographic designation%Cb3Country/parish code!Cb3 Census Tract!Extended AddresscXPNCb3 Family Name%Cb3 Given Name%Cb3Middle Initial or Name%Cb3Suffix%Cb3Prefix%Cb3Degree%Cb3Name Type CodeExtended person namecXTN Cb3Number%Cb3Telecommunications use codeCb3!Telecommunications equipment typeCb3 Email Address%Cb3 Country CodeLCb3Area/City CodeLCb3 Phone NumberLCb3 ExtensionLCb3Any Text%"Extended telecommunications numbercDTCb3ValueTrDate (YYYY[MM[DD]]DatecCMCb3Field1Cb3Field2Cb3Field3Cb3Field4Cb3Field5Cb3Field6Composite - discouragedcCPCb3PricecMOCb3QuantityLCb3 DenominationMoneyCb3 Price TypeCb3 From ValueLCb3To ValueLCb3 Range Units:Cb3 Range TypeComposite Price|cJCCCb3Job code!Cb3 Job class!Job code/classcEICb3Entity Identifier%Cb3 Namespace ID!Cb3 Universal ID%Cb3Universal ID TypeEntity IdentifiercCM_MSHCb3EventCb3TypeMSH Event-Type CompositecPTCb3Processing TypeCb3Processing ModeProcessing TypecDLNCb3License Number%Cb3Issuing province, country!Cb3Expiration DatepDriver's License NumbercPL Cb3 Point of Care!Cb3Room!Cb3Bed!Cb3Facility/Cb3Location Status!Cb3Person Location Type!Cb3Building!Cb3Floor!Cb3Location Description%Person locationcFCCb3Financial classCb3Effective dateFinancial class9'EVN52Event Type Code52Recorded Date/Time52Date/Time Planned Event52Event Reason Code!52 Operator ID#52Event Occurred Event Type9'IN1152 Set ID - IN1852Insurance Plan ID:52Insurance Company IDA52Insurance Company NameH52Insurance Company AddressS52Insurance Co. Contact Person^52Insurance Co Phone Numberf52 Group Number%52 Group NameH52Insured's Group Emp IDA52Insured's Group Emp NameH52Plan Effective Datep52Plan Expiration Datep52Authorization Informations52 Plan Type!52Name of Insured^52!Insured's Relationship to Patient!52Insured's Date of Birth52Insured's AddressS52Assignment of Benefits!52Coordination of Benefits!52Coord of Ben. Priority%52Notice of Admission Flag52Notice of Admission Datep52Rpt of Eligibility Flag52Rpt of Eligibility Datep52Release Information Code!52Pre-Admit Cert (PAC)%52Verification Date/Time52Verification By#52Type of Agreement Code!52Billing Status!52Lifetime Reserve DaysL52Delay Before L. R. DayL52Company Plan Code!52 Policy Number%52Policy Deductiblez52Policy Limit - Amountz52Policy Limit - DaysL52Room Rate - Semi-Privatez52Room Rate - Privatez52Insured's Employment Status:52 Insured's Sex!52Insured's Employer AddressS52Verification Status%52Prior Insurance Plan ID!52 Coverage Type!52Handicap!52Insured's ID NumberA Insurance9'IN2H52Insured's Employee IDA52 Insured's Social Security Number%52Insured's Employer Name#52Employer Information Data!52Mail Claim Party!52Medicare Health Ins Card Number%52Medicaid Case Name^52Medicaid Case Number%52Champus Sponsor Name^52Champus ID Number%52Dependent of Champus Recipient:52Champus Organization%52Champus Station%52Champus Service!52Champus Rank/Grade!52Champus Status!52Champus Retire Datep52Champus Non-Avail Cert on File52 Baby Coverage52Combine Baby Bill52Blood Deductible%52Special Coverage Approval Name^52Special Coverage Approval Title%52Non-Covered Insurance Code!52Payor IDA52Payor Subscriber IDA52Eligibility Source!52Room Coverage Type/Amounts52Policy Type/Amounts52Daily Deductibles52Living Dependency!52Ambulatory Status!52 Citizenship!52Primary Language:52Living Arrangement!52Publicity Indicator:52Protection Indicator52Student Indicator!52Religion!52Mothers Maiden Name^52 Nationality:52 Ethnic Group!52Marital Status!52Insured's Employment Start Datep52Insured's Employment Stop Datep52 Job Title%52Job Code/Class52 Job Status!52Employer Contact Person Name^52$Employer Contact Person Phone Numberf52Employer Contact Reason!52Insureds Contact Persons Name^52)Insureds Contact Person Telephone Numberf52Insureds Contact Person Reason!52&Relationship To The Patient Start Datep52%Relationship To The Patient Stop Datep52Insurance Co. Contact Reason!52!Insurance Co Contact Phone Numberf52 Policy Scope!52 Policy Source!52Patient Member NumberA52#Guarantors Relationship To Insured!52!Insureds Telephone Number - Homef52#Insureds Employer Telephone Numberf52Military Handicapped Program:52 Suspend Flag52Copay Limit Flag52Stoploss Limit Flag52 Insured Organization Name And IDH52)Insured Employer Organization Name And IDH52Race!52$HCFA Patient Relationship to Insured: Insurance Additional Information9'MSH52Field Separator%52Encoding Characters%52Sending Application52Sending Facility52Receiving Application52Receiving Facility52Date/Time of Message52Security%52 Message Type52Message Control ID%52 Processing ID52 Version ID52Sequence NumberL52Continuation Pointer%52Accept Acknowledgement Type52 Application Acknowledgement Type52 Country Code52 Character Set52Principal Language of Message:Message Header9'NK1%52 Set ID - NK1852Name^52 Relationship:52AddressS52 Phone Numberf52Business Phone Numberf52 Contact Role:52 Start Datep52End Datep52(Next of Kin/Associated Parties Job Title%52-Next of Kin/Associated Parties Job Code/Class52.Next of Kin/Associated Parties Employee NumberA52Organization Name-NK1H52Marital Status!52Sex!52Date/Time of Birth52Living Dependency!52Ambulatory Status!52 Citizenship!52Primary Language:52Living Arrangement!52Publicity Indicator:52Protection Indicator52Student Indicator!52Religion!52Mothers Maiden Name^52 Nationality:52 Ethnic Group!52Contact Reason:52Contact Persons Name^52!Contact Persons Telephone Numberf52Contact Persons AddressS52*Next of Kin/Associated Partys IdentifiersA52 Job Status!52Race!52Handicap!52%Contact Person Social Security Number%Next of Kin/Associated Parties9'PID52 Set ID - PID852Patient ID (External ID)A52Patient ID (Internal ID)A52Alternate Patient ID - PIDA52 Patient Name^52Mother's Maiden Name^52Date/Time of Birth52Sex!52 Patient Alias^52Race!52Patient AddressS52 County Code!52Phone Number - Homef52Phone Number - Businessf52Primary Language:52Marital Status!52Religion!52Patient Account NumberA52SSN Number - Patient%52Driver's Licence Number-Patient52Mother's IdentifierA52 Ethnic Group!52 Birth Place%52Multiple Birth Indicator52 Birth OrderL52 Citizenship!52Veterans Military Status:52 Nationalty:52Patient Death Date and Time52Patient Death IndicatorPatient Identification9'PV1452 Set ID - PV1852 Patient Class!52Assigned Patient Location52Admission Type!52Preadmit NumberA52Prior Patient Location52Attending Doctor#52Referring Doctor#52Consulting Doctor#52Hospital Service!52Temporary Location52Preadmit Test Indicator!52Readmission Indicator!52 Admit Source!52Ambulatory Status!52 VIP Indicator!52Admitting Doctor#52 Patient Type!52 Visit NumberA52Financial Class52Charge Price Indicator!52 Courtesy Code!52 Credit Rating!52 Contract Code!52Contract Effective Datep52Contract AmountL52Contract PeriodL52 Interest Code!52Transfer to Bad Debt Code!52Transfer to Bad Debt Datep52Bad Debt Agency Code!52Bad Debt Transfer AmountL52Bad Debt Recovery AmountL52Delete Account Indicator!52Delete Account Datep52Discharge Disposition!52Discharged to Locations52 Diet Type!52Servicing Facility!52 Bed Status!52Account Status!52Pending Location52Prior Temporary Location52Admit Date/Time52Discharge Date/Time52Current Patient BalanceL52 Total ChargesL52Total AdjustmentsL52Total PaymentsL52Alternate Visit IDA52Visit Indicator!52Other Healthcare Provider# Patient Visit9'ZPI9'ZP19'ZPS9'ZPX9'ZCS9'ZEN9'PR152 Set ID - PR1852Procedure Coding Method!52Procedure Code:52Procedure Description%52Procedure Date/Time52Procedure Functional Type!52Procedure MinutesL52Anesthesiologist#52Anesthesia Code!52Anesthesia MinutesL52Surgeon#52Procedure Practitioner#52 Consent Code:52Procedure PriorityL52Associated Diagnosis Code: Procedures rE53TE53T%MessageADTx#MSHA31x#MSHE53TMessageMapsetCopy of Mapset ADTx#MSH6ORUx#MSH6Pdef get_clean_phone(OrigNumber): Number = strip_non_numeric_chars(OrigNumber) if len(Number) == 10: Number = '(' + Number[0:3] + ')' + Number[3:6] + '-' + Number[6:10] elif len(Number) == 7: Number = Number[0:3] + '-' + Number[3:7] return Number def hard_delete(Value): if Value == "": return '""' else: return Value NteCount = 0 def count_of_NTE(): global NteCount return NteCount def resetNteCount(): global NteCount NteCount = 0 def add_NTE_segment(Value, Label): if Value <> '': global NteCount Value = strip_trailing_chars(' ', Value) NteCount = NteCount + 1 return "NTE|" + str(NteCount) + '||' + Label + ':' + Value + "|\r" else: return '' def escape_note(Note): Note = string.replace(Note, '$E$', '\\R\\') Note = string.replace(Note, '$F$', '\\S\\') Note = string.replace(Note, '$S$', '\\E\\') Note = string.replace(Note, '$T$', '\\T\\') Note = string.replace(Note, '$R$', '\\F\\') Note = strip_trailing_chars(' ', Note) return Note ..                0value = "fff" Noddy = chameleon.new_noddy !current_segment = environment.input_segment_iterator() Msh4 = current_segment.field(4).value current_segment.apply_transform() output = current_segment.output() if current_segment.move_next('EVN'): current_segment.apply_transform() output = output + current_segment.output() if current_segment.move_next('PID'): current_segment.apply_transform() current_segment.field(4).subfield(4).value ='FMPSSN' SponId = current_segment.field(4).subfield(0).value Id1 = SponId[3:] Id1 = strip_chars('-', Id1) current_segment.field(4).repeat_field(1).subfield(0).value = Id1 current_segment.field(4).repeat_field(1).subfield(4).value = 'SPONSSN' current_segment.field(4).repeat_field(2).subfield(0).value = SponId[0:2] current_segment.field(4).repeat_field(2).subfield(4).value = 'FMP' current_segment.field(4).repeat_field(3).subfield(0).value = current_segment.field(5).subfield(0).value[0:1] + SponId[10:14] current_segment.field(4).repeat_field(3).subfield(4).value = 'LNSPSSN' current_segment.field(4).repeat_field(4).subfield(0).value = current_segment.field(5).subfield(0).value[0:1] + current_segment.field(19).subfield(0).value[7:11] current_segment.field(4).repeat_field(4).subfield(4).value ='LNSSN' if current_segment.field(14).value == '': current_segment.field(14).value = '""' isPCMID = 'N' current_segment2 = environment.input_segment_iterator() current_segment2.reset() if current_segment2.move_next('ZPX'): Zpx4 = current_segment2.field(4).value if Zpx4 <> "" : # log("ZPX4=" + Zpx4) isPCMID='Y' current_segment.field(4).repeat_field(5).subfield(0).value = Zpx4 + '-' + Msh4 current_segment.field(4).repeat_field(5).subfield(4).value = 'PCMID' IsVip = 'N' current_segment2.reset() if current_segment2.move_next('ZP1'): for ItemIndex in range(0, current_segment2.field(4).count_of_repeat()): Title = current_segment2.field(4).repeat_field(ItemIndex).value if (Title == "CONGRESSIONAL"): IsVip = 'Y' elif (Title == "FLAG ADMISSIONS"): IsVip = 'Y' elif (Title == "FOREIGN DIGNITARY"): IsVip = 'Y' elif (Title == "SECRETARIAL DESIGNEE"): IsVip = 'Y' if isPCMID == 'Y' : field_number = 6 else : field_number = 5 if IsVip <> 'Y' : current_segment.field(4).repeat_field(field_number).subfield(0).value = 'N' else: current_segment.field(4).repeat_field(field_number).subfield(0).value = 'Y' current_segment.field(4).repeat_field(field_number).subfield(4).value = 'VIP' output = output + current_segment.output() ZenCount = 0 current_segment.reset() if current_segment.move_next('PID'): if not current_segment.field(27).is_null(): ZenCount = ZenCount + 1 output += "ZEN|" + str(ZenCount) + "|PATCAT|" output += current_segment.field(27).subfield(0).value + "^" + current_segment.field(27).subfield(3).value + " " + current_segment.field(27).subfield(1).value output += "\r" current_segment.reset() if current_segment.move_next('ZPX'): if not current_segment.field(1).is_null(): ZenCount = ZenCount + 1 Code = current_segment.field(1).value output = output + "ZEN|" + str(ZenCount) + "|ACV|" + Code + "^" if Code == "A": output += "TRICARE PRIME (ACTIVE DUTY)" elif Code == "B": output += "CHAMPVA (OCONUS)" elif Code == "C": output += "CHAMPUS" elif Code == "D": output += "MEDICARE DEMONSTRATION" elif Code == "E": output += "TRICARE PRIME (CHAMPUS)" elif Code == "I": output += "FEDERAL EMPLOYEE HEALTH BENEFITS PROGRAM" elif Code == "K": output += "CATCHMAN AREA MG" output += "|\r" if not current_segment.field(3).is_null(): ZenCount = ZenCount + 1 output = output + "ZEN|" + str(ZenCount) + "|DMISID|" output += current_segment.field(3).subfield(1).value + "^" + current_segment.field(3).subfield(1).value output += "|\r" current_segment.reset() if current_segment.move_next('ZPS'): if not current_segment.field(9).is_null(): ZenCount = ZenCount + 1 output = output + "ZEN|" + str(ZenCount) + "|UIC|^" output += current_segment.field(9).subfield(1).value + " (" + current_segment.field(9).subfield(3).value + ")" output += "|\r" if not current_segment.field(5).is_null(): ZenCount = ZenCount + 1 output = output + "ZEN|" + str(ZenCount) + "|RANK|" output += current_segment.field(5).subfield(0).value + "^" + current_segment.field(5).subfield(1).value output += "|\r" current_segment.reset() if current_segment.move_next('ZPI'): if not current_segment.field(7).is_null(): ZenCount = ZenCount + 1 output = output + "ZEN|" + str(ZenCount) + "|DEERS|" output += current_segment.field(7).value + "^" + current_segment.field(7).value output += "|\r" if not current_segment.field(9).is_null(): ZenCount = ZenCount + 1 output = output + "ZEN|" + str(ZenCount) + "|DST|" output += "^" + current_segment.field(9).value output += "|\r" if not current_segment.field(10).is_null(): ZenCount = ZenCount + 1 output = output + "ZEN|" + str(ZenCount) + "|DEND|" output += "^" + current_segment.field(10).value output += "|\r" current_segment.reset() if current_segment.move_next('ZP1'): if not current_segment.field(2).subfield(0).subfield(0).is_null(): ZenCount = ZenCount + 1 output = output + "ZEN|" + str(ZenCount) + "|RECSAT|" output += current_segment.field(2).subfield(0).subfield(0).value + "^" + current_segment.field(2).subfield(0).subfield(1).value output += "|\r" if not current_segment.field(5).is_null(): ZenCount = ZenCount + 1 output = output + "ZEN|" + str(ZenCount) + "|VMS|" output += current_segment.field(5).value output += "|\r" Code1 = '""' Code2 = '""' current_segment.reset() if current_segment.move_next('ZCS'): Code1 = hard_delete(current_segment.field(1).subfield(0).value) Code2 = hard_delete(current_segment.field(1).subfield(1).value) ZenCount = ZenCount + 1 output = output + "ZEN|" + str(ZenCount) + "|COMSEC|" + Code1 + "^" + Code2 + "|\r" current_segment.reset() if current_segment.move_next('ZCS'): if not current_segment.field(2).is_null(): ZenCount = ZenCount + 1 output = output + "ZEN|" + str(ZenCount) + "|DNAONFILE|" output += current_segment.field(2).value output += "|\r" ZenCount = ZenCount + 1 output = output + "ZEN|" + str(ZenCount) + "|COMINT|PRESENT" output += "|\r" ParentId = str(ZenCount) current_segment.reset() current_segment.move_next('ZP1') for ItemIndex in range(0, current_segment.field(4).count_of_repeat()) : if ((not current_segment.field(4).repeat_field(ItemIndex).is_null()) or (not current_segment.field(4).repeat_field(ItemIndex).subfield(1).is_null())): ZenCount = ZenCount + 1 output = output + "ZEN|" + str(ZenCount) + "|COMINT|" output = output + hard_delete(current_segment.field(4).repeat_field(ItemIndex).subfield(0).value) + "^" + hard_delete(current_segment.field(4).repeat_field(ItemIndex).subfield(1).value) + "|" + ParentId output += "|\r" if (ZenCount == 10): output = output + 'ZEN|11|COMINT|""^""|10\r' # empirically observed mapping rule current_segment.reset() if current_segment.move_next('NK1'): current_segment.apply_transform() output = output + current_segment.output() current_segment.reset() if current_segment.move_next('PV1'): current_segment.apply_transform() output = output + current_segment.output() current_segment.reset() if current_segment.move_next('PR1'): current_segment.apply_transform() output = output + current_segment.output() else: output = output + 'PR1||\r' # put an empty PR1 segment in #In1Count = 0 current_segment.reset() while current_segment.move_next('IN1'): if (current_segment.field(7).value == ''): current_segment.field(7).value = '""' else: current_segment.field(7).value = get_clean_phone(current_segment.field(7).value) current_segment.field(5).subfield(0).value = strip_trailing_chars(' ', current_segment.field(5).subfield(0).value) current_segment.field(32).subfield(0).value = '' # default this to null output = output + current_segment.output() value = output # The iterator object, named current_segment in this example is # effectively a pointer into the list segments that are found in # the message. We start by creating this object using the method # input_segment_iterator() on the built-in environment object. # Get an iterator, called current_segment, that points to the first # segment - in an HL7 message this will always be the MSH segment. current_segment = environment.input_segment_iterator() # The iterator starts out on the first segment - i.e. the MSH segment. The # apply_transform() method invokes the outbound segment scripts defined for # the current segment. This is a reasonable technique for small sets of scripts, but # for larger scripts, it is probably better to do all the processing explicitly here. current_segment.apply_transform() # The output() method of current_segment returns the flatwire - you will see that # the script uses this method repeatedly. output = current_segment.output() # The move_next() method on current_segment will return false if the segment named # is not found. This is a useful technique for dealing with optional segments. if current_segment.move_next('PID'): current_segment.field(1).value = "BLUE" current_segment.field(3).subfield(0).value = "D" current_segment.field(3).subfield(3).value = current_segment.field(3).subfield(2).value current_segment.field(3).subfield(5).value = current_segment.field(3).subfield(2).value current_segment.field(3).subfield(2).value = '' Pid4 = current_segment.field(4).value Pid4 = string.replace(Pid4, '/', '-') current_segment.field(4).value = Pid4 if current_segment.field(11).is_null(): current_segment.field(11).subfield(0).value = '""' current_segment.field(11).subfield(1).value = '""' current_segment.field(11).subfield(2).value = '""' current_segment.field(11).subfield(3).value = '""' current_segment.field(11).subfield(4).value = '""' # One very handy technique with scripted transformation is to define reusable # functions to do common tasks like cleaning up phone numbers. The function # described below is defined in the 'Global Inbound Script.' current_segment.field(13).value = get_clean_phone(current_segment.field(13).value) current_segment.field(14).value = get_clean_phone(current_segment.field(14).value) current_segment.field(18).value = "E" + current_segment.field(3).value # This code shows how we can use a python loop to clear a range of fields # Clear all fields after 18. for FieldIndex in range(19, current_segment.count_of_field()): current_segment.field(FieldIndex).clear() output = output + current_segment.output() if current_segment.move_next('OBR'): # We do the NTE segments for the OBR segment before # outputting or modifying the OBR segment because we'll need to # clear some fields in the OBR segment. # Here we are invoking some functions we defined in the 'Global Inbound # Script' to keep a track of the number of NTE segments we are putting out. # The add_NTE_segment function is just a handy re-usable function to make # formatting these additional NTE segments easier. resetNteCount() nte_output = '' nte_output = nte_output + add_NTE_segment(" " + current_segment.field(16).subfield(0).value + " " + current_segment.field(16).subfield(1).value + ", " + current_segment.field(16).subfield(2).value + " " + current_segment.field(16).subfield(3).value, "PROVIDER") nte_output = nte_output + add_NTE_segment(current_segment.field(5).subfield(0).value, "PRIORITY") nte_output = nte_output + add_NTE_segment(current_segment.field(15).subfield(1).value, "SPECIMEN") nte_output = nte_output + add_NTE_segment(current_segment.field(6).subfield(0).value, "DATE_ORDERED") Obr_15_7 = current_segment.field(15).subfield(6).value # we save this field because we nullify it later. Obr_15_1 = current_segment.field(15).subfield(0).value Obr_15_2 = current_segment.field(15).subfield(1).value Obr_15_3 = current_segment.field(15).subfield(2).value Obr_15_6 = current_segment.field(15).subfield(5).value # clear() is a helpful method for completely clearing a field and it's children. current_segment.field(15).clear() current_segment.field(15).subfield(0).subfield(0).value = Obr_15_1 current_segment.field(15).subfield(0).subfield(1).value = Obr_15_2 current_segment.field(15).subfield(0).subfield(2).value = Obr_15_3 current_segment.field(15).subfield(0).subfield(5).value = Obr_15_6 current_segment.field(3).subfield(0).value = current_segment.field(20).value current_segment.field(6).subfield(0).value = '' current_segment.field(13).clear() for FieldIndex in range(16, 24) : current_segment.field(FieldIndex).clear() for FieldIndex in range(26, current_segment.count_of_field()): current_segment.field(FieldIndex).clear() current_segment.field(15).subfield(6).value = '' current_segment.field(15).subfield(7).value = '' output = output + current_segment.output() output = output + nte_output if current_segment.move_next('OBX'): output = output + add_NTE_segment(current_segment.field(14).value, "DATE_RESULTED") # The reset() method is used to put the segment iterator back at the MSH segment. current_segment.reset() if current_segment.move_next('OBR'): output = output + add_NTE_segment(Obr_15_7, "COLLECT_SAMPLE") # this field is saved from before # we get the count of NTE segments - see Options Screen function NteCount = count_of_NTE() #NteCount = 99 while current_segment.move_one() and current_segment.segment_id() == 'NTE': NteCount = NteCount + 1 current_segment.field(1).value = str(NteCount) output = output + current_segment.output() current_segment.reset() while current_segment.move_next('OBX'): current_segment.field(2).value = 'TX' current_segment.field(3).subfield(0).value = current_segment.field(3).value + "-" + Obr_15_1 current_segment.apply_transform() NteCount = 1 if (not current_segment.field(14).is_null()): NteOutput = "NTE|1||DATE_RESULTED:" + current_segment.field(14).value + "\r" NteCount = NteCount + 1 for FieldIndex in range(12, current_segment.count_of_field()): current_segment.field(FieldIndex).clear() output = output + current_segment.output() output = output + NteOutput NteOutput = '' while current_segment.move_next('NTE'): current_segment.field(1).subfield(0).value = str(NteCount) NteCount = NteCount + 1 current_segment.field(3).subfield(0).value = escape_note(current_segment.field(3).value) output = output + current_segment.output() # All much of the same really - once you do one you can do a hundred! value = output ASCIIASCIIEXPANDEDSTANDARD1H%4+1H%4V$q