MDCEVN ;HINES OIFO/DP/BJ/TJ - Wrapper to create HL7 EVN segment;30 May 2006
;;1.0;CLINICAL PROCEDURES;**16,12,23**;Apr 01, 2004;Build 281
;Per VHA Directive 2004-038, this routine should not be modified.
;
; This routine uses the following IAs:
; # 2050 - $$EZBLD^DIALOG() FileMan (supported)
; # 417 - ^DG(40.8; node 0, piece 7 Registration (controlled, subscribed)
; # 3016 - $$EVN^VAFHLEVN call Registration (controlled, subscribed)
; #10112 - $$SITE^VASITE() call Registration (supported)
; # 2171 - $$STA^XUAF4() call Kernel (supported)
;
VALID ;;HL7 MESSAGE BUILDER
;
Q
;
EN(IBEVENT,REC,EVNSEG,ERR) ;
; REC = ^IBBAA(375,n array
; EVNSEG = Output EVN segment
; ERR = Error message
;
N FS,PATLOC,FIL408D0,FIL4D0,FIL44D0,MDCERRAY,STATNO
S FS=HL("FS")
K ERR
S EVNSEG=$$EVN^VAFHLEVN(IBEVENT,"","") ; using OTS
;
Q:'$D(EVNSEG)
I $P(EVNSEG,FS,2)'=IBEVENT D Q
.S MDCERRAY(1)="Event Type Code EVN.1",MDCERRAY(2)="EVN",MDCERRAY(3)=REC
.S ERR=$$EZBLD^DIALOG(7040020.004,.MDCERRAY)
.Q
I +$P(EVNSEG,FS,3)'>0 D Q
.S MDCERRAY(1)="Recorded Date/Time EVN.2.1",MDCERRAY(2)="EVN",MDCERRAY(3)=REC
.S ERR=$$EZBLD^DIALOG(7040020.004,.MDCERRAY)
.Q
; Event Facility EVN.7.1 - START WITH 375,13
S FIL408D0=+$P($G(REC(13)),U,1)
I FIL408D0>0 S FIL4D0=+$P($G(^DG(40.8,FIL408D0,0)),U,7) ; Medical Center Division
I +$G(FIL4D0)>0 S STATNO=$$STA^XUAF4(FIL4D0) ; Institution File
I $G(STATNO)]"" S $P(EVNSEG,FS,8)=STATNO Q
;
; no hit, try 375,1.03 pointer to Hospital Location File #44
S FIL44D0=+$P($G(REC("PV1")),U,3)
NEW DIERR
I FIL44D0>0 N DIERR S FIL408D0=$$GET1^DIQ(44,FIL44D0_",",3.5,"I") ; Hospital Location File
I FIL408D0>0 S FIL4D0=+$P($G(^DG(40.8,0,FIL408D0,0)),U,7) ; Medical Center Division
I +$G(FIL4D0)>0 S STATNO=$$STA^XUAF4(FIL4D0) ; Institution File
I $G(STATNO)]"" S $P(EVNSEG,FS,8)=STATNO Q
;
; no hit, try $$SITE^VASITE()
N IBBVSITE
S IBBVSITE=+$$SITE^VASITE()
I IBBVSITE>0 S $P(EVNSEG,FS,8)=IBBVSITE Q
;
; still no hit, error
S MDCERRAY(1)="Event Facility EVN.7.1",MDCERRAY(2)="EVN",MDCERRAY(3)=REC
S ERR=$$EZBLD^DIALOG(7040020.004,.MDCERRAY)
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMDCEVN 2366 printed Dec 13, 2024@01:42:20 Page 2
MDCEVN ;HINES OIFO/DP/BJ/TJ - Wrapper to create HL7 EVN segment;30 May 2006
+1 ;;1.0;CLINICAL PROCEDURES;**16,12,23**;Apr 01, 2004;Build 281
+2 ;Per VHA Directive 2004-038, this routine should not be modified.
+3 ;
+4 ; This routine uses the following IAs:
+5 ; # 2050 - $$EZBLD^DIALOG() FileMan (supported)
+6 ; # 417 - ^DG(40.8; node 0, piece 7 Registration (controlled, subscribed)
+7 ; # 3016 - $$EVN^VAFHLEVN call Registration (controlled, subscribed)
+8 ; #10112 - $$SITE^VASITE() call Registration (supported)
+9 ; # 2171 - $$STA^XUAF4() call Kernel (supported)
+10 ;
VALID ;;HL7 MESSAGE BUILDER
+1 ;
+2 QUIT
+3 ;
EN(IBEVENT,REC,EVNSEG,ERR) ;
+1 ; REC = ^IBBAA(375,n array
+2 ; EVNSEG = Output EVN segment
+3 ; ERR = Error message
+4 ;
+5 NEW FS,PATLOC,FIL408D0,FIL4D0,FIL44D0,MDCERRAY,STATNO
+6 SET FS=HL("FS")
+7 KILL ERR
+8 ; using OTS
SET EVNSEG=$$EVN^VAFHLEVN(IBEVENT,"","")
+9 ;
+10 if '$DATA(EVNSEG)
QUIT
+11 IF $PIECE(EVNSEG,FS,2)'=IBEVENT
Begin DoDot:1
+12 SET MDCERRAY(1)="Event Type Code EVN.1"
SET MDCERRAY(2)="EVN"
SET MDCERRAY(3)=REC
+13 SET ERR=$$EZBLD^DIALOG(7040020.004,.MDCERRAY)
+14 QUIT
End DoDot:1
QUIT
+15 IF +$PIECE(EVNSEG,FS,3)'>0
Begin DoDot:1
+16 SET MDCERRAY(1)="Recorded Date/Time EVN.2.1"
SET MDCERRAY(2)="EVN"
SET MDCERRAY(3)=REC
+17 SET ERR=$$EZBLD^DIALOG(7040020.004,.MDCERRAY)
+18 QUIT
End DoDot:1
QUIT
+19 ; Event Facility EVN.7.1 - START WITH 375,13
+20 SET FIL408D0=+$PIECE($GET(REC(13)),U,1)
+21 ; Medical Center Division
IF FIL408D0>0
SET FIL4D0=+$PIECE($GET(^DG(40.8,FIL408D0,0)),U,7)
+22 ; Institution File
IF +$GET(FIL4D0)>0
SET STATNO=$$STA^XUAF4(FIL4D0)
+23 IF $GET(STATNO)]""
SET $PIECE(EVNSEG,FS,8)=STATNO
QUIT
+24 ;
+25 ; no hit, try 375,1.03 pointer to Hospital Location File #44
+26 SET FIL44D0=+$PIECE($GET(REC("PV1")),U,3)
+27 NEW DIERR
+28 ; Hospital Location File
IF FIL44D0>0
NEW DIERR
SET FIL408D0=$$GET1^DIQ(44,FIL44D0_",",3.5,"I")
+29 ; Medical Center Division
IF FIL408D0>0
SET FIL4D0=+$PIECE($GET(^DG(40.8,0,FIL408D0,0)),U,7)
+30 ; Institution File
IF +$GET(FIL4D0)>0
SET STATNO=$$STA^XUAF4(FIL4D0)
+31 IF $GET(STATNO)]""
SET $PIECE(EVNSEG,FS,8)=STATNO
QUIT
+32 ;
+33 ; no hit, try $$SITE^VASITE()
+34 NEW IBBVSITE
+35 SET IBBVSITE=+$$SITE^VASITE()
+36 IF IBBVSITE>0
SET $PIECE(EVNSEG,FS,8)=IBBVSITE
QUIT
+37 ;
+38 ; still no hit, error
+39 SET MDCERRAY(1)="Event Facility EVN.7.1"
SET MDCERRAY(2)="EVN"
SET MDCERRAY(3)=REC
+40 SET ERR=$$EZBLD^DIALOG(7040020.004,.MDCERRAY)
+41 QUIT
+42 ;