source: FOIAVistA/trunk/r/MASTER_PATIENT_INDEX_VISTA-MPIF/MPIFQ1.m@ 1671

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

initial load of FOIAVistA 6/30/08 version

File size: 6.9 KB
Line 
1MPIFQ1 ;ALB/RJS-CIRN QUERY HANDLER ;JUN 30, 1997
2 ;;1.0; MASTER PATIENT INDEX VISTA ;**1,8,12,16,17,21,23,24,28,31,33,35**;30 Apr 99
3 ;
4 ; Integration Agreements Utilized:
5 ; EXC, START, STOP^RGHLLOG - #2796
6 ; FILE^VAFCTFU - #2988
7 ; ^DPT("AICN" - #2070
8 ; NAME^VAFCPID2 - #3492
9 ; EN1^XWB2HL7 - #3144
10 ; RTNDATA^XWBDRPC - #3149
11 ; VAFC REMOTE PDAT (RPC) - #3496
12 ;
13INIT ;Entry point for List Manager Template - MPIF REAL-TIME QUERY
14 Q
15HDR ;Header code for List Manager Template - MPIF REAL-TIME QUERY
16 N SSN,DOB,MPIFQ1,NAME1,SEX
17 D GETDATA^MPIFQ0("^DPT(",DFN,"MPIFQ1",".01;.03;.09;.02","EI")
18 S NAME1=$G(MPIFQ1(2,DFN,.01,"E")),SSN=$G(MPIFQ1(2,DFN,.09,"E"))
19 S DOB=$G(MPIFQ1(2,DFN,.03,"I")),SEX=$G(MPIFQ1(2,DFN,.02,"E"))
20 I DOB]"" S DOB=$TR($$FMTE^XLFDT(DOB,"5D"),"/","-")
21 S VALMHDR(1)=" Possible MPI Matches for Patient: "_IOINHI_NAME1_IOINORM
22 S VALMHDR(2)=" SSN: "_IOINHI_SSN_IOINORM
23 S VALMHDR(3)=" DOB: "_IOINHI_DOB_IOINORM
24 S VALMHDR(4)=" SEX: "_IOINHI_SEX_IOINORM,VALMHDR(5)=" "
25 Q
26START(INDEX) ;Starting entry point for envoking the List Manager Template MPIF Real-time query
27 S VALMCNT=INDEX
28 D EN^VALM("MPIF REAL-TIME QUERY")
29 Q
30SELECT N VALMY
31 D EN^VALM2(XQORNOD(0),"OS")
32 I '$D(VALMY) Q
33 N DATA,INDEX,ICN,CHKSUM,NODE2
34 S INDEX=$O(VALMY(0)),DATA=^TMP("MPIFVQQ",$J,INDEX,"DATA")
35 S NODE2=$G(^TMP("MPIFVQQ",$J,INDEX,"INDICATOR"))
36 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
37 S DATA(.03)=$P(DATA,"^",4),DATA(.09)=$P(DATA,"^",3),DATA(.02)=$P(DATA,"^",11) ;DOB, SSN, SEX
38 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))
39 ;If NODE2["*" we have a pt in our list whose ICN is already at this site
40 I NODE2["*",$O(^DPT("AICN",ICN,""))'=DFN D Q
41 .D CLEAR^VALM1,MSG1^MPIFQ3
42 .N DFN2 S DFN2=$O(^DPT("AICN",ICN,""))
43 .D TWODFNS^MPIF002(DFN2,DFN,ICN)
44 .W !!,"Assigning Local ICN" D LOCAL^MPIFQ3(DFN),PROMPT^MPIFQ3 S MPIFRTN="CONTINUE"
45 ;User selected from list, does SSN & Name match? no-ask if sure
46 N SSN,NAME,SEX
47 D GETDATA^MPIFQ0("^DPT(",DFN,"MPIFQ1",".01;.09;.02","EI")
48 S SSN=$G(MPIFQ1(2,DFN,.09,"E")),NAME=$G(MPIFQ1(2,DFN,.01,"E")),SEX=$G(MPIFQ1(2,DFN,.02,"I"))
49 ; if sex doesn't match -- not allowed to update ICN
50 I DATA(.02)'=SEX W !!,"Sex for these two patients doesn't match -- Can't select this patient until",!,"Sex matches between the MPI and your site. No action will be taken." D PROMPT^MPIFQ3 S VALMBCK="R" Q
51 I SSN["P" S SSN=""
52 I DATA(.09)'=SSN W !!,"SSN for these two patients doesn't match -- Can't select this patient until",!,"SSN matches between the MPI and your site. No action will be taken." D PROMPT^MPIFQ3 S VALMBCK="R" Q
53 D NAME^VAFCPID2(0,.NAME,0) ;reformat name into DG 149 format
54 N NAME3 S NAME3=DATA(.01) D NAME^VAFCPID2(0,.NAME3,0) S DATA(.01)=NAME3 ;reformat name into DG 149 format
55 N EXACT
56 ; check if Last, First MATCH if so is it a middle name vs middle initial
57 I $P(DATA(.01),",")=$P(NAME,",")&($P($P(NAME,",",2)," ")=$P($P(DATA(.01),",",2)," ")) D
58 .N MPIMID,NMMN S MPIMID=$P($P(DATA(.01),",",2)," ",2)
59 .S NMMN=$P($P(NAME,",",2)," ",2)
60 .I $L(NMMN)>1&($L(MPIMID)=1),($E(NMMN,1)=MPIMID) S EXACT=1
61 .I $L(MPIMID)>1&($L(NMMN)=1),($E(MPIMID,1)=NMMN) S EXACT=1
62 I DATA(.01)=NAME!($D(EXACT)) K DATA(.09),DATA(.01),DATA(.03) D EDIT^MPIFQED(DFN,"DATA") D MSG3^MPIFQ3,PROMPT^MPIFQ3,TF^MPIFQ3(DFN,.DATA) Q
63 ; \/ Name doesn't match exactly - ask if sure
64 D CLEAR^VALM1,MSG2^MPIFQ3,MSG^MPIFQ3(SSN,NAME,DATA(.09),DATA(.01))
65 N ANS S ANS=$$PROMPT1^MPIFQ3()
66 I ANS K DATA(.09),DATA(.01),DATA(.03) D EDIT^MPIFQED(DFN,"DATA") S MPIFRTN="CONTINUE" W !!,"ICN and CMOR Updated" D PROMPT^MPIFQ3,TF^MPIFQ3(DFN,.DATA) Q
67 D MSG5^MPIFQ3,PROMPT^MPIFQ3 S VALMBCK="R"
68 Q
69ADD ;Add (MPIF REAL-TIME QUERY (ADD PATIENT)) add pt to MPI Austin.
70 D A28^MPIFQ3(DFN),PROMPT^MPIFQ3 S MPIFRTN="CONTINUE"
71 Q
72MPIPD ; MPI PDAT CALL
73 N VALMY,CNT,Y
74 D EN^VALM2(XQORNOD(0),"OS")
75 I '$D(VALMY) Q
76 N DATA,INDEX,ICN,CHKSUM,CMOR,CASE,CMOR3,TTF,ALIAS,POW,TAL,TMP
77 S INDEX=$O(VALMY(0)),Y="" D CLEAR^VALM1
78 S DATA=^TMP("MPIFVQQ",$J,INDEX,"DATA")
79 S CMOR=$P(DATA,"^",5),CMOR3=CMOR,CMOR=$P($$NS^XUAF4($$LKUP^XUAF4(CMOR)),"^")
80 W !,"MPI Data:",!!!,?3,"ICN: ",+$P(DATA,"^",6),?30,"CMOR: ",CMOR," (",CMOR3,")"
81 W !,?2,"NAME: ",$P(DATA,"^")
82 W !,?3,"SSN: ",$P(DATA,"^",3),?30,"SEX: ",$P(DATA,"^",11)
83 W !,?3,"DOB: ",$P(DATA,"^",4)
84 W ?30,"DOD: ",$P(DATA,"^",9)
85 I $P(DATA,"^",20)="Y" W !?3,"Multiple Birth Indicator: Yes"
86 I ($P(DATA,"^",12)='"")&($P(DATA,"^",13)'="") W !,?2,"PLACE OF BIRTH: ",$P(DATA,"^",12),", ",$P(DATA,"^",13)
87 I $P(DATA,"^",12)=""!($P(DATA,"^",13)="") W !,?2,"PLACE OF BIRTH: ",$P(DATA,"^",12)," ",$P(DATA,"^",13)
88 W !,?2,"MOTHER'S MAIDEN NAME: ",$P(DATA,"^",16)
89 W !,?2,"CLAIM NUMBER: ",$P(DATA,"^",17)
90 S POW=$P(DATA,"^",19) I POW'="" W !,?2,"POW STATUS: ",POW
91 S CASE=$P(DATA,"^",18)
92 I CASE'="" W !,?2,"Open Data Management Case",!,?5,"CASE#: ",$P(CASE,"/")_" NOIS#: ",$P(CASE,"/",2),!,?5,"CASE WORKER: ",$P(CASE,"/",3)
93 I $D(^TMP("MPIFVQQ",$J,INDEX,"ALIAS")) W !,?2,"Alias(es): " D
94 .N XX S XX=0 F S XX=$O(^TMP("MPIFVQQ",$J,INDEX,"ALIAS",XX)) Q:'XX W !?10,^(XX)
95 I $D(^TMP("MPIFVQQ",$J,INDEX,"TF"))&($O(^TMP("MPIFVQQ",$J,INDEX,"TF",1))'="") D
96 .W !,?2,"TREATING FACILITY LIST:"
97 .N XX S XX=0 F S XX=$O(^TMP("MPIFVQQ",$J,INDEX,"TF",XX)) Q:'XX S TMP=$P($G(^(XX)),MPICOMP) I TMP'=CMOR3 W !?10,"Treating Facility: ",$P($$NS^XUAF4($$LKUP^XUAF4(TMP)),"^")," (",TMP,")"
98 D PROMPT^MPIFQ3
99 S VALMBCK="R"
100 Q
101CMOR ; CMOR PDAT CALL
102 N VALMY,DATA,INDEX,ICN,CHKSUM,CMOR
103 D EN^VALM2(XQORNOD(0),"OS")
104 I '$D(VALMY) Q
105 S INDEX=$O(VALMY(0)),DATA=^TMP("MPIFVQQ",$J,INDEX,"DATA")
106 S ICN=$P(DATA,"^",6),CHKSUM=$P(ICN,"V",2),ICN=$P(ICN,"V",1),CMOR=$P(DATA,"^",5)
107 I CMOR=$P($$SITE^VASITE(),"^",3) W !!,"CMOR is your site" G END
108 W !,"Please be patient while the data is being retrieved from the CMOR."
109 D EN1^XWB2HL7(.RETURN,CMOR,"VAFC REMOTE PDAT",1,ICN,"") ; Request
110 S ^XTMP("MPIFPDAT"_ICN,0)=$$FMADD^XLFDT(DT,2)_"^"_DT_"^"_"REMOTE PDAT QUERY",^XTMP("MPIFPDAT"_ICN,1)=RETURN(0)_"^"_$$NOW^XLFDT
111 S CNT=0
112AGAIN1 H 2 K RES1 D RTNDATA^XWBDRPC(.RES1,RETURN(0)) S CNT=CNT+1
113 I +RES1(0)=-1&(RES1(0)["Not DONE") I CNT<11 G AGAIN1
114 I +RES1(0)=-1&(RES1(0)["Not DONE") I CNT>10 W !,"Unable to get data" G END
115 I RES1(0)="0^New" I CNT<11 G AGAIN1
116 I RES1(0)="0^New" I CNT>10 W !,"Unable to get data" G END
117 I +RES1(0)=-1 W !!,$P(RES1(0),"^",2) G END
118 I RES1'="" I CNT<11 G AGAIN1
119 I RES1'="" I CNT>10 W !,"Unable to get data" Q
120 D CLEAR^VALM1
121 N NUM S NUM="",CNT=0
122 F S NUM=$O(RES1(NUM)) Q:NUM="" D
123 .I CNT>20 D PROMPT^MPIFQ3,CLEAR^VALM1 S CNT=0
124 .I RES1(NUM)["Additional" W !! S CNT=CNT+2
125 .I CNT<21 W !,RES1(NUM) S CNT=CNT+1
126END D PROMPT^MPIFQ3 S VALMBCK="R" K CNT,RETURN,RES1
127 Q
128HELP ; Help List Manager Action (MPIF REAL-TIME QUERY (HELP))
129 D CLEAR^VALM1,MSG4^MPIFQ3,PROMPT^MPIFQ3 S VALMBCK="R"
130 Q
131EXIT ;Exit for List Manager Template MPIF REAL-TIME QUERY
132 K VALMBCK,VALMCNT,VALMHDR
133 Q
Note: See TracBrowser for help on using the repository browser.