RGUTDAT ;CAIRO/DKM - Date range input;12-Oct-1998 12:01;DKM
;;2.1;RUN TIME LIBRARY;;Mar 22, 1999
;=================================================================
; Prompt for date range (normal format)
NORMAL D D1("P1"),D2("P2")
Q
; Prompt for date range (inverse format)
INVRSE D D1("PI1"),D2("PI2")
Q
; Prompt for starting date
D1(RGOPT) ;
S RGDAT1=$$ENTRY("Start date: ",.RGOPT,"",0,$Y)
Q
; Prompt for ending date
D2(RGOPT) ;
S RGDAT2=$$ENTRY("End date : ",.RGOPT,"",0,$Y+1)
Q
; Prompt for a date
ENTRY(%RGP,%RGOPT,%RGDAT,%RGX,%RGY,%RGTRP,%RGHLP) ;
N %RGD,%RGI,%RGDT,%RGZ,%RGDISV
S %RGX=$G(%RGX,$X),%RGY=$G(%RGY,$Y),DUZ=+$G(DUZ),IO=$G(IO,$I),DTIME=$G(DTIME,999999999),%RGOPT=$$UP^XLFSTR($G(%RGOPT)),%RGDISV=""
S %RGTRP=$G(%RGTRP),%RGDAT=$G(%RGDAT)
S:$G(%RGHLP)="" %RGHLP="HELP^RGUTDAT"
S:$G(%RGP)="" %RGP="Enter date: "
F %RGZ=0:1:9 I %RGOPT[%RGZ S %RGDISV="RGDAT"_%RGZ Q
U IO
DAT1 S %RGDT="",@$$TRAP^RGZOSF("DAT1^RGUTDAT")
F %RGZ="P","T","F","X" S:%RGOPT[%RGZ %RGDT=%RGDT_%RGZ
F D Q:$D(%RGI)
.W $$XY^RGUT(%RGX,%RGY)_%RGP,*27,"[J"
.S $X=%RGX+$L(%RGP)
.I %RGOPT["E" S %RGI=$$ENTRY^RGUTEDT(%RGDAT,79-$X,$X,$Y,"","R")
.E I %RGDAT'="" S %RGI=%RGDAT,%RGDAT=""
.E R %RGI:DTIME
.I $E(%RGI)="?" D Q
..W !
..I %RGI["??" D HELP
..E D @%RGHLP
..D PAUSE()
..K %RGI
.I %RGI=" " S %RGI=$S(%RGDISV="":"",1:$G(^DISV(DUZ,%RGDISV))) K:%RGI="" RGZ1
.W $$XY^RGUT(%RGX+$L(%RGP),%RGY),*27,"[K"
I %RGI="",%RGTRP'="" S %RGI=$G(@%RGTRP@(" "))
S %RGI=$$UP^XLFSTR(%RGI),%RGD=""
Q:"^^"[%RGI -$L(%RGI)
I %RGTRP'="" D I %RGD'="" S %RGOPT=$TR(%RGOPT,"I") G DAT2
.I $D(@%RGTRP@(%RGI)) S %RGD=@%RGTRP@(%RGI)
.E D
..N X
..S X=%RGI,%RGZ=""
..F S %RGZ=$O(@%RGTRP@("?",%RGZ)) Q:%RGZ="" I %RGI?@%RGZ D Q
...S %RGD=$$MSG^RGUT($G(@%RGTRP@("?",%RGZ)))
S %RGI=$$%DT^RGUT(%RGI,%RGDT)
G:%RGI=-1 DAT1
I %RGOPT["+",%RGI<$S(%RGI=%RGI\1:$$DT^XLFDT,1:$$NOW^XLFDT) D G DAT1
.D PAUSE("Must be on or after current date.")
I %RGOPT["-",%RGI>$S(%RGI=%RGI\1:$$DT^XLFDT,1:$$NOW^XLFDT) D G DAT1
.D PAUSE("Must be on or before current date.")
S %RGD=$$^RGCVTDT(%RGI)
DAT2 W %RGD
S:%RGDISV'="" ^DISV(DUZ,%RGDISV)=%RGI
Q $S(%RGOPT["I":9999999-%RGI,1:%RGI)
HELP W ?2,"Enter a valid ",$S(%RGOPT["+":"future ",%RGOPT["-":"past ",1:""),"date using one of the following formats:",!!
W ?5,"Format",?20,"Example",?35,"Explanation",?60,"Comments",!
W ?5,"------",?20,"-------",?35,"-----------",?60,"--------",!
W ?5,"mm/dd/yy",?20,"6/20/93",?35,"June 20, 1993",?60,"If you omit the",!
W ?5,"dd-mmm-yy",?20,"27-JUL-58",?35,"July 27, 1958",?60,"year, the "_$S(%RGOPT["P":"most",%RGOPT["F":"closest",1:"current"),!
W ?5,"mmddyy",?20,"070457",?35,"July 4, 1957",?60,$S(%RGOPT["P":"recent past date",%RGOPT["F":"future date",1:"calendar year"),!
W ?5,"mmm dd yyyy",?20,"JAN 5, 1984",?35,"January 5, 1984",?60,"is assumed.",!
W ?5,"T-n",?20,"T-5",?35,"Today's date - 5 days.",!!
Q
PAUSE(%RGZ) ;
W $$XY^RGUT(0,22),$G(%RGZ)
I $$PAUSE^RGUT
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRGUTDAT 3025 printed Dec 13, 2024@02:37:10 Page 2
RGUTDAT ;CAIRO/DKM - Date range input;12-Oct-1998 12:01;DKM
+1 ;;2.1;RUN TIME LIBRARY;;Mar 22, 1999
+2 ;=================================================================
+3 ; Prompt for date range (normal format)
NORMAL DO D1("P1")
DO D2("P2")
+1 QUIT
+2 ; Prompt for date range (inverse format)
INVRSE DO D1("PI1")
DO D2("PI2")
+1 QUIT
+2 ; Prompt for starting date
D1(RGOPT) ;
+1 SET RGDAT1=$$ENTRY("Start date: ",.RGOPT,"",0,$Y)
+2 QUIT
+3 ; Prompt for ending date
D2(RGOPT) ;
+1 SET RGDAT2=$$ENTRY("End date : ",.RGOPT,"",0,$Y+1)
+2 QUIT
+3 ; Prompt for a date
ENTRY(%RGP,%RGOPT,%RGDAT,%RGX,%RGY,%RGTRP,%RGHLP) ;
+1 NEW %RGD,%RGI,%RGDT,%RGZ,%RGDISV
+2 SET %RGX=$GET(%RGX,$X)
SET %RGY=$GET(%RGY,$Y)
SET DUZ=+$GET(DUZ)
SET IO=$GET(IO,$IO)
SET DTIME=$GET(DTIME,999999999)
SET %RGOPT=$$UP^XLFSTR($GET(%RGOPT))
SET %RGDISV=""
+3 SET %RGTRP=$GET(%RGTRP)
SET %RGDAT=$GET(%RGDAT)
+4 if $GET(%RGHLP)=""
SET %RGHLP="HELP^RGUTDAT"
+5 if $GET(%RGP)=""
SET %RGP="Enter date: "
+6 FOR %RGZ=0:1:9
IF %RGOPT[%RGZ
SET %RGDISV="RGDAT"_%RGZ
QUIT
+7 USE IO
DAT1 SET %RGDT=""
SET @$$TRAP^RGZOSF("DAT1^RGUTDAT")
+1 FOR %RGZ="P","T","F","X"
if %RGOPT[%RGZ
SET %RGDT=%RGDT_%RGZ
+2 FOR
Begin DoDot:1
+3 WRITE $$XY^RGUT(%RGX,%RGY)_%RGP,*27,"[J"
+4 SET $X=%RGX+$LENGTH(%RGP)
+5 IF %RGOPT["E"
SET %RGI=$$ENTRY^RGUTEDT(%RGDAT,79-$X,$X,$Y,"","R")
+6 IF '$TEST
IF %RGDAT'=""
SET %RGI=%RGDAT
SET %RGDAT=""
+7 IF '$TEST
READ %RGI:DTIME
+8 IF $EXTRACT(%RGI)="?"
Begin DoDot:2
+9 WRITE !
+10 IF %RGI["??"
DO HELP
+11 IF '$TEST
DO @%RGHLP
+12 DO PAUSE()
+13 KILL %RGI
End DoDot:2
QUIT
+14 IF %RGI=" "
SET %RGI=$SELECT(%RGDISV="":"",1:$GET(^DISV(DUZ,%RGDISV)))
if %RGI=""
KILL RGZ1
+15 WRITE $$XY^RGUT(%RGX+$LENGTH(%RGP),%RGY),*27,"[K"
End DoDot:1
if $DATA(%RGI)
QUIT
+16 IF %RGI=""
IF %RGTRP'=""
SET %RGI=$GET(@%RGTRP@(" "))
+17 SET %RGI=$$UP^XLFSTR(%RGI)
SET %RGD=""
+18 if "^^"[%RGI
QUIT -$LENGTH(%RGI)
+19 IF %RGTRP'=""
Begin DoDot:1
+20 IF $DATA(@%RGTRP@(%RGI))
SET %RGD=@%RGTRP@(%RGI)
+21 IF '$TEST
Begin DoDot:2
+22 NEW X
+23 SET X=%RGI
SET %RGZ=""
+24 FOR
SET %RGZ=$ORDER(@%RGTRP@("?",%RGZ))
if %RGZ=""
QUIT
IF %RGI?@%RGZ
Begin DoDot:3
+25 SET %RGD=$$MSG^RGUT($GET(@%RGTRP@("?",%RGZ)))
End DoDot:3
QUIT
End DoDot:2
End DoDot:1
IF %RGD'=""
SET %RGOPT=$TRANSLATE(%RGOPT,"I")
GOTO DAT2
+26 SET %RGI=$$%DT^RGUT(%RGI,%RGDT)
+27 if %RGI=-1
GOTO DAT1
+28 IF %RGOPT["+"
IF %RGI<$SELECT(%RGI=%RGI\1:$$DT^XLFDT,1:$$NOW^XLFDT)
Begin DoDot:1
+29 DO PAUSE("Must be on or after current date.")
End DoDot:1
GOTO DAT1
+30 IF %RGOPT["-"
IF %RGI>$SELECT(%RGI=%RGI\1:$$DT^XLFDT,1:$$NOW^XLFDT)
Begin DoDot:1
+31 DO PAUSE("Must be on or before current date.")
End DoDot:1
GOTO DAT1
+32 SET %RGD=$$^RGCVTDT(%RGI)
DAT2 WRITE %RGD
+1 if %RGDISV'=""
SET ^DISV(DUZ,%RGDISV)=%RGI
+2 QUIT $SELECT(%RGOPT["I":9999999-%RGI,1:%RGI)
HELP WRITE ?2,"Enter a valid ",$SELECT(%RGOPT["+":"future ",%RGOPT["-":"past ",1:""),"date using one of the following formats:",!!
+1 WRITE ?5,"Format",?20,"Example",?35,"Explanation",?60,"Comments",!
+2 WRITE ?5,"------",?20,"-------",?35,"-----------",?60,"--------",!
+3 WRITE ?5,"mm/dd/yy",?20,"6/20/93",?35,"June 20, 1993",?60,"If you omit the",!
+4 WRITE ?5,"dd-mmm-yy",?20,"27-JUL-58",?35,"July 27, 1958",?60,"year, the "_$SELECT(%RGOPT["P":"most",%RGOPT["F":"closest",1:"current"),!
+5 WRITE ?5,"mmddyy",?20,"070457",?35,"July 4, 1957",?60,$SELECT(%RGOPT["P":"recent past date",%RGOPT["F":"future date",1:"calendar year"),!
+6 WRITE ?5,"mmm dd yyyy",?20,"JAN 5, 1984",?35,"January 5, 1984",?60,"is assumed.",!
+7 WRITE ?5,"T-n",?20,"T-5",?35,"Today's date - 5 days.",!!
+8 QUIT
PAUSE(%RGZ) ;
+1 WRITE $$XY^RGUT(0,22),$GET(%RGZ)
+2 IF $$PAUSE^RGUT
+3 QUIT