DGRUGA02 ;ALB/GRR - HL7 ADT A02 MESSAGE BUILDER ;8/5/99 15:26
;;5.3;Registration;**190,312**;Aug 13, 1993
;
;This routine will build a ADT A02 (Transfer) HL7 message for an inpatient.
;
EN(DFN,DGMIEN,DGARRAY) ;Entry point of routine
;DFN - Patient Internal Entry Number
;DGMIEN - Patient Movement Internal Entry Number
;DGARRAY - Name of output array by reference where built message will be contained.
;
;The HL7 variables must be initialized before calling this routine!
;HL("FS"),HL("ECH"),HLFS,HLECH, and HLQ are used by segment builders called by this routine
;
N DGEDT,DGPV1,DGCNT,DGMDT,DGCDT,DGOADT,DGICD,DGICDCNT,DGIN,DGINCNT S DGCNT=0
Q:DGARRAY="" ;Required output variable name was not passed
K @DGARRAY ;Kill output array to insure erronuous data does not exist
Q:DGMIEN=""
S DGMDT=$$GET1^DIQ(405,DGMIEN,".01","I")
D NOW^%DTC S DGCDT=% ;Get current date/time
N DGBS I ($P(DGPMA,"^",6)=$P(DGPMP,"^",6)),($P(DGPMA,"^",7)'=$P(DGPMP,"^",7)) S DGEDT=DGCDT,DGBS=1 ;use current date/time because its a bed switch
E S DGEDT=DGMDT,DGBS=0 ;if not bed switch use movement date/time
S DGCNT=DGCNT+1 ;Increment node counter by one for first segment
S @DGARRAY@(DGCNT)=$$EVN^VAFHLEVN("A02","05",DGEDT) ;Create Event segment and store in output array
S DGCNT=DGCNT+1 ;Increment node counter by one for next segment
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
S DGMDT=$$GET1^DIQ(405,DGMIEN,".01","I") ;Retrieve Movement Date/Time
S DGCNT=DGCNT+1 ;Increment node counter by one to store next segment
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
S DGOADT=$$CKADMIT^DGRUUTL1(DFN)
I DGOADT]"" S $P(DGPV1,HL("FS"),45)=$$HLDATE^HLFNC(DGOADT) I DGTYPE=1,'DGBS S $P(@DGARRAY@(1),HL("FS"),7)=$$HLDATE^HLFNC(DGOADT)
S DGPV1=$$DOCID^DGRUUTL(DGPV1)
S @DGARRAY@(DGCNT)=$$LOCTRAN^DGRUUTL1(DGPV1) ;Translate Ward and room-Bed name if needed, then store into array
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDGRUGA02 2137 printed Nov 22, 2024@18:08:09 Page 2
DGRUGA02 ;ALB/GRR - HL7 ADT A02 MESSAGE BUILDER ;8/5/99 15:26
+1 ;;5.3;Registration;**190,312**;Aug 13, 1993
+2 ;
+3 ;This routine will build a ADT A02 (Transfer) HL7 message for an inpatient.
+4 ;
EN(DFN,DGMIEN,DGARRAY) ;Entry point of routine
+1 ;DFN - Patient Internal Entry Number
+2 ;DGMIEN - Patient Movement Internal Entry Number
+3 ;DGARRAY - Name of output array by reference where built message will be contained.
+4 ;
+5 ;The HL7 variables must be initialized before calling this routine!
+6 ;HL("FS"),HL("ECH"),HLFS,HLECH, and HLQ are used by segment builders called by this routine
+7 ;
+8 NEW DGEDT,DGPV1,DGCNT,DGMDT,DGCDT,DGOADT,DGICD,DGICDCNT,DGIN,DGINCNT
SET DGCNT=0
+9 ;Required output variable name was not passed
if DGARRAY=""
QUIT
+10 ;Kill output array to insure erronuous data does not exist
KILL @DGARRAY
+11 if DGMIEN=""
QUIT
+12 SET DGMDT=$$GET1^DIQ(405,DGMIEN,".01","I")
+13 ;Get current date/time
DO NOW^%DTC
SET DGCDT=%
+14 ;use current date/time because its a bed switch
NEW DGBS
IF ($PIECE(DGPMA,"^",6)=$PIECE(DGPMP,"^",6))
IF ($PIECE(DGPMA,"^",7)'=$PIECE(DGPMP,"^",7))
SET DGEDT=DGCDT
SET DGBS=1
+15 ;if not bed switch use movement date/time
IF '$TEST
SET DGEDT=DGMDT
SET DGBS=0
+16 ;Increment node counter by one for first segment
SET DGCNT=DGCNT+1
+17 ;Create Event segment and store in output array
SET @DGARRAY@(DGCNT)=$$EVN^VAFHLEVN("A02","05",DGEDT)
+18 ;Increment node counter by one for next segment
SET DGCNT=DGCNT+1
+19 ;Create PID segment using segment sequence numbers passed and store in output array
SET @DGARRAY@(DGCNT)=$$EN^VAFCPID(DFN,",2,5,7,8,10,11,13,16,17,19,23,29",1)
+20 ;Retrieve Movement Date/Time
SET DGMDT=$$GET1^DIQ(405,DGMIEN,".01","I")
+21 ;Increment node counter by one to store next segment
SET DGCNT=DGCNT+1
+22 ;Create the PV1 segment based on sequence numbers passed, and store in output array
SET DGPV1=$$IN^VAFHLPV1(DFN,DGMDT,",2,3,6,7,10,17,44,",$GET(DGMIEN),"","")
+23 SET DGOADT=$$CKADMIT^DGRUUTL1(DFN)
+24 IF DGOADT]""
SET $PIECE(DGPV1,HL("FS"),45)=$$HLDATE^HLFNC(DGOADT)
IF DGTYPE=1
IF 'DGBS
SET $PIECE(@DGARRAY@(1),HL("FS"),7)=$$HLDATE^HLFNC(DGOADT)
+25 SET DGPV1=$$DOCID^DGRUUTL(DGPV1)
+26 ;Translate Ward and room-Bed name if needed, then store into array
SET @DGARRAY@(DGCNT)=$$LOCTRAN^DGRUUTL1(DGPV1)
+27 QUIT