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

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

initial load of WorldVistAEHR

File size: 3.7 KB
Line 
1DGRUGA03 ;ALB/GRR - HL7 ADT A03 MESSAGE BUILDER ;8/5/99 15:31
2 ;;5.3;Registration;**190,312,328,430**;Aug 13, 1993
3 ;
4 ;This routine will build a ADT A03 (Discharge) 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 DGDT,DGHDT,DGPV1,DGCNT,DGMDT,DGCDT,DGOADT,DGICD,DGICDCNT,DGIN,DGINCNT,DGEDT,DGDEDT S DGCNT=0
15 Q:DGARRAY="" ;Required output variable name was not passed
16 K @DGARRAY ;Kill output array to insure erronuous data does not exist
17 Q:DGMIEN=""
18 N DGADAT ;p-430
19 S DGADAT=$P($G(VAIP(13,1)),"^") ;p-430
20 I DGADAT]"",$D(^DGRU(46.14,DFN,1,"B",DGADAT)) N DGIEN S DGIEN=$O(^DGRU(46.14,DFN,1,"B",DGADAT,0)) Q:$D(^DGRU(46.14,"AC",DFN,"I",DGIEN)) K DGIEN ;p-430
21 K DGADAT ;p-430
22 S DGMDT=$$GET1^DIQ(405,DGMIEN,".01","I")
23 D NOW^%DTC S DGCDT=$$HLDATE^HLFNC(%) ;Get current date/time and convert to HL7 format
24 S DGEDT=$S($G(DGASIH)=1:+$G(DGPMA),1:DGMDT) ;If discharged while ASIH, use discharge date/time (312)
25 S DGCNT=DGCNT+1 ;Increment node counter by one for first segment
26 S @DGARRAY@(DGCNT)=$$EVN^VAFHLEVN("A03","05",DGEDT) ;Create Event segment and store in output array
27 S DGDEDT=$P(@DGARRAY@(1),HL("FS"),7) ;Capture Event Date/Time
28 S DGCNT=DGCNT+1 ;Increment node counter by one for next segment
29 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
30 S DGMDT=$S($G(DGASIH)=2:DGMDT,1:$$GET1^DIQ(405,DGMIEN,".01","I")\1) ;Retrieve Movement Date/Time and truncate time
31 S DGCNT=DGCNT+1 ;Increment node counter by one to store next segment
32 S DGPV1=$$IN^VAFHLPV1(DFN,DGMDT,",2,3,6,7,10,17,36,44,45,",$G(DGMIEN),"","") ;Create the PV1 segment based on sequence numbers passed, and store in output array
33 S DGOADT=$$CKADMIT^DGRUUTL1(DFN) ;Check if integrated site and get original admit date/time
34 I DGOADT]"" S $P(DGPV1,HL("FS"),45)=$$HLDATE^HLFNC(DGOADT)
35 S DGPV1=$$DOCID^DGRUUTL(DGPV1)
36 I $P(DGPV1,HL("FS"),46)="""""" D
37 .S $P(DGPV1,HL("FS"),4)=$P(DGPV1,HL("FS"),7),$P(DGPV1,HL("FS"),37)=16,$P(DGPV1,HL("FS"),46)=$P(@DGARRAY@(1),HL("FS"),7) ;set discharge type to regular and date to event date
38 I $G(DGASIH)=2 D
39 .N VAIP,DGPCPNM,DGPCPPTR,DGWPTR,DGWTRAN,DGRBTRAN
40 .S VAIP("D")=DGPMDT D IN5^VADPT
41 .S DGPCPPTR=+$G(VAIP(18))
42 .S DGPCPNM=$$HLNAME^HLFNC($P($G(VAIP(18)),"^",2))
43 .S:DGPCPNM="" DGPCPNM=HL("Q")
44 .S $P(DGPV1,HL("FS"),8)=DGPCPPTR_$E(HL("ECH"))_DGPCPNM
45 .;GET WARD,ROOM,BED
46 .S DGW=$P($G(VAIP(5)),"^",2),DGWPTR=$P($G(VAIP(5)),"^")
47 .S DGRB=$P($G(VAIP(6)),"^",2),DGRBPTR=$P($G(VAIP(6)),"^")
48 .;TRANSLATE WARD AND ROOM-BED
49 .S DGWTRAN=$$WARDTRAN^DGRUUTL1(DGWPTR,DGW)
50 .S DGRBTRAN=$$RBTRAN^DGRUUTL1(DGRBPTR,DGRB)
51 .;PUT INTO PV1 SEGMENT
52 .S $P(DGPV1,HL("FS"),4)=DGWTRAN_$E(HL("ECH"))_$P(DGRBTRAN,"-")_$E(HL("ECH"))_$P(DGRBTRAN,"-",2)
53 .S $P(DGPV1,HL("FS"),7)=$P(DGPV1,HL("FS"),4)
54 .S $P(DGPV1,HL("FS"),46)=$$HLDATE^HLFNC($G(DGEVDT))
55 .S @DGARRAY@(DGCNT)=DGPV1
56 I $G(DGASIH)=1 S $P(DGPV1,HL("FS"),7)=$P(DGPV1,HL("FS"),4)
57 I $G(DGASIH)'=2 S @DGARRAY@(DGCNT)=$$LOCTRAN^DGRUUTL1(DGPV1) ;Translate Ward or Room-Bed name if needed, store into array
58 D IN^VAFHLDG1(DFN,DGMIEN,",2,3,5,","DGICD") ;Create DG1 segments if data exist and store in temporary array
59 I $O(DGICD(0))>0 D ;DG1 segments were built
60 .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 in output array
61 Q
Note: See TracBrowser for help on using the repository browser.