source: FOIAVistA/trunk/r/REGISTRATION-DGQE-DG-DPT-GRPX-VAD-VAF-VAS-VAT-VAU--VA-VIC--DGBT--DGJ--DGYA--VALM/VAFCMSG1.m@ 1397

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

initial load of FOIAVistA 6/30/08 version

File size: 4.1 KB
Line 
1VAFCMSG1 ;ALB/JRP-ADT/R MESSAGE BUILDING ; 22 Jan 2002 10:31 AM
2 ;;5.3;Registration;**91,149,494**;Aug 13, 1993
3 ;
4BLDMSG(DFN,EVNTHL7,EVNTDATE,EVNTINFO,XMITARRY,INSRTPNT) ;Entry point
5 ; for building HL7 ADT messages for a given patient
6 ;
7 ;Input : DFN - Pointer to entry in PATIENT file (#2) to build
8 ; message for
9 ; EVNTHL7 - HL7 ADT event to build message for (Defaults to A08)
10 ; Currently supported event types:
11 ; A04, A08, A28
12 ; EVNTDATE - Date/time event occurred in FileMan format
13 ; - Defaults to current date/time (NOW)
14 ; EVNTINFO - Array containing further event information needed
15 ; when building HL7 segments/message. Use and
16 ; subscripting of array is determined by segment
17 ; and/or message being built.
18 ; - Defaults to ^TMP("VAFCMSG",$J,"EVNTINFO")
19 ; Current subscripts include:
20 ; EVNTINFO("DFN") = Pointer to PATIENT file (#2)
21 ; EVNTINFO("EVENT") = Event type
22 ; EVNTINFO("DATE") = Event date/time
23 ; EVNTINFO("PIVOT") = Pointer to ADT/HL7 PIVOT
24 ; file (#391.71)
25 ; EVNTINFO("REASON",X) = Event reason codes
26 ; EVNTINFO("USER") = User associated with the event
27 ; XMITARRY - Array to build message into (full global reference)
28 ; - Defaults to ^TMP("HLS",$J)
29 ; INSRTPNT - Line to begin inserting message text at
30 ; - Defaults to 1 (can not be zero or less)
31 ;Output : LastLine^TotalLine = ADT-Axx message was build
32 ; LastLine = Last line number in message
33 ; TotalLine = Number of lines in message
34 ; (this total includes continuation lines)
35 ; XMITARRY will be in format compatible with HL7 package
36 ; XMITARRY(N) = Line N of message
37 ; XMITARRY(N,M) = Continuation number M of line N
38 ; -1^ErrorText = Error generating ADT-Axx message
39 ;Notes : It is the responsibility of the calling program to
40 ; initialize XMITARRY
41 ;
42 ;Check input
43 S DFN=+$G(DFN)
44 Q:('$D(^DPT(DFN,0))) "-1^Could not find entry in PATIENT file"
45 S EVNTHL7=$G(EVNTHL7)
46 S:(EVNTHL7="") EVNTHL7="A08"
47 S EVNTDATE=+$G(EVNTDATE)
48 S:('EVNTDATE) EVNTDATE=$$NOW^VAFCMSG5()
49 S EVNTINFO=$G(EVNTINFO)
50 S:(EVNTINFO="") EVNTINFO="^TMP(""VAFCMSG"","_$J_",""EVNTINFO"")"
51 S XMITARRY=$G(XMITARRY)
52 S:(XMITARRY="") XMITARRY="^TMP(""HLS"","_$J_")"
53 S INSRTPNT=+$G(INSRTPNT)
54 S:(INSRTPNT<1) INSRTPNT=1
55 ;Declare variables
56 N HLEID,HL,HLFS,HLECH,HLQ
57 N VAFSTR,LASTLINE,LINESADD,SEGARRY
58 N SEGORDR,SEGNAME,LINETAG,OK,TMP
59 S SEGARRY="^TMP(""VAFC SEGMENTS"","_$J_")"
60 K @SEGARRY
61 ;Check for supported event
62 S OK=0
63 F TMP="A04","A08","A28" I TMP=EVNTHL7 S OK=1 Q
64 Q:('OK) "-1^Event type not supported"
65 ;
66 K HL
67 I $G(@EVNTINFO@("SERVER PROTOCOL"))]"" DO
68 . D INIT^HLFNC2(@EVNTINFO@("SERVER PROTOCOL"),.HL)
69 ;or Get pointer to HL7 Server Protocol
70 E DO Q:'HLEID "-1^Server Protocol not found"
71 .S HLEID=$$GETSRVR^VAFCMSG5(EVNTHL7)
72 .Q:('HLEID)
73 .;Initialize HL7 variables
74 .D INIT^HLFNC2(HLEID,.HL)
75 Q:($O(HL(""))="") "-1^Unable to initialize HL7 variables"
76 ;
77 ;Get list of segments
78 N SEGERR
79 D SEGMENTS^VAFCMSG4(EVNTHL7,SEGARRY)
80 Q:('$O(@SEGARRY@(0))) "-1^Unable to determine list of segments to transmit"
81 ;Loop through list of segments
82 S LASTLINE=INSRTPNT-1
83 S LINESADD=0
84 S SEGORDR=0
85 F S SEGORDR=+$O(@SEGARRY@(SEGORDR)) Q:('SEGORDR) D Q:$G(SEGERR)
86 .S SEGNAME=""
87 .F S SEGNAME=$O(@SEGARRY@(SEGORDR,SEGNAME)) Q:(SEGNAME="") D
88 ..;Build segment
89 ..S VAFSTR=$G(@SEGARRY@(SEGORDR,SEGNAME))
90 ..S LINETAG=$G(@SEGARRY@(SEGNAME,"BLD"))
91 ..I (LINETAG'="") X LINETAG
92 ..;Copy segment into HL7 message
93 ..S LINETAG=$G(@SEGARRY@(SEGNAME,"CPY"))
94 ..I (LINETAG'="") X LINETAG
95 ..;Delete variables used by segment builder
96 ..S LINETAG=$G(@SEGARRY@(SEGNAME,"DEL"))
97 ..I (LINETAG'="") X LINETAG
98 ;S ^TMP("HLS",$J,11)="ZFF"_HL("FS")_2_HL("FS")_$P($G(^VAT(391.71,+$G(PIVOTPTR),2)),U)
99 ;Clean up and quit
100 K @SEGARRY
101 I $G(SEGERR) Q SEGERR
102 Q LASTLINE_"^"_LINESADD
Note: See TracBrowser for help on using the repository browser.