source: WorldVistAEHR/trunk/r/KERNEL-XU-A4A7-USC-XG-XLF-XNOA-XPD-XQ-XVIR-ZI-ZOSF-ZOSV-ZT-ZU-%Z-XIP--XQAB--XUC--XUR--ZIN--ZTED/XQARPRT2.m@ 1154

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

revised back to 6/30/08 version

File size: 8.7 KB
Line 
1XQARPRT2 ;DCN/BUF,JLI/OAK-OIFO - LOOKUP PROVIDER ALERTS 25 SEP 98 ;9/3/03 11:15
2 ;;8.0;KERNEL;**316**;Jul 10, 1995
3 ; Based on the original routine AEKALERT
4 Q
5EN ; OPT - interactive lists alerts from start date for a single user based on contents of alert tracking file
6 N DIR,XQADOC S DIR(0)="PO^200:EMZ" D ^DIR K DIR Q:$D(DIRUT) Q:Y'>0 S XQADOC=+Y
7EN1 ;
8 N XQASDATE,XQAWORDS,XQADISP,%ZIS,ZTRTN,ZTDESC,ZTSAVE,POP,XQAU1N4
9 D DATES Q:Y'>0
10 D WORDS() Q:$D(DIRUT) K Y
11 S %ZIS="MQ" D ^%ZIS Q:POP I $D(IO("Q")) K IO("Q") S ZTRTN="DQ1^XQARPRT2",ZTDESC="List of User Alerts",ZTSAVE("*")="" D ^%ZTLOAD W:$G(ZTSK)>0 !,"Task number is ",ZTSK K ZTSK Q
12DQ1 ;
13 N XQANWID,XQAIEN,XQADATE,XQANODE0,XQACTR,HEADERID,XQATOT
14 S HEADERID="User "_$$GET1^DIQ(200,XQADOC_",",.01)_" (DFN="_XQADOC_")"
15 D HEADER(HEADERID,1)
16 S XQAIEN=$O(^XTV(8992.1,"D",XQASDATE-.0000001)) I XQAIEN>0 S XQAIEN=$O(^(XQAIEN,0)) ; find starting point instead of having to work up through x-ref
17 I XQAIEN>0 F S XQAIEN=$O(^XTV(8992.1,"R",XQADOC,XQAIEN)) Q:XQAIEN'>0 D Q:$D(DIRUT)!(XQADATE>XQAEDATE)
18 . S XQANODE0=$G(^XTV(8992.1,XQAIEN,0)),XQADATE=$P(XQANODE0,"^",2) Q:(XQADATE<XQASDATE)!(XQADATE>XQAEDATE)
19 . D PRNTATRK(XQAIEN)
20 D HEADER(HEADERID,0)
21 K XQADATE,XQACTR,DATA,DIR,DIRUT,XQADOC,XQAIEN,XQANODE0,XQASDATE,Y
22 Q
23 ;
24WORDS(TYPE) ; Allow user to select alerts containing only certain words
25 S DIR(0)="Y",DIR("A")="Do you want to "_$S($G(TYPE)'="":"count",1:"list")_" only alerts containing specific words or phrase(s)"
26 S DIR("?",1)="You can enter one or more words or phrases which you want to be used to"
27 S DIR("?",2)="select the alerts to be listed. If you enter NO, all for the selected"
28 S DIR("?",3)="individual in the selected time period will be selected. If you enter"
29 S DIR("?",4)="YES, you will be prompted to enter a word or phrase. You will be prompted"
30 S DIR("?",5)="again, and you may enter as many word or phrase entries as you want."
31 S DIR("?",6)="Comparisons will NOT be case specific."
32 S DIR("?",7)=""
33 S DIR("?",8)="HOWEVER ALL WORDS OR PHRASES ENTERED MUST BE IN THE MESSAGE FOR AN ALERT"
34 S DIR("?")="TO BE SELECTED."
35 D ^DIR K DIR Q:Y'>0
36 ;
37 F J=1:1 W:J>1 !?7,"--- OR ---",!,"Enter another set of words or phrases that should",!,"be matched independently of the previous entr"_$S(J>2:"ies",1:"y") D Q:'$D(XQAWORDS(J))
38 . W !?10,"ALL words or phrases connected by -AND- must appear in the",!?10,"message for an alert to be selected"
39 . S DIR("?",1)="Enter a word, at least three characters long, or phrase, without regard to"
40 . S DIR("?",2)="case, that you want to be required for selection of alerts to be listed."
41 . S DIR("?",3)="If more than one word or phrase are specified, ALL of them must be in alerts"
42 . S DIR("?")="which will be listed."
43 . F I=1:1 S DIR(0)="FO^3:",DIR("A")="Enter "_$S(I=1:"a",1:"another")_" word or phrase" W:I>1 !?10,"-AND-" D ^DIR Q:(Y="")!(Y["^") S XQAWORDS(J,I)=$$UP^XLFSTR(Y)
44 . K DIR,DIRUT
45 . Q
46 ;
47 I $D(XQAWORDS)>1,$G(TYPE)="" D
48 . S DIR(0)="SO^1:Both Action and Info Only;2:Action Alerts;3:Info Only Alerts",DIR("?",1)="Select whether alerts listed should be alerts involving actions (2), info",DIR("?")="only or text only alerts (3), or both (1)."
49 . S DIR("A")="Select Alert Type(s) desired",DIR("B")=1 D ^DIR K DIR S:Y'>0 Y=1 K DIRUT S XQADISP=+Y
50 . Q
51 Q
52 ;
53USER ;USER ENTRY POINT
54 N DIR,XQADOC S XQADOC=DUZ
55 G EN1
56 ;
57DATES ;
58 S DIR(0)="DO^::EX",DIR("B")="TODAY",DIR("A")="START DATE" D ^DIR K DIR Q:Y'>0 S XQASDATE=+Y
59 I XQASDATE<$$OLDEST() W !?10,"The earliest date in the alert tracking file is ",$$FMTE^XLFDT($$OLDEST(),"D") S XQASDATE=$$OLDEST()
60 I $D(XQA1U4N) W !,"*** WARNING ***: Do not specify too many days - each entry in the Alert Tracking",!,"file must be checked for the date range specified.",! S DIR("B")=$$FMTE^XLFDT(XQASDATE)
61 S DIR(0)="DO^"_XQASDATE_":DT",DIR("A")="END DATE" D ^DIR K DIR Q:$D(DIRUT) I Y>0 S XQAEDATE=Y+.24
62 Q
63 ;
64PRNTATRK(IEN) ; Print data for an entry from the alert tracking file
65 N XQANODE0,XQADATE,Y,XQANEN,XQAMSG,XQAOPT,XQAROU,XQAMSGUC
66 S XQANODE0=$G(^XTV(8992.1,IEN,0)),XQADATE=$P(XQANODE0,"^",2)
67 S XQAMSG=$G(^XTV(8992.1,IEN,1)),XQAOPT=$P(XQAMSG,U,2),XQAROU=$P(XQAMSG,U,3,4),XQAMSG=$P(XQAMSG,U)
68 S XQAOPT=$S(XQAOPT>0:" [OPT]",1:"") S XQAROU=$S((XQAROU'="")&(XQAROU'="^"):" [ROU]",1:"") S XQAOPT=$S(XQAOPT'="":XQAOPT,XQAROU'="":XQAROU,1:" ")
69 I $D(XQAWORDS)>1 S XQAMSGUC=$$UP^XLFSTR(XQAMSG) D Q:XQAMSGUC=""
70 . N XQAMSG1,J,I S XQAMSG1=XQAMSGUC F J=0:0 S J=$O(XQAWORDS(J)) Q:J'>0 S XQAMSGUC=XQAMSG1 D Q:XQAMSGUC'=""
71 . . F I=0:0 S I=$O(XQAWORDS(J,I)) Q:I'>0 I XQAMSGUC'[XQAWORDS(J,I) S XQAMSGUC="" Q
72 . . I XQAMSGUC'="",XQADISP'=1 D
73 . . . I XQADISP=2,XQAOPT="",XQAROU="" S XQAMSGUC=""
74 . . . I XQADISP=3,(XQAOPT'="")!(XQAROU'="") S XQAMSGUC=""
75 . . . Q
76 . . Q
77 . Q
78 S XQANEN=$$FMTE^XLFDT(XQADATE,"5Z")_XQAOPT_" ien="_IEN
79 W !,$E(XQAMSG,1,IOM-1) W !?35,XQANEN S XQATOT=XQATOT+1
80 S XQACTR=XQACTR+2 I XQACTR>(IOSL-4) D Q:$D(DIRUT) S XQACTR=0
81 . I $D(ZTQUEUED) W @IOF
82 . E S DIR(0)="E" D ^DIR K DIR W !
83 . Q
84 Q
85 ;
86HEADER(XQANAME,DOFF) ; Output header at start of report XQANAME indicates who report is for
87 W:DOFF @IOF W:'DOFF ! W $S('DOFF:"Found "_XQATOT_" ",1:""),$S($D(XQAWORDS)>1:"Selected ",1:""),"Alerts for ",XQANAME,!," for dates ",$$FMTE^XLFDT(XQASDATE)," through "
88 N OUTDATE S OUTDATE=$$FMTE^XLFDT(XQAEDATE,"D") I 'DOFF,$D(XQADATE),XQADATE<XQAEDATE,'$D(ZTQUEUED) S OUTDATE=$$FMTE^XLFDT(XQADATE)
89 W OUTDATE S XQACTR=2
90 D WORDHDR
91 W ! S XQACTR=XQACTR+1
92 S XQATOT=0
93 Q
94 ;
95WORDHDR ;
96 N I,J
97 F I=0:0 S I=$O(XQAWORDS(I)) Q:I'>0 W:I>1 !?10,"--- OR ---" D
98 . F J=0:0 S J=$O(XQAWORDS(I,J)) Q:J'>0 W !?5,$S(J=1:"Selected alerts containing:",1:" and containing:"),?35,XQAWORDS(I,J) S XQACTR=XQACTR+1
99 . Q
100 Q
101DTPT ; OPT - GIVEN DATE AND PATIENT, TAKE A LOOK AT ALL USING 'D' X-REF
102 ; for one day and for 1 patient list data in alert tracking file related to patient
103 N DIR,XQANAME,XQADFN,XQA1U4N,XQASDATE,XQAEDATE,XQA1U4NP,XQAWORDS
104 S DIR(0)="PO^2:EMZ" D ^DIR Q:Y'>0 S XQANAME=$P(Y,"^",2),XQADFN=+Y,XQA1U4N=$$GET1^DIQ(2,XQADFN_",",.0905),XQA1U4NP="("_XQA1U4N_")"
105 D CHEKSCAN(XQADFN) Q:$D(DIRUT)
106 D DATES Q:Y'>0
107 D WORDS() K Y Q:$D(DIRUT)
108 S %ZIS="MQ" D ^%ZIS Q:POP I $D(IO("Q")) K IO("Q") S ZTRTN="DTPTDQ^XQARPRT2",ZTDESC="List of Patient Alerts",ZTSAVE("*")="" D ^%ZTLOAD W:$G(ZTSK)>0 !,"Task number is ",ZTSK K ZTSK Q
109DTPTDQ ;
110 N XQANWID,FOUND,ONE,ZERO,XQACTR,XQAIEN,XQATYPE,XQADATE,HEADERID,XQATOT
111 S HEADERID="Patient "_$$GET1^DIQ(2,XQADFN_",",.01)_" ("_$$GET1^DIQ(2,XQADFN_",",.0905)_")"
112 D HEADER(HEADERID,1)
113 S XQADATE=XQASDATE-0.0000001 F S XQADATE=$O(^XTV(8992.1,"D",XQADATE)) Q:(XQADATE'>0)!(XQADATE>XQAEDATE) D Q:$D(DIRUT)
114 . S XQAIEN=0 F S XQAIEN=$O(^XTV(8992.1,"D",XQADATE,XQAIEN)) Q:XQAIEN="" S ONE=$G(^XTV(8992.1,XQAIEN,1)),ZERO=$G(^(0)),XQATYPE=$E(ZERO,1,3) D Q:$D(DIRUT)
115 . . S FOUND=0
116 . . I (XQATYPE="DVB")!(XQATYPE="OR,") I $P(ZERO,U,4)=XQADFN S FOUND=1
117 . . I (XQATYPE="GMA"),$P(ONE,U)[XQANAME S FOUND=1
118 . . I (XQATYPE="TIU"),$P(ONE,U)[$E(XQANAME,1,9),$P(ONE,U)[XQA1U4NP S FOUND=1
119 . . I FOUND D PRNTATRK(XQAIEN)
120 . . Q
121 . Q
122 D HEADER(HEADERID,0)
123 Q
124 ;
125CHEKSCAN(XQADFN) ; Output a list of dates when OR, and DVB alerts are found
126 N DIR,OLDEST,X,Y,XQASDATE,XX,CNT,COL,BASECNT,I
127 W !!! S DIR(0)="Y",DIR("A")="Do you want to scan for a list of dates that have at least some alerts for this patient",DIR("A",1)="The quick scan method used here will not pick up some alerts,"
128 S DIR("A",2)="but should give an indication of when alerts might be found.",DIR("A",3)=""
129 D ^DIR K DIR Q:$D(DIRUT) I Y D
130 . K ^TMP("XQARPRT2",$J)
131 . N OLDEST S OLDEST=$$FMTE^XLFDT($$OLDEST(),"5DZ")
132 . S DIR(0)="SO^;1:1 Week ago;2:1 month ago;3:3 months ago;4:6 months ago;5:1 year ago;6:As far back as possible",DIR("A")="Select a period for starting",DIR("A",1)="The oldest entry in your Alert Tracking file is from "_OLDEST,DIR("A",2)=""
133 . D ^DIR K DIR Q:Y'>0
134 . S X=$S(Y=1:"1W",Y=2:"1M",Y=3:"3M",Y=4:"6M",Y=5:"12M",1:"1000M"),X="T-"_X D ^%DT S XQASDATE=Y
135 . F I=0:0 S I=$O(^XTV(8992.1,"C",XQADFN,I)) Q:I'>0 S ZERO=$P(^XTV(8992.1,I,0),U,2) I ZERO'<XQASDATE S ^TMP("XQARPRT2",$J,(ZERO\1))=$G(^TMP("XQARPRT2",$J,(ZERO\1)))+1
136 . ; Output date and number found in vertical columns, with (if lots of dates) three columns per screen
137 . I $D(^TMP("XQARPRT2",$J)) W !,"Dates and number of alerts found in () [may not be all of them]"
138 . ; S CNT=0,COL=1,BASECNT=0 F I=0:0 S I=$O(^TMP("XQARPRT2",$J,I)) Q:I'>0 S CNT=CNT+1,XX(CNT)=$G(XX(CNT))_$$FMTE^XLFDT(I,"5DZ")_" ("_^(I)_")"_" " I (CNT-BASECNT)>(IOSL-4) S COL=COL+1 S:'(COL#3) BASECNT=CNT S CNT=BASECNT
139 . S CNT=2 F I=0:0 S I=$O(^TMP("XQARPRT2",$J,I)) Q:I'>0 S CNT=CNT+1,XX(CNT\3)=$G(XX(CNT\3))_$$FMTE^XLFDT(I,"5DZ")_" ("_^(I)_")"_" "
140 . F I=0:0 S I=$O(XX(I)) Q:I'>0 W !,XX(I)
141 . Q
142 Q
143 ;
144VIEWTRAK ; OPT. View an entry in the Alert Tracking file in Captioned mode
145 D VIEWTRAK^XQARPRT1
146 Q
147 ;
148OLDEST() ; Returns date of oldest entry in alert tracking file
149 Q $$OLDEST^XQARPRT1()
Note: See TracBrowser for help on using the repository browser.