SCMCHLL ;BP/DJB - PCMM HL7 Log Transmission ; 3/2/00 12:59pm
;;5.3;Scheduling;**210,272**;AUG 13, 1993
;
LOG ;Record HL7 messages in PCMM HL7 TRANSMISSION LOG file.
;Parse the HL7 array and build an array in ^TMP("PCMM","LOG",$J) and
;use to record transmissions.
;
NEW FS,MSGID,TDATE
;
;Initialize variables
KILL ^TMP("PCMM","LOG",$J)
S FS=HL("FS") ;........................Field separator
S MSGID=$P(HLRESLT,"^",1) Q:'MSGID ;..Message ID
S TDATE=$$NOW^XLFDT ;..................Transmission date
S ^TMP("PCMM","LOG",$J,"MSGID")=MSGID
S ^TMP("PCMM","LOG",$J,"DT")=TDATE
;
D GETDATA ;..Get data from HL7 message array
D ADD ;......Create entry in Transmission Log and stuff data
;
KILL ^TMP("PCMM","LOG",$J)
Q
;
GETDATA ;Go thru HL7 array and build array of data in ^TMP("PCMM","LOG",$J).
NEW CNT,DATA,DFN,SEG,SEQ,ZPCID
S CNT=""
F S CNT=$O(^TMP("HLS",$J,CNT)) Q:'CNT D ;
. S DATA=$G(^(CNT)) Q:DATA=""
. S SEG=$P(DATA,FS,1)
. ;
. ;PID segment - Get patient DFN
. I SEG="PID" D Q
. . S DFN=+$P(DATA,U,4)
. . S ^TMP("PCMM","LOG",$J,"DFN")=DFN
. ;
. ;ZPC segment - Get sequence # and ZPC ID.
. I SEG="ZPC" D Q
. . S SEQ=$P(DATA,U,8)
. . S ZPCID=$P(DATA,U,2)
. . S ^TMP("PCMM","LOG",$J,"ZPC",SEQ)=ZPCID
Q
;
ADD ;Process data array built in GETDATA
NEW TRANI
S TRANI=$$CREATE(^TMP("PCMM","LOG",$J,"MSGID")) ;..Create new entry
Q:+TRANI<0
D STORE(TRANI) ;..Store transmission info
Q
;
CREATE(MSGID) ;Create new entry
; Input: Message Control ID
;Output: Pointer to entry in PCMM HL7 TRANSMISSION LOG (#404.471)
; -1^Error - Unable to create entry
;
NEW SCERR,SCFDA,SCIEN
S SCFDA(404.471,"+1,",.01)=MSGID
D UPDATE^DIE("E","SCFDA","SCIEN","SCERR")
I $D(SCERR) Q "-1^Unable to create entry in file #404.471"
Q SCIEN(1)
;
STORE(TRANI) ;Store data
;
; Input: TRANI - Pointer PCMM HL7 TRANSMISSION LOG file (#404.471)
;Output: None
;
NEW CNT,SCERR,SCIEN,SCIENS,SCIENS1,SCFDA,SEQ,ZPCID
;
;Check input
Q:'+$G(TRANI)
Q:'$D(^SCPT(404.471,TRANI))
;
S SCIENS=TRANI_","
S SCFDA(404.471,SCIENS,.02)=$G(^TMP("PCMM","LOG",$J,"DFN")) ;Patient
S SCFDA(404.471,SCIENS,.03)=$G(^TMP("PCMM","LOG",$J,"DT")) ;.Date
S SCFDA(404.471,SCIENS,.04)="T" ;........................Status
I $G(WORK),'SCFDA(404.471,SCIENS,.02) D
.S SCFDA(404.471,SCIENS,.07)=$G(VARPTR)
.I $G(VARPTR)[404.52 S SCFDA(404.471,SCIENS,.08)=$P($G(^SCTM(404.52,+VARPTR,0)),U,3)
D FILE^DIE("I","SCFDA","SCERR")
KILL SCFDA,SCERR
;
;Fill in ZPC multiple
S (CNT,SEQ)=0
F S SEQ=$O(^TMP("PCMM","LOG",$J,"ZPC",SEQ)) Q:'SEQ D ;
. S ZPCID=$$CONVERT^SCMCHLRI($G(^(SEQ)))
. S CNT=CNT+1
. S SCIENS1="+"_CNT_","_SCIENS
. S SCFDA(404.47141,SCIENS1,.01)=SEQ
. S SCFDA(404.47141,SCIENS1,.02)=ZPCID
. D UPDATE^DIE("","SCFDA","SCIEN","SCERR")
. ;I $D(SCERR) ZW SCERR
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSCMCHLL 2881 printed Nov 22, 2024@17:50:27 Page 2
SCMCHLL ;BP/DJB - PCMM HL7 Log Transmission ; 3/2/00 12:59pm
+1 ;;5.3;Scheduling;**210,272**;AUG 13, 1993
+2 ;
LOG ;Record HL7 messages in PCMM HL7 TRANSMISSION LOG file.
+1 ;Parse the HL7 array and build an array in ^TMP("PCMM","LOG",$J) and
+2 ;use to record transmissions.
+3 ;
+4 NEW FS,MSGID,TDATE
+5 ;
+6 ;Initialize variables
+7 KILL ^TMP("PCMM","LOG",$JOB)
+8 ;........................Field separator
SET FS=HL("FS")
+9 ;..Message ID
SET MSGID=$PIECE(HLRESLT,"^",1)
if 'MSGID
QUIT
+10 ;..................Transmission date
SET TDATE=$$NOW^XLFDT
+11 SET ^TMP("PCMM","LOG",$JOB,"MSGID")=MSGID
+12 SET ^TMP("PCMM","LOG",$JOB,"DT")=TDATE
+13 ;
+14 ;..Get data from HL7 message array
DO GETDATA
+15 ;......Create entry in Transmission Log and stuff data
DO ADD
+16 ;
+17 KILL ^TMP("PCMM","LOG",$JOB)
+18 QUIT
+19 ;
GETDATA ;Go thru HL7 array and build array of data in ^TMP("PCMM","LOG",$J).
+1 NEW CNT,DATA,DFN,SEG,SEQ,ZPCID
+2 SET CNT=""
+3 ;
FOR
SET CNT=$ORDER(^TMP("HLS",$JOB,CNT))
if 'CNT
QUIT
Begin DoDot:1
+4 SET DATA=$GET(^(CNT))
if DATA=""
QUIT
+5 SET SEG=$PIECE(DATA,FS,1)
+6 ;
+7 ;PID segment - Get patient DFN
+8 IF SEG="PID"
Begin DoDot:2
+9 SET DFN=+$PIECE(DATA,U,4)
+10 SET ^TMP("PCMM","LOG",$JOB,"DFN")=DFN
End DoDot:2
QUIT
+11 ;
+12 ;ZPC segment - Get sequence # and ZPC ID.
+13 IF SEG="ZPC"
Begin DoDot:2
+14 SET SEQ=$PIECE(DATA,U,8)
+15 SET ZPCID=$PIECE(DATA,U,2)
+16 SET ^TMP("PCMM","LOG",$JOB,"ZPC",SEQ)=ZPCID
End DoDot:2
QUIT
End DoDot:1
+17 QUIT
+18 ;
ADD ;Process data array built in GETDATA
+1 NEW TRANI
+2 ;..Create new entry
SET TRANI=$$CREATE(^TMP("PCMM","LOG",$JOB,"MSGID"))
+3 if +TRANI<0
QUIT
+4 ;..Store transmission info
DO STORE(TRANI)
+5 QUIT
+6 ;
CREATE(MSGID) ;Create new entry
+1 ; Input: Message Control ID
+2 ;Output: Pointer to entry in PCMM HL7 TRANSMISSION LOG (#404.471)
+3 ; -1^Error - Unable to create entry
+4 ;
+5 NEW SCERR,SCFDA,SCIEN
+6 SET SCFDA(404.471,"+1,",.01)=MSGID
+7 DO UPDATE^DIE("E","SCFDA","SCIEN","SCERR")
+8 IF $DATA(SCERR)
QUIT "-1^Unable to create entry in file #404.471"
+9 QUIT SCIEN(1)
+10 ;
STORE(TRANI) ;Store data
+1 ;
+2 ; Input: TRANI - Pointer PCMM HL7 TRANSMISSION LOG file (#404.471)
+3 ;Output: None
+4 ;
+5 NEW CNT,SCERR,SCIEN,SCIENS,SCIENS1,SCFDA,SEQ,ZPCID
+6 ;
+7 ;Check input
+8 if '+$GET(TRANI)
QUIT
+9 if '$DATA(^SCPT(404.471,TRANI))
QUIT
+10 ;
+11 SET SCIENS=TRANI_","
+12 ;Patient
SET SCFDA(404.471,SCIENS,.02)=$GET(^TMP("PCMM","LOG",$JOB,"DFN"))
+13 ;.Date
SET SCFDA(404.471,SCIENS,.03)=$GET(^TMP("PCMM","LOG",$JOB,"DT"))
+14 ;........................Status
SET SCFDA(404.471,SCIENS,.04)="T"
+15 IF $GET(WORK)
IF 'SCFDA(404.471,SCIENS,.02)
Begin DoDot:1
+16 SET SCFDA(404.471,SCIENS,.07)=$GET(VARPTR)
+17 IF $GET(VARPTR)[404.52
SET SCFDA(404.471,SCIENS,.08)=$PIECE($GET(^SCTM(404.52,+VARPTR,0)),U,3)
End DoDot:1
+18 DO FILE^DIE("I","SCFDA","SCERR")
+19 KILL SCFDA,SCERR
+20 ;
+21 ;Fill in ZPC multiple
+22 SET (CNT,SEQ)=0
+23 ;
FOR
SET SEQ=$ORDER(^TMP("PCMM","LOG",$JOB,"ZPC",SEQ))
if 'SEQ
QUIT
Begin DoDot:1
+24 SET ZPCID=$$CONVERT^SCMCHLRI($GET(^(SEQ)))
+25 SET CNT=CNT+1
+26 SET SCIENS1="+"_CNT_","_SCIENS
+27 SET SCFDA(404.47141,SCIENS1,.01)=SEQ
+28 SET SCFDA(404.47141,SCIENS1,.02)=ZPCID
+29 DO UPDATE^DIE("","SCFDA","SCIEN","SCERR")
+30 ;I $D(SCERR) ZW SCERR
End DoDot:1
+31 QUIT