SCMCHLG ;BP/DJB - PCMM HL7 Generate Message ; 3/2/00 12:39pm
;;5.3;Scheduling;**177,210,1015**;AUG 13, 1993;Build 21
;
GENERATE() ;Generate a PCMM Primary Care HL7 message
;
;Input:
;Output:
;Return: Number of HL7 array nodes built
;
;Declare variables
NEW DATA,ERROR,ID,LINES,NUM,SEG
NEW HLN,HLRESLT,HLSAN,HLX
;
;Convert XMITARRY array to HL7 format - ^TMP("HLS",$J,x)
KILL ^TMP("HLS",$J)
S NUM=0
F S NUM=$O(@XMITARRY@(NUM)) Q:'NUM D ;
. S LINES=0 ;Initialize subscript counter
. S SEG=""
. F S SEG=$O(@XMITARRY@(NUM,SEG)) Q:SEG="" D ;
. . S ID=""
. . F S ID=$O(@XMITARRY@(NUM,SEG,ID)) Q:ID="" D ;
. . . ;Convert array to HL7 format
. . . S DATA=$G(@XMITARRY@(NUM,SEG,ID))
. . . Q:DATA']""
. . . S LINES=LINES+1
. . . S ^TMP("HLS",$J,LINES)=DATA
. . . ;Convert continuation node
. . . I $D(@XMITARRY@(NUM,SEG,ID,1)) D ;
. . . . S DATA=$G(@XMITARRY@(NUM,SEG,ID,1))
. . . . I DATA]"" S ^TMP("HLS",$J,LINES,1)=DATA
. ;
. ;Generate message.
. ; This call returns HLRESLT with 1-3 pieces as follows:
. ; MessageID^ErrorCode^ErrorDescription
. ; If no error occurs, only first piece is returned equal to unique
. ; ID for message. Otherwise, 3 pieces are returned with 1st piece
. ; equal to msg ID if one was assigned, otherwise 0.
. ;
. S HLP("PRIORITY")="I" ;........Immediate priority
. D GENERATE^HLMA(HLEID,"GM",1,.HLRESLT,,.HLP)
. ;
. ;djb/bp Patch 210. Moved re-initialize code up so it occurs before
. ;call to LOG^SCMCHLL.
. ;Re-initialize HL7 message variables
. KILL HL,HLP
. S HLEID=$$HLEID^SCMCHL()
. D INIT^HLFNC2(HLEID,.HL)
. ;
. ;If message not generated, log reason & reset LINES to zero.
. I $P(HLRESLT,"^",2)'="" D ;
. . S @XMITERR@(VARPTR)=$P(HLRESLT,"^",3)
. E D ;
. . S MSGCNT=$G(MSGCNT)+1 ;..Increment message count
. . ;djb/bp Patch 210 Following line added to log transmission.
. . I $P(HLRESLT,"^",1) D LOG^SCMCHLL
. ;
. ;Re-initialize HL7 message array
. KILL ^TMP("HLS",$J)
;
;Done
Q +$G(MSGCNT)
SCMCHLG ;BP/DJB - PCMM HL7 Generate Message ; 3/2/00 12:39pm
+1 ;;5.3;Scheduling;**177,210,1015**;AUG 13, 1993;Build 21
+2 ;
GENERATE() ;Generate a PCMM Primary Care HL7 message
+1 ;
+2 ;Input:
+3 ;Output:
+4 ;Return: Number of HL7 array nodes built
+5 ;
+6 ;Declare variables
+7 NEW DATA,ERROR,ID,LINES,NUM,SEG
+8 NEW HLN,HLRESLT,HLSAN,HLX
+9 ;
+10 ;Convert XMITARRY array to HL7 format - ^TMP("HLS",$J,x)
+11 KILL ^TMP("HLS",$JOB)
+12 SET NUM=0
+13 ;
FOR
SET NUM=$ORDER(@XMITARRY@(NUM))
IF 'NUM
QUIT
Begin DoDot:1
+14 ;Initialize subscript counter
SET LINES=0
+15 SET SEG=""
+16 ;
FOR
SET SEG=$ORDER(@XMITARRY@(NUM,SEG))
IF SEG=""
QUIT
Begin DoDot:2
+17 SET ID=""
+18 ;
FOR
SET ID=$ORDER(@XMITARRY@(NUM,SEG,ID))
IF ID=""
QUIT
Begin DoDot:3
+19 ;Convert array to HL7 format
+20 SET DATA=$GET(@XMITARRY@(NUM,SEG,ID))
+21 IF DATA']""
QUIT
+22 SET LINES=LINES+1
+23 SET ^TMP("HLS",$JOB,LINES)=DATA
+24 ;Convert continuation node
+25 ;
IF $DATA(@XMITARRY@(NUM,SEG,ID,1))
Begin DoDot:4
+26 SET DATA=$GET(@XMITARRY@(NUM,SEG,ID,1))
+27 IF DATA]""
SET ^TMP("HLS",$JOB,LINES,1)=DATA
End DoDot:4
End DoDot:3
End DoDot:2
+28 ;
+29 ;Generate message.
+30 ; This call returns HLRESLT with 1-3 pieces as follows:
+31 ; MessageID^ErrorCode^ErrorDescription
+32 ; If no error occurs, only first piece is returned equal to unique
+33 ; ID for message. Otherwise, 3 pieces are returned with 1st piece
+34 ; equal to msg ID if one was assigned, otherwise 0.
+35 ;
+36 ;........Immediate priority
SET HLP("PRIORITY")="I"
+37 DO GENERATE^HLMA(HLEID,"GM",1,.HLRESLT,,.HLP)
+38 ;
+39 ;djb/bp Patch 210. Moved re-initialize code up so it occurs before
+40 ;call to LOG^SCMCHLL.
+41 ;Re-initialize HL7 message variables
+42 KILL HL,HLP
+43 SET HLEID=$$HLEID^SCMCHL()
+44 DO INIT^HLFNC2(HLEID,.HL)
+45 ;
+46 ;If message not generated, log reason & reset LINES to zero.
+47 ;
IF $PIECE(HLRESLT,"^",2)'=""
Begin DoDot:2
+48 SET @XMITERR@(VARPTR)=$PIECE(HLRESLT,"^",3)
End DoDot:2
+49 ;
IF '$TEST
Begin DoDot:2
+50 ;..Increment message count
SET MSGCNT=$GET(MSGCNT)+1
+51 ;djb/bp Patch 210 Following line added to log transmission.
+52 IF $PIECE(HLRESLT,"^",1)
DO LOG^SCMCHLL
End DoDot:2
+53 ;
+54 ;Re-initialize HL7 message array
+55 KILL ^TMP("HLS",$JOB)
End DoDot:1
+56 ;
+57 ;Done
+58 QUIT +$GET(MSGCNT)