VistA-WorldVistAEHR/r/MASTER_PATIENT_INDEX_VISTA-.../MPIFA24B.m

65 lines
2.7 KiB
Mathematica

MPIFA24B ;BP/CMC-BUILD A24 ADD ME MSGS ;JULY 22, 2002
;;1.0; MASTER PATIENT INDEX VISTA ;**22,28,31,25,43,44**;30 Apr 99;Build 7
;
; Integration Agreements Utilized:
; START, EXC, STOP^RGHLLOG - #2796
; BLDEVN, BLDPD1, BLDPID^VAFCQRY - #3630
;
A24(DFN,PID2) ;BUILD AND SEND A24 **43 added PID2 as a parameter - not required.
; if PID2 is defined it will contain the previous ICN data, passed by reference
N RESLT,CNT,MPI,EVN,TCNT,ERR,PD1,PID
K HLA("HLA"),HLA("HLS")
S CNT=1
D INIT^HLFNC2("MPIF ADT-A24 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,"A24",.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
I '$D(PID2) D BLDPID^VAFCQRY(DFN,2,"ALL",.PID2,.HL,.ERR) ;**43 TO ONLY BUILD 2ND PID SEGMENT IF NOT PASSED
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 CNT=0 F S CNT=$O(PID2(CNT)) Q:CNT="" D
.I CNT=1 S HLA("HLS",4)=PID2(CNT)
.I CNT>1 S HLA("HLS",4,CNT-1)=PID2(CNT)
S HLA("HLS",5)=$$EN1^VAFHLZPD(DFN,"1,17,21,34") ;25 ;**44 Adding Pseudo SSN Reason, 1 and 21 to ZPD segment
K HLL("LINKS")
D GENERATE^HLMA("MPIF ADT-A24 SERVER","LM",1,.MPIFRSLT,"","")
S RESLT=$S(+MPIFRSLT:MPIFRSLT,1:$P(MPIFRSLT,"^",3))
I '+RESLT S ^XTMP("MPIFA24%"_DFN,0)=$$FMADD^XLFDT(DT,5)_"^"_DT_"^"_"A24 message to MPI for DFN "_DFN,^XTMP("MPIFA24%"_DFN,"MPI",0)="A"
K HLA,HLEID,HLL("LINKS"),COMP,REP,SUBCOMP,HLECH,HLFS,HLA("HLA"),HLA("HLS"),MPIFRSLT
;**44 TRIGGER A31 TO UPDATE ANY DEMOGRAPHIC CHANGES
N A31 S A31=$$A31^MPIFA31B(DFN)
I $P(A31,"^",2)'="" D
.;log exception about A31 not being sent
.D START^RGHLLOG()
.D EXC^RGHLLOG(208,$P(A31,"^",2,3),"Unable to generate A31 for DFN"_DFN,DFN)
.D STOP^RGHLLOG(0)
I $P(A31,"^",2)="" S ^XTMP("MPIFA31%"_DFN,0)=$$FMADD^XLFDT(DT,5)_"^"_DT_"^"_"A31 message to MPI for DFN "_DFN,^XTMP("MPIFA31%"_DFN,"MPI",0)="A"
Q RESLT
;
RT ;
S MPI=$$MPILINK^MPIFAPI()
I $P($G(MPI),"^")=-1 D START^RGHLLOG(),EXC^RGHLLOG(224,"No logical link defined for the MPI",$G(DFN)),STOP^RGHLLOG() Q
S HLL("LINKS",1)="MPIF ADT-A24 CLIENT^"_MPI
Q
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)
.I $E(HLNODE,1,3)="MSA"&($P(HLNODE,HL("FS"),4)'="") D
..; ERROR RETURNED IN MSA - LOG EXCEPTION --**44 stopped logging exception as MPI has already logged it.
..;D START^RGHLLOG(HLMTIEN,"","")
..;D EXC^RGHLLOG(208,$P(HLNODE,HL("FS"),4)_" for HL msg# "_HLMTIEN,DFN)
..;D STOP^RGHLLOG(0)
K ^XTMP("MPIFA24%"_DFN)
Q