source: WorldVistAEHR/trunk/r/MASTER_PATIENT_INDEX_VISTA-MPIF/MPIFRPC3.m@ 862

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

initial load of WorldVistAEHR

File size: 2.1 KB
Line 
1MPIFRPC3 ;DRI/BHM - MPIF RPC API'S ;11/2/05 16:42
2 ;;1.0; MASTER PATIENT INDEX VISTA ;**42**;30 Apr 99
3 ;
4 ;Integration Agreements Utilized:
5 ; ^DPT( - #2070
6 ; ^A7RCP( - #4830
7 ;
8PRIMARY(RETURN,SITE,DFN) ; rpc to return primary patient record ;**42
9 ; site - station number or legacy station number
10 ; dfn - patient dfn or dfn in legacy site
11 ; return = primary dfn^icn icn (if available) can be local or national
12 ; if a problem
13 ; return = -1^error type^error text
14 ;
15 N ICN,NDFN,PDFN,SITEIEN K RETURN
16 ;
17 I $G(SITE)="" S RETURN="-1^NULL STATION NUMBER^Null station number passed." Q
18 I $G(DFN)="" S RETURN="-1^NULL PATIENT NUMBER^Null patient DFN passed." Q
19 ;
20 S PDFN=DFN ;assume primary dfn passed in
21 ;
22 I +$$SITE^VASITE()'=SITE D ;use ndbi data
23 . S SITEIEN=$O(^A7RCP("B",SITE,0)) ;check ndbi x-ref for site ien
24 . I SITEIEN="",$D(^A7RCP(SITE)) S SITEIEN=SITE ;some sites have site number as ien
25 . I SITEIEN="" S RETURN="-1^NO LEGACY DATA FOR SITE^Legacy site '"_SITE_"' data does not exist." Q
26 . S PDFN=$P($G(^A7RCP(SITEIEN,1,2,1,DFN,1)),"^",1) ;find primary dfn for patient file (#2) data
27 . I 'PDFN,$D(^A7RCP(SITEIEN,1,2,1,DFN,2)) S RETURN="-1^DUP MERGE AT LEGACY^"_$P($G(^(2)),"^",4)_"." Q
28 . I 'PDFN S RETURN="-1^NO LEGACY DATA FOR DFN^DFN '"_DFN_"' does not exist in legacy data" Q
29 I $G(RETURN) Q ;invalid ndbi data
30 ;
31 I $D(^DPT(PDFN,-9)) D ;check merge records
32 . S NDFN=PDFN ;next dfn
33 . F S NDFN=$P($G(^DPT(NDFN,-9)),"^") I $S('NDFN:1,'$D(^DPT(NDFN,-9)):1,1:0) Q ;could be multiple merges
34 . S PDFN=NDFN ;last dfn is new primary dfn
35 . I 'PDFN S RETURN="-1^NO MERGE DATA FOR DFN^No DFN for merged DFN '"_DFN_"'." Q
36 . I '$D(^DPT(PDFN)) S RETURN="-1^DFN NOT IN DATABASE FOR MERGED DFN^DFN '"_PDFN_"' does not exist for merged DFN '"_DFN_"'." Q
37 I $G(RETURN) Q ;invalid merge data
38 ;
39 I '$D(^DPT(PDFN)) S RETURN="-1^PATIENT NOT IN DATABASE^DFN '"_PDFN_"' does not exist in database." Q
40 ;
41 S ICN=$$GETICN^MPIF001(PDFN) ;get icn
42 I ICN<0 S RETURN=PDFN_"^"_$P(ICN,"^",2) Q ;return primary dfn and icn error message
43 S RETURN=PDFN_"^"_ICN ; return primary dfn and icn
44 Q
45 ;
Note: See TracBrowser for help on using the repository browser.