TIUHL7P2 ; SLC/AJB - TIUHL7 Msg Processing; March 23, 2005
;;1.0;TEXT INTEGRATION UTILITIES;**200,228**;Jun 20, 1997
Q
CONTINUE ; data verification
;
; DOCUMENT TEXT
D
. N TIUI S TIUTMP=0 F S TIUTMP=$O(TIUZ("TEXT",TIUTMP)) Q:'TIUTMP I +$L(TIUZ("TEXT",TIUTMP,0)) S TIUI=1
. I '+$G(TIUI) D ERR^TIUHL7U1("OBX",1,"0000.00","Missing DOCUMENT TEXT.")
;
; DOCUMENT TITLE
I +TIU("TDA")'>0 D ERR^TIUHL7U1("TXA",16,"0000.00","Could not resolve the document title "_TIU("TITLE")_".")
I +$$GET1^DIQ(8925.1,TIU("TDA"),.07,"I")'=11 D ERR^TIUHL7U1("TXA",16,"0000.00","The document title "_TIU("TITLE")_" must be ACTIVE before use.")
;
; AUTHOR/DICTATOR
D
. I '+$L(TIU("AUNAME")) D ERR^TIUHL7U1("TXA",9,"0000.00","Missing AUTHOR/DICTATOR name from HL7 message.") Q
. I '+$G(TIU("AUDA")),'+$G(TIU("AUSSN")) S TIU("AUDA")=$$LU^TIUHL7U1(200,TIU("AUNAME"),"X") I '+TIU("AUDA") D ERR^TIUHL7U1("TXA",9,"0000.00","AUTHOR/DICTATOR name lookup failed for ["_TIU("AUNAME")_"].") Q
. I '+$G(TIU("AUDA")),+$G(TIU("AUSSN")) S TIU("AUDA")=+$$FIND1^DIC(200,"","X",+$G(TIU("AUSSN")),"SSN") I '+TIU("AUDA") D ERR^TIUHL7U1("TXA",9,"0000.00","SSN ["_TIU("AUSSN")_"] lookup failed for AUTHOR/DICTATOR.") Q
. I '$$COMPARE^TIUHL7U1($$GET1^DIQ(200,TIU("AUDA"),.01),TIU("AUNAME")) D
. . D ERR^TIUHL7U1("TXA",9,"0000.00","AUTHOR/DICTATOR name discrepancy between HL7 message IEN/SSN ["_$$GET1^DIQ(200,TIU("AUDA"),.01)_"]"_" & the HL7 message name ["_TIU("AUNAME")_"].")
;
; EXPECTED CO-SIGNER [ignored if AUTHOR/DICTATOR does not require]
I $$REQCOSIG^TIULP($G(TIU("TDA")),,$G(TIU("AUDA")),$G(TIU("RFDT"))) D
. N TIUTMP
. S TIUZ(1506)=1
. I +$L($G(TIU("CSNAME")))!(+$G(TIU("CSDA")))!(+$G(TIU("CSSSN"))) D
. . I '+$L($G(TIU("CSNAME"))) D ERR^TIUHL7U1("TXA",10,"0000.00","Missing EXPECTED COSIGNER name from HL7 message.") Q
. . I '+$G(TIU("CSDA")),'+$G(TIU("CSSSN")) S TIU("CSDA")=$$LU^TIUHL7U1(200,TIU("CSNAME"),"X") I '+TIU("CSDA") D ERR^TIUHL7U1("TXA",10,"0000.000","EXPECTED COSIGNER name lookup failed for ["_TIU("CSNAME")_"].") Q
. . I '+$G(TIU("CSDA")),+$G(TIU("CSSSN")) S TIU("CSDA")=+$$FIND1^DIC(200,"","X",+$G(TIU("CSSSN")),"SSN") I '+TIU("CSDA") D ERR^TIUHL7U1("TXA",10,"0000.00","SSN ["_TIU("CSSSN")_"] lookup failed for EXPECTED COSIGNER.") Q
. . I '$$COMPARE^TIUHL7U1($$GET1^DIQ(200,TIU("CSDA"),.01),TIU("CSNAME")) D
. . . D ERR^TIUHL7U1("TXA",10,"0000.00","EXPECTED COSIGNER name discrepancy between HL7 message IEN/SSN ["_$$GET1^DIQ(200,TIU("CSDA"),.01)_"]"_" & HL7 message name ["_TIU("CSNAME")_"].")
. I '+$G(TIU("CSDA")) D ERR^TIUHL7U1("TXA",10,"0000.000","Unable to resolve EXPECTED COSIGNER; the AUTHOR/DICTATOR ["_TIU("AUNAME")_"] requires COSIGNATURE.")
;
; ENTERED BY [optional]
I +$L($G(TIU("EBNAME")))!(+$G(TIU("EBDA")))!(+$G(TIU("EBSSN"))) D
. I '+$L($G(TIU("EBNAME"))) D ERR^TIUHL7U1("TXA",11,"0000.00","Missing ENTERED BY name from HL7 message.") Q
. I '+$G(TIU("EBDA")),'+$G(TIU("EBSSN")) S TIU("EBDA")=$$LU^TIUHL7U1(200,TIU("EBNAME"),"X") I '+TIU("EBDA") D ERR^TIUHL7U1("TXA",11,"0000.000","ENTERED BY name lookup failed for ["_TIU("EBNAME")_"].") Q
. I '+$G(TIU("EBDA")),+$G(TIU("EBSSN")) S TIU("EBDA")=+$$FIND1^DIC(200,"","X",+$G(TIU("EBSSN")),"SSN") I '+TIU("EBDA") D ERR^TIUHL7U1("TXA",11,"0000.00","SSN ["_TIU("EBSSN")_"] lookup failed for ENTERED BY.") Q
. I '$$COMPARE^TIUHL7U1($$GET1^DIQ(200,TIU("EBDA"),.01),TIU("EBNAME")) D
. . D ERR^TIUHL7U1("TXA",11,"0000.00","ENTERED BY name discrepancy between HL7 message IEN/SSN ["_$$GET1^DIQ(200,TIU("EBDA"),.01)_"]"_" & HL7 message name ["_TIU("EBNAME")_"].")
;
; EPISODE BEGIN DATE/TIME for DISCHARGE SUMMARIES
I $$MEMBEROF^TIUHL7U1(TIU("TITLE"),"DISCHARGE SUMMARIES") D
. I '+$G(TIU("CSDA")) D ERR^TIUHL7U1("TXA",10,"0000.000","DISCHARGE SUMMARIES require an ATTENDING PHYSICIAN (EXPECTED COSIGNER).")
. S TIUZ(1209)=$G(TIU("CSDA"))
. I +TIU("VNUM") D Q
. . I '$$COMPARE^TIUHL7U1($$GET1^DIQ(9000010,TIU("VNUM"),.05),$S(+$G(DFN):$$GET1^DIQ(2,DFN,.01),1:TIU("PTNAME"))) D
. . . D ERR^TIUHL7U1("PV1",19,"0000.00","HL7 message PATIENT NAME ["_TIU("PTNAME")_"] does not match VISIT PATIENT NAME ["_$$GET1^DIQ(9000010,TIU("VNUM"),.05)_"].") Q
. . S TIU("EPDT")=$$GET1^DIQ(9000010,TIU("VNUM"),.01,"I"),TIU("VSTR")=$$VSTRBLD^TIUSRVP(TIU("VNUM"))
. I '+TIU("EPDT") D ERR^TIUHL7U1("PV1",44,"0000.000",TIU("TITLE")_" requires an EPISODE BEGIN DATE/TIME.") Q
. I '+$$GETADMIT^TIUHL7U1(+$G(DFN),TIU("EPDT")) D ERR^TIUHL7U1("PV1","44","0000.00","Could not resolve ADMISSION DT[TIME] for "_$$FMTE^XLFDT(TIUDT)_".")
;
; VISIT information for PROGRESS NOTES
I $$MEMBEROF^TIUHL7U1(TIU("TITLE"),"PROGRESS NOTES") D
. I TIU("VNUM")="NEW" D Q
. . N TYP
. . I '+TIU("HLOC"),TIU("AVAIL")'="AV" D ERR^TIUHL7U1("PV1",4,"0000.00","Missing/Invalid HOSPITAL LOCATION ('AV' not set); required for NEW visits.") Q
. . I +TIU("EPDT")'>0 S TIU("EPDT")=$$NOW^XLFDT
. . I $L(TIU("EPDT"),".")=1 S TIU("EPDT")=TIU("EPDT")_"."_$P($$NOW^XLFDT,".",2)
. . I +TIU("HLOC") I $$GET1^DIQ(44,TIU("HLOC"),2,"I")="W" S TYP="I"
. . I +TIU("HLOC")'>0 S TIU("HLOC")=""
. . S TIU("VSTR")=TIU("HLOC")_";"_TIU("EPDT")_";"_$S($G(TYP)="I":"I",TIU("AVAIL")="AV":"E",1:"A")
. I +TIU("VNUM") D Q
. . I '$$COMPARE^TIUHL7U1($$GET1^DIQ(9000010,TIU("VNUM"),.05),$S(+$G(DFN):$$GET1^DIQ(2,DFN,.01),1:TIU("PTNAME"))) D Q
. . . D ERR^TIUHL7U1("PV1",19,"0000.00","HL7 message PATIENT NAME ["_TIU("PTNAME")_"] does not match VISIT PATIENT NAME ["_$$GET1^DIQ(9000010,TIU("VNUM"),.05)_"].")
. . S TIU("EPDT")=$$GET1^DIQ(9000010,TIU("VNUM"),.01,"I"),TIU("VSTR")=$$VSTRBLD^TIUSRVP(TIU("VNUM"))
. I '+TIU("VNUM") D
. . I +TIU("EPDT") I '+$$GETADMIT^TIUHL7U1(+$G(DFN),TIU("EPDT")),TIU("AVAIL")'="AV" D ERR^TIUHL7U1("PV1","44","0000.00","Could not find a visit for "_$$FMTE^XLFDT(TIU("EPDT"))_".") Q
. . I '+$$GETVISIT^TIUHL7U1(+$G(DFN),TIU("RFDT")),TIU("AVAIL")'="AV" D ERR^TIUHL7U1("PV1","44","0000.00","Could not find a visit for "_$$FMTE^XLFDT(TIU("RFDT"))_".") Q
. . S TIU("VSTR")=TIU("HLOC")_";"_$$NOW^XLFDT_";E"
;
D CONTINUE^TIUHL7P3
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HTIUHL7P2 6063 printed Dec 13, 2024@02:41:40 Page 2
TIUHL7P2 ; SLC/AJB - TIUHL7 Msg Processing; March 23, 2005
+1 ;;1.0;TEXT INTEGRATION UTILITIES;**200,228**;Jun 20, 1997
+2 QUIT
CONTINUE ; data verification
+1 ;
+2 ; DOCUMENT TEXT
+3 Begin DoDot:1
+4 NEW TIUI
SET TIUTMP=0
FOR
SET TIUTMP=$ORDER(TIUZ("TEXT",TIUTMP))
if 'TIUTMP
QUIT
IF +$LENGTH(TIUZ("TEXT",TIUTMP,0))
SET TIUI=1
+5 IF '+$GET(TIUI)
DO ERR^TIUHL7U1("OBX",1,"0000.00","Missing DOCUMENT TEXT.")
End DoDot:1
+6 ;
+7 ; DOCUMENT TITLE
+8 IF +TIU("TDA")'>0
DO ERR^TIUHL7U1("TXA",16,"0000.00","Could not resolve the document title "_TIU("TITLE")_".")
+9 IF +$$GET1^DIQ(8925.1,TIU("TDA"),.07,"I")'=11
DO ERR^TIUHL7U1("TXA",16,"0000.00","The document title "_TIU("TITLE")_" must be ACTIVE before use.")
+10 ;
+11 ; AUTHOR/DICTATOR
+12 Begin DoDot:1
+13 IF '+$LENGTH(TIU("AUNAME"))
DO ERR^TIUHL7U1("TXA",9,"0000.00","Missing AUTHOR/DICTATOR name from HL7 message.")
QUIT
+14 IF '+$GET(TIU("AUDA"))
IF '+$GET(TIU("AUSSN"))
SET TIU("AUDA")=$$LU^TIUHL7U1(200,TIU("AUNAME"),"X")
IF '+TIU("AUDA")
DO ERR^TIUHL7U1("TXA",9,"0000.00","AUTHOR/DICTATOR name lookup failed for ["_TIU("AUNAME")_"].")
QUIT
+15 IF '+$GET(TIU("AUDA"))
IF +$GET(TIU("AUSSN"))
SET TIU("AUDA")=+$$FIND1^DIC(200,"","X",+$GET(TIU("AUSSN")),"SSN")
IF '+TIU("AUDA")
DO ERR^TIUHL7U1("TXA",9,"0000.00","SSN ["_TIU("AUSSN")_"] lookup failed for AUTHOR/DICTATOR.")
QUIT
+16 IF '$$COMPARE^TIUHL7U1($$GET1^DIQ(200,TIU("AUDA"),.01),TIU("AUNAME"))
Begin DoDot:2
+17 DO ERR^TIUHL7U1("TXA",9,"0000.00","AUTHOR/DICTATOR name discrepancy between HL7 message IEN/SSN ["_$$GET1^DIQ(200,TIU("AUDA"),.01)_"]"_" & the HL7 message name ["_TIU("AUNAME")_"].")
End DoDot:2
End DoDot:1
+18 ;
+19 ; EXPECTED CO-SIGNER [ignored if AUTHOR/DICTATOR does not require]
+20 IF $$REQCOSIG^TIULP($GET(TIU("TDA")),,$GET(TIU("AUDA")),$GET(TIU("RFDT")))
Begin DoDot:1
+21 NEW TIUTMP
+22 SET TIUZ(1506)=1
+23 IF +$LENGTH($GET(TIU("CSNAME")))!(+$GET(TIU("CSDA")))!(+$GET(TIU("CSSSN")))
Begin DoDot:2
+24 IF '+$LENGTH($GET(TIU("CSNAME")))
DO ERR^TIUHL7U1("TXA",10,"0000.00","Missing EXPECTED COSIGNER name from HL7 message.")
QUIT
+25 IF '+$GET(TIU("CSDA"))
IF '+$GET(TIU("CSSSN"))
SET TIU("CSDA")=$$LU^TIUHL7U1(200,TIU("CSNAME"),"X")
IF '+TIU("CSDA")
DO ERR^TIUHL7U1("TXA",10,"0000.000","EXPECTED COSIGNER name lookup failed for ["_TIU("CSNAME")_"].")
QUIT
+26 IF '+$GET(TIU("CSDA"))
IF +$GET(TIU("CSSSN"))
SET TIU("CSDA")=+$$FIND1^DIC(200,"","X",+$GET(TIU("CSSSN")),"SSN")
IF '+TIU("CSDA")
DO ERR^TIUHL7U1("TXA",10,"0000.00","SSN ["_TIU("CSSSN")_"] lookup failed for EXPECTED COSIGNER.")
QUIT
+27 IF '$$COMPARE^TIUHL7U1($$GET1^DIQ(200,TIU("CSDA"),.01),TIU("CSNAME"))
Begin DoDot:3
+28 DO ERR^TIUHL7U1("TXA",10,"0000.00","EXPECTED COSIGNER name discrepancy between HL7 message IEN/SSN ["_$$GET1^DIQ(200,TIU("CSDA"),.01)_"]"_" & HL7 message name ["_TIU("CSNAME")_"].")
End DoDot:3
End DoDot:2
+29 IF '+$GET(TIU("CSDA"))
DO ERR^TIUHL7U1("TXA",10,"0000.000","Unable to resolve EXPECTED COSIGNER; the AUTHOR/DICTATOR ["_TIU("AUNAME")_"] requires COSIGNATURE.")
End DoDot:1
+30 ;
+31 ; ENTERED BY [optional]
+32 IF +$LENGTH($GET(TIU("EBNAME")))!(+$GET(TIU("EBDA")))!(+$GET(TIU("EBSSN")))
Begin DoDot:1
+33 IF '+$LENGTH($GET(TIU("EBNAME")))
DO ERR^TIUHL7U1("TXA",11,"0000.00","Missing ENTERED BY name from HL7 message.")
QUIT
+34 IF '+$GET(TIU("EBDA"))
IF '+$GET(TIU("EBSSN"))
SET TIU("EBDA")=$$LU^TIUHL7U1(200,TIU("EBNAME"),"X")
IF '+TIU("EBDA")
DO ERR^TIUHL7U1("TXA",11,"0000.000","ENTERED BY name lookup failed for ["_TIU("EBNAME")_"].")
QUIT
+35 IF '+$GET(TIU("EBDA"))
IF +$GET(TIU("EBSSN"))
SET TIU("EBDA")=+$$FIND1^DIC(200,"","X",+$GET(TIU("EBSSN")),"SSN")
IF '+TIU("EBDA")
DO ERR^TIUHL7U1("TXA",11,"0000.00","SSN ["_TIU("EBSSN")_"] lookup failed for ENTERED BY.")
QUIT
+36 IF '$$COMPARE^TIUHL7U1($$GET1^DIQ(200,TIU("EBDA"),.01),TIU("EBNAME"))
Begin DoDot:2
+37 DO ERR^TIUHL7U1("TXA",11,"0000.00","ENTERED BY name discrepancy between HL7 message IEN/SSN ["_$$GET1^DIQ(200,TIU("EBDA"),.01)_"]"_" & HL7 message name ["_TIU("EBNAME")_"].")
End DoDot:2
End DoDot:1
+38 ;
+39 ; EPISODE BEGIN DATE/TIME for DISCHARGE SUMMARIES
+40 IF $$MEMBEROF^TIUHL7U1(TIU("TITLE"),"DISCHARGE SUMMARIES")
Begin DoDot:1
+41 IF '+$GET(TIU("CSDA"))
DO ERR^TIUHL7U1("TXA",10,"0000.000","DISCHARGE SUMMARIES require an ATTENDING PHYSICIAN (EXPECTED COSIGNER).")
+42 SET TIUZ(1209)=$GET(TIU("CSDA"))
+43 IF +TIU("VNUM")
Begin DoDot:2
+44 IF '$$COMPARE^TIUHL7U1($$GET1^DIQ(9000010,TIU("VNUM"),.05),$SELECT(+$GET(DFN):$$GET1^DIQ(2,DFN,.01),1:TIU("PTNAME")))
Begin DoDot:3
+45 DO ERR^TIUHL7U1("PV1",19,"0000.00","HL7 message PATIENT NAME ["_TIU("PTNAME")_"] does not match VISIT PATIENT NAME ["_$$GET1^DIQ(9000010,TIU("VNUM"),.05)_"].")
QUIT
End DoDot:3
+46 SET TIU("EPDT")=$$GET1^DIQ(9000010,TIU("VNUM"),.01,"I")
SET TIU("VSTR")=$$VSTRBLD^TIUSRVP(TIU("VNUM"))
End DoDot:2
QUIT
+47 IF '+TIU("EPDT")
DO ERR^TIUHL7U1("PV1",44,"0000.000",TIU("TITLE")_" requires an EPISODE BEGIN DATE/TIME.")
QUIT
+48 IF '+$$GETADMIT^TIUHL7U1(+$GET(DFN),TIU("EPDT"))
DO ERR^TIUHL7U1("PV1","44","0000.00","Could not resolve ADMISSION DT[TIME] for "_$$FMTE^XLFDT(TIUDT)_".")
End DoDot:1
+49 ;
+50 ; VISIT information for PROGRESS NOTES
+51 IF $$MEMBEROF^TIUHL7U1(TIU("TITLE"),"PROGRESS NOTES")
Begin DoDot:1
+52 IF TIU("VNUM")="NEW"
Begin DoDot:2
+53 NEW TYP
+54 IF '+TIU("HLOC")
IF TIU("AVAIL")'="AV"
DO ERR^TIUHL7U1("PV1",4,"0000.00","Missing/Invalid HOSPITAL LOCATION ('AV' not set); required for NEW visits.")
QUIT
+55 IF +TIU("EPDT")'>0
SET TIU("EPDT")=$$NOW^XLFDT
+56 IF $LENGTH(TIU("EPDT"),".")=1
SET TIU("EPDT")=TIU("EPDT")_"."_$PIECE($$NOW^XLFDT,".",2)
+57 IF +TIU("HLOC")
IF $$GET1^DIQ(44,TIU("HLOC"),2,"I")="W"
SET TYP="I"
+58 IF +TIU("HLOC")'>0
SET TIU("HLOC")=""
+59 SET TIU("VSTR")=TIU("HLOC")_";"_TIU("EPDT")_";"_$SELECT($GET(TYP)="I":"I",TIU("AVAIL")="AV":"E",1:"A")
End DoDot:2
QUIT
+60 IF +TIU("VNUM")
Begin DoDot:2
+61 IF '$$COMPARE^TIUHL7U1($$GET1^DIQ(9000010,TIU("VNUM"),.05),$SELECT(+$GET(DFN):$$GET1^DIQ(2,DFN,.01),1:TIU("PTNAME")))
Begin DoDot:3
+62 DO ERR^TIUHL7U1("PV1",19,"0000.00","HL7 message PATIENT NAME ["_TIU("PTNAME")_"] does not match VISIT PATIENT NAME ["_$$GET1^DIQ(9000010,TIU("VNUM"),.05)_"].")
End DoDot:3
QUIT
+63 SET TIU("EPDT")=$$GET1^DIQ(9000010,TIU("VNUM"),.01,"I")
SET TIU("VSTR")=$$VSTRBLD^TIUSRVP(TIU("VNUM"))
End DoDot:2
QUIT
+64 IF '+TIU("VNUM")
Begin DoDot:2
+65 IF +TIU("EPDT")
IF '+$$GETADMIT^TIUHL7U1(+$GET(DFN),TIU("EPDT"))
IF TIU("AVAIL")'="AV"
DO ERR^TIUHL7U1("PV1","44","0000.00","Could not find a visit for "_$$FMTE^XLFDT(TIU("EPDT"))_".")
QUIT
+66 IF '+$$GETVISIT^TIUHL7U1(+$GET(DFN),TIU("RFDT"))
IF TIU("AVAIL")'="AV"
DO ERR^TIUHL7U1("PV1","44","0000.00","Could not find a visit for "_$$FMTE^XLFDT(TIU("RFDT"))_".")
QUIT
+67 SET TIU("VSTR")=TIU("HLOC")_";"_$$NOW^XLFDT_";E"
End DoDot:2
End DoDot:1
+68 ;
+69 DO CONTINUE^TIUHL7P3
+70 QUIT