LRSORA ;VA/DRH/DALISC - HIGH/LOW VALUE REPORT ;2/19/91 11:42 ;
;;5.2;LAB SERVICE;**1030**;NOV 01, 1997
;;5.2;LAB SERVICE;**344,357,369**;Sep 27, 1994;Build 2
MAIN D INIT,GDT,GAA:'LREND,GLRT:'LREND,GLOG:'LREND,SORTBY^LRSORA1:'LREND
D PATS^LRSORA1:'LREND,LOCS^LRSORA1:'LREND,GDV:'LREND,RUN:'LREND
D STOP
Q
RUN ;
K ^TMP("LR",$J)
S:$D(ZTQUEUED) ZTREQ="@" U IO
S (LRPAG,LREND)=0,$P(LRDASH,"-",IOM)="-"
K %DT S X=$P(LRSDT,"."),%DT="X" D ^%DT,DD^LRX S LRSDAT=Y
K %DT S X=LREDT,%DT="X" D ^%DT,DD^LRX S LREDAT=Y
S LRHDR2="For date range: "_LREDAT_" to "_LRSDAT
D:'LREND START^LRSORA2
D:$D(ZTQUEUED) STOP
Q
STOP ;
D STOP^LRSORA0
Q
GAA ;
D GAA^LRSORA0
Q
GLRT ;
W ! K LRTST S LRTST=1
F I=0:0 D GTSC Q:'$D(LRTST(LRTST,1)) W ! S LRTST=LRTST+1
K LRTST(LRTST) S LRTST=LRTST-1 Q
GTSC ;
S LRA=1
F I=0:0 D @$S(LRA=2:"SPEC",LRA=3:"CND",LRA=4:"GV",1:"TST") Q:LRA=0
Q
TST ;
K DIC S DIC="^LAB(60,",DIC(0)="AEMOQ"
S DIC("S")="I $P(^(0),U,5)[""CH"",""BO""[$P(^(0),U,3)" D ^DIC
S LRA=$S(Y>0:2,1:0)
S:X["^" LREND=1
I Y>0 S $P(LRTST(LRTST,3),"^",1)=$P($P(^LAB(60,+Y,0),U,5),";",2)
I S $P(LRTST(LRTST,2),"^",1)=$P(Y,"^",2)
Q
SPEC ;
S LRCNT=LRCNT+1
K DIC S DIC="^LAB(61,",DIC(0)="AEMOQ"
S DIC("A")="Select SPECIMEN/SITE: ANY// " D ^DIC
S:Y<1 $P(LRTST(LRTST,3),"^",2)="",$P(LRTST(LRTST,2),"^",2)=""
S LRA=$S(X["^":1,1:3)
I Y>0 S $P(LRTST(LRTST,3),"^",2)=+Y,$P(LRTST(LRTST,2),"^",2)=$P(Y,"^",2)
Q
CND ;
W !,"Select CONDITION: " R X:DTIME S:'$T X="^"
D @$S(X?1.N1":"1.N:"RNG",1:"GC") Q
RNG ;
N Y
S LRV=+$P(X,":",1),LRV2=+$P(X,":",2),LRA=0
S:LRV>LRV2 X=LRV,LRV=LRV2,LRV2=X
S $P(LRTST(LRTST,2),U,3)="BETWEEN "_LRV_" AND "_LRV2
S X=$P(LRTST(LRTST,3),U,1)
S Y="I $D(^("_X
S Y=Y_")) S LRVX=$P(^("_X
S Y=Y_"),U),LRVX=$S(LRVX?1A.E:LRVX,"
S Y=Y_"""<>""[$E(LRVX):$E(LRVX,2,$L(LRVX)),1:LRVX)"
S LRTST(LRTST,1)=Y_" I LRVX>"_LRV_",LRVX<"_LRV2
D ASPC Q
GC ;
S DIC="^DOPT(""DIS"",",DIC(0)="EMQZ",DIC("S")="I $L($P(^(0),U,2))"
D ^DIC K DIC
S LRA=$S(X["^":2,Y<0:3,1:4) D:X["?" HLP1 W:'$L(X) " ??" Q:Y<0
GV ;
N LY,ALPHA,DEC,II,TT
W !,"Enter VALUE: "
R X:DTIME S:'$T X="^"
S LRA=$S(X["^":3,"?"[X:4,1:0)
W:X="" " ??" D:X["?" HLP2 Q:LRA
S:"<>"[$P(Y(0),U,2) X=+X
S $P(LRTST(LRTST,2),"^",3)=$P(Y(0),"^",1)_" "_X
;
; determine if entered value is alphanumeric
S (ALPHA,DEC)=0
F II=1:1 S TT=$E(X,II) Q:TT="" D Q:ALPHA
. I TT?1N Q
. I TT?1"." S DEC=DEC+1 S:DEC>1 ALPHA=1 Q
. S ALPHA=1
I X="""""" S ALPHA=0 ;ADDED FOR LR*5.2*357
;
S LY="I $D(^("_$P(LRTST(LRTST,3),U)
S LY=LY_")) S LRVX=$P(^("
S LY=LY_$P(LRTST(LRTST,3),U)
S LY=LY_"),U),LRVX=$S(LRVX?1A.E:LRVX,"
S LY=LY_"""<>""[$E(LRVX):$E(LRVX,2,$L(LRVX)),1:LRVX) I LRVX"
S LRTST(LRTST,1)=LY_$P(Y(0),U,2)_$S(ALPHA:""""_X_"""",1:X) D ASPC Q
ASPC ;
S:$L($P(LRTST(LRTST,3),U,2)) LRTST(LRTST,1)=LRTST(LRTST,1)_",$P(^(0),U,5)="_$P(LRTST(LRTST,3),U,2) Q
INIT ;
S LRCNT=0
S U="^"
S LREND=0
S LRLONG=0
S LRSDT="TODAY"
S LREDT="T-1"
S LRTW=.00001
S:'$D(DTIME) DTIME=300
W !,"SPECIAL REPORT - Search for high/low values" Q
GDT ;
F W=0:0 D SDF,GSD Q:LREND S LRSDT=Y D GED I Y>0 S LREDT=Y S:LREDT>LRSDT X=LREDT,LREDT=LRSDT,LRSDT=X D CXR W:Y'>0 !!,"No data for the year selected.",! Q:Y>0
K %DT S X=$P(LRSDT,"."),%DT="X" D ^%DT,DD^LRX S LRSDAT=Y
K %DT S X=$P(LREDT,"."),%DT="X" D ^%DT,DD^LRX S LREDAT=Y
S LRHDR2="For date range: "_LREDAT_" to "_LRSDAT
K LRSDAT,LREDAT,%DT Q
GSD ;
S %DT("A")="Enter START date: ",%DT("B")=LRSDT,%DT="AET"
D ^%DT S LREND=Y<1 Q
GED ;
S %DT("A")="Enter END date: ",%DT("B")=LREDT D ^%DT Q
CXR ;
S Y=$E(LREDT,1,3)_"0000" F I=0:0 S Y=$O(^LRO(69,Y)) Q:Y=""!($D(^LRO(69,+Y,1,"AN")))
I Y>LREDT D DD^LRX W !,"The earliest date in the X-ref is ",Y,". Long search required.",! D CXR1
Q
CXR1 ;
F I=0:0 S %=2 W " OK to continue" D YN^DICN S:%=2!(%<0) LREND=1 S:%=1 LRLONG=1 Q:% W !,"Enter 'YES' for the long search, 'NO' to exit.",!
Q
SDF ;
I LRSDT?1.7N S Y=LRSDT D DD^LRX S LRSDT=Y
I LREDT?1.7N S Y=LREDT D DD^LRX S LREDT=Y
Q
GLOG ;
S:LRTST=1 LRTST(0)="A" D:LRTST>1 EN^LRSORA1 S:LRTST<1 LREND=1 Q
GDV ;
S %ZIS="Q" D ^%ZIS K %ZIS I POP S LREND=1 Q
I $D(IO("Q")) K IO("Q") S (LRQUE,LREND)=1,ZTRTN="RUN^LRSORA",ZTDESC="Lab Special Report",ZTSAVE("LR*")="" D ^%ZTLOAD
Q
HLP1 ;
W !,"A VALUE RANGE may also be entered (value:value).",!," For Example, 100:200 will search for values between 100 and 200.",!
Q
HLP2 ;
W !,"Enter a value for the comparison: "
W $P(LRTST(LRTST,2),U,1)," ",$P(Y(0),U,1)_" _____."
Q
XX ;
WAIT K DIR S DIR(0)="E" D ^DIR S:($D(DUOUT))!($D(DTOUT)) LREND=1
Q
LRSORA ;VA/DRH/DALISC - HIGH/LOW VALUE REPORT ;2/19/91 11:42 ;
+1 ;;5.2;LAB SERVICE;**1030**;NOV 01, 1997
+2 ;;5.2;LAB SERVICE;**344,357,369**;Sep 27, 1994;Build 2
MAIN DO INIT
DO GDT
IF 'LREND
DO GAA
IF 'LREND
DO GLRT
IF 'LREND
DO GLOG
IF 'LREND
DO SORTBY^LRSORA1
+1 IF 'LREND
DO PATS^LRSORA1
IF 'LREND
DO LOCS^LRSORA1
IF 'LREND
DO GDV
IF 'LREND
DO RUN
+2 DO STOP
+3 QUIT
RUN ;
+1 KILL ^TMP("LR",$JOB)
+2 IF $DATA(ZTQUEUED)
SET ZTREQ="@"
USE IO
+3 SET (LRPAG,LREND)=0
SET $PIECE(LRDASH,"-",IOM)="-"
+4 KILL %DT
SET X=$PIECE(LRSDT,".")
SET %DT="X"
DO ^%DT
DO DD^LRX
SET LRSDAT=Y
+5 KILL %DT
SET X=LREDT
SET %DT="X"
DO ^%DT
DO DD^LRX
SET LREDAT=Y
+6 SET LRHDR2="For date range: "_LREDAT_" to "_LRSDAT
+7 IF 'LREND
DO START^LRSORA2
+8 IF $DATA(ZTQUEUED)
DO STOP
+9 QUIT
STOP ;
+1 DO STOP^LRSORA0
+2 QUIT
GAA ;
+1 DO GAA^LRSORA0
+2 QUIT
GLRT ;
+1 WRITE !
KILL LRTST
SET LRTST=1
+2 FOR I=0:0
DO GTSC
IF '$DATA(LRTST(LRTST,1))
QUIT
WRITE !
SET LRTST=LRTST+1
+3 KILL LRTST(LRTST)
SET LRTST=LRTST-1
QUIT
GTSC ;
+1 SET LRA=1
+2 FOR I=0:0
DO @$SELECT(LRA=2:"SPEC",LRA=3:"CND",LRA=4:"GV",1:"TST")
IF LRA=0
QUIT
+3 QUIT
TST ;
+1 KILL DIC
SET DIC="^LAB(60,"
SET DIC(0)="AEMOQ"
+2 SET DIC("S")="I $P(^(0),U,5)[""CH"",""BO""[$P(^(0),U,3)"
DO ^DIC
+3 SET LRA=$SELECT(Y>0:2,1:0)
+4 IF X["^"
SET LREND=1
+5 IF Y>0
SET $PIECE(LRTST(LRTST,3),"^",1)=$PIECE($PIECE(^LAB(60,+Y,0),U,5),";",2)
+6 IF $TEST
SET $PIECE(LRTST(LRTST,2),"^",1)=$PIECE(Y,"^",2)
+7 QUIT
SPEC ;
+1 SET LRCNT=LRCNT+1
+2 KILL DIC
SET DIC="^LAB(61,"
SET DIC(0)="AEMOQ"
+3 SET DIC("A")="Select SPECIMEN/SITE: ANY// "
DO ^DIC
+4 IF Y<1
SET $PIECE(LRTST(LRTST,3),"^",2)=""
SET $PIECE(LRTST(LRTST,2),"^",2)=""
+5 SET LRA=$SELECT(X["^":1,1:3)
+6 IF Y>0
SET $PIECE(LRTST(LRTST,3),"^",2)=+Y
SET $PIECE(LRTST(LRTST,2),"^",2)=$PIECE(Y,"^",2)
+7 QUIT
CND ;
+1 WRITE !,"Select CONDITION: "
READ X:DTIME
IF '$TEST
SET X="^"
+2 DO @$SELECT(X?1.N1":"1.N:"RNG",1:"GC")
QUIT
RNG ;
+1 NEW Y
+2 SET LRV=+$PIECE(X,":",1)
SET LRV2=+$PIECE(X,":",2)
SET LRA=0
+3 IF LRV>LRV2
SET X=LRV
SET LRV=LRV2
SET LRV2=X
+4 SET $PIECE(LRTST(LRTST,2),U,3)="BETWEEN "_LRV_" AND "_LRV2
+5 SET X=$PIECE(LRTST(LRTST,3),U,1)
+6 SET Y="I $D(^("_X
+7 SET Y=Y_")) S LRVX=$P(^("_X
+8 SET Y=Y_"),U),LRVX=$S(LRVX?1A.E:LRVX,"
+9 SET Y=Y_"""<>""[$E(LRVX):$E(LRVX,2,$L(LRVX)),1:LRVX)"
+10 SET LRTST(LRTST,1)=Y_" I LRVX>"_LRV_",LRVX<"_LRV2
+11 DO ASPC
QUIT
GC ;
+1 SET DIC="^DOPT(""DIS"","
SET DIC(0)="EMQZ"
SET DIC("S")="I $L($P(^(0),U,2))"
+2 DO ^DIC
KILL DIC
+3 SET LRA=$SELECT(X["^":2,Y<0:3,1:4)
IF X["?"
DO HLP1
IF '$LENGTH(X)
WRITE " ??"
IF Y<0
QUIT
GV ;
+1 NEW LY,ALPHA,DEC,II,TT
+2 WRITE !,"Enter VALUE: "
+3 READ X:DTIME
IF '$TEST
SET X="^"
+4 SET LRA=$SELECT(X["^":3,"?"[X:4,1:0)
+5 IF X=""
WRITE " ??"
IF X["?"
DO HLP2
IF LRA
QUIT
+6 IF "<>"[$PIECE(Y(0),U,2)
SET X=+X
+7 SET $PIECE(LRTST(LRTST,2),"^",3)=$PIECE(Y(0),"^",1)_" "_X
+8 ;
+9 ; determine if entered value is alphanumeric
+10 SET (ALPHA,DEC)=0
+11 FOR II=1:1
SET TT=$EXTRACT(X,II)
IF TT=""
QUIT
Begin DoDot:1
+12 IF TT?1N
QUIT
+13 IF TT?1"."
SET DEC=DEC+1
IF DEC>1
SET ALPHA=1
QUIT
+14 SET ALPHA=1
End DoDot:1
IF ALPHA
QUIT
+15 ;ADDED FOR LR*5.2*357
IF X=""""""
SET ALPHA=0
+16 ;
+17 SET LY="I $D(^("_$PIECE(LRTST(LRTST,3),U)
+18 SET LY=LY_")) S LRVX=$P(^("
+19 SET LY=LY_$PIECE(LRTST(LRTST,3),U)
+20 SET LY=LY_"),U),LRVX=$S(LRVX?1A.E:LRVX,"
+21 SET LY=LY_"""<>""[$E(LRVX):$E(LRVX,2,$L(LRVX)),1:LRVX) I LRVX"
+22 SET LRTST(LRTST,1)=LY_$PIECE(Y(0),U,2)_$SELECT(ALPHA:""""_X_"""",1:X)
DO ASPC
QUIT
ASPC ;
+1 IF $LENGTH($PIECE(LRTST(LRTST,3),U,2))
SET LRTST(LRTST,1)=LRTST(LRTST,1)_",$P(^(0),U,5)="_$PIECE(LRTST(LRTST,3),U,2)
QUIT
INIT ;
+1 SET LRCNT=0
+2 SET U="^"
+3 SET LREND=0
+4 SET LRLONG=0
+5 SET LRSDT="TODAY"
+6 SET LREDT="T-1"
+7 SET LRTW=.00001
+8 IF '$DATA(DTIME)
SET DTIME=300
+9 WRITE !,"SPECIAL REPORT - Search for high/low values"
QUIT
GDT ;
+1 FOR W=0:0
DO SDF
DO GSD
IF LREND
QUIT
SET LRSDT=Y
DO GED
IF Y>0
SET LREDT=Y
IF LREDT>LRSDT
SET X=LREDT
SET LREDT=LRSDT
SET LRSDT=X
DO CXR
IF Y'>0
WRITE !!,"No data for the year selected.",!
IF Y>0
QUIT
+2 KILL %DT
SET X=$PIECE(LRSDT,".")
SET %DT="X"
DO ^%DT
DO DD^LRX
SET LRSDAT=Y
+3 KILL %DT
SET X=$PIECE(LREDT,".")
SET %DT="X"
DO ^%DT
DO DD^LRX
SET LREDAT=Y
+4 SET LRHDR2="For date range: "_LREDAT_" to "_LRSDAT
+5 KILL LRSDAT,LREDAT,%DT
QUIT
GSD ;
+1 SET %DT("A")="Enter START date: "
SET %DT("B")=LRSDT
SET %DT="AET"
+2 DO ^%DT
SET LREND=Y<1
QUIT
GED ;
+1 SET %DT("A")="Enter END date: "
SET %DT("B")=LREDT
DO ^%DT
QUIT
CXR ;
+1 SET Y=$EXTRACT(LREDT,1,3)_"0000"
FOR I=0:0
SET Y=$ORDER(^LRO(69,Y))
IF Y=""!($DATA(^LRO(69,+Y,1,"AN")))
QUIT
+2 IF Y>LREDT
DO DD^LRX
WRITE !,"The earliest date in the X-ref is ",Y,". Long search required.",!
DO CXR1
+3 QUIT
CXR1 ;
+1 FOR I=0:0
SET %=2
WRITE " OK to continue"
DO YN^DICN
IF %=2!(%<0)
SET LREND=1
IF %=1
SET LRLONG=1
IF %
QUIT
WRITE !,"Enter 'YES' for the long search, 'NO' to exit.",!
+2 QUIT
SDF ;
+1 IF LRSDT?1.7N
SET Y=LRSDT
DO DD^LRX
SET LRSDT=Y
+2 IF LREDT?1.7N
SET Y=LREDT
DO DD^LRX
SET LREDT=Y
+3 QUIT
GLOG ;
+1 IF LRTST=1
SET LRTST(0)="A"
IF LRTST>1
DO EN^LRSORA1
IF LRTST<1
SET LREND=1
QUIT
GDV ;
+1 SET %ZIS="Q"
DO ^%ZIS
KILL %ZIS
IF POP
SET LREND=1
QUIT
+2 IF $DATA(IO("Q"))
KILL IO("Q")
SET (LRQUE,LREND)=1
SET ZTRTN="RUN^LRSORA"
SET ZTDESC="Lab Special Report"
SET ZTSAVE("LR*")=""
DO ^%ZTLOAD
+3 QUIT
HLP1 ;
+1 WRITE !,"A VALUE RANGE may also be entered (value:value).",!," For Example, 100:200 will search for values between 100 and 200.",!
+2 QUIT
HLP2 ;
+1 WRITE !,"Enter a value for the comparison: "
+2 WRITE $PIECE(LRTST(LRTST,2),U,1)," ",$PIECE(Y(0),U,1)_" _____."
+3 QUIT
XX ;
WAIT KILL DIR
SET DIR(0)="E"
DO ^DIR
IF ($DATA(DUOUT))!($DATA(DTOUT))
SET LREND=1
+1 QUIT