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

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

revised back to 6/30/08 version

File size: 4.4 KB
RevLine 
[623]1DGRUGA01 ;ALB/GRR - HL7 ADT A01 MESSAGE BUILDER ;06/08/99
2 ;;5.3;Registration;**190,303**;Aug 13, 1993
3 ;
4 ;This routine will build a ADT A01 (Admit) HL7 message for an inpatient.
5 ;
6EN(DFN,DGMIEN,DGARRAY) ;Entry point of routine
7 ;DFN - Patient Internal Entry Number
8 ;DGMIEN - Patient Movement Internal Entry Number
9 ;DGARRAY - Name of output array by reference where built message will be contained.
10 ;
11 ;The HL7 variables must be initialized before calling this routine!
12 ;HL("FS"),HL("ECH"),HLFS,HLECH, and HLQ are used by segment builders called by this routine
13 ;
14 N DGPV1,DGHOLD,DGCNT,DGMDT,DGCDT,DGOADT,DGZEL,DGICD,DGICDCNT,DGIN,DGIN1,DGRB,DGW,DGINCNT S DGCNT=0
15 Q:DGARRAY="" ;Required output variable name was not passed
16 K @DGARRAY ;Kill output array to insure erroneous data does not exist
17 Q:DGMIEN=""
18 S DGMDT=$$GET1^DIQ(405,DGMIEN,".01","I")
19 D NOW^%DTC S DGCDT=$$HLDATE^HLFNC(%) ;Get current date/time and convert to HL7 format
20 S DGCNT=DGCNT+1 ;Increment node counter by one for first segment
21 S @DGARRAY@(DGCNT)=$$EVN^VAFHLEVN("A01","05",DGMDT) ;Create Event segment and store in output array
22 S DGCNT=DGCNT+1 ;Increment node counter by one for next segment
23 S @DGARRAY@(DGCNT)=$$EN^VAFCPID(DFN,",2,5,7,8,10,11,13,16,17,19,23,29",1) ;Create PID segment using segment sequence numbers passed and store in output array
24 S DGHOLD=$$EN^VAFHLNK1(DFN,DGMIEN,",2,3,4,5,") ;Create the NK1 segment using the segment sequence numbers passed, and store in output array
25 I DGHOLD]"" S DGCNT=DGCNT+1,@DGARRAY@(DGCNT)=DGHOLD
26 S DGCNT=DGCNT+1 ;Increment node counter by one to store next segment
27 S DGPV1=$$IN^VAFHLPV1(DFN,DGMDT,",2,3,6,7,10,17,44,",$G(DGMIEN),"","") ;Create the PV1 segment based on sequence numbers passed, and store in output array
28 S DGOADT=$$CKADMIT^DGRUUTL1(DFN) ;Check if integrated site and get original admit date
29 ;Check if doing data seed of RAI/MDS machine
30 I $G(DGSEED)=1 D
31 .N VAIP,DGPCPNM,DGPCPPTR,DGWPTR,DGRBPTR,DGWTRAN,DGRBTRAN
32 .D IN5^VADPT
33 .;Put current Primary Care Physician into PV1 segment
34 .S DGPCPPTR=+$G(VAIP(7))
35 .S DGPCPNM=$$HLNAME^HLFNC($P($G(VAIP(7)),"^",2))
36 .S:DGPCPNM="" DGPCPNM=HL("Q")
37 .S $P(DGPV1,HL("FS"),8)=DGPCPPTR_$E(HL("ECH"))_DGPCPNM
38 .;Get current ward & room/bed
39 .S DGW=$$GET1^DIQ(2,DFN,.1,"I")
40 .S DGRB=$$GET1^DIQ(2,DFN,.101,"I")
41 .;Convert ward & room/bed to pointers
42 .S DGWPTR=$$FIND1^DIC(42,,"XQ",DGW)
43 .S DGRBPTR=$$FIND1^DIC(405.4,,"XQ",DGRB)
44 .;Translate ward & room/bed
45 .S DGWTRAN=$$WARDTRAN^DGRUUTL1(DGWPTR,DGW)
46 .S DGRBTRAN=$$RBTRAN^DGRUUTL1(DGRBPTR,DGRB)
47 .;Put translated ward & room/bed into PV1 segment
48 .S $P(DGPV1,HL("FS"),4)=DGWTRAN_$E(HL("ECH"))_$P(DGRBTRAN,"-")_$E(HL("ECH"))_$P(DGRBTRAN,"-",2)
49 I DGOADT]"" S $P(DGPV1,HL("FS"),45)=$$HLDATE^HLFNC(DGOADT) S $P(@DGARRAY@(1),HL("FS"),7)=$$HLDATE^HLFNC(DGOADT)
50 S DGPV1=$$DOCID^DGRUUTL(DGPV1)
51 ;TRANSLATE WARD AND ROOM-BED NAMES IF NEEDED (ALREADY DONE IF SEEDING)
52 S:'$G(DGSEED) DGPV1=$$LOCTRAN^DGRUUTL1(DGPV1)
53 S @DGARRAY@(DGCNT)=DGPV1
54 S DGCNT=DGCNT+1 ;Increment node counter to store next segment
55 S @DGARRAY@(DGCNT)=$$EN^VAFHLPV2(DFN,DGMIEN,",3,") ;Create PV2 segment
56 D IN^VAFHLDG1(DFN,DGMIEN,",2,3,5,","DGICD",DGMDT) ;Create the DG1 segment(s) and store in a temporary array
57 I $O(DGICD(0))>0 D ;DG1 segment were built
58 .S DGICDCNT=0 F S DGICDCNT=$O(DGICD(DGICDCNT)) Q:DGICDCNT="" S DGCNT=DGCNT+1,@DGARRAY@(DGCNT)=DGICD(DGICDCNT,0) ;Loop through temporary array and store DG1 segment(s) in output array
59 S DGIN1=$$IN1^DGRUUTL1(DFN)
60 S DGCNT=DGCNT+1,@DGARRAY@(DGCNT)=DGIN1
61 S DGCNT=DGCNT+1 ;Increment node counter by one for next segment
62 S @DGARRAY@(DGCNT)=$$EN^VAFHLIN2(DFN,DGMIEN,",2,3,6,8,") ;Create and store IN2 segment in output array
63 S DGCNT=DGCNT+1 ;Increment node counter by one for next segment
64 S DGZEL=$$EN^VAFHLZEL(DFN,",1,8,",1) ;Create ZEL segment (only primary eligibility - param 3 = 1)
65 I $P(DGZEL,HL("FS"),9)'=0&($P(DGZEL,HL("FS"),9)'=1) S $P(DGZEL,HL("FS"),9)=1 ;stuff patient as veteran
66 S @DGARRAY@(DGCNT)=DGZEL
67 S DGCNT=DGCNT+1 ;Increment node counter by one for next segment
68 S @DGARRAY@(DGCNT)=$$EN^VAFHLZEM(DFN,",1,5,",1,1) ;Create ZEM segment for Patient (param 3 = 1)
69 S DGCNT=DGCNT+1 ;Increment node counter by one for next segment
70 S @DGARRAY@(DGCNT)=$$EN^VAFHLZEN(DFN,",1,9,",1,"",HL("FS")) ;Create ZEN segment and add to message array
71 S DGCNT=DGCNT+1 ;Increment node counter by one for next segment
72 S @DGARRAY@(DGCNT)=$$EN^VAFHLZMH(DFN,DGMIEN,",4,") ;Create the ZMH segment and store in the output array
73 Q
Note: See TracBrowser for help on using the repository browser.