source: FOIAVistA/trunk/r/MASTER_PATIENT_INDEX_VISTA-MPIF/MPIFBT3.m@ 1742

Last change on this file since 1742 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 6.4 KB
Line 
1MPIFBT3 ;SLC/ARS-BATCH RESPONSE FROM MPI ;FEB 4, 1997
2 ;;1.0; MASTER PATIENT INDEX VISTA ;**1,3,10,17,21,24,28,31,33,35,43**;30 Apr 99
3 ;
4 ; Integration Agreements Utilized:
5 ; ^DPT("AICN", ^DPT("AICNL", ^DPT("AMPIMIS" - #2070
6 ; EXC^RGHLLOG - #2796
7 ; FILE^VAFCTFU - #2988
8 ; NAME^VAFCPID2 - #3492
9 ;
10MULT(CNTR,ACK5,SEP,MPIMSG,PATID) ;multiple RDT segments
11 N NEXTTF,MPITMP S CNTR=$O(^XTMP($J,"MPIF","MPIIN",CNTR)),NEXTTF=$P(ACK5,SEP,8)
12 S MPITMP=$O(^XTMP($J,"MPIF","MPIIN",CNTR)) Q:MPITMP'>0
13 S ACK5=^XTMP($J,"MPIF","MPIIN",MPITMP) K NEXTTF,MPITMP
14 I $P(ACK5,SEP)="RDT" D MULT(.CNTR,ACK5,SEP,MPIMSG,PATID) ; ^ add to treating facility list. If not RDT continue on processing next msh
15 Q
16VFYRDT(ACK4,SEP,CNTR,PATID,SITE,MPIMSG) ;Here is the meat
17 N MPIY,IEN,MPICMOR,MPICOMP S DGSENFLG=""
18 S MPICOMP=$E(HL("ECH"),1)
19 D RDT^MPIFSA3(.CNTR,.HL,.ACK4)
20 D FINDHM(PATID,SEP,.MPIY,MPIMSG,CNTR)
21 Q:$D(^XTMP($J,"MPIF","MSHERR"))
22 N MPINUM,MPICKG,MPIIT,DR,DIE,X,MPIIPPF,MPIPPF,RESLT
23 S MPINUM=$P(^TMP("MPIFVQQ",$J,CNTR,"DATA"),"^",6),MPICKG=$P(MPINUM,"V",2),MPINUM=$P(MPINUM,"V",1)
24 ;check if ICN already in use in Patient file
25 I $D(^DPT("AICN",MPINUM)) D
26 .Q:PATID=$O(^DPT("AICN",MPINUM,"")) ; same patient
27 .S ^XTMP($J,"MPIF","MSHERR")="ICN already in use"
28 .N DFN2 S DFN2=$O(^DPT("AICN",MPINUM,""))
29 .D TWODFNS^MPIF002(DFN2,PATID,MPINUM)
30 Q:$D(^XTMP($J,"MPIF","MSHERR"))
31 S DIE="^DPT(",DA=$P(MPIY,"^",1),MPIIT=$P(MPIY,"^",1),DR="991.01////^S X=MPINUM;991.02////^S X=MPICKG" D ^DIE K DR,DIE,DA
32 S IEN=$P(MPIY,"^") ; check if need to kill Local/MISSING ICN field
33 I $D(^DPT("AMPIMIS",IEN)) K ^DPT("AMPIMIS",IEN)
34 I $D(^DPT("AICNL",1,IEN)) D
35 .S DIE="^DPT(",DA=IEN,DR="991.04///@" D ^DIE K DR,DIE,DA
36 S MPIIPPF=""
37 S MPIPPF=$P(^TMP("MPIFVQQ",$J,CNTR,"DATA"),"^",5),MPICMOR=$$LKUP^XUAF4(MPIPPF)
38 I MPICMOR'="" S MPIIPPF=$$CHANGE^MPIF001(MPIIT,MPICMOR)
39 I +MPIIPPF<0 D EXC^RGHLLOG(211,"Around line number "_(CNTR*2)_" CMOR= "_MPIPPF_" DFN= "_MPIIT_" MESSAGE# "_MPIMSG,MPIIT)
40 Q:+MPIIPPF<0
41 I $D(^TMP("MPIFVQQ",$J,CNTR,"TF")) D
42 . N MPINTFI,MPINTF,TFSTRG,TFIEN
43 . S MPINTFI=0,MPINTF="",TFIEN="",TFSTRG=""
44 . F S MPINTFI=$O(^TMP("MPIFVQQ",$J,CNTR,"TF",MPINTFI)) Q:'MPINTFI D
45 .. S MPINTF=^TMP("MPIFVQQ",$J,CNTR,"TF",MPINTFI)
46 .. S TFIEN=$$IEN^XUAF4($P(MPINTF,MPICOMP,1))
47 .. Q:'TFIEN
48 .. S TFSTRG=TFIEN_"^"_$$FMDATE^HLFNC($P(MPINTF,MPICOMP,2))_"^"_$P(MPINTF,MPICOMP,3)
49 .. D FILE^VAFCTFU(PATID,TFSTRG,1)
50 S RESLT=$$A24^MPIFA24B(PATID)
51 I +RESLT<0 D EXC^RGHLLOG(208,"Problem building A24 (ADD TF) for DFN= "_PATID,PATID)
52 K RESLT N RESLT
53 S RESLT=$$A31^MPIFA31B(PATID)
54 I +RESLT<0 D EXC^RGHLLOG(208,"Problem building A31 for DFN= "_PATID,PATID)
55 K ^TMP("MPIFVQQ",$J)
56 Q
57FINDHM(PATID,SEP,MPIY,MPIMSG,CNTR) ;LOOKUP
58 N DIC,X,Y,NM,YTMP,MPIN,EXACT
59 Q:'$D(^TMP("MPIFVQQ",$J,CNTR,"DATA"))
60 ;added I to DIC(0) allow processing of sensitive patients when DUZ=0
61 S DGSENFLG="",DIC="^DPT(",DIC(0)="OISZ",X="`"_PATID D ^DIC K DIC
62 S YTMP=Y
63 I YTMP=-1 S ^XTMP($J,"MPIF","MSHERR")="LOOKUP FAILED" D EXC^RGHLLOG(210,"SSN = "_$P(^TMP("MPIFVQQ",$J,CNTR,"DATA"),"^",3)_" MESSAGE# "_MPIMSG_" around line number "_(CNTR*2),PATID)
64 Q:YTMP=-1
65 S NM=$P(Y(0),"^"),YTMP=$G(Y(0)),MPIY=Y ; check if ICN already populated
66 N ICN S ICN=$$GETICN^MPIF001(PATID)
67 I +ICN'=-1,$E(+ICN,1,3)'=$P($$SITE^VASITE,"^",3) S ^XTMP($J,"MPIF","MSHERR")="Patient "_PATID_" Already has an ICN"
68 Q:$D(^XTMP($J,"MPIF","MSHERR"))
69 S Y(0)=$G(YTMP)
70 ;**43 ONLY EXACT MATCHES BEING RETURNED NO LONGER MAKE THESE CHECKES IN VISTA
71 ;Q:$P(Y(0),"^",9)["P"&($P(^TMP("MPIFVQQ",$J,CNTR,"DATA"),"^",3)="")
72 ;I $P(Y(0),"^",9)'=$P(^TMP("MPIFVQQ",$J,CNTR,"DATA"),"^",3) D
73 ;.S ^XTMP($J,"MPIF","MSHERR")="SSN MISMATCH"
74 ;.D EXC^RGHLLOG(213,"SSN on File = "_$P(Y(0),"^",9)_" SSN in Message = "_$P(^TMP("MPIFVQQ",$J,CNTR,"DATA"),"^",3)_" MESSAGE # "_MPIMSG_" around line number "_(CNTR*2),PATID)
75 ;.N LICN S LICN=$$ICNLC^MPIF001(PATID) ; create local ICN
76 ;Q:$D(^XTMP($J,"MPIF","MSHERR"))
77 ;D NAME^VAFCPID2(0,.NM,0) ; reformat name in DG 149 fashion for comparison
78 ;S MPIN=$P(^TMP("MPIFVQQ",$J,CNTR,"DATA"),"^",2)_","_$P(^TMP("MPIFVQQ",$J,CNTR,"DATA"),"^",7)
79 ;I $P(^TMP("MPIFVQQ",$J,CNTR,"DATA"),"^",10)'="" S MPIN=MPIN_" "_$P(^TMP("MPIFVQQ",$J,CNTR,"DATA"),"^",10)
80 ;I $P(^TMP("MPIFVQQ",$J,CNTR,"DATA"),"^",15)'="" S MPIN=MPIN_" "_$P(^TMP("MPIFVQQ",$J,CNTR,"DATA"),"^",15)
81 ;I $P(^TMP("MPIFVQQ",$J,CNTR,"DATA"),"^",14)'="" S MPIN=MPIN_" "_$P(^TMP("MPIFVQQ",$J,CNTR,"DATA"),"^",14)
82 ;D NAME^VAFCPID2(0,.MPIN,0)
83 ; check if Last and First Match--yes-- then check if middle name vs initial
84 ;I $P(NM,",")=$P(MPIN,",")&($P($P(MPIN,",",2)," ")=$P($P(NM,",",2)," ")) D
85 ;.N MPIMID,NMMN S MPIMID=$P(^TMP("MPIFVQQ",$J,CNTR,"DATA"),"^",10)
86 ;.S NMMN=$P($P(NM,",",2)," ",2)
87 ;.I $L(NMMN)>1&($L(MPIMID)=1),($E(NMMN,1)=MPIMID) S EXACT=1
88 ;.I $L(MPIMID)>1&($L(NMMN)=1),($E(MPIMID,1)=NMMN) S EXACT=1
89 ;I NM'=MPIN,'$D(EXACT) D
90 ;.S ^XTMP($J,"MPIF","MSHERR")="NAME MISMATCH"
91 ;.D EXC^RGHLLOG(214,"Name on File = "_$P(Y(0),"^")_" Name in Message = "_MPIN_" MESSAGE# "_MPIMSG_" around line number "_(CNTR*2),PATID)
92 ;.N LICN S LICN=$$ICNLC^MPIF001(PATID) ;create local ICN
93 ;check to see if SEX on MPI and local site match - no exception
94 ;I $P($G(^DPT(PATID,0)),"^",2)'=$P($G(^TMP("MPIFVQQ",$J,CNTR,"DATA")),"^",11) D
95 ;.S ^XTMP($J,"MPIF","MSHERR")="SEX MISMATCH"
96 ;.D EXC^RGHLLOG(209,"PT on MPI "_MPIN_" has gender as "_$P($G(^TMP("MPIFVQQ",$J,CNTR,"DATA")),"^",10)_" While the Patient DFN= "_PATID_" has "_$P($G(^DPT(PATID,0)),"^",2)_" msg # "_MPIMSG_" about line number "_(CNTR*2),PATID)
97 ;.N LICN S LICN=$$ICNLC^MPIF001(PATID) ;create local ICN
98 ;
99 ;check to see if MPI has Date of Death or if VistA has DOD
100 N MPIDTH,VISTDTH K %DT
101 I $P(^TMP("MPIFVQQ",$J,CNTR,"DATA"),"^",9)'="" S X=$P(^TMP("MPIFVQQ",$J,CNTR,"DATA"),"^",9) D ^%DT S MPIDTH=Y
102 I $D(^DPT(PATID,.35)),$P($G(^DPT(PATID,.35)),"^")'="" S VISTDTH=$P($G(^DPT(PATID,.35)),"^")\1
103 I $D(MPIDTH)&$D(VISTDTH),MPIDTH'=VISTDTH D
104 .N Y S Y=MPIDTH D DD^%DT S MPIDTH=Y,Y=VISTDTH D DD^%DT S VISTDTH=Y
105 .D EXC^RGHLLOG(217,"Around line "_(CNTR*2)_" VISTA DOD= "_VISTDTH_" MPI DOD= "_MPIDTH_" DFN= "_PATID_" MESSAGE# "_MPIMSG,PATID)
106 ; ^ BOTH HAVE DOD BUT THEY DON'T MATCH
107 I '$D(MPIDTH)&($D(VISTDTH)) D
108 .N Y S Y=VISTDTH D DD^%DT S VISTDTH=Y
109 .D EXC^RGHLLOG(216,"Around line "_(CNTR*2)_" VISTA DOD= "_VISTDTH_" DFN= "_PATID_" MESSAGE# "_MPIMSG,PATID)
110 ; ^ VISTA HAS DOD BUT MPI DOESN'T
111 I $D(MPIDTH)&('$D(VISTDTH)) D
112 .N Y S Y=MPIDTH D DD^%DT S MPIDTH=Y
113 .D EXC^RGHLLOG(215,"Around line "_(CNTR*2)_" MPI DOD= "_MPIDTH_" DFN= "_PATID_" MESSAGE# "_MPIMSG,PATID)
114 ; ^ MPI HAS DOD BUT VISTA DOESN'T
115 Q
Note: See TracBrowser for help on using the repository browser.