source: WorldVistAEHR/trunk/r/MASTER_PATIENT_INDEX_VISTA-MPIF/MPIFDUP.m@ 1800

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

initial load of WorldVistAEHR

File size: 9.0 KB
Line 
1MPIFDUP ;BIRM/CMC-RESOLVE DUP ACTION ;DEC 2, 2005
2 ;;1.0; MASTER PATIENT INDEX VISTA ;**43,46,48**;30 Apr 99;Build 6
3 ;
4POT ;EXCEPTION HANDLER CALLS HERE
5 ;Potential Match on MPI, Query MPI, resolve duplicate if needed. **43 Added this entry point
6 ; Only available when Exception Being Reviewed is Potential Match
7 N PELV,PTEN
8 ;S PTEN=$P(DATA,"^",10)
9 ;I '$D(^RGHL7(991.1,"ADFN",218,DFN)) W !,"Potential Match Review Option is Only Available for Potential Match Exceptions" H 5 S VALMBCK="R" Q
10 ;I $D(^RGHL7(991.1,"ADFN",218,DFN,PTEN)) S SUB=$O(^RGHL7(991.1,"ADFN",218,DFN,PTEN,"")) I $P($G(^RGHL7(991.1,PTEN,SUB,1,0)),"^",5)=1 W !,"Potential Match Review is Only Available for Exceptions still pending." H 5 S VALMBCK="R" Q
11 S PTEN=$P(DATA,"^",10) ;IEN IN 991.1
12 S PELV=$P(DATA,"^",11) ;IEN IN 991.12
13 I $P($G(^RGHL7(991.1,PTEN,1,PELV,0)),"^",3)'=218 S VALMSG="Action is ONLY for POTENTIAL MATCH exceptions!",VALMBCK="R" Q
14 ; ^**46 changed check to ensure exception is Potential Match exception
15 I $E($$GETICN^MPIF001(DFN),1,3)=$P($$SITE^VASITE,"^",3) W !,"Messaging outstanding please try again in a few minutes." H 5 Q
16 S VALMBCK="",MPIFRES="",MPIFINT=""
17 D FULL^VALM1
18 D EXC
19 D PAUSE^VALM1
20 K MPIFRES,MPIFINT
21 N X,Y,DIR,DIE,DA,DR,IEN,IEN2,PROCDT,%,X,%I,%H
22 I '$D(PROCESS) D
23 .S DIR("A")="Do you want to mark this exception as processed? ",DIR(0)="YA",DIR("B")="NO" D ^DIR K DIR(0),DIR("A")
24 .I Y S PROCESS=1 K X,Y
25 I $D(PROCESS) D
26 .;**48 CAPTURE DATE/TIME AND WHO MARKED AS PROCESSED
27 .D NOW^%DTC S PROCDT=%
28 .S IEN="",IEN2="",IEN=$P(DATA,"^",10),IEN2=$P(DATA,"^",11)
29 .L +^RGHL7(991.1,IEN):10
30 .S DA(1)=IEN,DA=IEN2,DR="6///"_1_";7///"_PROCDT_";8///"_$G(DUZ),DIE="^RGHL7(991.1,"_DA(1)_",1," D ^DIE K DIE,DA,DR
31 .L -^RGHL7(991.1,IEN)
32 .S $P(DATA,"^",9)=1
33 K PROCESS
34 Q
35EXC ; Exception Entry Point
36 N LOCDATA ;Data Returned from GETDATA in ICN array
37 D GETDATA("^DPT(",DFN,"LOCDATA",".01;.02;.03;.09;.301;391;1901")
38 S LOCDATA(2,DFN,991.01)=$P($$MPINODE^MPIFAPI(DFN),"^"),TSSN=LOCDATA(2,DFN,.09)
39 S HLP("ACKTIME")=300,MPIQRYNM="POTENTIAL_DUP_RES"
40 N TIME,% D NOW^%DTC S TIME=%
41 N HL,MPIINM,MPIOUT,MPIIN,MPIMCNT,MPICNT,MPICS,HEADER,TEST,SITE,MPIDC,SSN
42 S HL("ECH")="^~\&",HL("FS")="|"
43 S MPIIN="",MPIMCNT=DFN,MPICNT=1,MPICS=$E(HL("ECH"),1),MPIFRES=1
44 D VTQ1^MPIFVTQ(DFN,.MPIOUT,.HL,.MPIQRYNM)
45 I +MPIOUT(0)=-1 D G EXIT
46 .S ^TMP($J,"MPIFQ0-ERROR-LOG",DFN,TIME)=$G(MPIOUT(0)),MPIFRTN="CONTINUE"
47 ;Create MSH
48 S SITE=$$SITE^VASITE,SITE=$P(SITE,"^",3),SITE=SITE\1,HEADER="MSH"_HL("FS")_HL("ECH")_HL("FS")_"MPI_LOAD"_HL("FS")_SITE_HL("FS")
49 S HEADER=HEADER_"MPI-ICN"_HL("FS")_HL("FS")_HL("FS")_HL("FS")_"VQQ"_MPICS_"Q02"_HL("FS")_MPIMCNT_"-"_MPICNT_HL("FS") ;**38 changed VTQ to VQQ
50 S MPIOUT(1)=HEADER K MPIOUT(0)
51 W !!,"Attempting to connect to the Master Patient Index in Austin...",!,"If no SSN or inexact DOB or common name, this request",!,"may take some time, please be patient...",!
52 S TEST=$$EN^HLCSAC("MPIVA DIR","MPIOUT","MPIDC")
53 K HLP("ACKTIME") ;kill the HLP array set for the ack timeout
54 I +TEST=-1 D G EXIT
55 .S ^TMP($J,"MPIFQ0-ERROR-LOG",DFN,TIME)=TEST
56 .I '$D(MPIFS) W:'$D(MPIFRPC) !!,"Could not connect to MPI or Timed Out. Try again later."
57 K ^TMP("MPIFVQQ",$J),^TMP("MPIFQ0",$J) ;array data is parsed into for display in LM
58INIPARS ;
59 N SEG,INDEX,SKIP,CHECK,AL,TTF2,TFLL,TF,TF2,MPIREP,MPICOMP
60 S INDEX=0 K CHECK
61LOOP1 ;
62 ;process in ADT type messages
63 N MPIX S MPIX=0 N REP,SG,MSG,MPIQUIT,MPINODE
64 K TWODFN S MPIQUIT=0
65 F MPIX=0:1 X "D LOOP2" D K MPINODE,MSG Q:MPIQUIT'>0
66 . I $D(MPINODE(1)) S SG=$E(MPINODE(1),1,3) S MSG(1)=MPINODE(1) D
67 .. S MPIJ=1 F S MPIJ=$O(MPINODE(MPIJ)) Q:'MPIJ S MSG(MPIJ)=MPINODE(MPIJ)
68 .. D:SG?2A1(1A,1N) @SG
69DECIDE ;If no data in ^TMP that means the patient was not found in the MPI w/VTQ Query. So we go to A28 to add the patient to the MPI.
70 N EXC,TEXT,EXACT,EXACT2,DATA,NODE2,ICN,CHKSUM,MORE,COMMON
71 I '$D(^TMP("MPIFVQQ",$J)) W !,"No Potential Matches Found.",!!,"Exception has been marked automatically as processed." S PROCESS=1 G EXIT
72 I INDEX=1 D
73 .;need to check if exact match was returned.
74 .S DATA=^TMP("MPIFVQQ",$J,INDEX,"DATA")
75 .S NODE2=$G(^TMP("MPIFVQQ",$J,INDEX,"INDICATOR"))
76 .S DATA(.01)=$P(DATA,"^",1) I $E(DATA(.01),$L(DATA(.01)))=" " S DATA(.01)=$E(DATA(.01),1,$L(DATA(.01))-1) ;NAME
77 .S DATA(.03)=$P(DATA,"^",4),DATA(.09)=$P(DATA,"^",3),DATA(.02)=$P(DATA,"^",11) ;DOB, SSN, SEX
78 .S ICN=$P(DATA,"^",6),CHKSUM=$P(ICN,"V",2),ICN=$P(ICN,"V",1),DATA(991.01)=ICN,DATA(991.02)=CHKSUM,DATA(991.03)=$$LKUP^XUAF4($P(DATA,"^",5))
79 .Q:NODE2["*"
80 .;^ ICN is already known at this site
81 .;check if this patient has another VISTA site now OR tfs in common
82 .S (MORE,COMMON)=0
83 .D COMPARE^MPIF002(DFN,INDEX,.COMMON,.MORE)
84 .Q:COMMON!(MORE)
85 .; check that now have an exact match returned
86 .N MPIFD,SSN,NAME,SEX,NAME3,BIR K COMMON,MORE
87 .D GETDATA^MPIFQ0("^DPT(",DFN,"MPIFD",".01;.09;.02;.03","EI")
88 .S SSN=$G(MPIFD(2,DFN,.09,"E")),NAME=$G(MPIFD(2,DFN,.01,"E")),SEX=$G(MPIFD(2,DFN,.02,"I"))
89 .S BIR=$G(MPIFD(2,DFN,.03,"I")) I BIR]"" S BIR=$TR($$FMTE^XLFDT(BIR,"5D"),"/","-")
90 .; if dob doesn't match -- not allowed to update ICN automatically
91 .Q:DATA(.03)'=BIR
92 .; if sex doesn't match -- not allowed to update ICN automatically
93 .Q:DATA(.02)'=SEX
94 .;if dob doesn't match -- not allowed to update ICN automatically
95 .I SSN["P" S SSN=""
96 .Q:DATA(.09)'=SSN
97 .D NAME^VAFCPID2(0,.NAME,0) ;reformat name into DG 149 format
98 .S NAME3=DATA(.01) D NAME^VAFCPID2(0,.NAME3,0) S DATA(.01)=NAME3 ;reformat name into DG 149 format
99 .; check if Last, First MATCH if so is it a middle name vs middle initial
100 .I $P(DATA(.01),",")=$P(NAME,",")&($P($P(NAME,",",2)," ")=$P($P(DATA(.01),",",2)," ")) D
101 ..N MPIMID,NMMN S MPIMID=$P($P(DATA(.01),",",2)," ",2)
102 ..S NMMN=$P($P(NAME,",",2)," ",2)
103 ..I $L(NMMN)>1&($L(MPIMID)=1),($E(NMMN,1)=MPIMID) S EXACT=1
104 ..I $L(MPIMID)>1&($L(NMMN)=1),($E(MPIMID,1)=NMMN) S EXACT=1
105 .I DATA(.01)=NAME!($D(EXACT)) K DATA(.09),DATA(.01),DATA(.03) D Q
106 ..N PID2,ERR
107 ..D INIT^HLFNC2("MPIF ADT-A24 SERVER",.HL)
108 ..D BLDPID^VAFCQRY(DFN,2,"ALL",.PID2,.HL,.ERR)
109 ..;**48 want to resolve an reject exceptions for "current" ICN
110 ..D RESEX(DFN)
111 ..D EDIT^MPIFQED(DFN,"DATA"),MSG3^MPIFQ3,PROMPT^MPIFQ3
112 ..S RESLT=$$A24^MPIFA24B(DFN,.PID2) ;send a24 link icns
113 ..S PROCESS=1
114 I $G(PROCESS)=1 G END
115 D START^MPIFD1(INDEX) G END
116EXIT I $D(MPIFINT) K MPIFINT,MPIFRES,MPIQRYNM,TSSN,TWODFN,SDFN
117 K VALMCNT,VALMLST,CCMOR,FICN H 3 W:'$D(MPIFRPC) !!
118END K ^TMP("MPIFVQQ",$J),^TMP("MPIFQ0",$J) Q
119 ;
120GETDATA(DIC,DA,MPIFAR,DR,EI) ;
121 ;This function returns the values stored in the fields via FM call DIQ1
122 ;DIC=file reference, DA=IEN in file, ARRAY=array for the values to be stored in, DR=fields requested, EI=external/internal values
123 N DIQ S DIQ=MPIFAR
124 I $G(EI)]"" S DIQ(0)=EI
125 D EN^DIQ1
126 Q
127LOOP2 ;
128 N MPIDONE,MPII,MPIJ
129 S MPII=0,MPIDONE=0
130 F S MPIQUIT=$O(MPIDC(MPIQUIT)) Q:'MPIQUIT D Q:MPIDONE
131 . I MPIDC(MPIQUIT)="" S MPIDONE=1 Q
132 . S MPII=MPII+1,MPINODE(MPII)=$G(MPIDC(MPIQUIT)) Q
133 Q
134MSH ;
135 S MPIREP=$E(HL("ECH"),2),MPICOMP=$E(HL("ECH"),1)
136 Q
137MSA ;
138 Q
139RDF ;
140 Q
141QAK ;**43 added check for potential matches
142 K MPIPOT S MPIPOT=0
143 I MSG(1)["POTENTIAL MATCHES" S MPIPOT=1
144 S SDFN=$P(MSG(1),HL("FS"),2)
145 Q
146RDT ;
147 N NAME,ICN,BIRTHDAY,CMOR,IEN,SEG,HEREICN,STRING,LASTNAME,FRSTNAME,MIDDLE,SUFF,SEX,THISGUY
148 S STRING="",INDEX=$G(INDEX)+1
149 D RDT^MPIFSA3(.INDEX,.HL,.MSG)
150 S SEG=^TMP("MPIFVQQ",$J,INDEX,"DATA")
151 S FRSTNAME=$P(SEG,"^",7),LASTNAME=$P(SEG,"^",2),MIDDLE=$P(SEG,"^",10),SUFF=$P(SEG,"^",15)
152 S SSN=$P(SEG,"^",3),NAME=LASTNAME_","_FRSTNAME
153 I MIDDLE'="" S NAME=NAME_" "_MIDDLE
154 I SUFF'="" S NAME=NAME_" "_SUFF
155 S SEX=$P(SEG,"^",11)
156 S ICN=$P(SEG,"^",6)
157 S THISGUY=$$GETDFN^MPIF001(+ICN) I THISGUY=DFN Q
158 S BIRTHDAY=$P(SEG,"^",4)
159 S CMOR=$P(SEG,"^",5),IEN=$$IEN^XUAF4(CMOR)
160 S CMOR=$P($$NS^XUAF4(IEN),"^")
161 S HEREICN=$$HEREICN^MPIFQ3($P(ICN,"V",1))
162 I HEREICN S STRING=$$SETSTR^VALM1("*",STRING,1,1),^TMP("MPIFVQQ",$J,INDEX,"INDICATOR")="*"_"^"_HEREICN
163 S STRING=$$SETSTR^VALM1(INDEX,STRING,2,4),STRING=$$SETSTR^VALM1($E(NAME,1,23),STRING,6,23)
164 S STRING=$$SETSTR^VALM1(SSN,STRING,30,9),STRING=$$SETSTR^VALM1(BIRTHDAY,STRING,41,10)
165 S STRING=$$SETSTR^VALM1(CMOR,STRING,54,20)
166 S ^TMP("MPIFVQQ",$J,INDEX,0)=STRING,^TMP("MPIFVQQ",$J,"IDX",INDEX,INDEX)=""
167 Q
168RESEX(DFN,POT) ;look for any pv reject (234) exceptions and resolve them for this DFN
169 ;IF POT IS SET TO 2 LOOK FOR ANY POTENTIAL MATCH (218) EXCEPTIONS AND RESOLVE THEM FOR THIS DFN
170 ;**48 CREATED THIS API
171 N IEN,DA,DR,PROCDT,DIE,IEN2
172 S IEN=0
173 F S IEN=$O(^RGHL7(991.1,"ADFN",234,DFN,IEN)) Q:IEN="" D
174 .S IEN2=$O(^RGHL7(991.1,"ADFN",234,DFN,IEN,""))
175 .Q:$P(^RGHL7(991.1,IEN,1,IEN2,0),"^",5)=1 ;**ALREADY MARKED AS PROCESSED
176 .D NOW^%DTC S PROCDT=%
177 .L +^RGHL7(991.1,IEN):10
178 .S DA(1)=IEN,DA=IEN2,DR="6///"_1_";7///"_PROCDT_";8///"_$G(DUZ),DIE="^RGHL7(991.1,"_DA(1)_",1," D ^DIE K DIE,DA,DR
179 .L -^RGHL7(991.1,IEN)
180 ;
181 I $G(POT)=2 D
182 .S IEN=0
183 .F S IEN=$O(^RGHL7(991.1,"ADFN",218,DFN,IEN)) Q:IEN="" D
184 ..S IEN2=$O(^RGHL7(991.1,"ADFN",218,DFN,IEN,""))
185 ..Q:$P(^RGHL7(991.1,IEN,1,IEN2,0),"^",5)=1 ;**ALREADY MARKED AS PROCESSED
186 ..D NOW^%DTC S PROCDT=%
187 ..L +^RGHL7(991.1,IEN):10
188 ..S DA(1)=IEN,DA=IEN2,DR="6///"_1_";7///"_PROCDT_";8///"_$G(DUZ),DIE="^RGHL7(991.1,"_DA(1)_",1," D ^DIE K DIE,DA,DR
189 ..L -^RGHL7(991.1,IEN)
190 Q
Note: See TracBrowser for help on using the repository browser.