MPIFA28 ;BP/CMC-BUILD A28 ADD ME MSGS ; 5/4/20 11:01am
;;1.0;MASTER PATIENT INDEX VISTA;**22,31,25,35,44,75**;30 Apr 99;Build 1
;
; Integration Agreements Utilized:
; START, EXC, STOP^RGHLLOG - #2796
; BLDEVN, BLDPD1, BLDPID^VAFCQRY - #3630
;
A28(DFN) ;BUILD AND SEND A28
N RESLT,CNT,MPI,EVN,TCNT,ERR,PD1,PID
K HLA("HLA"),HLA("HLS")
S CNT=1
D INIT^HLFNC2("MPIF ADT-A28 SERVER",.HL)
I $O(HL(""))="" Q "-1^"_$P(HL,"^",2)
S HLECH=HL("ECH"),HLFS=HL("FS"),COMP=$E(HL("ECH"),1),REP=$E(HL("ECH"),2),SUBCOMP=$E(HL("ECH"),4)
S ERR="",TCNT=0
D BLDEVN^VAFCQRY(DFN,"1,2",.EVN,.HL,"A28",.ERR)
Q:ERR'="" ERR
D BLDPID^VAFCQRY(DFN,1,"ALL",.PID,.HL,.ERR)
Q:ERR'="" ERR
D BLDPD1^VAFCQRY(DFN,"3",.PD1,.HL,.ERR)
Q:ERR'="" ERR
S HLA("HLS",1)=EVN(1)
S HLA("HLS",3)=PD1(1)
S CNT=0 F S CNT=$O(PID(CNT)) Q:CNT="" D
.I CNT=1 S HLA("HLS",2)=PID(CNT)
.I CNT>1 S HLA("HLS",2,CNT-1)=PID(CNT)
S HLA("HLS",4)=$$EN1^VAFHLZPD(DFN,"1,17,21,34") ;25 ;**44 ADDED PSEUDO SSN REASON, 1 and 21 TO ZPD SEGMENT
S MPI=$$MPILINK^MPIFAPI()
Q:$P($G(MPI),"^")=-1 "-1^No logical link defined for the MPI"
;**75 - Story - 1260465 (ckn) - Include 200M in HLL links for HAC
S HLL("LINKS",1)="MPIF ADT-A28 CLIENT^"_MPI_$S($P($$SITE^VASITE(),"^",3)=741:"^200M",1:"")
D GENERATE^HLMA("MPIF ADT-A28 SERVER","LM",1,.MPIFRSLT,"","")
S RESLT=$S(+MPIFRSLT:MPIFRSLT,1:$P(MPIFRSLT,"^",3))
I +RESLT S ^XTMP("MPIFA28%"_DFN,0)=$$FMADD^XLFDT(DT,5)_"^"_DT_"^"_"A28 message to MPI for DFN "_DFN,^XTMP("MPIFA28%"_DFN,"MPI",0)="A"
I $D(^DPT("AICNL",1,DFN)) D
.I $G(^DPT("AICNL",1,DFN))="" S ^DPT("AICNL",1,DFN)="2^"_DT
.; **35
K HLA,HLEID,HLL("LINKS"),COMP,REP,SUBCOMP,HLECH,HLFS,HLA("HLA"),HLA("HLS"),MPIFRSLT
Q RESLT
;
RES ;
N NXT,DFN
F NXT=1:1 X HLNEXT Q:HLQUIT'>0 D
.I $E(HLNODE,1,3)="MSA" S DFN=$P($P(HLNODE,HL("FS"),7),"=",2)
K ^XTMP("MPIFA28%"_DFN)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMPIFA28 1883 printed Dec 13, 2024@02:10:47 Page 2
MPIFA28 ;BP/CMC-BUILD A28 ADD ME MSGS ; 5/4/20 11:01am
+1 ;;1.0;MASTER PATIENT INDEX VISTA;**22,31,25,35,44,75**;30 Apr 99;Build 1
+2 ;
+3 ; Integration Agreements Utilized:
+4 ; START, EXC, STOP^RGHLLOG - #2796
+5 ; BLDEVN, BLDPD1, BLDPID^VAFCQRY - #3630
+6 ;
A28(DFN) ;BUILD AND SEND A28
+1 NEW RESLT,CNT,MPI,EVN,TCNT,ERR,PD1,PID
+2 KILL HLA("HLA"),HLA("HLS")
+3 SET CNT=1
+4 DO INIT^HLFNC2("MPIF ADT-A28 SERVER",.HL)
+5 IF $ORDER(HL(""))=""
QUIT "-1^"_$PIECE(HL,"^",2)
+6 SET HLECH=HL("ECH")
SET HLFS=HL("FS")
SET COMP=$EXTRACT(HL("ECH"),1)
SET REP=$EXTRACT(HL("ECH"),2)
SET SUBCOMP=$EXTRACT(HL("ECH"),4)
+7 SET ERR=""
SET TCNT=0
+8 DO BLDEVN^VAFCQRY(DFN,"1,2",.EVN,.HL,"A28",.ERR)
+9 if ERR'=""
QUIT ERR
+10 DO BLDPID^VAFCQRY(DFN,1,"ALL",.PID,.HL,.ERR)
+11 if ERR'=""
QUIT ERR
+12 DO BLDPD1^VAFCQRY(DFN,"3",.PD1,.HL,.ERR)
+13 if ERR'=""
QUIT ERR
+14 SET HLA("HLS",1)=EVN(1)
+15 SET HLA("HLS",3)=PD1(1)
+16 SET CNT=0
FOR
SET CNT=$ORDER(PID(CNT))
if CNT=""
QUIT
Begin DoDot:1
+17 IF CNT=1
SET HLA("HLS",2)=PID(CNT)
+18 IF CNT>1
SET HLA("HLS",2,CNT-1)=PID(CNT)
End DoDot:1
+19 ;25 ;**44 ADDED PSEUDO SSN REASON, 1 and 21 TO ZPD SEGMENT
SET HLA("HLS",4)=$$EN1^VAFHLZPD(DFN,"1,17,21,34")
+20 SET MPI=$$MPILINK^MPIFAPI()
+21 if $PIECE($GET(MPI),"^")=-1
QUIT "-1^No logical link defined for the MPI"
+22 ;**75 - Story - 1260465 (ckn) - Include 200M in HLL links for HAC
+23 SET HLL("LINKS",1)="MPIF ADT-A28 CLIENT^"_MPI_$SELECT($PIECE($$SITE^VASITE(),"^",3)=741:"^200M",1:"")
+24 DO GENERATE^HLMA("MPIF ADT-A28 SERVER","LM",1,.MPIFRSLT,"","")
+25 SET RESLT=$SELECT(+MPIFRSLT:MPIFRSLT,1:$PIECE(MPIFRSLT,"^",3))
+26 IF +RESLT
SET ^XTMP("MPIFA28%"_DFN,0)=$$FMADD^XLFDT(DT,5)_"^"_DT_"^"_"A28 message to MPI for DFN "_DFN
SET ^XTMP("MPIFA28%"_DFN,"MPI",0)="A"
+27 IF $DATA(^DPT("AICNL",1,DFN))
Begin DoDot:1
+28 IF $GET(^DPT("AICNL",1,DFN))=""
SET ^DPT("AICNL",1,DFN)="2^"_DT
+29 ; **35
End DoDot:1
+30 KILL HLA,HLEID,HLL("LINKS"),COMP,REP,SUBCOMP,HLECH,HLFS,HLA("HLA"),HLA("HLS"),MPIFRSLT
+31 QUIT RESLT
+32 ;
RES ;
+1 NEW NXT,DFN
+2 FOR NXT=1:1
XECUTE HLNEXT
if HLQUIT'>0
QUIT
Begin DoDot:1
+3 IF $EXTRACT(HLNODE,1,3)="MSA"
SET DFN=$PIECE($PIECE(HLNODE,HL("FS"),7),"=",2)
End DoDot:1
+4 KILL ^XTMP("MPIFA28%"_DFN)
+5 QUIT