source: FOIAVistA/trunk/r/MASTER_PATIENT_INDEX_VISTA-MPIF/MPIFRPC2.m@ 1397

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

initial load of FOIAVistA 6/30/08 version

File size: 3.8 KB
Line 
1MPIFRPC2 ;SFCIO/CMC-MPIF RPC APIS ;24 OCT 01
2 ;;1.0; MASTER PATIENT INDEX VISTA ;**20,24,33,43**;30 Apr 99
3 ;
4 ;Integration Agreements Utilized:
5 ; ^DPT( - #2070
6 ; FILE^VAFCTFU - #2988
7 ; AVAFC^VAFCDD01 - #3493
8 ; START, STOP, EXC^RGHLLOG - #2070
9 ;
10MULT(DFN,OLDFN) ; API to get "primary" dfn for a merged record
11 ;**43 api created
12 I $D(^DPT(DFN,-9)) S OLDFN=OLDFN_DFN_"^"
13 F S DFN=$P($G(^DPT(DFN,-9)),"^") Q:'DFN!'$D(^DPT(DFN,-9)) S OLDFN=OLDFN_DFN_"^"
14 Q
15 ;
16SPI(RETURN,SSN,DFN1) ;
17 ;RPC to Single Patient Initialization on patient with SSN
18 ; RETURN - 1 for successful inactivation or -1^error msg
19 ; SSN = is the SSN for the patient that is to be SPI'd
20 ; DFN1 = is the IEN for the patient that is to be SPI'd
21 ;
22 N RES,XX,DFN,ICN,TICN,MPIFA,OLDC,DFNOLD
23 I SSN=""&($G(DFN1)="") S RETURN="-1^No SSN or DFN Passed" Q
24 I SSN'="",SSN'?9N S RETURN="-1^Invalid SSN" Q
25 I SSN'="",'$D(^DPT("SSN",SSN)) S RETURN="-1^No such SSN" Q
26 I SSN'="" D
27 .S RETURN(0)="SSN USED "_SSN
28 .S RES=$$GETDFNS^MPIF002(SSN)
29 I SSN="",DFN1'?1N.N S RETURN="-1^Invalid DFN" Q
30 I SSN="",'$D(^DPT(DFN1)) S RETURN="-1^No such DFN" Q
31 ;^ **43 Check only for DFN1 not DFN1,0 as not all merges have 0 nodes
32 I SSN="" D
33 .S RETURN(0)="DFN USED "_DFN1
34 .S RES=DFN1
35 I +RES=-1 S RETURN=RES Q
36 S DFNOLD=""
37 F XX=1:1 S DFN=$P(RES,"^",XX) Q:DFN="" D
38 .;**43 check to see if DFN is a FROM record in a duplicate record merge pair
39 .I $D(^DPT(DFN,-9)) S DFNOLD=DFNOLD_DFN_"^" S DFN=$P($G(^DPT(DFN,-9)),"^") D
40 ..I $D(^DPT(DFN,-9)) D MULT(.DFN,.DFNOLD)
41 ..S RETURN(0)="DFN-"_DFN_"-was used to SPI patient because the DFN passed was a merged DFN. The merged DFN(s) are: "_DFNOLD
42 .; a TO record of a merge can be the from record in another merge, need to find the final primary record
43 .; DFN is now the primary DFN
44 .; can be multiple entries with same SSN
45 .S TICN=$$GETICN^MPIF001(DFN)
46 .I +TICN'=-1&($P($$SITE^VASITE,"^",3)'=$E(TICN,1,3)) S RETURN(XX,0)="The DFN= "_DFN_" already has an ICN, ICN="_TICN Q
47 .S MPIFS=1,HLP("ACKTIME")=300,MPIFRES=1,MPIFRPC=1
48 .I '$D(^DPT(DFN)) S RETURN="-1^No such DFN" Q
49 .D GETS^DIQ(2,DFN_",",".01","IE","MPIFA")
50 .D CIRNEXC^MPIFQ0
51 .;**43 check to see if A28 message was requested to be sent to Add patient to MPI
52 .I MPIFRTN="DID A28" S RETURN(XX,0)="A28 Add Patient message has been triggered" K MPIFRTN,MPIFS,MPIFRES,MPIFRPC Q
53 .K MPIFRTN,MPIFS,MPIFRES,MPIFRPC
54 .S ICN=$$GETICN^MPIF001(DFN)
55 .I +ICN=-1 S RETURN(XX,0)="DFN "_DFN_" problem getting ICN assinged "_$P(ICN,"^",2),RETURN="-1^Unable to get ICN" Q
56 .K RET S RET=""
57 .;commented out in **43 as these exceptions shouldn't be happening any longer AND we want to SPI a local ICN
58 .;I $P($$SITE^VASITE,"^",3)=$E(+ICN,1,3) S RETURN="-1^Local ICN assigned" Q
59 .;D EXC^MPIFRPC(DFN,.RET,XX)
60 .;S RET(XX,"EXCEPTIONS")=$TR($G(RET(XX,"EXCEPTIONS")),"""","")
61 .;S RETURN(XX,0)="DFN "_DFN_" Local ICN assigned "_ICN_" EXCEPTIONS: "_$G(RET(XX,"EXCEPTIONS")),RETURN="-1^Local ICN assigned" Q
62 .S RETURN(XX)=ICN
63 Q
64 ;
65UPDATE(RET,SSN,ICN,CHK,CMOR,A08) ;
66 ; update fields 991.01,991.02 and 991.03 remotely
67 I SSN=""!(ICN="")!(CHK="")!(CMOR="") S RET="-1^Missing required parameter" Q
68 I '$D(^DPT("SSN",SSN)) S RET="-1^No patient has that SSN at this site" Q
69 N DFN,MPIFA,TMP,RESLT
70 S DFN=$O(^DPT("SSN",SSN,""))
71 I $O(^DPT("SSN",SSN,DFN))'="" S RET="-1^More than one patient has that SSN at this site" Q
72 S TMP=$P($$MPINODE^MPIFAPI(DFN),"^")
73 I +TMP'=-1,$E(TMP,1,3)'=$P($$SITE^VASITE(),"^",3) S RET="-1^Patient has a national ICN, ICN="_TMP Q
74 S MPIFA(991.01)=ICN,MPIFA(991.02)=CHK,MPIFA(991.03)=$$LKUP^XUAF4(CMOR)
75 S RET=$$UPDATE^MPIFAPI(DFN,"MPIFA")
76 S RESLT=$$A24^MPIFA24B(DFN)
77 I +RESLT<0 D START^RGHLLOG(),EXC^RGHLLOG(208,"Problem building A24 (ADD TF) for DFN= "_DFN,DFN),STOP^RGHLLOG() S RET="-1^Problem building A24 (ADD TF) for Pt" Q
78 I A08=1 D AVAFC^VAFCDD01(DFN) ; trigger A08 msg
79 I A08=1 S RET=RET_"^and A08 triggered"
80 Q
Note: See TracBrowser for help on using the repository browser.