source: WorldVistAEHR/trunk/r/TEXT_INTEGRATION_UTILITIES-GMRP-TIU/TIUALRT.m@ 1046

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

initial load of WorldVistAEHR

File size: 7.9 KB
Line 
1TIUALRT ; SLC/JER,AJB - Notify Author and Attending. ; Mar 17, 2003
2 ;;1.0;TEXT INTEGRATION UTILITIES;**21,84,79,88,58,61,151,158,175,221**;Jun 20, 1997;Build 2
3SEND(DA,OVERDUE) ; Generate "available for signature" alert
4 N TIU0,TIU12,TIU13,TIU14,TIU15,TIUESNR,TIUPNM,TIUECSNR,TIUSIG,TIUDPRM
5 N TIUCOSG,TIUEDT,TIUSSN,TIU,TIUTYP,XQA,XQAKILL,XQAMSG,XQAROU,XQAID
6 N XQAFLG,STATUS,SIGACT,ECSNRFLG
7 I '$D(TIUPRM0)!'$D(TIUPRM1) D SETPARM^TIULE
8 I '$D(TIUTMP("NODEL")) D ALERTDEL(DA)
9 S TIU0=$G(^TIU(8925,+DA,0)),TIU12=$G(^(12)),TIU13=$G(^(13))
10 S TIU14=$G(^TIU(8925,+DA,14)),TIU15=$G(^(15))
11 D DOCPRM^TIULC1(+TIU0,.TIUDPRM,DA)
12 ; Quit if notifications not enabled
13 I '$D(TIUDPRM(0)) Q
14 ; If document is an addendum, and the original is incomplete, quit
15 ; per NOIS DUR-0101-32087
16 ; I +$$ISADDNDM^TIULC1(DA),($P($G(^TIU(8925,+$P(TIU0,U,6),0)),U,5)<7) Q
17 I '+$P(TIUPRM1,U,7)!(+$P(TIU12,U)<+$P(TIUPRM1,U,7)) Q
18 ;VMP/ELR PATCH 221 DO NOT SEND ALERTS FOR RETRACTED DOCUMENTS
19 I +$P(TIU0,U,5)=15 Q
20 ; If third party alert from TIUALFUN **158**
21 I $D(TIUTMP("THIRD PARTY ALERTS")) G THIRD
22 ; If document is completed, jump to additional signers
23 I (+$P(TIU0,U,5)'<7) G ADDSNR
24 I +$P(TIU0,U,5)=3,+$P($G(TIUDPRM(0)),U,2),'+$P(TIU13,U,4) Q ; not released **175**
25 ; If Verification required, and not verified, don't send
26 I +$P(TIU0,U,5)=4,+$$REQVER^TIULC(DA,+$P($G(TIUDPRM(0)),U,3)),'+$P(TIU13,U,5) Q ; **175**
27 ; Set up for call to XQALERT
28 S TIUEDT=$$DATE^TIULS($P(TIU0,U,7))
29 S TIUESNR=$P(TIU12,U,4)
30 S TIUSIG=$P(TIU15,U)
31 S TIUECSNR=$P(TIU12,U,8),TIUCOSG=$P(TIU15,U,7)
32 ; If author has been identified, but not Expected Signer, make
33 ; author the expected signer
34 I +TIUESNR'>0,(+$P(TIU12,U,2)>0) D
35 . N DIE,DR
36 . S TIUESNR=$P(TIU12,U,2)
37 . S DIE=8925,DR="1204////^S X=TIUESNR" D ^DIE
38 ; If attending has been identified, but not Expected Cosigner, make
39 ; attending the expected cosigner
40 I +TIUECSNR'>0,(+$P(TIU12,U,9)>0) D
41 . N DIE,DR
42 . S TIUECSNR=$P(TIU12,U,9)
43 . S DIE=8925,DR="1208////^S X=TIUECSNR" D ^DIE
44 ; If first signature required and the expected signer is authorized
45 ; to sign this record, and the record is not yet signed
46 ; ** Set AUTHOR as recipient
47 I '+$G(TIUSIG),(+TIUESNR>0),(+$P(TIUDPRM(0),U,4)>0) S XQA(TIUESNR)=""
48 ; If the record requires cosignature, and is not yet cosigned
49 ; ** Set Expected Cosigner as recipient
50 I TIUECSNR]"",(+$P(TIU0,U,5)<7),(+$G(TIUCOSG)'>0) D
51 . N TIUDA S TIUDA=DA
52 . ; For documents other than Discharge Summaries, defer alerting
53 . ; Expected Cosigner 'til AUTHOR has signed
54 . ; If current document is an addendum apply test to its parent
55 . I +$$ISADDNDM^TIULC1(DA) S TIUDA=$P(^TIU(8925,DA,0),U,6)
56 . ; If cosigner alerts are to be deferred until signature, quit
57 . I '+$P(TIUDPRM(0),U,20),'+$G(TIUSIG),+$P(TIUDPRM(0),U,4) Q ; **84,112/151**
58 . S XQA(TIUECSNR)="",ECSNRFLG=1 ; **151**
59ADDSNR ; Send addendum alerts, check for additional signers
60 ;VMP/ELR PATCH 221 DO NOT SEND AMENDMENT ALERT IF CAUSED BY A DELINQUENT ADDITIONAL SIGNER
61 I +$$ISADDNDM^TIULC1(DA),$G(TIUADDL)'=1 D SENDADD(DA)
62 ; If additional signers have been designated, alert them too
63 I +$O(^TIU(8925.7,"B",DA,0)),(+$P(TIU0,U,5)>5) D
64 . N TIUXTRA,TIUI D XTRASGNR^TIULG(.TIUXTRA,DA) Q:+$D(TIUXTRA)'>9
65 . S TIUI=0 F S TIUI=$O(TIUXTRA(TIUI)) Q:+TIUI'>0 S XQA(TIUI)=""
66 Q:$D(XQA)'>9
67THIRD ; **158**
68 I $D(TIUTMP("THIRD PARTY ALERTS")) D
69 . N TIUX
70 . S TIUX="" F S TIUX=$O(TIUXQA(TIUX)) Q:TIUX="" S XQA(TIUX)=""
71 ; Get demographics for alert message
72 S TIUPNM=$E($P($G(^DPT(+$P(TIU0,U,2),0)),U),1,9)
73 S TIUTYP=$$PNAME^TIULC1(+$G(TIU0))
74 D PATVADPT^TIULV(.TIU,+$P(TIU0,U,2))
75 S TIUSSN=$E(TIUPNM,1)_$P($G(TIU("SSN")),"-",3)
76 S XQAID="TIU"_+DA,STATUS=$$UP^XLFSTR($$GET1^DIQ(8925,DA,.05)) ; **175** $$STATUS^TIULC(DA))
77 S SIGACT=$S(STATUS="UNSIGNED":"SIGNATURE",STATUS="UNCOSIGNED":"COSIGNATURE",1:"ADD'L SIGNATURE")
78 I $G(ECSNRFLG),$P(TIU0,U,5)=5 S STATUS="UNSIG/UNCOS'D" ; **151**
79 S XQAMSG=TIUPNM_" ("_TIUSSN_"): "_STATUS_" "_$S($P(TIU0,U,9)="P":"STAT ",1:"")_TIUTYP
80 I +$G(OVERDUE) S XQAMSG=XQAMSG_" OVERDUE for "_SIGACT_"." G ENDMSG
81 S XQAMSG=XQAMSG_" available for "_SIGACT_"."
82ENDMSG ;
83 S XQAROU="ACT^TIUALRT",XQADATA=+DA_U
84 D SETUP^XQALERT
85 Q
86ACT ; Act on alerts
87 N TIUQUIK,TIUDA,TIUPRM0,TIUPRM1,TIUPRM3,RSTOK S TIUQUIK=1 K XQAKILL
88 S TIUDA=$P(XQADATA,U)
89 I '$D(^TIU(8925,+TIUDA,0)) D ALERTDEL(TIUDA) Q
90 S RSTOK=$$DOCCHK^TIULRR(TIUDA)
91 I RSTOK'>0 D Q
92 . W !!,$C(7),"Ok, no harm done...",! ; Echo denial message
93 . I $$READ^TIUU("EA","RETURN to continue...") ; pause
94 I $P(^TIU(8925,+TIUDA,0),U,5)'<7,'+$$ISSIGNR(TIUDA,DUZ) S XQAKILL=1
95 D:'$D(TIUPRM0)!'$D(TIUPRM1) SETPARM^TIULE
96 D EN^VALM("TIU BROWSE FOR CLINICIAN")
97 Q
98SENDTRAN(DA) ; Generate "Send back to transcription" alert
99 N TIUEDT,TIU0,TIUPNM,TIUSSN,TIUTRAN,TIU,XQA,XQAMSG,TIUMSG
100 N TIUESNR,TIU12,TIU13,TIU14,TIU15,TIUTYP
101 I '$D(TIUPRM0)!'$D(TIUPRM1) D SETPARM^TIULE
102 D ALERTDEL(DA)
103 ; Don't send if notifications not enabled
104 I '+$P(TIUPRM1,U,7) Q
105 S TIU0=$G(^TIU(8925,+DA,0)),TIU12=$G(^(12)),TIU13=$G(^(13))
106 S TIU14=$G(^TIU(8925,+DA,14)),TIU15=$G(^(15))
107 S TIUPNM=$E($P($G(^DPT(+$P(TIU0,U,2),0)),U),1,9)
108 S TIUEDT=$$DATE^TIULS($P(TIU0,U,7))
109 S TIUTYP=$$PNAME^TIULC1(+$G(TIU0))
110 S TIUTRAN=$P(TIU13,U,2),TIUESNR=$P(TIU12,U,2) ; **175**
111 D PATVADPT^TIULV(.TIU,+$P(TIU0,U,2)) ;Used to get SSN. Date not important.
112 S TIUSSN=$E(TIUPNM,1)_$P($G(TIU("SSN")),"-",3)
113 I $D(^VA(200,+TIUTRAN,0)) S XQA(TIUTRAN)=""
114 Q:$D(XQA)'>9
115 S TIUMSG=$S(TIUTRAN=TIUESNR:" needs editing",1:" needs retranscription.")
116 S XQAID="TIU"_+DA
117 S XQAMSG=TIUPNM_" ("_TIUSSN_"): "_TIUTYP_TIUMSG
118 D SETUP^XQALERT
119 Q
120SENDADD(DA) ; Generates "Addendum added" alert
121 N TIU12,TIU13,TIU14,TIU15,TIU0,TIUPNM,TIUSSN,TIUTRAN,TIU,TIUTITLE,TIUDPRM
122 N XQA,XQAMSG,XQAFLG,XQADATA,XQAROU,TIUESNR,TIUDATE,TIUESNM,TIUO0,TIUO12,TIUO13
123 I '$D(TIUPRM0)!'$D(TIUPRM1) D SETPARM^TIULE
124 D ADDENDEL(DA)
125 ; Don't send if notifications not enabled
126 I '+$P(TIUPRM1,U,7) Q
127 S TIU0=$G(^TIU(8925,+DA,0))
128 ; Only send upon completion
129 Q:+$P(TIU0,U,5)'>6
130 D DOCPRM^TIULC1(+TIU0,.TIUDPRM,DA) Q:'+$P(TIUDPRM(0),U,17)
131 S TIU12=$G(^TIU(8925,+DA,12)),TIU13=$G(^(13)),TIU14=$G(^(14)),TIU15=$G(^(15))
132 S TIUO0=$G(^TIU(8925,$P(TIU0,U,6),0)),TIUO12=$G(^(12)),TIUO13=$G(^(13))
133 S TIUPNM=$E($$PTNAME^TIULC1(+$P(TIU0,U,2)),1,9)
134 S TIUESNM=$$NAME^TIULS($$PERSNAME^TIULC1(+$P(TIU12,U,2)),"LAST,FI MI")
135 S TIUTITLE=$E($$PNAME^TIULC1(+TIUO0),1,20)
136 S TIUDATE=$S(+$P(TIUO13,U):$P(TIUO13,U),1:$G(DT))
137 S TIUDATE=$$DATE^TIULS(TIUDATE)
138 D PATVADPT^TIULV(.TIU,+$P(TIU0,U,2)) ;Used to get SSN. Date not important.
139 S TIUSSN=$E(TIUPNM,1)_$P($G(TIU("SSN")),"-",3)
140 S TIUTRAN=$P(TIU13,U,2)
141 ;Expected Cosigner and Author of original document
142 S TIUECSNR=$P($G(^TIU(8925,$P(TIU0,U,6),12)),U,8),TIUESNR=$P($G(^(12)),U,4)
143 ; Not entered by Expected Signer: SET Expected Signer as recipient
144 I TIUESNR'=TIUTRAN,$D(^VA(200,+TIUESNR,0)) S XQA(TIUESNR)=""
145 ; Not entered by Expected Cosigner: SET Expected Cosigner as recipient
146 I +TIUECSNR>0,(TIUECSNR'=TIUTRAN),$D(^VA(200,+TIUECSNR,0)) S XQA(TIUECSNR)=""
147 Q:$D(XQA)'>9
148 S XQAID="TIUADD"_+DA,XQADATA=+DA_U,XQAROU="ACTADD^TIUALRT"
149 S XQAMSG=TIUPNM_" ("_TIUSSN_"): ADDENDUM to "_TIUTITLE_" of "_TIUDATE_" by "_TIUESNM
150 D SETUP^XQALERT
151 Q
152ACTADD ; Act on ADDENDUM alerts
153 N TIUQUIK,TIUDA,TIUPRM0,TIUPRM1,TIUPRM3 S TIUQUIK=1 K XQAKILL
154 S TIUDA=$P(XQADATA,U),XQAKILL=1
155 I '$D(^TIU(8925,+TIUDA,0)) D ADDENDEL(TIUDA) Q
156 W !!,"A NEW Addendum has been added to your document...",!
157 W:$L($P($G(XQX),U,3)) !,$P($G(XQX),U,3),!
158 I '+$$READ^TIUU("YAO","Do you wish to Browse the Addendum now? ","NO") Q
159 D:'$D(TIUPRM0)!'$D(TIUPRM1) SETPARM^TIULE
160 D EN^VALM("TIU BROWSE FOR CLINICIAN")
161 Q
162ALERTDEL(DA) ; Delete alerts associated with a given document
163 N XQA,XQAID,XQAKILL S XQAID="TIU"_DA
164 D DELETEA^XQALERT
165 Q
166ADDENDEL(DA) ; Delete alert associated with a Addendum added
167 N XQA,XQAID,XQAKILL S XQAID="TIUADD"_DA
168 D DELETEA^XQALERT
169 Q
170ISSIGNR(DA,USER) ; Is USER an additional signer of document DA?
171 N TIUY,TIUSDA,TIUSD0 S (TIUY,TIUSDA)=0
172 S TIUSDA=+$O(^TIU(8925.7,"AE",DA,USER,0)) G:'TIUSDA ISSIGNX
173 S TIUSD0=$G(^TIU(8925.7,TIUSDA,0)) G:'$L(TIUSD0) ISSIGNX
174 I +$P(TIUSD0,U,4)'>0 S TIUY=1
175ISSIGNX Q TIUY
Note: See TracBrowser for help on using the repository browser.