MDHL7X ; HOIFO/WAA -Generate HL7 Error Message ; 06/08/00
;;1.0;CLINICAL PROCEDURES;**6**;Apr 01, 2004;Build 102
; Reference IA #1131 for ^XMB("NETNAME") access.
; Reference IA #2165 for HLMA1 calls.
; Reference IA #2729 for XMXAPI calls.
D GENERR,GENACK Q
GENERR ; Generate error message
N TXT,INST,MG,XMTO,XMDUZ,XMSUBJ,XMBODY,N,X S MG=0
S INST=DEVIEN
I INST>1 S MG=$P($G(^MDS(702.09,INST,0)),"^",2)
I 'MG!('$$MG^MDHL7U2(MG)) S MG=$$FIND1^DIC(3.8,"","BX","MD DEVICE ERRORS") Q:'MG
S MG=$$GET1^DIQ(3.8,+MG_",",.01)
S XMTO="G."_MG_"@"_^XMB("NETNAME"),XMINSTR("FROM")=.5
I '$D(X) S X=$G(ECODE(0))
S TXT(1)=ERRTX,TXT(2)=X,TXT(3)=" "
S N=3
I '$G(ECODE,1) D ; This is to process Device errors
. N X
. S X=0
. F S X=$O(ECODE(X)) Q:X<1 S N=N+1,TXT(N)=ECODE(X)
. S N=N+1,TXT(N)=" "
. Q
F X="MSH","PID","OBR","OBX" I $D(SEG(X)) S N=N+1,TXT(N)=SEG(X)
S XMSUBJ="A Clinical Instrument HL7 Error has occurred."
S XMBODY="TXT"
D SENDMSG^XMXAPI(DUZ,XMSUBJ,XMBODY,XMTO,.XMINSTR)
Q
GENACK ; Generate an HL7 ACK message
; Reference IA #2165 for GENACK^HLMA1 call
N HLA,HLEID,HLEIDS,HLARYTYP,HLFORMAT,HLRESLTA
S HLA("HLA",1)="MSA"_HL("FS")_$S($D(ERRTX):"AR",1:"AA")_HL("FS")_HL("MID")_$S($D(ERRTX):HL("FS")_ERRTX,1:"")
S HLEID=HL("EID"),HLEIDS=HL("EIDS"),HLARYTYP="LM",HLFORMAT=1,HLRESLTA=HL("MID")
D GENACK^HLMA1(HLEID,HLMTIENS,HLEIDS,HLARYTYP,HLFORMAT,.HLRESTLA)
N ERRTX Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMDHL7X 1424 printed Oct 16, 2024@17:43:50 Page 2
MDHL7X ; HOIFO/WAA -Generate HL7 Error Message ; 06/08/00
+1 ;;1.0;CLINICAL PROCEDURES;**6**;Apr 01, 2004;Build 102
+2 ; Reference IA #1131 for ^XMB("NETNAME") access.
+3 ; Reference IA #2165 for HLMA1 calls.
+4 ; Reference IA #2729 for XMXAPI calls.
+5 DO GENERR
DO GENACK
QUIT
GENERR ; Generate error message
+1 NEW TXT,INST,MG,XMTO,XMDUZ,XMSUBJ,XMBODY,N,X
SET MG=0
+2 SET INST=DEVIEN
+3 IF INST>1
SET MG=$PIECE($GET(^MDS(702.09,INST,0)),"^",2)
+4 IF 'MG!('$$MG^MDHL7U2(MG))
SET MG=$$FIND1^DIC(3.8,"","BX","MD DEVICE ERRORS")
if 'MG
QUIT
+5 SET MG=$$GET1^DIQ(3.8,+MG_",",.01)
+6 SET XMTO="G."_MG_"@"_^XMB("NETNAME")
SET XMINSTR("FROM")=.5
+7 IF '$DATA(X)
SET X=$GET(ECODE(0))
+8 SET TXT(1)=ERRTX
SET TXT(2)=X
SET TXT(3)=" "
+9 SET N=3
+10 ; This is to process Device errors
IF '$GET(ECODE,1)
Begin DoDot:1
+11 NEW X
+12 SET X=0
+13 FOR
SET X=$ORDER(ECODE(X))
if X<1
QUIT
SET N=N+1
SET TXT(N)=ECODE(X)
+14 SET N=N+1
SET TXT(N)=" "
+15 QUIT
End DoDot:1
+16 FOR X="MSH","PID","OBR","OBX"
IF $DATA(SEG(X))
SET N=N+1
SET TXT(N)=SEG(X)
+17 SET XMSUBJ="A Clinical Instrument HL7 Error has occurred."
+18 SET XMBODY="TXT"
+19 DO SENDMSG^XMXAPI(DUZ,XMSUBJ,XMBODY,XMTO,.XMINSTR)
+20 QUIT
GENACK ; Generate an HL7 ACK message
+1 ; Reference IA #2165 for GENACK^HLMA1 call
+2 NEW HLA,HLEID,HLEIDS,HLARYTYP,HLFORMAT,HLRESLTA
+3 SET HLA("HLA",1)="MSA"_HL("FS")_$SELECT($DATA(ERRTX):"AR",1:"AA")_HL("FS")_HL("MID")_$SELECT($DATA(ERRTX):HL("FS")_ERRTX,1:"")
+4 SET HLEID=HL("EID")
SET HLEIDS=HL("EIDS")
SET HLARYTYP="LM"
SET HLFORMAT=1
SET HLRESLTA=HL("MID")
+5 DO GENACK^HLMA1(HLEID,HLMTIENS,HLEIDS,HLARYTYP,HLFORMAT,.HLRESTLA)
+6 NEW ERRTX
QUIT