ORAERPT ; SPFO/AJB - Alert Enhancements Reports ;Dec 18, 2019@08:09:39
;;3.0;ORDER ENTRY/RESULTS REPORTING;**518**;Dec 17, 1997;Build 11
Q
EN ; main entry point
N DATA,DTRG,MENU,SETUP,TIME,TMP,TMP1,TOP10,TOTNTF,X,Y
D PREP^XGF W IOCUON
; S DATA="DATA",TMP="TMP" ; use tmp global for safety
S DATA=$NA(^TMP($J,"ORAERPT",$H)),TMP=$NA(^TMP($J,"ORAETMP",$H)),TMP1=$NA(^TMP($J,"ORMDIV",$H))
EN1 ; entry point for re-entering a date range
D ASKRNG I '+DTRG("Start")!('+DTRG("Stop")) W ! Q ; get date range
W @IOF,!,"Gathering notification data..."
S TIME("Start")=$$NOW^XLFDT
S TOTNTF=0 D REPORT^ORALEAPI(.DATA,DTRG("Start"),DTRG("Stop"),"") ; get data for report
S X=0 F S X=$O(@DATA@(X)) Q:'+X D
. ; set data fields, use z to put blank entries at end of lists
. N USR S USR=$P(@DATA@(X),U,2),USR=$S(USR="":"z<blank>",1:USR)
. N TTL S TTL=$P(@DATA@(X),U,3),TTL=$S(TTL="":"z<blank>",1:TTL)
. N SRV S SRV=$P(@DATA@(X),U,4),SRV=$S(SRV="":"z<blank>",1:SRV)
. N DTE S DTE=$P(@DATA@(X),U,6),DTE=$S(DTE="":"z<date unknown>",1:DTE)
. N NTF S NTF=$P(@DATA@(X),U,7),NTF=$S(NTF="":"z<blank>",1:NTF)
. N DIV S DIV=$P(@DATA@(X),U,8),DIV=$S(DIV="":"z<blank>",1:DIV)
. N LOC S LOC=$P(@DATA@(X),U,9),LOC=$S(LOC="":"z<blank>",1:LOC)
. ; set ALL index
. S @TMP@("ALL",USR,TTL,SRV,NTF,DIV,LOC)=$S($D(@TMP@("ALL",USR,TTL,SRV,NTF,DIV,LOC)):@TMP@("ALL",USR,TTL,SRV,NTF,DIV,LOC)+1,1:1)
. ; total counts by type
. S @TMP@("USR",USR)=$S($D(@TMP@("USR",USR)):@TMP@("USR",USR)+1,1:1)
. S @TMP@("TTL",TTL)=$S($D(@TMP@("TTL",TTL)):@TMP@("TTL",TTL)+1,1:1)
. S @TMP@("DTE",DTE)=$S($D(@TMP@("DTE",DTE)):@TMP@("DTE",DTE)+1,1:1)
. S @TMP@("SRV",SRV)=$S($D(@TMP@("SRV",SRV)):@TMP@("SRV",SRV)+1,1:1)
. S @TMP@("NTF",NTF)=$S($D(@TMP@("NTF",NTF)):@TMP@("NTF",NTF)+1,1:1)
. S @TMP@("DIV",DIV)=$S($D(@TMP@("DIV",DIV)):@TMP@("DIV",DIV)+1,1:1)
. S @TMP@("LOC",LOC)=$S($D(@TMP@("LOC",LOC)):@TMP@("LOC",LOC)+1,1:1)
. ; total counts by division
. S @TMP1@(DIV,"USR",USR)=$S($D(@TMP1@(DIV,"USR",USR)):@TMP1@(DIV,"USR",USR)+1,1:1)
. S @TMP1@(DIV,"TTL",TTL)=$S($D(@TMP1@(DIV,"TTL",TTL)):@TMP1@(DIV,"TTL",TTL)+1,1:1)
. S @TMP1@(DIV,"DTE",DTE)=$S($D(@TMP1@(DIV,"DTE",DTE)):@TMP1@(DIV,"DTE",DTE)+1,1:1)
. S @TMP1@(DIV,"SRV",SRV)=$S($D(@TMP1@(DIV,"SRV",SRV)):@TMP1@(DIV,"SRV",SRV)+1,1:1)
. S @TMP1@(DIV,"NTF",NTF)=$S($D(@TMP1@(DIV,"NTF",NTF)):@TMP1@(DIV,"NTF",NTF)+1,1:1)
. S @TMP1@(DIV,"DIV",DIV)=$S($D(@TMP1@(DIV,"DIV",DIV)):@TMP1@(DIV,"DIV",DIV)+1,1:1)
. S @TMP1@(DIV,"LOC",LOC)=$S($D(@TMP1@(DIV,"LOC",LOC)):@TMP1@(DIV,"LOC",LOC)+1,1:1)
. ; total # of notifications
. S @TMP@(1,"TOTAL")=$S($D(@TMP@(1,"TOTAL")):(@TMP@(1,"TOTAL")+1),1:1)
;
S TIME("Stop")=$$NOW^XLFDT,TIME("Total")=$FN($$FMDIFF^XLFDT(TIME("Start"),TIME("Stop"),2),"-") ; timing information
S TIME("Minutes")=TIME("Total")\60,TIME("Seconds")=TIME("Total")#60,TIME("Elapsed")=""
S:+TIME("Minutes") TIME("Elapsed")=TIME("Minutes")_" minute(s) "
S:+TIME("Seconds") TIME("Elapsed")=TIME("Elapsed")_TIME("Seconds")_" second(s)"
S:+TIME("Elapsed")=0 TIME("Elapsed")="<1 second" S:+TIME("Total")=0 TIME("Total")=1
;
I DTRG("Stop")[".999999" S $P(DTRG("Stop"),".",2)="2400"
W IOCUON
I +$G(@TMP@(1,"TOTAL"))=0 D G EN1 ; re-enter date range for zero results
. W !!,"No results found. Please enter another date range.",!
;
;D
;. N AVG,DIFF S DIFF=$$FMDIFF^XLFDT(DTRG("Stop"),DTRG("Start"),1) S DIFF=DIFF_$S(DIFF>1:" days",1:" day")
;. I +DIFF=0 S DIFF=$$FMDIFF^XLFDT(DTRG("Stop"),DTRG("Start"),2),DIFF=DIFF/3600_" hours" S:+DIFF=1 DIFF="1 hour" S:+DIFF=24 DIFF="1 day"
;. W !!," Elapsed Time:",?(38+$L(TOTNTF)-$S(+TIME("Elapsed"):$L(+TIME("Elapsed")),1:2)),TIME("Elapsed")
;. W !," Length of Date Range: ",?(38+$L(TOTNTF)-$L(+DIFF)),DIFF
;. W !," Notifications Searched: ",TOTNTF
;. W !," Notifications Searched/Second: ",?(38+$L(TOTNTF)-$L($FN(TOTNTF/TIME("Total"),"",0))),$FN(TOTNTF/TIME("Total"),"",0)
;. W !," OE/RR & TIU Notifications Found: ",?(38+$L(TOTNTF)-$L(@TMP@(1,"TOTAL"))),@TMP@(1,"TOTAL")
;. S AVG("TOTAL")=TOTNTF\$S(DIFF["hour":1,1:+DIFF),AVG("ORTIU")=@TMP@(1,"TOTAL")\$S(DIFF["hour":1,1:+DIFF)
;. W !," Average Notifications/Day: ",?(38+$L(TOTNTF)-$L(AVG("ORTIU"))),AVG("ORTIU"),!
;
N DIR,DIRUT,DTOUT,DUOUT,X,Y
D CRTOP10 ; pre-load top10 list for filter default values (default is highest by count per type)
F D Q:$D(DIRUT)!$D(DTOUT)!$D(DUOUT)
. S DIR(0)="SA^S:SUMMARY;T:TOP10;F:FILTERED;Q:QUIT"
. S DIR("A")="Select report type: ",DIR("B")="SUMMARY"
. W:'+TOTNTF @IOF S TOTNTF=""
. D ^DIR Q:$D(DIRUT)!$D(DTOUT)!$D(DUOUT) I Y(0)="QUIT" S DTOUT=1 Q
. I Y(0)="TOP10" S Y(0)="TOP10(0)"
. I Y(0)="FILTERED" S Y(0)="FILTERED^ORAERPT1"
. D @Y(0)
;
K @DATA,@TMP,@TMP1 D CLEAN,CLEAN^XGF ; clean up
Q
SETUP ; create entries in PROTOCOL file
; adds menus and actions based on data for filter selection
Q:+$G(SETUP) ; don't do it again if you've alredy done it
N ACTION,MENU,TYP
F TYP="FILTER","NTF","USR","TTL","SRV","DIV","LOC" D
. ; create a MENU for each type
. S MENU(TYP)=$$GIEN("ORAE MENU "_TYP_" "_$J)
. N ERR,FDA
. S FDA(101,MENU(TYP)_",",4)="M"
. S FDA(101,MENU(TYP)_",",5)=DUZ
. D UPDATE^DIE("","FDA","","ERR")
. ; create an ACTION for each type (except FILTER)
. I TYP="FILTER" Q
. S ACTION(TYP)=$$GIEN("ORAE ACTION "_TYP_" "_$J)
. S FDA(101,ACTION(TYP)_",",1)=$S(TYP="NTF":"NOTIFICATION",TYP="USR":"RECIPIENT",TYP="TTL":"TITLE",TYP="SRV":"SERVICE",TYP="DIV":"DIVISION",TYP="LOC":"LOCATION",1:"FILTER")
. S FDA(101,ACTION(TYP)_",",4)="A"
. S FDA(101,ACTION(TYP)_",",5)=DUZ
. S FDA(101.02,"+1,"_ACTION(TYP)_",",.01)=TYP
. D UPDATE^DIE("","FDA","","ERR") D
. . ; add ACTION to FILTER MENU
. . S FDA(101.01,"+1,"_MENU("FILTER")_",",.01)=ACTION(TYP)
. . D UPDATE^DIE("","FDA","","ERR")
. ; add data entries as ACTIONs
. N CNT,IEN,ITM S CNT=0,ITM="" F S ITM=$O(@TMP@(TYP,ITM)) Q:ITM="" D
. . S CNT=CNT+1
. . N ENTRY S ENTRY=$$GIEN("ORAE "_TYP_" "_$TR(ITM,"z<","<")_" "_$J)
. . S FDA(101,ENTRY_",",1)=$TR(ITM,"z<","<") ; item text
. . S FDA(101,ENTRY_",",3)=CNT ; sequence
. . S FDA(101,ENTRY_",",4)="A" ; type
. . S FDA(101,ENTRY_",",5)=DUZ ; creator
. . D UPDATE^DIE("","FDA","IEN","ERR")
. . S FDA(101.01,"+1,"_MENU(TYP)_",",.01)=ENTRY
. . S FDA(101.01,"+1,"_MENU(TYP)_",",2)=CNT
. . D UPDATE^DIE("","FDA","","ERR")
S SETUP=1
Q
GIEN(NAME) ; get an IEN from #101
N DA,DO,DIC,DLAYGO,X,Y
S (DIC,DLAYGO)=101,DIC(0)="F",X=NAME D FILE^DICN
Q +Y
SUMMARY(MDIV) ;
N CNT,SAVE,TXT,X,Y
I +$G(MDIV) S SAVE("TXT")="" D DPSUMM(.TXT) W ! D EN^XUTMDEVQ("DISPLAY^ORAERPT(.TXT)","Summary Report",.SAVE) Q
W ! I '$$READ^ORPARMG1("Y","Would you like SUMMARY data by DIVISION","NO") D SUMMARY(1) Q
N DEFAULT D SETUP ; create entries in protocol file, in case filtered option/top10 hasn't been run yet
S DEFAULT=$P(TOP10("DIV",1),U)
S MDIV=$$ASK^ORAERPT(.MDIV,"A",DEFAULT,"ORAE MENU DIV "_$J,"DIVISION: ","D HELP1^ORAEHLP") Q:MDIV'>0
I +MDIV,$P(MDIV(1),U,4)="ALL" D DPSUMM(.TXT) W ! D EN^XUTMDEVQ("DISPLAY^ORAERPT(.TXT)","Summary Report",.SAVE) Q ; don't bother if they select ALL, normal summary
;
S MDIV=0 F S MDIV=$O(MDIV(MDIV)) Q:'+MDIV D
. N DIV S DIV=$P(^ORD(101,$P(MDIV(MDIV),U,2),0),U,2) Q:DIV="" ; set to data from File #101
. D DPSUMM(.TXT,DIV)
W ! D EN^XUTMDEVQ("DISPLAY^ORAERPT(.TXT)","Summary Report",.SAVE)
Q
DPSUMM(TXT,DIV) ; setup summary data to display
N CNT,LOC,X,Y
S CNT=+$O(TXT(""),-1) ; get last line number
S CNT=CNT+1,TXT(CNT)=$$CJ^XLFSTR("Notification Data [SUMMARY"_$S($G(DIV)="":"]",1:" for "_DIV_"]"),IOM),CNT=CNT+1,TXT(CNT)=""
S CNT=CNT+1,TXT(CNT)=$$CJ^XLFSTR($$FMTE^XLFDT(DTRG("Start"))_" to "_$$FMTE^XLFDT(DTRG("Stop")),IOM),CNT=CNT+1,TXT(CNT)=""
S LOC=$S(+$D(DIV):TMP1,1:TMP) S:$G(DIV)'="" $P(LOC,")")=$P(LOC,")")_",DIV" ; set where to look at the data
F X="NTF","USR","TTL","SRV","DIV","LOC" D
. S Y=$S(X="NTF":"Notification",X="USR":"Recipient",X="TTL":"Title",X="SRV":"Service",X="DIV":"Division",X="LOC":"Location")
. S CNT=CNT+1,TXT(CNT)=Y,TXT(CNT)=$$SETSTR^VALM1("Total",TXT(CNT),34,5),TXT(CNT)=$$SETSTR^VALM1(Y,TXT(CNT),40,$L(Y)),TXT(CNT)=$$SETSTR^VALM1("Total",TXT(CNT),75,5)
. S $P(TXT,"=",IOM-1)="",$P(TXT,"=",39)=" ",CNT=CNT+1,TXT(CNT)=TXT
. N I S I=0,Y="" F S Y=$O(@LOC@(X,Y)) Q:Y="" D
. . S I=I+1
. . I I#2'=0 S CNT=CNT+1,TXT(CNT)=$S($E(Y)="z":$E(Y,2,31),1:$E(Y,1,30)),TXT(CNT)=$$SETSTR^VALM1(@LOC@(X,Y),TXT(CNT),(39-$L(@LOC@(X,Y))),$L(@LOC@(X,Y)))
. . I I#2=0 S TXT(CNT)=$$SETSTR^VALM1($S($E(Y)="z":$E(Y,2,31),1:$E(Y,1,30)),TXT(CNT),40,$L(Y)),TXT(CNT)=$$SETSTR^VALM1(@LOC@(X,Y),TXT(CNT),(IOM-$L(@LOC@(X,Y))),$L(@LOC@(X,Y)))
. S CNT=CNT+1,TXT(CNT)=""
S CNT=CNT+1,TXT(CNT)="Total Notifications: "_$S($G(DIV)="":@LOC@(1,"TOTAL"),1:@LOC@("DIV",DIV)),CNT=CNT+1,TXT(CNT)=" "
Q
TOP10(MDIV) ;
N CNT,SAVE,TXT,X,Y
I +$G(MDIV) S SAVE("TXT")="" D DPTOP10(.TXT) W ! D EN^XUTMDEVQ("DISPLAY^ORAERPT(.TXT)","Top 10 Report",.SAVE) Q
W ! I '$$READ^ORPARMG1("Y","Would you like TOP 10 data by DIVISION","NO") D TOP10(1) Q
N DEFAULT D SETUP ; create entries in protocol file, in case the filtered option hasn't been run yet
S DEFAULT=$P(TOP10("DIV",1),U)
S MDIV=$$ASK^ORAERPT(.MDIV,"A",DEFAULT,"ORAE MENU DIV "_$J,"DIVISION: ","D HELP1^ORAEHLP") Q:MDIV'>0
I +MDIV,$P(MDIV(1),U,4)="ALL" D DPTOP10(.TXT) W ! D EN^XUTMDEVQ("DISPLAY^ORAERPT(.TXT)","Top 10 Report",.SAVE) Q ; don't bother if they select ALL, just do the normal TOP 10
;
S MDIV=0 F S MDIV=$O(MDIV(MDIV)) Q:'+MDIV D
. N DIV S DIV=$P(^ORD(101,$P(MDIV(MDIV),U,2),0),U,2) Q:DIV="" ; set to data from File #101
. N TOP10,X,Y F X="NTF","USR","TTL","SRV","DIV","LOC" F Y=1:1:10 S TOP10(X,Y)=$$SETSTR^VALM1(" ","",20,1) ; set blank list
. N CNT,ITM,TYP S TYP="" F S TYP=$O(@TMP1@(DIV,TYP)) Q:TYP="" S ITM="" F S ITM=$O(@TMP1@(DIV,TYP,ITM)) Q:ITM="" D
. . S TOP10("TMP",TYP,@TMP1@(DIV,TYP,ITM),ITM)=""
. F X="NTF","USR","TTL","SRV","DIV","LOC" S CNT=0,Y="" F S Y=$O(TOP10("TMP",X,Y),-1) Q:'+Y!(CNT'<10) S USR="" F S USR=$O(TOP10("TMP",X,Y,USR)) Q:USR=""!(CNT'<10) D
. . S CNT=CNT+1,TOP10(X,CNT)=USR_U_Y ; only save 10 at most of descending values
. K TOP10("TMP")
. D DPTOP10(.TXT,DIV)
. S CNT=$O(TXT(""),-1) S CNT=CNT+1,TXT(CNT)=" ",CNT=CNT+1,TXT(CNT)=" " ; add blank lines
S SAVE("TXT")="" W ! D EN^XUTMDEVQ("DISPLAY^ORAERPT(.TXT)","Top 10 Report",.SAVE)
Q
CRTOP10 ; create the default top 10 list, highest values by type are default selections for the filtered search
N CNT,ITM,TYP,USR,X,Y
F X="NTF","USR","TTL","SRV","DIV","LOC" F Y=1:1:10 S TOP10(X,Y)=" " ; set blank list
S TYP="ALL" F S TYP=$O(@TMP@(TYP)) Q:TYP="" S ITM="" F S ITM=$O(@TMP@(TYP,ITM)) Q:ITM="" D
. S TOP10("TMP",TYP,@TMP@(TYP,ITM),ITM)="" ; put all types in order, temporary list
F X="NTF","USR","TTL","SRV","DIV","LOC" S CNT=0,Y="" F S Y=$O(TOP10("TMP",X,Y),-1) Q:'+Y!(CNT'<10) S USR="" F S USR=$O(TOP10("TMP",X,Y,USR)) Q:USR=""!(CNT'<10) D
. S CNT=CNT+1,TOP10(X,CNT)=USR_U_Y ; only save 10 at most of descending values
K TOP10("TMP") ; kill temporary list
Q
DPTOP10(TXT,DIV) ; setup the top 10 list to display
N CNT,X,Y
S CNT=+$O(TXT(""),-1) ; get last line number
S CNT=CNT+1,TXT(CNT)=$$CJ^XLFSTR("Top 10"_$S($D(DIV):" ["_DIV_"]",1:""),IOM),CNT=CNT+1,TXT(CNT)=" "
;S CNT=CNT+1,TXT(CNT)=$$CJ^XLFSTR("[Descending Order]",IOM),CNT=CNT+1,TXT(CNT)=""
F X=1:1:3 F Y=1:1:10 D I Y=10 S CNT=CNT+1,TXT(CNT)=""
. I Y=1 S CNT=CNT+1,TXT(CNT)=$S(X=1:"Notification",X=2:"Title",X=3:"Division"),TXT(CNT)=$$SETSTR^VALM1("Total",TXT(CNT),34,5)
. I S TXT=$S(X=1:"Recipient",X=2:"Service",X=3:"Location"),TXT(CNT)=$$SETSTR^VALM1(TXT,TXT(CNT),40,$L(TXT)),TXT(CNT)=$$SETSTR^VALM1("Total",TXT(CNT),75,5)
. I S CNT=CNT+1,$P(TXT(CNT),"=",IOM-1)="",$P(TXT(CNT),"=",39)=" "
. S CNT=CNT+1
. S TXT=$NA(TOP10($S(X=1:"NTF",X=2:"TTL",X=3:"DIV"),Y))
. S TXT(CNT)=$P(@TXT,U),TXT(CNT)=$S($E(TXT(CNT))="z":$E(TXT(CNT),2,32),1:TXT(CNT))
. S TXT=$P(@TXT,U,2),TXT(CNT)=$$SETSTR^VALM1(TXT,TXT(CNT),(39-$L(TXT)),$L(TXT))
. S TXT=$NA(TOP10($S(X=1:"USR",X=2:"SRV",X=3:"LOC"),Y))
. S TXT(CNT)=$$SETSTR^VALM1($S($E($P(@TXT,U))="z":$E($P(@TXT,U),2,32),1:$P(@TXT,U)),TXT(CNT),40,$L($P(@TXT,U)))
. S TXT(CNT)=$$SETSTR^VALM1($P(@TXT,U,2),TXT(CNT),(IOM-$L($P(@TXT,U,2))),$L($P(@TXT,U,2)))
;S CNT=CNT+1,TXT(CNT)="Total Notifications: "_@TMP1@(DIV,"DIV",DIV)
S CNT=CNT+1,TXT(CNT)="Total Notifications: "_$S($G(DIV)="":@TMP@(1,"TOTAL"),1:@TMP1@(DIV,"DIV",DIV))
Q
ASKRNG ; ask user for the date range
W "Enter the desired date range for the notification search.",!!
W "Search times typically vary from 30-90 seconds for each day searched.",!
S (DTRG("Start"),DTRG("Stop"))=""
D I '+DTRG("Start")!('+DTRG("Stop")) W ! Q
. N %DT,DIR,X,Y S %DT(0)=-$$DT^XLFDT_".24",%DT="AETX",%DT("A")="Select Beginning DATE: ",%DT("B")=$$FMTE^XLFDT($$FMADD^XLFDT(DT,-30))
. D ^%DT K %DT Q:Y<0 S DTRG("Start")=Y
. S %DT(0)=DTRG("Start"),%DT="AETX",%DT("A")=" Ending DATE: ",%DT("B")=$$FMTE^XLFDT(DT)
. W ! D ^%DT Q:Y<0 S DTRG("Stop")=Y S:$P(DTRG("Stop"),".",2)="" $P(DTRG("Stop"),".",2)="999999"
Q
CLEAN ; S DATA=$NA(^TMP($J,"ORAERPT",$H)),TMP=$NA(^TMP($J,"ORAETMP",$H))
N DA,DIK,NAME,IEN,X,Y
S NAME="ORAE" F S NAME=$O(^ORD(101,"B",NAME)) Q:NAME'["ORAE" S IEN=0 F S IEN=$O(^ORD(101,"B",NAME,IEN)) Q:'+IEN D
. Q:NAME'[$J
. S DA=IEN,DIK="^ORD(101," D ^DIK
Q
ASK(Y,PARAM,DEFAULT,MENU,PROMPT,HELP) ;
N I,X,XQORM
S XQORM=+$O(^ORD(101,"B",MENU,0))_";ORD(101,"
I '+XQORM Q "-1^Menu entry not found."
S XQORM(0)=$G(PARAM),XQORM("A")=PROMPT,XQORM("B")=DEFAULT,XQORM("?")=$S($G(HELP)="":"D HELP^ORAEHLP",1:HELP)
D EN^XQORM
Q $G(Y)
DISPLAY(OUTPUT) ;
N END,Y S (END,Y)=0
D:$E(IOST,1,2)="C-" HDR2
F S Y=$O(OUTPUT(Y)) Q:'+Y!(+END) D
. D HDR1:$Y+3>IOSL Q:+END W OUTPUT(Y),!
Q:+END
I $E(IOST,1,2)="C-",IOSL'>24 F Q:$Y+3>IOSL W !
R:$E(IOST,1,2)="C-" !,"Report Complete. Press <Enter> to continue ",X:DTIME
Q
HDR1 ;
I $E(IOST,1,2)="C-" D
. R !,"Press <ENTER> to continue or '^' to exit ",X:DTIME S END='$T!(X=U)
Q:+END
HDR2 ;
I $E(IOST,1,2)="C-" D
. W @IOF
. I +$D(HDR) S X=0 F S X=$O(HDR(X)) Q:'+X W HDR(X),!
W IOUOFF
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HORAERPT 14286 printed Dec 13, 2024@02:26:54 Page 2
ORAERPT ; SPFO/AJB - Alert Enhancements Reports ;Dec 18, 2019@08:09:39
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**518**;Dec 17, 1997;Build 11
+2 QUIT
EN ; main entry point
+1 NEW DATA,DTRG,MENU,SETUP,TIME,TMP,TMP1,TOP10,TOTNTF,X,Y
+2 DO PREP^XGF
WRITE IOCUON
+3 ; S DATA="DATA",TMP="TMP" ; use tmp global for safety
+4 SET DATA=$NAME(^TMP($JOB,"ORAERPT",$HOROLOG))
SET TMP=$NAME(^TMP($JOB,"ORAETMP",$HOROLOG))
SET TMP1=$NAME(^TMP($JOB,"ORMDIV",$HOROLOG))
EN1 ; entry point for re-entering a date range
+1 ; get date range
DO ASKRNG
IF '+DTRG("Start")!('+DTRG("Stop"))
WRITE !
QUIT
+2 WRITE @IOF,!,"Gathering notification data..."
+3 SET TIME("Start")=$$NOW^XLFDT
+4 ; get data for report
SET TOTNTF=0
DO REPORT^ORALEAPI(.DATA,DTRG("Start"),DTRG("Stop"),"")
+5 SET X=0
FOR
SET X=$ORDER(@DATA@(X))
if '+X
QUIT
Begin DoDot:1
+6 ; set data fields, use z to put blank entries at end of lists
+7 NEW USR
SET USR=$PIECE(@DATA@(X),U,2)
SET USR=$SELECT(USR="":"z<blank>",1:USR)
+8 NEW TTL
SET TTL=$PIECE(@DATA@(X),U,3)
SET TTL=$SELECT(TTL="":"z<blank>",1:TTL)
+9 NEW SRV
SET SRV=$PIECE(@DATA@(X),U,4)
SET SRV=$SELECT(SRV="":"z<blank>",1:SRV)
+10 NEW DTE
SET DTE=$PIECE(@DATA@(X),U,6)
SET DTE=$SELECT(DTE="":"z<date unknown>",1:DTE)
+11 NEW NTF
SET NTF=$PIECE(@DATA@(X),U,7)
SET NTF=$SELECT(NTF="":"z<blank>",1:NTF)
+12 NEW DIV
SET DIV=$PIECE(@DATA@(X),U,8)
SET DIV=$SELECT(DIV="":"z<blank>",1:DIV)
+13 NEW LOC
SET LOC=$PIECE(@DATA@(X),U,9)
SET LOC=$SELECT(LOC="":"z<blank>",1:LOC)
+14 ; set ALL index
+15 SET @TMP@("ALL",USR,TTL,SRV,NTF,DIV,LOC)=$SELECT($DATA(@TMP@("ALL",USR,TTL,SRV,NTF,DIV,LOC)):@TMP@("ALL",USR,TTL,SRV,NTF,DIV,LOC)+1,1:1)
+16 ; total counts by type
+17 SET @TMP@("USR",USR)=$SELECT($DATA(@TMP@("USR",USR)):@TMP@("USR",USR)+1,1:1)
+18 SET @TMP@("TTL",TTL)=$SELECT($DATA(@TMP@("TTL",TTL)):@TMP@("TTL",TTL)+1,1:1)
+19 SET @TMP@("DTE",DTE)=$SELECT($DATA(@TMP@("DTE",DTE)):@TMP@("DTE",DTE)+1,1:1)
+20 SET @TMP@("SRV",SRV)=$SELECT($DATA(@TMP@("SRV",SRV)):@TMP@("SRV",SRV)+1,1:1)
+21 SET @TMP@("NTF",NTF)=$SELECT($DATA(@TMP@("NTF",NTF)):@TMP@("NTF",NTF)+1,1:1)
+22 SET @TMP@("DIV",DIV)=$SELECT($DATA(@TMP@("DIV",DIV)):@TMP@("DIV",DIV)+1,1:1)
+23 SET @TMP@("LOC",LOC)=$SELECT($DATA(@TMP@("LOC",LOC)):@TMP@("LOC",LOC)+1,1:1)
+24 ; total counts by division
+25 SET @TMP1@(DIV,"USR",USR)=$SELECT($DATA(@TMP1@(DIV,"USR",USR)):@TMP1@(DIV,"USR",USR)+1,1:1)
+26 SET @TMP1@(DIV,"TTL",TTL)=$SELECT($DATA(@TMP1@(DIV,"TTL",TTL)):@TMP1@(DIV,"TTL",TTL)+1,1:1)
+27 SET @TMP1@(DIV,"DTE",DTE)=$SELECT($DATA(@TMP1@(DIV,"DTE",DTE)):@TMP1@(DIV,"DTE",DTE)+1,1:1)
+28 SET @TMP1@(DIV,"SRV",SRV)=$SELECT($DATA(@TMP1@(DIV,"SRV",SRV)):@TMP1@(DIV,"SRV",SRV)+1,1:1)
+29 SET @TMP1@(DIV,"NTF",NTF)=$SELECT($DATA(@TMP1@(DIV,"NTF",NTF)):@TMP1@(DIV,"NTF",NTF)+1,1:1)
+30 SET @TMP1@(DIV,"DIV",DIV)=$SELECT($DATA(@TMP1@(DIV,"DIV",DIV)):@TMP1@(DIV,"DIV",DIV)+1,1:1)
+31 SET @TMP1@(DIV,"LOC",LOC)=$SELECT($DATA(@TMP1@(DIV,"LOC",LOC)):@TMP1@(DIV,"LOC",LOC)+1,1:1)
+32 ; total # of notifications
+33 SET @TMP@(1,"TOTAL")=$SELECT($DATA(@TMP@(1,"TOTAL")):(@TMP@(1,"TOTAL")+1),1:1)
End DoDot:1
+34 ;
+35 ; timing information
SET TIME("Stop")=$$NOW^XLFDT
SET TIME("Total")=$FNUMBER($$FMDIFF^XLFDT(TIME("Start"),TIME("Stop"),2),"-")
+36 SET TIME("Minutes")=TIME("Total")\60
SET TIME("Seconds")=TIME("Total")#60
SET TIME("Elapsed")=""
+37 if +TIME("Minutes")
SET TIME("Elapsed")=TIME("Minutes")_" minute(s) "
+38 if +TIME("Seconds")
SET TIME("Elapsed")=TIME("Elapsed")_TIME("Seconds")_" second(s)"
+39 if +TIME("Elapsed")=0
SET TIME("Elapsed")="<1 second"
if +TIME("Total")=0
SET TIME("Total")=1
+40 ;
+41 IF DTRG("Stop")[".999999"
SET $PIECE(DTRG("Stop"),".",2)="2400"
+42 WRITE IOCUON
+43 ; re-enter date range for zero results
IF +$GET(@TMP@(1,"TOTAL"))=0
Begin DoDot:1
+44 WRITE !!,"No results found. Please enter another date range.",!
End DoDot:1
GOTO EN1
+45 ;
+46 ;D
+47 ;. N AVG,DIFF S DIFF=$$FMDIFF^XLFDT(DTRG("Stop"),DTRG("Start"),1) S DIFF=DIFF_$S(DIFF>1:" days",1:" day")
+48 ;. I +DIFF=0 S DIFF=$$FMDIFF^XLFDT(DTRG("Stop"),DTRG("Start"),2),DIFF=DIFF/3600_" hours" S:+DIFF=1 DIFF="1 hour" S:+DIFF=24 DIFF="1 day"
+49 ;. W !!," Elapsed Time:",?(38+$L(TOTNTF)-$S(+TIME("Elapsed"):$L(+TIME("Elapsed")),1:2)),TIME("Elapsed")
+50 ;. W !," Length of Date Range: ",?(38+$L(TOTNTF)-$L(+DIFF)),DIFF
+51 ;. W !," Notifications Searched: ",TOTNTF
+52 ;. W !," Notifications Searched/Second: ",?(38+$L(TOTNTF)-$L($FN(TOTNTF/TIME("Total"),"",0))),$FN(TOTNTF/TIME("Total"),"",0)
+53 ;. W !," OE/RR & TIU Notifications Found: ",?(38+$L(TOTNTF)-$L(@TMP@(1,"TOTAL"))),@TMP@(1,"TOTAL")
+54 ;. S AVG("TOTAL")=TOTNTF\$S(DIFF["hour":1,1:+DIFF),AVG("ORTIU")=@TMP@(1,"TOTAL")\$S(DIFF["hour":1,1:+DIFF)
+55 ;. W !," Average Notifications/Day: ",?(38+$L(TOTNTF)-$L(AVG("ORTIU"))),AVG("ORTIU"),!
+56 ;
+57 NEW DIR,DIRUT,DTOUT,DUOUT,X,Y
+58 ; pre-load top10 list for filter default values (default is highest by count per type)
DO CRTOP10
+59 FOR
Begin DoDot:1
+60 SET DIR(0)="SA^S:SUMMARY;T:TOP10;F:FILTERED;Q:QUIT"
+61 SET DIR("A")="Select report type: "
SET DIR("B")="SUMMARY"
+62 if '+TOTNTF
WRITE @IOF
SET TOTNTF=""
+63 DO ^DIR
if $DATA(DIRUT)!$DATA(DTOUT)!$DATA(DUOUT)
QUIT
IF Y(0)="QUIT"
SET DTOUT=1
QUIT
+64 IF Y(0)="TOP10"
SET Y(0)="TOP10(0)"
+65 IF Y(0)="FILTERED"
SET Y(0)="FILTERED^ORAERPT1"
+66 DO @Y(0)
End DoDot:1
if $DATA(DIRUT)!$DATA(DTOUT)!$DATA(DUOUT)
QUIT
+67 ;
+68 ; clean up
KILL @DATA,@TMP,@TMP1
DO CLEAN
DO CLEAN^XGF
+69 QUIT
SETUP ; create entries in PROTOCOL file
+1 ; adds menus and actions based on data for filter selection
+2 ; don't do it again if you've alredy done it
if +$GET(SETUP)
QUIT
+3 NEW ACTION,MENU,TYP
+4 FOR TYP="FILTER","NTF","USR","TTL","SRV","DIV","LOC"
Begin DoDot:1
+5 ; create a MENU for each type
+6 SET MENU(TYP)=$$GIEN("ORAE MENU "_TYP_" "_$JOB)
+7 NEW ERR,FDA
+8 SET FDA(101,MENU(TYP)_",",4)="M"
+9 SET FDA(101,MENU(TYP)_",",5)=DUZ
+10 DO UPDATE^DIE("","FDA","","ERR")
+11 ; create an ACTION for each type (except FILTER)
+12 IF TYP="FILTER"
QUIT
+13 SET ACTION(TYP)=$$GIEN("ORAE ACTION "_TYP_" "_$JOB)
+14 SET FDA(101,ACTION(TYP)_",",1)=$SELECT(TYP="NTF":"NOTIFICATION",TYP="USR":"RECIPIENT",TYP="TTL":"TITLE",TYP="SRV":"SERVICE",TYP="DIV":"DIVISION",TYP="LOC":"LOCATION",1:"FILTER")
+15 SET FDA(101,ACTION(TYP)_",",4)="A"
+16 SET FDA(101,ACTION(TYP)_",",5)=DUZ
+17 SET FDA(101.02,"+1,"_ACTION(TYP)_",",.01)=TYP
+18 DO UPDATE^DIE("","FDA","","ERR")
Begin DoDot:2
+19 ; add ACTION to FILTER MENU
+20 SET FDA(101.01,"+1,"_MENU("FILTER")_",",.01)=ACTION(TYP)
+21 DO UPDATE^DIE("","FDA","","ERR")
End DoDot:2
+22 ; add data entries as ACTIONs
+23 NEW CNT,IEN,ITM
SET CNT=0
SET ITM=""
FOR
SET ITM=$ORDER(@TMP@(TYP,ITM))
if ITM=""
QUIT
Begin DoDot:2
+24 SET CNT=CNT+1
+25 NEW ENTRY
SET ENTRY=$$GIEN("ORAE "_TYP_" "_$TRANSLATE(ITM,"z<","<")_" "_$JOB)
+26 ; item text
SET FDA(101,ENTRY_",",1)=$TRANSLATE(ITM,"z<","<")
+27 ; sequence
SET FDA(101,ENTRY_",",3)=CNT
+28 ; type
SET FDA(101,ENTRY_",",4)="A"
+29 ; creator
SET FDA(101,ENTRY_",",5)=DUZ
+30 DO UPDATE^DIE("","FDA","IEN","ERR")
+31 SET FDA(101.01,"+1,"_MENU(TYP)_",",.01)=ENTRY
+32 SET FDA(101.01,"+1,"_MENU(TYP)_",",2)=CNT
+33 DO UPDATE^DIE("","FDA","","ERR")
End DoDot:2
End DoDot:1
+34 SET SETUP=1
+35 QUIT
GIEN(NAME) ; get an IEN from #101
+1 NEW DA,DO,DIC,DLAYGO,X,Y
+2 SET (DIC,DLAYGO)=101
SET DIC(0)="F"
SET X=NAME
DO FILE^DICN
+3 QUIT +Y
SUMMARY(MDIV) ;
+1 NEW CNT,SAVE,TXT,X,Y
+2 IF +$GET(MDIV)
SET SAVE("TXT")=""
DO DPSUMM(.TXT)
WRITE !
DO EN^XUTMDEVQ("DISPLAY^ORAERPT(.TXT)","Summary Report",.SAVE)
QUIT
+3 WRITE !
IF '$$READ^ORPARMG1("Y","Would you like SUMMARY data by DIVISION","NO")
DO SUMMARY(1)
QUIT
+4 ; create entries in protocol file, in case filtered option/top10 hasn't been run yet
NEW DEFAULT
DO SETUP
+5 SET DEFAULT=$PIECE(TOP10("DIV",1),U)
+6 SET MDIV=$$ASK^ORAERPT(.MDIV,"A",DEFAULT,"ORAE MENU DIV "_$JOB,"DIVISION: ","D HELP1^ORAEHLP")
if MDIV'>0
QUIT
+7 ; don't bother if they select ALL, normal summary
IF +MDIV
IF $PIECE(MDIV(1),U,4)="ALL"
DO DPSUMM(.TXT)
WRITE !
DO EN^XUTMDEVQ("DISPLAY^ORAERPT(.TXT)","Summary Report",.SAVE)
QUIT
+8 ;
+9 SET MDIV=0
FOR
SET MDIV=$ORDER(MDIV(MDIV))
if '+MDIV
QUIT
Begin DoDot:1
+10 ; set to data from File #101
NEW DIV
SET DIV=$PIECE(^ORD(101,$PIECE(MDIV(MDIV),U,2),0),U,2)
if DIV=""
QUIT
+11 DO DPSUMM(.TXT,DIV)
End DoDot:1
+12 WRITE !
DO EN^XUTMDEVQ("DISPLAY^ORAERPT(.TXT)","Summary Report",.SAVE)
+13 QUIT
DPSUMM(TXT,DIV) ; setup summary data to display
+1 NEW CNT,LOC,X,Y
+2 ; get last line number
SET CNT=+$ORDER(TXT(""),-1)
+3 SET CNT=CNT+1
SET TXT(CNT)=$$CJ^XLFSTR("Notification Data [SUMMARY"_$SELECT($GET(DIV)="":"]",1:" for "_DIV_"]"),IOM)
SET CNT=CNT+1
SET TXT(CNT)=""
+4 SET CNT=CNT+1
SET TXT(CNT)=$$CJ^XLFSTR($$FMTE^XLFDT(DTRG("Start"))_" to "_$$FMTE^XLFDT(DTRG("Stop")),IOM)
SET CNT=CNT+1
SET TXT(CNT)=""
+5 ; set where to look at the data
SET LOC=$SELECT(+$DATA(DIV):TMP1,1:TMP)
if $GET(DIV)'=""
SET $PIECE(LOC,")")=$PIECE(LOC,")")_",DIV"
+6 FOR X="NTF","USR","TTL","SRV","DIV","LOC"
Begin DoDot:1
+7 SET Y=$SELECT(X="NTF":"Notification",X="USR":"Recipient",X="TTL":"Title",X="SRV":"Service",X="DIV":"Division",X="LOC":"Location")
+8 SET CNT=CNT+1
SET TXT(CNT)=Y
SET TXT(CNT)=$$SETSTR^VALM1("Total",TXT(CNT),34,5)
SET TXT(CNT)=$$SETSTR^VALM1(Y,TXT(CNT),40,$LENGTH(Y))
SET TXT(CNT)=$$SETSTR^VALM1("Total",TXT(CNT),75,5)
+9 SET $PIECE(TXT,"=",IOM-1)=""
SET $PIECE(TXT,"=",39)=" "
SET CNT=CNT+1
SET TXT(CNT)=TXT
+10 NEW I
SET I=0
SET Y=""
FOR
SET Y=$ORDER(@LOC@(X,Y))
if Y=""
QUIT
Begin DoDot:2
+11 SET I=I+1
+12 IF I#2'=0
SET CNT=CNT+1
SET TXT(CNT)=$SELECT($EXTRACT(Y)="z":$EXTRACT(Y,2,31),1:$EXTRACT(Y,1,30))
SET TXT(CNT)=$$SETSTR^VALM1(@LOC@(X,Y),TXT(CNT),(39-$LENGTH(@LOC@(X,Y))),$LENGTH(@LOC@(X,Y)))
+13 IF I#2=0
SET TXT(CNT)=$$SETSTR^VALM1($SELECT($EXTRACT(Y)="z":$EXTRACT(Y,2,31),1:$EXTRACT(Y,1,30)),TXT(CNT),40,$LENGTH(Y))
SET TXT(CNT)=$$SETSTR^VALM1(@LOC@(X,Y),TXT(CNT),(IOM-$LENGTH(@LOC@(X,Y))),$LENGTH(@LOC@(X,Y)))
End DoDot:2
+14 SET CNT=CNT+1
SET TXT(CNT)=""
End DoDot:1
+15 SET CNT=CNT+1
SET TXT(CNT)="Total Notifications: "_$SELECT($GET(DIV)="":@LOC@(1,"TOTAL"),1:@LOC@("DIV",DIV))
SET CNT=CNT+1
SET TXT(CNT)=" "
+16 QUIT
TOP10(MDIV) ;
+1 NEW CNT,SAVE,TXT,X,Y
+2 IF +$GET(MDIV)
SET SAVE("TXT")=""
DO DPTOP10(.TXT)
WRITE !
DO EN^XUTMDEVQ("DISPLAY^ORAERPT(.TXT)","Top 10 Report",.SAVE)
QUIT
+3 WRITE !
IF '$$READ^ORPARMG1("Y","Would you like TOP 10 data by DIVISION","NO")
DO TOP10(1)
QUIT
+4 ; create entries in protocol file, in case the filtered option hasn't been run yet
NEW DEFAULT
DO SETUP
+5 SET DEFAULT=$PIECE(TOP10("DIV",1),U)
+6 SET MDIV=$$ASK^ORAERPT(.MDIV,"A",DEFAULT,"ORAE MENU DIV "_$JOB,"DIVISION: ","D HELP1^ORAEHLP")
if MDIV'>0
QUIT
+7 ; don't bother if they select ALL, just do the normal TOP 10
IF +MDIV
IF $PIECE(MDIV(1),U,4)="ALL"
DO DPTOP10(.TXT)
WRITE !
DO EN^XUTMDEVQ("DISPLAY^ORAERPT(.TXT)","Top 10 Report",.SAVE)
QUIT
+8 ;
+9 SET MDIV=0
FOR
SET MDIV=$ORDER(MDIV(MDIV))
if '+MDIV
QUIT
Begin DoDot:1
+10 ; set to data from File #101
NEW DIV
SET DIV=$PIECE(^ORD(101,$PIECE(MDIV(MDIV),U,2),0),U,2)
if DIV=""
QUIT
+11 ; set blank list
NEW TOP10,X,Y
FOR X="NTF","USR","TTL","SRV","DIV","LOC"
FOR Y=1:1:10
SET TOP10(X,Y)=$$SETSTR^VALM1(" ","",20,1)
+12 NEW CNT,ITM,TYP
SET TYP=""
FOR
SET TYP=$ORDER(@TMP1@(DIV,TYP))
if TYP=""
QUIT
SET ITM=""
FOR
SET ITM=$ORDER(@TMP1@(DIV,TYP,ITM))
if ITM=""
QUIT
Begin DoDot:2
+13 SET TOP10("TMP",TYP,@TMP1@(DIV,TYP,ITM),ITM)=""
End DoDot:2
+14 FOR X="NTF","USR","TTL","SRV","DIV","LOC"
SET CNT=0
SET Y=""
FOR
SET Y=$ORDER(TOP10("TMP",X,Y),-1)
if '+Y!(CNT'<10)
QUIT
SET USR=""
FOR
SET USR=$ORDER(TOP10("TMP",X,Y,USR))
if USR=""!(CNT'<10)
QUIT
Begin DoDot:2
+15 ; only save 10 at most of descending values
SET CNT=CNT+1
SET TOP10(X,CNT)=USR_U_Y
End DoDot:2
+16 KILL TOP10("TMP")
+17 DO DPTOP10(.TXT,DIV)
+18 ; add blank lines
SET CNT=$ORDER(TXT(""),-1)
SET CNT=CNT+1
SET TXT(CNT)=" "
SET CNT=CNT+1
SET TXT(CNT)=" "
End DoDot:1
+19 SET SAVE("TXT")=""
WRITE !
DO EN^XUTMDEVQ("DISPLAY^ORAERPT(.TXT)","Top 10 Report",.SAVE)
+20 QUIT
CRTOP10 ; create the default top 10 list, highest values by type are default selections for the filtered search
+1 NEW CNT,ITM,TYP,USR,X,Y
+2 ; set blank list
FOR X="NTF","USR","TTL","SRV","DIV","LOC"
FOR Y=1:1:10
SET TOP10(X,Y)=" "
+3 SET TYP="ALL"
FOR
SET TYP=$ORDER(@TMP@(TYP))
if TYP=""
QUIT
SET ITM=""
FOR
SET ITM=$ORDER(@TMP@(TYP,ITM))
if ITM=""
QUIT
Begin DoDot:1
+4 ; put all types in order, temporary list
SET TOP10("TMP",TYP,@TMP@(TYP,ITM),ITM)=""
End DoDot:1
+5 FOR X="NTF","USR","TTL","SRV","DIV","LOC"
SET CNT=0
SET Y=""
FOR
SET Y=$ORDER(TOP10("TMP",X,Y),-1)
if '+Y!(CNT'<10)
QUIT
SET USR=""
FOR
SET USR=$ORDER(TOP10("TMP",X,Y,USR))
if USR=""!(CNT'<10)
QUIT
Begin DoDot:1
+6 ; only save 10 at most of descending values
SET CNT=CNT+1
SET TOP10(X,CNT)=USR_U_Y
End DoDot:1
+7 ; kill temporary list
KILL TOP10("TMP")
+8 QUIT
DPTOP10(TXT,DIV) ; setup the top 10 list to display
+1 NEW CNT,X,Y
+2 ; get last line number
SET CNT=+$ORDER(TXT(""),-1)
+3 SET CNT=CNT+1
SET TXT(CNT)=$$CJ^XLFSTR("Top 10"_$SELECT($DATA(DIV):" ["_DIV_"]",1:""),IOM)
SET CNT=CNT+1
SET TXT(CNT)=" "
+4 ;S CNT=CNT+1,TXT(CNT)=$$CJ^XLFSTR("[Descending Order]",IOM),CNT=CNT+1,TXT(CNT)=""
+5 FOR X=1:1:3
FOR Y=1:1:10
Begin DoDot:1
+6 IF Y=1
SET CNT=CNT+1
SET TXT(CNT)=$SELECT(X=1:"Notification",X=2:"Title",X=3:"Division")
SET TXT(CNT)=$$SETSTR^VALM1("Total",TXT(CNT),34,5)
+7 IF $TEST
SET TXT=$SELECT(X=1:"Recipient",X=2:"Service",X=3:"Location")
SET TXT(CNT)=$$SETSTR^VALM1(TXT,TXT(CNT),40,$LENGTH(TXT))
SET TXT(CNT)=$$SETSTR^VALM1("Total",TXT(CNT),75,5)
+8 IF $TEST
SET CNT=CNT+1
SET $PIECE(TXT(CNT),"=",IOM-1)=""
SET $PIECE(TXT(CNT),"=",39)=" "
+9 SET CNT=CNT+1
+10 SET TXT=$NAME(TOP10($SELECT(X=1:"NTF",X=2:"TTL",X=3:"DIV"),Y))
+11 SET TXT(CNT)=$PIECE(@TXT,U)
SET TXT(CNT)=$SELECT($EXTRACT(TXT(CNT))="z":$EXTRACT(TXT(CNT),2,32),1:TXT(CNT))
+12 SET TXT=$PIECE(@TXT,U,2)
SET TXT(CNT)=$$SETSTR^VALM1(TXT,TXT(CNT),(39-$LENGTH(TXT)),$LENGTH(TXT))
+13 SET TXT=$NAME(TOP10($SELECT(X=1:"USR",X=2:"SRV",X=3:"LOC"),Y))
+14 SET TXT(CNT)=$$SETSTR^VALM1($SELECT($EXTRACT($PIECE(@TXT,U))="z":$EXTRACT($PIECE(@TXT,U),2,32),1:$PIECE(@TXT,U)),TXT(CNT),40,$LENGTH($PIECE(@TXT,U)))
+15 SET TXT(CNT)=$$SETSTR^VALM1($PIECE(@TXT,U,2),TXT(CNT),(IOM-$LENGTH($PIECE(@TXT,U,2))),$LENGTH($PIECE(@TXT,U,2)))
End DoDot:1
IF Y=10
SET CNT=CNT+1
SET TXT(CNT)=""
+16 ;S CNT=CNT+1,TXT(CNT)="Total Notifications: "_@TMP1@(DIV,"DIV",DIV)
+17 SET CNT=CNT+1
SET TXT(CNT)="Total Notifications: "_$SELECT($GET(DIV)="":@TMP@(1,"TOTAL"),1:@TMP1@(DIV,"DIV",DIV))
+18 QUIT
ASKRNG ; ask user for the date range
+1 WRITE "Enter the desired date range for the notification search.",!!
+2 WRITE "Search times typically vary from 30-90 seconds for each day searched.",!
+3 SET (DTRG("Start"),DTRG("Stop"))=""
+4 Begin DoDot:1
+5 NEW %DT,DIR,X,Y
SET %DT(0)=-$$DT^XLFDT_".24"
SET %DT="AETX"
SET %DT("A")="Select Beginning DATE: "
SET %DT("B")=$$FMTE^XLFDT($$FMADD^XLFDT(DT,-30))
+6 DO ^%DT
KILL %DT
if Y<0
QUIT
SET DTRG("Start")=Y
+7 SET %DT(0)=DTRG("Start")
SET %DT="AETX"
SET %DT("A")=" Ending DATE: "
SET %DT("B")=$$FMTE^XLFDT(DT)
+8 WRITE !
DO ^%DT
if Y<0
QUIT
SET DTRG("Stop")=Y
if $PIECE(DTRG("Stop"),".",2)=""
SET $PIECE(DTRG("Stop"),".",2)="999999"
End DoDot:1
IF '+DTRG("Start")!('+DTRG("Stop"))
WRITE !
QUIT
+9 QUIT
CLEAN ; S DATA=$NA(^TMP($J,"ORAERPT",$H)),TMP=$NA(^TMP($J,"ORAETMP",$H))
+1 NEW DA,DIK,NAME,IEN,X,Y
+2 SET NAME="ORAE"
FOR
SET NAME=$ORDER(^ORD(101,"B",NAME))
if NAME'["ORAE"
QUIT
SET IEN=0
FOR
SET IEN=$ORDER(^ORD(101,"B",NAME,IEN))
if '+IEN
QUIT
Begin DoDot:1
+3 if NAME'[$JOB
QUIT
+4 SET DA=IEN
SET DIK="^ORD(101,"
DO ^DIK
End DoDot:1
+5 QUIT
ASK(Y,PARAM,DEFAULT,MENU,PROMPT,HELP) ;
+1 NEW I,X,XQORM
+2 SET XQORM=+$ORDER(^ORD(101,"B",MENU,0))_";ORD(101,"
+3 IF '+XQORM
QUIT "-1^Menu entry not found."
+4 SET XQORM(0)=$GET(PARAM)
SET XQORM("A")=PROMPT
SET XQORM("B")=DEFAULT
SET XQORM("?")=$SELECT($GET(HELP)="":"D HELP^ORAEHLP",1:HELP)
+5 DO EN^XQORM
+6 QUIT $GET(Y)
DISPLAY(OUTPUT) ;
+1 NEW END,Y
SET (END,Y)=0
+2 if $EXTRACT(IOST,1,2)="C-"
DO HDR2
+3 FOR
SET Y=$ORDER(OUTPUT(Y))
if '+Y!(+END)
QUIT
Begin DoDot:1
+4 if $Y+3>IOSL
DO HDR1
if +END
QUIT
WRITE OUTPUT(Y),!
End DoDot:1
+5 if +END
QUIT
+6 IF $EXTRACT(IOST,1,2)="C-"
IF IOSL'>24
FOR
if $Y+3>IOSL
QUIT
WRITE !
+7 if $EXTRACT(IOST,1,2)="C-"
READ !,"Report Complete. Press <Enter> to continue ",X:DTIME
+8 QUIT
HDR1 ;
+1 IF $EXTRACT(IOST,1,2)="C-"
Begin DoDot:1
+2 READ !,"Press <ENTER> to continue or '^' to exit ",X:DTIME
SET END='$TEST!(X=U)
End DoDot:1
+3 if +END
QUIT
HDR2 ;
+1 IF $EXTRACT(IOST,1,2)="C-"
Begin DoDot:1
+2 WRITE @IOF
+3 IF +$DATA(HDR)
SET X=0
FOR
SET X=$ORDER(HDR(X))
if '+X
QUIT
WRITE HDR(X),!
End DoDot:1
+4 WRITE IOUOFF
+5 QUIT