source: FOIAVistA/trunk/r/SCHEDULING-SD-SC/SCMCHLG.m@ 1608

Last change on this file since 1608 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

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