source: FOIAVistA/trunk/r/MASTER_PATIENT_INDEX_VISTA-MPIF/MPIFEDIT.m@ 1015

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

initial load of FOIAVistA 6/30/08 version

File size: 5.0 KB
Line 
1MPIFEDIT ;BHM/RGY-Request a CMOR for patient ;FEB 20, 1998
2 ;;1.0; MASTER PATIENT INDEX VISTA ;**11,22,30,34**;30 Apr 99
3 ;
4 ; Integration Agreements Utilized:
5 ;
6 ; EXC^RGHLLOG IA #2796
7 ; START^RGHLLOG IA #2796
8 ; STOP^RGHLLOG IA #2796
9 ; $$EN^VAFCPID IA #3015
10 ;
11NEW ;
12 ;Entry point for option: MPIF NEW REQUEST - create a new request
13 ; to change CMOR. No input or output variables.
14 ;
15 ;Only if the site is not the CMOR can this option be used
16 N DIC,X,Y,DTOUT,DUOUT,PAT
17 S DIC="^DPT(",DIC(0)="QEAMZ",DIC("A")="Select PATIENT: "
18 D ^DIC
19 Q:$D(DTOUT)!$D(DUOUT)!(Y=-1)
20 S PAT=+Y
21 I +$$GETICN^MPIF001(PAT)<0 W !!,"Patient doesn't have ICN, try again" G NEW
22 I $$GETVCCI^MPIF001(PAT)<0 W !!,"Patient doesn't have a CMOR, try again" G NEW
23 I $$GETVCCI^MPIF001(PAT)=$P($$SITE^VASITE(),"^",3) W !!,"You are the CMOR, to push the CMOR to another site use option: PUSH CMOR REQUEST" G NEW
24 ; CHECK IF ALREADY OPEN/PENDING REQUEST
25 N ENT,STOP
26 S ENT=0,STOP=0 F S ENT=$O(^MPIF(984.9,"C",PAT,ENT)) Q:ENT=""!(STOP) D
27 .I $P($G(^MPIF(984.9,ENT,0)),"^",6)<4 S STOP=1
28 I STOP W !!,"Already have request for this patient" G NEW
29 ;
30 N N0,PHONE,DA,DIE,DR,DIR,ERROR,DIK,Y,DIRUT,REQ,CMOR,MPIFREQ,CMORI
31 S DA=$$ADD^MPIFNEW()
32 S DIE="^MPIF(984.9,",DR=".04///`"_PAT D ^DIE
33 S REQ=$P($G(^MPIF(984.9,DA,0)),"^")
34 W !,"REQUEST NUMBER:",REQ
35 S CMOR=$$HL7CMOR^MPIF001($P($G(^MPIF(984.9,DA,0)),"^",4),"^")
36 ;station # ^ Station Name
37 S CMORI=$$IEN^XUAF4($P(CMOR,"^"))
38 W !,"*** Current CMOR: "_$P(CMOR,"^",2)_" ("_$P(CMOR,"^")_") ***"
39 S DIE="^MPIF(984.9,",DR=".07///`"_CMORI_";1.03///1;.09///`"_+$$SITE^VASITE() D ^DIE
40 ; ^ update site, type of action, and cmor after approval
41 ;
42 S REQ=DA
43EDIT I $D(DUZ) D
44 .S PHONE=$P($G(^MPIF(984.9,+$O(^MPIF(984.9,"AD",DUZ,""),-1),0)),"^",5)
45 .N DA,DIC,DIQ S DIQ="MPIFREQ",DR=".01",DIQ(0)="E",DIC="^VA(200,",DA=DUZ
46 .D EN^DIQ1
47 .S MPIFREQ=MPIFREQ(200,DUZ,.01,"E")
48 I '$D(DUZ) S (MPIFREQ,PHONE)=""
49 ;
50REASON S DIR("A")="Reason for Request",DIR("?")="Answer must be 3-60 characters in length.",DIR(0)="F^3:60" D ^DIR
51 I Y="" W !,"Answer must be 3-60 characters in length." G REASON
52 I Y="^" S DIK="^MPIF(984.9," D ^DIK W "... Request deleted" Q
53 S DIE="^MPIF(984.9,",DR="1.02///"_X D ^DIE
54REQNM S DIR("A")="Requestor's Name:",DIR("B")=MPIFREQ,DIR("?")="Answer must be a valid user",DIR(0)="P^200:EQZ" D ^DIR K DIR("B")
55 I Y="" W !,"Must pick valid user" G REQNM
56 I Y="^" S DIK="^MPIF(984.9," D ^DIK W "... Request deleted" Q
57 S DIE="^MPIF(984.9,",DR=".02///`"_+Y D ^DIE
58PHONE S DIR("A")="Requestor Phone:",DIR("B")=PHONE,DIR("?")="Answer must be 4-20 charaters in length.",DIR(0)="F" D ^DIR K DIR("B")
59 I Y="" W !,"Answer must be 4-20 charaters in length." G PHONE
60 I Y="^" S DIK="^MPIF(984.9," D ^DIK W "... Request deleted" Q
61 S DIE="^MPIF(984.9,",DR=".05///"_X D ^DIE
62 I $$CHK^MPIFEDIT(DA) W !,"This request is missing required data." G EDIT
63 ;
64APP S DIR("A")="Select Request Action (SEND/EDIT/DELETE)? ",DIR("B")="SEND",DIR(0)="SAO^SEND:SEND;EDIT:EDIT;DELETE:DELETE"
65 D ^DIR K DIR
66 I $E(Y)="D"!$D(DIRUT) D Q
67 .S DIK="^MPIF(984.9," D ^DIK W "... Request deleted"
68 .Q
69 I $E(Y)="E" G REASON
70 S DR=".08////^S X=2;.06////^S X=2",DIE="^MPIF(984.9," D ^DIE W !,"... Request will be sent"
71 ;
72 I '$D(REQ) S REQ=DA
73 S N0=$G(^MPIF(984.9,REQ,0)),CNT=0
74 I N0="" S ERROR="Node for request #"_REQ_" is not defined" Q
75 S INST=$P($$SITE^VASITE(),"^",3)
76 N X,Y,DIC
77 S DIC="^VA(200,",DIC(0)="MZO",X="`"_+$P(N0,"^",2)
78 D ^DIC
79 I $G(Y)<1 S USER=""
80 I $G(Y)>0 S USER=$G(Y(0,0))
81 S REASON=$P($G(^MPIF(984.9,REQ,1)),"^",2)
82 S NDATE=$P(N0,"^",3)
83 S ICN=$$ICN^MPIFNQ(+$P(N0,"^",4))
84 S PHONE=$P(N0,"^",5)
85 S ID=$P(N0,"^")
86 K HLA
87 D INIT^HLFNC2("MPIF CMOR REQUEST",.HL)
88 I $O(HL(""))="" D START^RGHLLOG(),EXC^RGHLLOG(220,"Unable to setup HL7 for sending Change of CMOR Request # "_REQ_" FOR ICN= "_ICN,$P(N0,"^",4)),STOP^RGHLLOG() D RESET^MPIFREQ(REQ) Q
89 K HLL("LINKS") N MPILK
90 S MPILK=$$MPILINK^MPIFAPI ;routing all messages through the MPI
91 I +MPILK<0 D Q
92 .D START^RGHLLOG()
93 .D EXC^RGHLLOG(224,"No MPI link found for Change CMOR Request # "_REQ_" for ICN="_ICN,$P(N0,"^",4))
94 .D STOP^RGHLLOG()
95 .D RESET^MPIFREQ(REQ)
96 .S ERROR="-1^No Links found"
97 ;Broadcast new CMOR to MPI which will send it out to all sites
98 S HLL("LINKS",1)="MPIF CMOR RESPONSE^"_MPILK
99 S CNT=CNT+1,PID=$$EN^VAFCPID(+$P(N0,"^",4),"1,2,4,5,6,7,8,11,12,13,14,16,17,19")
100 S HLA("HLS",CNT)=PID
101 S CNT=CNT+1
102 S CMOR=$P($$HL7CMOR^MPIF001($P($G(^MPIF(984.9,DA,0)),"^",4),"^"),"^")
103 S HLA("HLS",CNT)="NTE"_HL("FS")_HL("FS")_"P"_HL("FS")_PHONE_HL("FS")_REASON_HL("FS")_HL("FS")_ID_HL("FS")_INST_HL("FS")_HL("FS")_CMOR
104 S CNT=CNT+1
105 S HLA("HLS",CNT)="EVN"_HL("FS")_"A31"_HL("FS")_NDATE_HL("FS")_HL("FS")_""_HL("FS")_USER
106 N RLST
107 D GENERATE^HLMA("MPIF CMOR REQUEST","LM",1,.RLST,"",.HL)
108 I 'RLST D START^RGHLLOG(),EXC^RGHLLOG(220,"Unable to setup HL7 for sending Change of CMOR Request # "_REQ_" for ICN= "_ICN,$P(N0,"^",4)),STOP^RGHLLOG(),RESET^MPIFREQ(REQ)
109 K CNT,ICN,INST,NDATE,PID,REASON,RGL,USER,XX,ID
110 Q
111 ;
112CHK(IEN) ;
113 N N0,X,ERROR
114 S ERROR=0
115 S N0=$G(^MPIF(984.9,IEN,0))
116 F X=1:1:7 I $P(N0,"^",X)="" S ERROR=1 Q
117 I $P($G(^MPIF(984.9,IEN,1)),"^",2)="" S ERROR=1
118 Q ERROR
Note: See TracBrowser for help on using the repository browser.