DGRUGA11 ;ALB/GRR - HL7 ADT A11 MESSAGE BUILDER ;8/5/99 15:33
;;5.3;Registration;**190,1015**;Aug 13, 1993;Build 21
;
;This routine will build a ADT A11 (Cancel Admit) HL7 message for an inpatient.
;
EN(DFN,DGMIEN,DGARRAY,DGWARD,DGDT) ;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.
;DGWARD - IEN of Ward Location (OPTIONAL)
;
;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 DGCNT,DGMDT,DGCDT,DGOADT,DGPV1,DGICD,DGICDCNT,DGIN,DGINCNT,DGWARDNM,DGCTRAN,DGHMDT S DGCNT=0,DGWARDNM=""
Q:DGARRAY="" ;Required output variable name was not passed
K @DGARRAY ;Kill output array to insure erronuous data does not exist
S DGMDT=$S($G(DGCTRAN)=1:+DGPMP,1:$$GET1^DIQ(405,DGMIEN,.01,"I")),DGHMDT=$$HLDATE^HLFNC(DGMDT)
D NOW^%DTC S DGCDT=$$HLDATE^HLFNC(%) ;Get current date/time and convert to HL7 format
S DGCNT=DGCNT+1 ;Increment node counter by one for first segment
S @DGARRAY@(DGCNT)=$$EVN^VAFHLEVN("A11","05",DGMDT) ;Create Event segment and store in output array (Use current date/time for cancel)
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
I DGWARD]"" S DGWARDNM=$$GET1^DIQ(42,+DGWARD,.01)
S DGCNT=DGCNT+1 ;Increment node counter by one to store next segment
S DGPV1="PV1"_HL("FS")_1_HL("FS")_"I" ;Create the PV1 segment with no visit data and store in output array
S $P(DGPV1,HL("FS"),45)=$$HLDATE^HLFNC(DGDT) ;GRR 1/26/00
S DGOADT=$$CKADMIT^DGRUUTL1(DFN) ;check if integrated site get original admit date/time
I DGOADT]"" S $P(DGPV1,HL("FS"),45)=$$HLDATE^HLFNC(DGOADT)
S DGPV1=$$DOCID^DGRUUTL(DGPV1)
I DGWARDNM]"" S $P(DGPV1,HL("FS"),7)=DGWARDNM
S @DGARRAY@(DGCNT)=DGPV1
S DGCNT=DGCNT+1
S @DGARRAY@(DGCNT)="PV2"
Q
DGRUGA11 ;ALB/GRR - HL7 ADT A11 MESSAGE BUILDER ;8/5/99 15:33
+1 ;;5.3;Registration;**190,1015**;Aug 13, 1993;Build 21
+2 ;
+3 ;This routine will build a ADT A11 (Cancel Admit) HL7 message for an inpatient.
+4 ;
EN(DFN,DGMIEN,DGARRAY,DGWARD,DGDT) ;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 ;DGWARD - IEN of Ward Location (OPTIONAL)
+5 ;
+6 ;The HL7 variables must be initialized before calling this routine!
+7 ;HL("FS"),HL("ECH"),HLFS,HLECH, and HLQ are used by segment builders called by this routine
+8 ;
+9 NEW DGCNT,DGMDT,DGCDT,DGOADT,DGPV1,DGICD,DGICDCNT,DGIN,DGINCNT,DGWARDNM,DGCTRAN,DGHMDT
SET DGCNT=0
SET DGWARDNM=""
+10 ;Required output variable name was not passed
IF DGARRAY=""
QUIT
+11 ;Kill output array to insure erronuous data does not exist
KILL @DGARRAY
+12 SET DGMDT=$SELECT($GET(DGCTRAN)=1:+DGPMP,1:$$GET1^DIQ(405,DGMIEN,.01,"I"))
SET DGHMDT=$$HLDATE^HLFNC(DGMDT)
+13 ;Get current date/time and convert to HL7 format
DO NOW^%DTC
SET DGCDT=$$HLDATE^HLFNC(%)
+14 ;Increment node counter by one for first segment
SET DGCNT=DGCNT+1
+15 ;Create Event segment and store in output array (Use current date/time for cancel)
SET @DGARRAY@(DGCNT)=$$EVN^VAFHLEVN("A11","05",DGMDT)
+16 ;Increment node counter by one for next segment
SET DGCNT=DGCNT+1
+17 ;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)
+18 IF DGWARD]""
SET DGWARDNM=$$GET1^DIQ(42,+DGWARD,.01)
+19 ;Increment node counter by one to store next segment
SET DGCNT=DGCNT+1
+20 ;Create the PV1 segment with no visit data and store in output array
SET DGPV1="PV1"_HL("FS")_1_HL("FS")_"I"
+21 ;GRR 1/26/00
SET $PIECE(DGPV1,HL("FS"),45)=$$HLDATE^HLFNC(DGDT)
+22 ;check if integrated site get original admit date/time
SET DGOADT=$$CKADMIT^DGRUUTL1(DFN)
+23 IF DGOADT]""
SET $PIECE(DGPV1,HL("FS"),45)=$$HLDATE^HLFNC(DGOADT)
+24 SET DGPV1=$$DOCID^DGRUUTL(DGPV1)
+25 IF DGWARDNM]""
SET $PIECE(DGPV1,HL("FS"),7)=DGWARDNM
+26 SET @DGARRAY@(DGCNT)=DGPV1
+27 SET DGCNT=DGCNT+1
+28 SET @DGARRAY@(DGCNT)="PV2"
+29 QUIT