source: WorldVistAEHR/trunk/r/MASTER_PATIENT_INDEX_VISTA-MPIF/MPIFREQ.m@ 1686

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

initial load of WorldVistAEHR

File size: 4.7 KB
Line 
1MPIFREQ ;SF/TN/CMC-CMOR CHANGE REQUEST ;FEB 20, 1998
2 ;;1.0; MASTER PATIENT INDEX VISTA ;**1,6,11,26,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 ;
11EN(TYPE,REQNO,ERROR,HL7) ;
12 ; Create HL7 message for Change of CMOR Request
13 N RGL,INST,USER,REASON,NDATE,ICN,PHONE,N0,CNT,HLA,HL,ID,XX,PID
14 S CNT=0,HL=0
15 S N0=$G(^MPIF(984.9,REQNO,0))
16 I N0="" S ERROR="Node for request #"_REQNO_" is not defined" Q
17 S INST=$P($$SITE^VASITE(),"^",3) ;station number
18 N X,Y,DIC
19 S DIC="^VA(200,",DIC(0)="MZO",X="`"_+$P(N0,"^",2)
20 D ^DIC
21 I $G(Y)<1 S USER=""
22 I $G(Y)>0 S USER=$G(Y(0,0))
23 S REASON=$P($G(^MPIF(984.9,REQNO,1)),"^",2)
24 S NDATE=$P(N0,"^",3)
25 S ICN=$$ICN^MPIFNQ(+$P(N0,"^",4))
26 S PHONE=$P(N0,"^",5)
27 S ID=$P(N0,"^")
28 D INIT^HLFNC2("MPIF CMOR REQUEST",.HL)
29 I HL D START^RGHLLOG(),EXC^RGHLLOG(220,"Unable to setup HL7 for sending Change of CMOR Request # "_REQNO_" FOR ICN= "_ICN,$P(N0,"^",4)),STOP^RGHLLOG() D RESET(REQNO) Q
30 K HLL("LINKS") N MPILK
31 S MPILK=$$MPILINK^MPIFAPI ;routing all messages through the MPI
32 I +MPILK<0 D Q
33 .D START^RGHLLOG()
34 .D EXC^RGHLLOG(224,"No MPI link found for Change CMOR Request # "_REQNO_" for ICN="_ICN,$P(N0,"^",4))
35 .D STOP^RGHLLOG()
36 .D RESET^MPIFREQ(REQNO)
37 .S ERROR="-1^No Links found"
38 ;Broadcast new CMOR to MPI which will send it out to all sites
39 S HLL("LINKS",1)="MPIF CMOR RESPONSE^"_MPILK
40 S CNT=CNT+1,PID=$$EN^VAFCPID(+$P(N0,"^",4),"1,2,4,5,6,7,8,11,12,13,14,16,17,19")
41 S HLA("HLS",CNT)=PID
42 S CNT=CNT+1
43 S CMOR=$P(^MPIF(984.9,REQNO,0),"^",9),CMOR=$$STA^XUAF4(CMOR)
44 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
45 S CNT=CNT+1
46 S HLA("HLS",CNT)="EVN"_HL("FS")_"A31"_HL("FS")_NDATE_HL("FS")_HL("FS")_""_HL("FS")_USER
47 N RLST
48 D GENERATE^HLMA("MPIF CMOR REQUEST","LM",1,.RLST,"",.HL)
49 I 'RLST D START^RGHLLOG(),EXC^RGHLLOG(220,"Unable to setup HL7 for sending Change of CMOR Request # "_REQNO_" for ICN= "_ICN,$P(N0,"^",4)),STOP^RGHLLOG(),RESET(REQNO)
50 Q
51 ;
52RESET(REQNO) ; reset status to Open
53 S DIE="^MPIF(984.9,",DA=REQNO,DR=".06///1" D ^DIE
54 K DIE,DA,DR
55 Q
56 ;
57IN(INST,USER,REASON,NDATE,ICN,PHONE,ID) ;Process an incoming CMOR request
58 N INSTN,PATIEN,MAIL,MPIF,TYPE,N0,IEN,XMCHAN,XMDUZ,XMTEXT,XMSUB,XMY,TEXT,X
59 S PATIEN=$$GETDFN^MPIF001(ICN)
60 I PATIEN<1 D Q
61 . D START^RGHLLOG()
62 . D EXC^RGHLLOG(210,"Received CMOR Change Request for ICN "_ICN_" ICN not Found. Request # "_ID)
63 . D STOP^RGHLLOG()
64 S IEN=$$ADD^MPIFNEW(ID) ;add request to request file
65 S TYPE=2 ;type of action to Request Received From
66 S INSTN=$G(HL("SFN")) ; site that sent this message - station #
67 S INST=$$IEN^XUAF4(INSTN),INST="`"_INST ; institution ien
68 S DIE="^MPIF(984.9,",DA=IEN,DR="[MPIF REQUEST INCOMING]" D ^DIE
69 I $$IFVCCI^MPIF001(+PATIEN)=-1 D PUSH(IEN) Q
70 ; ^ your site isn't the CMOR, so this is a push to make you the CMOR
71 S DIE="^MPIF(984.9,",DA=IEN,DR=".09///"_INST D ^DIE
72 ; ^ update CMOR AFTER APPROVAL field
73 I $$AUTO^MPIFNQ() D AUTO(IEN) Q
74 S MAIL=$$MAIL^MPIFUTL()
75 I MAIL="" S MAIL="MPIF EXCEPTIONS"
76 S XMDUZ="MPI VISTA Package",XMTEXT="MPIF(1,",MPIF(1,1)="New Coordinating Master Of Record (CMOR) request received for patient "_$S($P($G(^DPT(+PATIEN,0)),U)]"":$P(^DPT(PATIEN,0),"^")_" ("_$E($P(^(0),"^",9),6,9)_")",1:"UNKNOWN")
77 I MAIL="MPIF EXCEPTIONS" S XMTEXT=XMTEXT_" no mail group defined for CMOR requests"
78 S XMSUB="CMOR Change Request #"_$P(^MPIF(984.9,IEN,0),"^"),XMY("G."_MAIL)="" D ^XMD
79 Q
80 ;
81AUTO(REQNO) ;Process a request automatically
82 N DFN,MPIFERR,DIE,DR,DA,CMOR,RES,CMORN
83 S MPIFERR=0
84 S DIE="^MPIF(984.9,",DR="[MPIF REVIEW AUTO]",DA=REQNO D ^DIE
85 S DFN=$P($G(^MPIF(984.9,REQNO,0)),"^",4)
86 S CMORN=$P($G(^MPIF(984.9,REQNO,0)),"^",7)
87 S CMOR=$$CMORNAME^MPIF001(CMORN)
88 I +CMOR=-1 D START^RGHLLOG(),EXC^RGHLLOG(220,"CMOR not sent in Change CMOR message for patient DFN= "_DFN_" Request # "_REQNO,DFN),STOP^RGHLLOG(),RESET2(REQNO)
89 Q:+CMOR=-1 ;No CMOR defined
90 I $P($G(^MPIF(984.9,REQNO,1)),"^",3)=2 D
91 .S RES=1,RES=$$CHANGE^MPIF001(DFN,CMORN)
92 .I +RES<1 I +RES<1 D START^RGHLLOG(),EXC^RGHLLOG(220,"Unable to Change CMOR to "_CMOR_" in a CMOR Change Message for Patient DFN= "_DFN_" Request # "+REQNO,DFN),STOP^RGHLLOG(),RESET2(REQNO)
93 .Q:+RES<1
94 .D BROAD^MPIFCMOR(REQNO,.MPIFERR)
95 .I +MPIFERR=0 D EN^MPIFRESS(REQNO)
96 .; ^ trigger approval msg
97 Q
98 ;
99RESET2(REQNO) ; reset status to Pending Approval
100 S DIE="^MPIF(984.9,",DA=REQNO,DR=".06///3" D ^DIE
101 K DIE,DA,DR
102 Q
103 ;
104PUSH(IEN) ;Change of CMOR Request is a Push
105 ; just want to get request into 984.9 for
106 ; tracking purposes, marking it as approved
107 N DA,DIE,X,Y,TEXT
108 S DIE="^MPIF(984.9,",DA=IEN,TEXT="Auto change - CMOR pushed here"
109 S DR=".06///4;1.03///4;3.01///"_TEXT_";.09///`"_+$$SITE^VASITE()
110 D ^DIE
111 Q
Note: See TracBrowser for help on using the repository browser.