- DGRUGA13 ;ALB/GRR - HL7 ADT A13 MESSAGE BUILDER ;8/5/99 15:34
- ;;5.3;Registration;**190,312,373,1015**;Aug 13, 1993;Build 21
- ;
- ;This routine will build a ADT A13 (Cancel Discharge) 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 DGHOLD,DGCNT,DGMDT,DGCDT,DGEDT,DGOADT,DGHMDT,DGCTRAN,DGICD,DGICDCNT,DGIN,DGINCNT,DGPV1 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"),DGHMDT=$$HLDATE^HLFNC(DGMDT)
- D NOW^%DTC S DGCDT=$$HLDATE^HLFNC(%) ;Get current date/time and convert to HL7 format
- S DGEDT=$S($G(DGASIH)=1:+$G(DGPMA),$G(DGASIH)=3:+$G(DGPMP),1:DGMDT) ;If discharge was while ASIH (312), p-373
- S DGCNT=DGCNT+1 ;Increment node counter by one for first segment
- S @DGARRAY@(DGCNT)=$$EVN^VAFHLEVN("A13","05",DGEDT) ;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
- 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
- I DGHOLD]"" S DGCNT=DGCNT+1,@DGARRAY@(DGCNT)=DGHOLD
- 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
- ;; testing SCK
- S DGPV1=$$IN^VAFHLPV1(DFN,DGMDT,",2,3,6,7,10,17,44,45,",$G(DGMIEN),"","")
- 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 $G(DGCTRAN)=1 S $P(DGPV1,HL("FS"),4)=$P(DGPV1,HL("FS"),7) ;need to make prior location the current one because changing prior transaction
- S @DGARRAY@(DGCNT)=$$LOCTRAN^DGRUUTL1(DGPV1) ;translate ward, room-bed if needed
- D IN^VAFHLDG1(DFN,DGMIEN,",2,3,5,","DGICD") ;Create the DG1 segment(s) and store in a temporary array
- I $O(DGICD(0))>0 D ;DG1 segment were built
- .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
- D EN^VAFHLIN1(DFN,",2,4,12,","",HL("FS"),"DGIN") ;Create IN1 segment(s) and store in temporary array
- I $D(DGIN(1,0)),$P(DGIN(1,0),HL("FS"),5)]"" D ;IN1 segments were built
- .S DGINCNT=0 F S DGINCNT=$O(DGIN(DGINCNT)) Q:DGINCNT="" S DGCNT=DGCNT+1,@DGARRAY@(DGCNT)=DGIN(DGINCNT,0) ;Loop through temporary array and store IN1 segment(s) in output array
- Q
- DGRUGA13 ;ALB/GRR - HL7 ADT A13 MESSAGE BUILDER ;8/5/99 15:34
- +1 ;;5.3;Registration;**190,312,373,1015**;Aug 13, 1993;Build 21
- +2 ;
- +3 ;This routine will build a ADT A13 (Cancel Discharge) 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 DGHOLD,DGCNT,DGMDT,DGCDT,DGEDT,DGOADT,DGHMDT,DGCTRAN,DGICD,DGICDCNT,DGIN,DGINCNT,DGPV1
- 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")
- SET DGHMDT=$$HLDATE^HLFNC(DGMDT)
- +13 ;Get current date/time and convert to HL7 format
- DO NOW^%DTC
- SET DGCDT=$$HLDATE^HLFNC(%)
- +14 ;If discharge was while ASIH (312), p-373
- SET DGEDT=$SELECT($GET(DGASIH)=1:+$GET(DGPMA),$GET(DGASIH)=3:+$GET(DGPMP),1:DGMDT)
- +15 ;Increment node counter by one for first segment
- SET DGCNT=DGCNT+1
- +16 ;Create Event segment and store in output array (Use current date/time for cancel)
- SET @DGARRAY@(DGCNT)=$$EVN^VAFHLEVN("A13","05",DGEDT)
- +17 ;Increment node counter by one for next segment
- SET DGCNT=DGCNT+1
- +18 ;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)
- +19 ;Create the NK1 segment using the segment sequence numbers passed, and store in output array
- SET DGHOLD=$$EN^VAFHLNK1(DFN,DGMIEN,",2,3,4,5,")
- +20 IF DGHOLD]""
- SET DGCNT=DGCNT+1
- SET @DGARRAY@(DGCNT)=DGHOLD
- +21 ;Retrieve Movement Date/Time
- SET DGMDT=$$GET1^DIQ(405,DGMIEN,".01","I")
- +22 ;Increment node counter by one to store next segment
- SET DGCNT=DGCNT+1
- +23 ;; testing SCK
- +24 SET DGPV1=$$IN^VAFHLPV1(DFN,DGMDT,",2,3,6,7,10,17,44,45,",$GET(DGMIEN),"","")
- +25 ;check if integrated site get original admit date/time
- SET DGOADT=$$CKADMIT^DGRUUTL1(DFN)
- +26 IF DGOADT]""
- SET $PIECE(DGPV1,HL("FS"),45)=$$HLDATE^HLFNC(DGOADT)
- +27 SET DGPV1=$$DOCID^DGRUUTL(DGPV1)
- +28 ;need to make prior location the current one because changing prior transaction
- IF $GET(DGCTRAN)=1
- SET $PIECE(DGPV1,HL("FS"),4)=$PIECE(DGPV1,HL("FS"),7)
- +29 ;translate ward, room-bed if needed
- SET @DGARRAY@(DGCNT)=$$LOCTRAN^DGRUUTL1(DGPV1)
- +30 ;Create the DG1 segment(s) and store in a temporary array
- DO IN^VAFHLDG1(DFN,DGMIEN,",2,3,5,","DGICD")
- +31 ;DG1 segment were built
- IF $ORDER(DGICD(0))>0
- Begin DoDot:1
- +32 ;Loop through temporary array and store DG1 segment(s) in output array
- SET DGICDCNT=0
- FOR
- SET DGICDCNT=$ORDER(DGICD(DGICDCNT))
- IF DGICDCNT=""
- QUIT
- SET DGCNT=DGCNT+1
- SET @DGARRAY@(DGCNT)=DGICD(DGICDCNT,0)
- End DoDot:1
- +33 ;Create IN1 segment(s) and store in temporary array
- DO EN^VAFHLIN1(DFN,",2,4,12,","",HL("FS"),"DGIN")
- +34 ;IN1 segments were built
- IF $DATA(DGIN(1,0))
- IF $PIECE(DGIN(1,0),HL("FS"),5)]""
- Begin DoDot:1
- +35 ;Loop through temporary array and store IN1 segment(s) in output array
- SET DGINCNT=0
- FOR
- SET DGINCNT=$ORDER(DGIN(DGINCNT))
- IF DGINCNT=""
- QUIT
- SET DGCNT=DGCNT+1
- SET @DGARRAY@(DGCNT)=DGIN(DGINCNT,0)
- End DoDot:1
- +36 QUIT