VAFHLA04 ;ALB/JLU;CREATES THE REGISTRATION MESSAGE;
;;5.3;Registration;**91,179**;Jun 06, 1996
;hl7v1.6
EN(VAFHDFN,VAFHDT) ;THE MAIN ENTRY POINT FOR THE A04 MESSAGE TYPE
;
S ERR="^TMP(""VAFHERR"",$J)" K ^TMP("VAFHERR",$J)
I '$D(VAFHDFN)!('$D(VAFHDT)) S @ERR@(1)="-1^Can not build the A04 message. Parameters not defined correctly." D EBULL^VAFHUTL2("","","",ERR) G EX
I VAFHDFN=""!(VAFHDT="") S @ERR@(1)="-1^Can not build the A04 message. Parameters are null." D EBULL^VAFHUTL2(VAFHDFN,VAFHDT,"",ERR) G EX
;
S VAFHPID="1,2,4,6,7,8,11,12,13,14,16,19"
S VAFHZPD="2,3,4,5,6,7,8,9,10,11,12,13,14,15"
K HLERR
S CTR=1,HLSDT="VAFHREG"
K HL D INIT^HLFNC2("VAFH A04",.HL)
I $D(HL)#2 G EX
;. S @ERR@(1)="-1^Can not build the A04 message. Failed during HLFNC2"
;. S @ERR@(2)=HL
;. D EBULL^VAFHUTL2(VAFHDFN,VAFHDT,"",ERR)
S HLMTN="ADT"_$E(HL("ECH"))_"A04"
S VAFHGBL="^TMP(""HLS"",$J)" K ^TMP("HLS",$J)
S SING="" ;SINGLE MESSAGES (NOT BATCH)
;
BAT ;THIS ENTRY POINT IS TO BE CONSIDERED IF A BATCH PROCESS IS NEEDED.
;
S VAFHPTR=VAFHDFN_";DPT("
S VAFHPIV=$$PIVNW^VAFHPIVT(VAFHDFN,VAFHDT,3,VAFHPTR)
I VAFHPIV<0 S @ERR@(1)="-1^Can not build the A04 message. Failed to get a PIVOT entry." D EBULL^VAFHUTL2(VAFHDFN,VAFHDT,"",ERR) G EX
S EVN=$$EVN^VAFHLEVN("A04","05") I +EVN=-1 S @ERR@(1)=EVN D EBULL^VAFHUTL2(VAFHDFN,VAFHDT,+VAFHPIV,ERR) G EX
S @VAFHGBL@(CTR)=EVN
S CTR=CTR+1,@VAFHGBL@(CTR)=$$EN^VAFHLPID(VAFHDFN,VAFHPID)
S CTR=CTR+1,@VAFHGBL@(CTR)=$$EN^VAFHLZPD(VAFHDFN,VAFHZPD)
S PV1=$$OPV1^VAFHCPV(VAFHDFN,+VAFHPIV,VAFHDT,VAFHPTR,50) I +PV1=-1 S @ERR@(1)=PV1 D EBULL^VAFHUTL2(VAFHDFN,VAFHDT,+VAFHPIV,ERR) G EX
;;;I $P(PV1,HLFS,3)'="O" S $P(PV1,HLFS,3)="T"
;;;I $P(PV1,HLFS,3)]"",$P(PV1,HLFS,3)'="O" S $P(PV1,HLFS,3)="T"
S $P(PV1,HLFS,3)="T"
S CTR=CTR+1,@VAFHGBL@(CTR)=PV1
I $D(SING) DO
.D GENERATE^HLMA("VAFH A04","GM",1,.HLRST)
;
EX ;
D KILL^HLTRANS
K VAFHGBL,VAFHDT,VAFHPTR,VAFHPID,VAFHZPD,PV1,EVN,CTR,SING,ERR
K ^TMP("HLS",$J),^TMP("VAFHERR",$J)
Q
VAFHLA04 ;ALB/JLU;CREATES THE REGISTRATION MESSAGE;
+1 ;;5.3;Registration;**91,179**;Jun 06, 1996
+2 ;hl7v1.6
EN(VAFHDFN,VAFHDT) ;THE MAIN ENTRY POINT FOR THE A04 MESSAGE TYPE
+1 ;
+2 SET ERR="^TMP(""VAFHERR"",$J)"
KILL ^TMP("VAFHERR",$JOB)
+3 IF '$DATA(VAFHDFN)!('$DATA(VAFHDT))
SET @ERR@(1)="-1^Can not build the A04 message. Parameters not defined correctly."
DO EBULL^VAFHUTL2("","","",ERR)
GOTO EX
+4 IF VAFHDFN=""!(VAFHDT="")
SET @ERR@(1)="-1^Can not build the A04 message. Parameters are null."
DO EBULL^VAFHUTL2(VAFHDFN,VAFHDT,"",ERR)
GOTO EX
+5 ;
+6 SET VAFHPID="1,2,4,6,7,8,11,12,13,14,16,19"
+7 SET VAFHZPD="2,3,4,5,6,7,8,9,10,11,12,13,14,15"
+8 KILL HLERR
+9 SET CTR=1
SET HLSDT="VAFHREG"
+10 KILL HL
DO INIT^HLFNC2("VAFH A04",.HL)
+11 IF $DATA(HL)#2
GOTO EX
+12 ;. S @ERR@(1)="-1^Can not build the A04 message. Failed during HLFNC2"
+13 ;. S @ERR@(2)=HL
+14 ;. D EBULL^VAFHUTL2(VAFHDFN,VAFHDT,"",ERR)
+15 SET HLMTN="ADT"_$EXTRACT(HL("ECH"))_"A04"
+16 SET VAFHGBL="^TMP(""HLS"",$J)"
KILL ^TMP("HLS",$JOB)
+17 ;SINGLE MESSAGES (NOT BATCH)
SET SING=""
+18 ;
BAT ;THIS ENTRY POINT IS TO BE CONSIDERED IF A BATCH PROCESS IS NEEDED.
+1 ;
+2 SET VAFHPTR=VAFHDFN_";DPT("
+3 SET VAFHPIV=$$PIVNW^VAFHPIVT(VAFHDFN,VAFHDT,3,VAFHPTR)
+4 IF VAFHPIV<0
SET @ERR@(1)="-1^Can not build the A04 message. Failed to get a PIVOT entry."
DO EBULL^VAFHUTL2(VAFHDFN,VAFHDT,"",ERR)
GOTO EX
+5 SET EVN=$$EVN^VAFHLEVN("A04","05")
IF +EVN=-1
SET @ERR@(1)=EVN
DO EBULL^VAFHUTL2(VAFHDFN,VAFHDT,+VAFHPIV,ERR)
GOTO EX
+6 SET @VAFHGBL@(CTR)=EVN
+7 SET CTR=CTR+1
SET @VAFHGBL@(CTR)=$$EN^VAFHLPID(VAFHDFN,VAFHPID)
+8 SET CTR=CTR+1
SET @VAFHGBL@(CTR)=$$EN^VAFHLZPD(VAFHDFN,VAFHZPD)
+9 SET PV1=$$OPV1^VAFHCPV(VAFHDFN,+VAFHPIV,VAFHDT,VAFHPTR,50)
IF +PV1=-1
SET @ERR@(1)=PV1
DO EBULL^VAFHUTL2(VAFHDFN,VAFHDT,+VAFHPIV,ERR)
GOTO EX
+10 ;;;I $P(PV1,HLFS,3)'="O" S $P(PV1,HLFS,3)="T"
+11 ;;;I $P(PV1,HLFS,3)]"",$P(PV1,HLFS,3)'="O" S $P(PV1,HLFS,3)="T"
+12 SET $PIECE(PV1,HLFS,3)="T"
+13 SET CTR=CTR+1
SET @VAFHGBL@(CTR)=PV1
+14 IF $DATA(SING)
Begin DoDot:1
+15 DO GENERATE^HLMA("VAFH A04","GM",1,.HLRST)
End DoDot:1
+16 ;
EX ;
+1 DO KILL^HLTRANS
+2 KILL VAFHGBL,VAFHDT,VAFHPTR,VAFHPID,VAFHZPD,PV1,EVN,CTR,SING,ERR
+3 KILL ^TMP("HLS",$JOB),^TMP("VAFHERR",$JOB)
+4 QUIT