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

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

initial load of FOIAVistA 6/30/08 version

File size: 4.9 KB
Line 
1VAFHADT2 ;ALB/RJS - HL7 ADT MESSAGE BUILDING ROUTINE - MAY 18,1995 ; 3/6/06 8:08am
2 ;;5.3;Registration;**91,692**;Jun 06, 1996
3 ;hl7v1.6
4 ;
5 ;This routine builds ADT HL7 messages: A01 = Admission
6 ; A02 = Transfer
7 ; A03 = Discharge
8 ; A08 = Update
9 ; A11 = Cancel Admission
10 ; A12 = Cancel Transfer
11 ; A13 = Cancel Discharge
12 ;
13 ;It is called by VAFHADT1, which is itself is called by the
14 ;DGPM patient movement event driver.
15 ;
16 ;
17BLDMSG(DFN,EVENT,VAFHDT,EVCODE,IEN,PIVOT,PV1) ;
18 ;Required Variables are: DFN = IEN of Patient File
19 ; EVENT = HL7 Event, A01, A02, A03, etc.
20 ; VAFHDT = Date/Time of Admission, Transfer, etc
21 ;
22 ;Optional Variables are: Event Code = (EVCODE):A string literal which is
23 ; inserted in the Event Reason
24 ; Code Field of the EVN segment
25 ; of the message. This serves to
26 ; indicate that the message might
27 ; need to be processed in a special
28 ; way. PIMS ADT software uses the
29 ; Event Code to indicate whether
30 ; the message is the most recent
31 ; "Snapshot" of the data "05" or
32 ; a "Snapshot" of data that is
33 ; followed by more recent data "04"
34 ;
35 ;
36 ; IEN = The IEN of the Patient Movement
37 ; that the HL7 message is being
38 ; built from. This is especially
39 ; useful for Discharge Movements
40 ; where date/time (VAFHDT) is not
41 ; enough information to retrieve
42 ; the movement
43 ;
44 ; PIVOT = The PIMS Pivot number that
45 ; uniquely identifies the ADMISSION
46 ;
47 ; PV1 = In the case of a "Deleted
48 ; Admission" the record in the
49 ; Patient Movement File has already
50 ; been deleted. But, a PV1 segment
51 ; can be built from the DGPMP
52 ; variable that has been saved off
53 ; by the DGPM Event Driver. This
54 ; PV1 segment is passed a string
55 ; literal that is built by a call
56 ; to DGBUILD^VAFHAPV1 previous to
57 ; calling this software.
58 ;
59 K HLA N VAFDIAG
60 ;Q:($G(EVCODE)'="05")
61 ;D INIT^HLTRANS
62 K HL D INIT^HLFNC2("VAFH "_EVENT,.HL)
63 I $D(HL)=1 G EXIT
64 S HLA("HLS",2)=$$EN^VAFHLPID(DFN,",2,3,5,7,8,19")
65 S $P(HLA("HLS",2),HLFS,2)=1 ;SET ID
66 ;MERGE HLA("HLS",2)=VAFPID
67 S HLA("HLS",3)=$$EN^VAFHLZPD(DFN,",1,2,3,4,5,6,7,8,9,10,11,12,13,14,15")
68 S $P(HLA("HLS",3),HLFS,2)=1 ;SET ID
69 I EVENT="A11" D G NEXT
70 . S HLA("HLS",4)=PV1
71 . S $P(HLA("HLS",4),HLFS,51)=$G(PIVOT) ; VISIT&SET ID'S
72 I EVENT="A01"!(EVENT="A03")!(EVENT="A08")!(EVENT="A12")!(EVENT="A13") D G NEXT
73 . S HLA("HLS",4)=$$IN^VAFHLPV1(DFN,VAFHDT,",2,3,7,8,10,19,44,45",$G(IEN),PIVOT,"",.VAFDIAG)
74 I EVENT="A02" D G NEXT
75 . S HLA("HLS",4)=$$IN^VAFHLPV1(DFN,VAFHDT,",2,3,6,7,8,10,19,44,45",$G(IEN),PIVOT,"",.VAFDIAG)
76 G EXIT
77NEXT ;
78 S $P(HLA("HLS",4),HLFS,2)=1
79 S HLA("HLS",1)="EVN"_HLFS_EVENT_HLFS_$$HLDATE^HLFNC(VAFHDT,"TS")_HLFS
80 S HLA("HLS",1)=HLA("HLS",1)_HLFS_$G(EVCODE)
81 I (EVENT="A01")!(EVENT="A08")!(EVENT="A11")!(EVENT="A12")!(EVENT="A13") S HLA("HLS",6)="DG1"_HLFS_1_HLFS_HLFS_HLFS_$$HLQ^VAFHUTL($G(VAFDIAG))
82 ;Get patient directory call center parameter
83 N VAFCCON
84 S VAFCCON=$$GET^XPAR("SYS","DG PT DIRECTORY CALL CENTER")
85 I VAFCCON S HLA("HLS",5)=$$EN^VAFHLPV2(DFN,IEN,",22,")
86 D:$D(VATRACE) LOOP
87 ;
88 S COUNTER=""
89 F S COUNTER=$O(HLA("HLS",COUNTER)) Q:COUNTER'>0 D
90 .; I +(HLA("HLS",COUNTER))=-1 S HLERR="Bad "_COUNTER_" Segment"
91 . I +(HLA("HLS",COUNTER))=-1 S HL="Bad "_COUNTER_" Segment"
92 .
93 ;
94EXIT ;
95 ;I $D(HLERR) D
96 I $D(HL)=1 DO
97 . S HLERR(1)=HL
98 . D EBULL^VAFHUTL2(DFN,VAFHDT,PIVOT,"HLERR(")
99 ;I '$D(HLERR)&($D(HLSDATA)) S HLMTN="ADT"_$E(HLECH)_EVENT D EN^HLTRANS
100 I $D(HL)>1,$D(HLA("HLS")) S HLMTN="ADT"_$E(HL("ECH"))_EVENT DO
101 .D GENERATE^HLMA("VAFH "_EVENT,"LM",1,.HLRST)
102 D KVAR^VADPT,KVAR^VAFHLPV1 K HLA,HLERR
103 Q
104LOOP ;
105 ;
106 ;
107 W !!
108 N XX S XX=0
109 F S XX=$O(HLA("HLS",XX)) Q:XX="" W !,HLA("HLS",XX)
110 Q
Note: See TracBrowser for help on using the repository browser.