source: WorldVistAEHR/trunk/r/MASTER_PATIENT_INDEX_VISTA-MPIF/MPIFRPC.m@ 660

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

initial load of WorldVistAEHR

File size: 6.6 KB
RevLine 
[613]1MPIFRPC ;SFCIO/CMC-MPIF RPC APIS ;26 JUN 01
2 ;;1.0; MASTER PATIENT INDEX VISTA ;**20**;30 Apr 99
3 ;
4 ;Integration Agreements Utilized:
5 ; ^DPT( - #2070
6 ; AVAFC^VAFCDD01 - #3493
7 ; GETEX^RGEX03 - #3554
8 ; NOTICE^DGSEC4 - #3027
9 ; PTSEC^DGSEC4 - #3027
10 ;
11ICNSTAT(RETURN,ICN,SSN,RPC) ;
12 ;RPC to return status of ICN passed or if SSN is passed find ICN and return status including ICN, ICN History, CMOR History, Exceptions pending
13 ; RETURN - array to return ICN data
14 ; ICN - ICN for the patient in the Patient (#2) file data is to be returned on
15 ; SSN - social security number for the patient in the Patient (#2) file data is to be returned on
16 ; RPC - 0 or 1 to denote if the call is being made from a RPC or called locally. 1=RPC remote call 0=locally called - 1 is default
17 ;
18 N PICN,CNTD,DFN,TICN,LOCAL,XX,RETS,TEXT,CMOR,ICNH,CMORH
19 I $G(RPC)="" S RPC=1
20 I $G(ICN)=""&($G(SSN)="") S RETURN="-1^NO ICN OR SSN PASSED" Q
21 I $G(SSN)'="" S ICN=$$GETICNS^MPIF002(SSN),RETURN(1,"SSN USED")="MPI(""SSN USED"")="_""""_SSN_"""" ; possible to have multiple entries with same SSN
22 S PICN=ICN,CNTD=0,TEXT=""
23 F XX=1:1 S ICN=$P(PICN,"^",XX) Q:ICN="" D
24 .S DFN=$$GETDFN^MPIF001(+ICN),CNTD=CNTD+1
25 .I +DFN=-1 S RETURN(XX)="-1^NO SUCH ICN "_ICN Q
26 .I '$D(^DPT(DFN)) S RETURN(DFN)="-1^BAD AICN X-REF, PT FILE ENTRY DOESN'T EXIST DFN= "_DFN_" ICN= "_ICN Q
27 .; check if this data can be returned and if sensative pt bulletin needed
28 .N SENS D PTSEC^DGSEC4(.SENS,DFN,1,"Remote Procedure from MPI^RPC from MPI for ICN Information")
29 .N NOT D NOTICE^DGSEC4(.NOT,DFN,"Remote Procedure from MPI^RPC from MPI for ICN Information")
30 .I SENS(1)=3!(SENS(1)=4)!(SENS(1)=-1) S RETURN(XX)="-1^SENSATIVE PT ISSUE "_SENS(2)_" DFN= "_DFN_" ICN= "_ICN Q
31 .I RPC=1 S TEXT="MPI("_DFN_",""DFN"")="
32 .S RETURN(DFN,"DFN")=TEXT_""""_DFN_""""
33 .S TICN=$$GETICN^MPIF001(DFN)
34 .I +TICN<0 D
35 ..I RPC=1 S RETURN(DFN,1)="MPI("_DFN_",1)="_""""_"No current ICN"
36 ..I RPC=0 S RETURN(DFN,1)="""No Current ICN"
37 .I +TICN>0 D
38 ..I RPC=1 S RETURN(DFN,"ICN")="MPI("_DFN_",""ICN"")="_""""_TICN_""""
39 ..I RPC=0 S RETURN(DFN,"ICN")=""""_TICN_""""
40 .S LOCAL=""
41 .I $E($G(RETURN(DFN,"ICN")),1,3)=$P($$SITE^VASITE(),"^",3) S LOCAL="Y"
42 .I LOCAL=""&(+TICN>0) D
43 ..I RPC=1 S RETURN(DFN,1)="MPI("_DFN_",1)="_""""_"NATIONAL ICN"
44 ..I RPC=0 S RETURN(DFN,1)=""""_"NATIONAL ICN"
45 .I LOCAL="Y"&(+TICN>0) D
46 ..I RPC=1 S RETURN(DFN,1)="MPI("_DFN_",1)="_""""_"LOCAL ICN"
47 ..I RPC=0 S RETURN(DFN,1)=""""_"LOCAL ICN"_""""
48 .S CMOR=$$GETVCCI^MPIF001(DFN)
49 .I +CMOR=-1 S CMOR=$P(CMOR,"^",2)
50 .I RPC=1 S RETURN(DFN,"CMOR")="MPI("_DFN_",""CMOR"")="""_CMOR_""""
51 .I RPC=0 S RETURN(DFN,"CMOR")=""""_CMOR_""""
52 .D GETICNH^MPIF002(DFN,.ICNH)
53 .I +ICNH=-1 D
54 ..I RPC=1 S RETURN(DFN,"ICN HISTORY")="MPI("_DFN_",""ICN HISTORY"")="""_$P(ICNH,"^",2)_""""
55 ..I RPC=0 S RETURN(DFN,"ICN HISTORY")=""""_$P(ICNH,"^",2)_""""
56 .I +ICNH'=-1 D
57 ..M RETURN(DFN,"ICN HISTORY")=ICNH
58 ..I RPC=1 D
59 ...N IEN
60 ...S IEN="" F S IEN=$O(RETURN(DFN,"ICN HISTORY",IEN)) Q:IEN="" S RETURN(DFN,"ICN HISTORY",IEN)="MPI("_DFN_",""ICN HISTORY"","_IEN_")="_$G(RETURN(DFN,"ICN HISTORY",IEN))
61 ...S RETURN(DFN,"ICN HISTORY")="MPI("_DFN_",""ICN HISTORY"")="_$G(RETURN(DFN,"ICN HISTORY"))
62 .;
63 .D GETCMORH^MPIF002(DFN,.CMORH)
64 .I +CMORH=-1 D
65 ..I RPC=1 S RETURN(DFN,"CMOR HISTORY")="MPI("_DFN_",""CMOR HISTORY"")="""_$P(CMORH,"^",2)_""""
66 ..I RPC=0 S RETURN(DFN,"CMOR HISTORY")=""""_$P(CMORH,"^",2)_""""
67 .I +CMORH'=-1 D
68 ..M RETURN(DFN,"CMOR HISTORY")=CMORH
69 ..I RPC=1 D
70 ...N IEN
71 ...S IEN="" F S IEN=$O(RETURN(DFN,"CMOR HISTORY",IEN)) Q:IEN="" S RETURN(DFN,"CMOR HISTORY",IEN)="MPI("_DFN_",""CMOR HISTORY"","_IEN_")="_$G(RETURN(DFN,"CMOR HISTORY",IEN))
72 ...S RETURN(DFN,"CMOR HISTORY")="MPI("_DFN_",""CMOR HISTORY"")="_$G(RETURN(DFN,"CMOR HISTORY"))
73 .;
74 .D EXC(DFN,.RETS,XX)
75 .I RETS(XX,"EXCEPTIONS")="No Exceptions" D
76 ..I RPC=1 S RETURN(DFN,"EXCEPTIONS")="MPI("_DFN_",""EXCEPTIONS"")=""NO EXCEPTIONS""",RETURN(DFN,1)=$G(RETURN(DFN,1))_" with No Exceptions"_""""
77 ..I RPC=0 S RETURN(DFN,"EXCEPTIONS")="""NO EXCEPTIONS""",RETURN(DFN,1)=$G(RETURN(DFN,1))_" with No Exceptions"_""""
78 .I RETS(XX,"EXCEPTIONS")'="No Exceptions" D
79 ..I RPC=1 S RETURN(DFN,1)=$G(RETURN(DFN,1))_" with Exceptions"_"""",RETURN(DFN,"EXCEPTIONS")="MPI("_DFN_",""EXCEPTIONS"")="_""""_$G(RETS(XX,"EXCEPTIONS"))_""""
80 ..I RPC=0 S RETURN(DFN,1)=$G(RETURN(DFN,1))_" with Exceptions"_"""",RETURN(DFN,"EXCEPTIONS")=$G(RETS(XX,"EXCEPTIONS"))
81 I CNTD>1 D
82 .I RPC=1 S RETURN(1,"ICNS PROCESSED")="MPI(""ICNS PROCESSED"")="_""""_CNTD_""""
83 .I RPC=0 S RETURN(1,"ICNS PROCESSED")="MPI(""ICNS PROCESSED"")="_CNTD
84 Q
85EXC(DFN,RET,YY) ;
86 ; process exceptions into single value
87 N TVAL,IEN
88 D GETEX^RGEX03(.VAL,DFN)
89 I +VAL(0)=0 S RET(YY,"EXCEPTIONS")="No Exceptions"
90 I +VAL(0)'=0 D
91 .S IEN=0,TVAL=""
92 .F IEN=$O(VAL(IEN)) Q:IEN="" S TVAL=TVAL_$P($G(VAL(IEN)),"^")_"^"
93 .S RET(YY,"EXCEPTIONS")=""""_TVAL_""""
94 K VAL
95 Q
96 ;
97INACT(RETURN,ICN) ;
98 ;RPC to inactivate the ICN passed.
99 ; RETURN - 1 for successful inactivation or -1^error msg
100 ; ICN = is the ICN for the patient that is to be inactivated
101 ;
102 I $G(ICN)="" S RETURN="-1^No ICN Passed" Q
103 I +ICN<1 S RETURN="-1^Invalid ICN" Q
104 N DFN,TICN,ER
105 S DFN=$$GETDFN^MPIF001(ICN)
106 I +DFN<0 S RETURN="-1^No such ICN" Q
107 S TICN=$$GETICN^MPIF001(DFN)
108 I +TICN'=+ICN S RETURN="-1^ICN is not active" Q
109 D PAT^MPIFDEL(DFN,.ER)
110 I ER'="" S RETURN="-1^"_ER Q
111 S RETURN=1
112 Q
113 ;
114RCCMOR(RETURN,ICN,CMOR,SSN,A08) ;
115 ;RPC to change the CMOR value to CMOR for patient with ICN value ICN
116 ; RETURN - array to return 1 for successful update or -1^ERROR MSG
117 ; ICN = ICN for the patient that the CMOR is to be changed for
118 ; CMOR = Station Number of the site that should become the CMOR
119 ; SSN = Social Security Number of the patient involved, to be used if
120 ; ICN is not found due to bad AICN x-ref
121 ; A08 = 1 means trigger A08 message, 0 means don't send A08 msg
122 ;
123 I $G(ICN)=""!($G(CMOR)="") S RETURN="-1^Missing Required fields" Q
124 N DFN,CIEN,DFNS
125 S DFN=$$GETDFN^MPIF001(ICN)
126 I DFN'>0&($G(SSN)="") S RETURN(1)="-1^Unknown ICN" Q
127 I DFN'>0 D
128 .Q:'$D(^DPT("SSN",SSN))
129 .S DFNS=$$GETDFNS^MPIF002(SSN)
130 .S DFN=$$CHK(DFNS,ICN)
131 I DFN'>0!(+ICN=-1) S RETURN(1)="-1^Unknown ICN" Q
132 S CIEN=$$IEN^XUAF4(CMOR)
133 I CIEN'>0 S RETURN(1)="-1^Unknown Institution" Q
134 S RETURN(1)=$$CHANGE^MPIF001(DFN,CIEN)
135 I A08=1 D AVAFC^VAFCDD01(DFN) ; trigger A08 msg
136 I A08=1 S RETURN(1)=RETURN(1)_"^and A08 triggered"
137 ;trigger a08
138 Q
139 ;
140CHK(DFNS,ICN) ; see if had broken AICN x-ref, if so, fix it and return
141 ; correct DFN for patient that's CMOR is to be changed.
142 ;
143 N IEN,NODE,NXT,FOUND,DFN
144 S FOUND=0
145 F NXT=1:1 S IEN=$P(DFNS,"^",NXT) Q:IEN=""!(FOUND=1) D
146 .S NODE=$$MPINODE^MPIFAPI(NXT)
147 .I $P(NODE,"^")=ICN S FOUND=1,^DPT("AICN",ICN,IEN)="",DFN=IEN
148 I FOUND=0 Q "-1^No such ICN"
149 Q DFN
Note: See TracBrowser for help on using the repository browser.