source: FOIAVistA/trunk/r/MASTER_PATIENT_INDEX_VISTA-MPIF/MPIFRCMP.m@ 677

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

initial load of FOIAVistA 6/30/08 version

File size: 3.1 KB
Line 
1MPIFRCMP ;BPCIO/CMC-PUSHING CMOR TO ANOTHER SITE REMOTELY ;JUNE 23, 2004
2 ;;1.0; MASTER PATIENT INDEX VISTA ;**36**;30 Apr 99
3 ;
4 ; Integration Agreements Utilized:
5 ;
6 ; ^DGCN(391.91 IA #2751
7 ; AVAFC^VAFCDD01 IA #3493
8 ;
9 ; Create a new request to change CMOR when your site is the CMOR VIA
10 ; Remote RPC from the MPI
11 ;
12EN(RETURN,ICN,NCMOR) ;
13 ; RETURN - Array to return the value 1 if successfully created request
14 ; or -1^error message
15 ; ICN - ICN for the patient that the CMOR is being changed for
16 ; NCMOR - Which site should be the new CMOR - Station #
17 ;
18 N DFN
19 S DFN=$$GETDFN^MPIF001(+ICN)
20 I +DFN<1 S RETURN="-1^No such ICN at site" Q
21 I $$GETVCCI^MPIF001(DFN)<0 S RETURN="-1^Patient doesn't have a CMOR" Q
22 I $$GETVCCI^MPIF001(DFN)'=$P($$SITE^VASITE(),"^",3) S RETURN="-1^This site is NOT the CMOR, can't push the CMOR somewhere else." Q
23 N TMP,TCNT,TF
24 S TF=0
25 S TMP=$O(^DGCN(391.91,"APAT",DFN,"")) I $O(^DGCN(391.91,"APAT",DFN,TMP))="" S RETURN="-1^Patient isn't SHARED - CAN'T change CMOR" Q
26 ;Pt is shared, but are they shared with another VAMC?
27 S TMP="",TCNT=0 F S TMP=$O(^DGCN(391.91,"APAT",DFN,TMP)) Q:TMP="" D
28 .N TP S TP=$$GET1^DIQ(4,TMP_",",13)
29 .Q:TP'="VAMC"&(TP'="OC")&(TP'="M&ROC")&(TP'="RO-OC")
30 .; ^ only valid types of TFs that can be a CMOR
31 .S TCNT=TCNT+1
32 .I $$STA^XUAF4(TMP)=NCMOR S TF=1
33 I TCNT<2 S RETURN="-1^Patient isn't SHARED with another VAMC - CAN'T change CMOR" Q
34 I TF=0 S RETURN="-1^Site to be new CMOR is NOT a TF - Can't change CMOR" Q
35 ; CHECK IF ALREADY OPEN/PENDING REQUEST
36 N ENT,STOP,MPIFNM,REQNM
37 S ENT=0,STOP=0 F S ENT=$O(^MPIF(984.9,"C",DFN,ENT)) Q:ENT=""!(STOP) D
38 .I $P($G(^MPIF(984.9,ENT,0)),"^",6)<4 S STOP=1
39 I STOP S RETURN="-1^There is already an open CMOR request for this patient" Q
40 N DA,DIE,DR,DIK,Y,DIRUT,REQ,TDA,XX,WHO,PHONE
41 S DA=$$ADD^MPIFNEW(),TDA=DA,PHONE=""
42 S DIE="^MPIF(984.9,",DR=".04///`"_DFN D ^DIE
43 S REQ=$P($G(^MPIF(984.9,DA,0)),"^")
44 S XX="CMOR Push by MPI Data Quality Team",WHO=.5,PHONE="MPI DQ Team"
45 S DIE="^MPIF(984.9,",DR="1.02///"_XX_";.02///`"_WHO_";.05///"_PHONE D ^DIE
46 N TSITE S TSITE=$$IEN^XUAF4(NCMOR)
47 S DIE="^MPIF(984.9,",DR=".07///`"_TSITE_";1.03///3;.09///`"_TSITE D ^DIE
48 ;update site, type of action and cmor after approval
49 ;
50 I $$CHK^MPIFEDIT(DA) S RETURN="-1^This request is missing required data." Q
51 ;
52 S DR=".08////^S X=2;.06////^S X=2",DIE="^MPIF(984.9," D ^DIE S RETURN=1
53 ; removed event queue due to delivery issues - this msg must be sent first followed by the actual change cmor msg.
54 N ERR,MPIFHL7 S ERR="ERRS",MPIFHL7=""
55 D EN^MPIFREQ("CMOR CHANGE REQUEST",DA,.ERR,MPIFHL7)
56 ;
57 ;NOW CHANGE CMOR AND SEND CHANGE CMOR MESSAGE
58 N TEXT,DIR,DR,CMOR,TMP,ERROR
59 S TEXT="Auto change - pushed CMOR",ERROR=0
60 S DIE="^MPIF(984.9,",DA=TDA,DR=".06///^S X=4;3.01///^S X=TEXT"
61 D ^DIE
62 S CMOR=$P($G(^MPIF(984.9,TDA,0)),"^",7)
63 I CMOR="" D Q
64 .S RETURN="-1^New CMOR Not Defined, PROBLEM WITH REQUEST"
65 S TMP=$$CHANGE^MPIF001(DFN,CMOR)
66 I +TMP<0 S ^DIE="^MPIF(984.9,",DA=TDA,DR=".06///^S X=1" D ^DIE Q
67 D BROAD^MPIFCMOR(DA,.ERROR)
68 Q
69SYNC(RETURN,ICN) ;
70 N DFN
71 S DFN=$$GETDFN^MPIF001(ICN)
72 I +DFN<0 S RETURN(1)="-1^ICN doesn't exist at this site" Q
73 D AVAFC^VAFCDD01(DFN) ; trigger A08 msg
74 S RETURN(1)=1
75 Q
Note: See TracBrowser for help on using the repository browser.