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

69 lines
2.7 KiB
Mathematica
Raw Normal View History

2009-11-29 13:37:14 -05:00
MPIFA40 ;BP/CMC-BUILD A40 MERGE MESSAGE ;25 MARCH 2002
;;1.0; MASTER PATIENT INDEX VISTA ;**22,41**;30 Apr 99
;
; Integration Agreements Utilized:
; START, EXC, STOP^RGHLLOG - #2796
; BLDEVN, BLDPD1, BLDPID^VAFCQRY - #3630
;
A40(DFN,DFN2) ;BUILD AND SEND A40
N PID,PD1,EVN,PD1,MRG,MPI,RESLT,CNT,ICN1,ICN2
D INIT^HLFNC2("MPIF ADT-A40 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=""
D BLDEVN^VAFCQRY(DFN,"1,2",.EVN,.HL,"A40",.ERR)
Q:ERR'="" ERR
D BLDPID^VAFCQRY(DFN,1,"ALL",.PID,.HL,.ERR) ;**41
Q:ERR'="" ERR
D BLDPD1^VAFCQRY(DFN,"3",.PD1,.HL,.ERR)
Q:ERR'="" ERR
D BLDMRG(DFN2,"1,7",.MRG,.HL,.ERR)
S HLA("HLS",1)=EVN(1)
S HLA("HLS",3)=PD1(1)
S HLA("HLS",4)=MRG
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 MPI=$$MPILINK^MPIFAPI()
Q:$P($G(MPI),"^")=-1 "-1^No logical link defined for the MPI"
S HLL("LINKS",1)="MPIF ADT-A40 CLIENT^"_MPI
D GENERATE^HLMA("MPIF ADT-A40 SERVER","LM",1,.MPIFRSLT,"","") ;**41
S RESLT=$S(+MPIFRSLT:MPIFRSLT,1:$P(MPIFRSLT,"^",3))
S ^XTMP("MPIFA40%"_DFN,0)=$$FMADD^XLFDT(DT,5)_"^"_DT_"^"_"MPIA40 msg to MPI for DFN "_DFN
I +RESLT D
.S ICN1=$$GETICN^MPIF001(DFN),ICN2=$$GETICN^MPIF001(DFN2)
.S ^XTMP("MPIFA40%"_DFN,DFN2,"MPI",0)="A"
.S ^XTMP("MPIFA40%"_DFN,DFN2,"MPI",1)=ICN1_"^"_ICN2_"^"_RESLT
K HLA,HLEID,HLL("LINKS"),COMP,REP,SUBCOMP,HLECH,HLFS,HLA("HLA"),HLA("HLS"),MPIFRSLT ;**41
Q RESLT
;
RES ;
N NXT
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
..D START^RGHLLOG(HLMTIEN,"","")
..D EXC^RGHLLOG(208,$P(HLNODE,HL("FS"),4)_" for HL msg# "_HLMTIEN,DFN)
..D STOP^RGHLLOG(0)
K ^XTMP("MPIFA40%"_DFN)
Q
;
BLDMRG(IEN,FLD,SEG,HL,ERR) ; bld MRG segment ONLY FIELDS 2 AND 8 SUPPORTED
N NODE,MPIZN,MG,X,COMP,SUBCOMP,REP,NAME,ICN,SITE
S COMP=$E(HL("ECH"),1),SUBCOMP=$E(HL("ECH"),4),REP=$E(HL("ECH"),2)
S MPIZN=$D(^DPT(IEN,0))
I MPIZN="" S ERR="-1^No such DFN entry "_IEN Q
S SEG="MRG"
;repeat prior ID's including ICN and DFN
S NODE=$$MPINODE^MPIFAPI(IEN)
S ICN=$P(NODE,"^",1)_"V"_$P(NODE,"^",2),SITE=$P($$SITE^VASITE(),"^",3)
S MG(2)=ICN_COMP_COMP_COMP_"USVHA"_SUBCOMP_SUBCOMP_"0363"_COMP_"NI"_COMP_"VA FACILITY ID"_SUBCOMP_SITE_SUBCOMP_"L"_REP_IEN_COMP_COMP_COMP_"USVHA"_SUBCOMP_SUBCOMP_"0363"_COMP_"PI"_COMP_"VA FACILITY ID"_SUBCOMP_SITE_SUBCOMP_"L" ;**41
;NAME
S NAME("FILE")=2,NAME("IENS")=IEN,NAME("FIELD")=.01
S MG(8)=$$HLNAME^XLFNAME(.NAME,"",COMP)
S $P(MG(8),COMP,7)="L"
S $P(SEG,HL("FS"),2)=MG(2)
S $P(SEG,HL("FS"),8)=MG(8)
Q