RORTSK14 ;HCIOFO/SG - PARSER FOR REPORT PARAMETERS (TOOLS) ; 4/25/07 2:48pm
;;1.5;CLINICAL CASE REGISTRIES;**2**;Feb 17, 2006;Build 6
;
Q
;
;***** CALCULATES START AND END DATES FROM DATE RANGE ATTRIBUTES
;
; .ATTR Reference to a local variable that contains
; attributes of the <DATE_RANGE> element.
;
; .STDT Reference to a local variable where
; the start date is returned to
;
; .ENDT Reference to a local variable where
; the end date is returned to
;
; Return Values:
; <0 Error code
; 0 Ok
;
; NOTE: In case of an error the function does not change
; values of the STDT and ENDT parameters.
;
DTRANGE(ATTR,STDT,ENDT) ;
N ENDT1,FISCAL,I,QUARTER,RC,RORMSG,STDT1,TMP,TYPE,YEAR
S (STDT1,ENDT1)="",TYPE=$G(ATTR("TYPE"))
S RC=0 D Q:RC<0 $$DBS^RORERR("RORMSG",-9)
. ;
. ;--- CUSTOM: StartDate, EndDate
. I TYPE="CUSTOM" D Q
. . S STDT1=$G(ATTR("START")),ENDT1=$G(ATTR("END"))
. ;
. ;--- CUTOFF: Cutoff
. I TYPE="CUTOFF" D Q
. . S ENDT1=$$DT^XLFDT,TMP=$$TRIM^XLFSTR($G(ATTR("CUTOFF")))
. . ;--- Strip "TODAY-" (or "T-") from the attribute value
. . S:TMP["-" TMP=$P(TMP,"-",2)
. . ;--- Calculate the start date
. . D DT^DILF("P","TODAY-"_TMP,.STDT1,-ENDT1,"RORMSG")
. . S:STDT1<0 RC=STDT1
. ;
. ;--- QUARTER: Quarter, Year, Fiscal
. I TYPE="QUARTER" D Q
. . S QUARTER=+$G(ATTR("QUARTER")),YEAR=+$G(ATTR("YEAR"))
. . S FISCAL=+$G(ATTR("FISCAL")) S:FISCAL QUARTER=QUARTER-1
. . S TMP=$P("10/01^01/01^04/01^07/01^10/01","^",QUARTER+1)
. . S TMP=TMP_"/"_$S(QUARTER:YEAR,1:YEAR-1)
. . D DT^DILF("P",TMP,.STDT1,,"RORMSG")
. . I STDT1<0 S RC=STDT1 Q
. . S TMP=$P("12/31^03/31^06/30^09/30^12/31","^",QUARTER+1)
. . S TMP=TMP_"/"_$S(QUARTER:YEAR,1:YEAR-1)
. . D DT^DILF("P",TMP,.ENDT1,STDT1,"RORMSG")
. . I ENDT1<0 S RC=ENDT1 Q
. ;
. ;--- YEAR: Year, Fiscal
. I TYPE="YEAR" D Q
. . S YEAR=+$G(ATTR("YEAR")),FISCAL=+$G(ATTR("FISCAL"))
. . S TMP=$S(FISCAL:"10/01/"_(YEAR-1),1:"01/01/"_YEAR)
. . D DT^DILF("P",TMP,.STDT1,,"RORMSG")
. . I STDT1<0 S RC=STDT1 Q
. . S TMP=$S(FISCAL:"09/30/"_YEAR,1:"12/31/"_YEAR)
. . D DT^DILF("P",TMP,.ENDT1,STDT1,"RORMSG")
. . I ENDT1<0 S RC=ENDT1 Q
;
;--- Invalid time frame
I (STDT1'>0)!(ENDT1'>0)!(STDT1>ENDT1) D Q RC
. S RC=$$ERROR^RORERR(-88,,,,"DATE_RANGE",STDT1_"-"_ENDT1)
;
;--- Success
S STDT=STDT1,ENDT=ENDT1
Q 0
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRORTSK14 2490 printed Dec 13, 2024@01:43:36 Page 2
RORTSK14 ;HCIOFO/SG - PARSER FOR REPORT PARAMETERS (TOOLS) ; 4/25/07 2:48pm
+1 ;;1.5;CLINICAL CASE REGISTRIES;**2**;Feb 17, 2006;Build 6
+2 ;
+3 QUIT
+4 ;
+5 ;***** CALCULATES START AND END DATES FROM DATE RANGE ATTRIBUTES
+6 ;
+7 ; .ATTR Reference to a local variable that contains
+8 ; attributes of the <DATE_RANGE> element.
+9 ;
+10 ; .STDT Reference to a local variable where
+11 ; the start date is returned to
+12 ;
+13 ; .ENDT Reference to a local variable where
+14 ; the end date is returned to
+15 ;
+16 ; Return Values:
+17 ; <0 Error code
+18 ; 0 Ok
+19 ;
+20 ; NOTE: In case of an error the function does not change
+21 ; values of the STDT and ENDT parameters.
+22 ;
DTRANGE(ATTR,STDT,ENDT) ;
+1 NEW ENDT1,FISCAL,I,QUARTER,RC,RORMSG,STDT1,TMP,TYPE,YEAR
+2 SET (STDT1,ENDT1)=""
SET TYPE=$GET(ATTR("TYPE"))
+3 SET RC=0
Begin DoDot:1
+4 ;
+5 ;--- CUSTOM: StartDate, EndDate
+6 IF TYPE="CUSTOM"
Begin DoDot:2
+7 SET STDT1=$GET(ATTR("START"))
SET ENDT1=$GET(ATTR("END"))
End DoDot:2
QUIT
+8 ;
+9 ;--- CUTOFF: Cutoff
+10 IF TYPE="CUTOFF"
Begin DoDot:2
+11 SET ENDT1=$$DT^XLFDT
SET TMP=$$TRIM^XLFSTR($GET(ATTR("CUTOFF")))
+12 ;--- Strip "TODAY-" (or "T-") from the attribute value
+13 if TMP["-"
SET TMP=$PIECE(TMP,"-",2)
+14 ;--- Calculate the start date
+15 DO DT^DILF("P","TODAY-"_TMP,.STDT1,-ENDT1,"RORMSG")
+16 if STDT1<0
SET RC=STDT1
End DoDot:2
QUIT
+17 ;
+18 ;--- QUARTER: Quarter, Year, Fiscal
+19 IF TYPE="QUARTER"
Begin DoDot:2
+20 SET QUARTER=+$GET(ATTR("QUARTER"))
SET YEAR=+$GET(ATTR("YEAR"))
+21 SET FISCAL=+$GET(ATTR("FISCAL"))
if FISCAL
SET QUARTER=QUARTER-1
+22 SET TMP=$PIECE("10/01^01/01^04/01^07/01^10/01","^",QUARTER+1)
+23 SET TMP=TMP_"/"_$SELECT(QUARTER:YEAR,1:YEAR-1)
+24 DO DT^DILF("P",TMP,.STDT1,,"RORMSG")
+25 IF STDT1<0
SET RC=STDT1
QUIT
+26 SET TMP=$PIECE("12/31^03/31^06/30^09/30^12/31","^",QUARTER+1)
+27 SET TMP=TMP_"/"_$SELECT(QUARTER:YEAR,1:YEAR-1)
+28 DO DT^DILF("P",TMP,.ENDT1,STDT1,"RORMSG")
+29 IF ENDT1<0
SET RC=ENDT1
QUIT
End DoDot:2
QUIT
+30 ;
+31 ;--- YEAR: Year, Fiscal
+32 IF TYPE="YEAR"
Begin DoDot:2
+33 SET YEAR=+$GET(ATTR("YEAR"))
SET FISCAL=+$GET(ATTR("FISCAL"))
+34 SET TMP=$SELECT(FISCAL:"10/01/"_(YEAR-1),1:"01/01/"_YEAR)
+35 DO DT^DILF("P",TMP,.STDT1,,"RORMSG")
+36 IF STDT1<0
SET RC=STDT1
QUIT
+37 SET TMP=$SELECT(FISCAL:"09/30/"_YEAR,1:"12/31/"_YEAR)
+38 DO DT^DILF("P",TMP,.ENDT1,STDT1,"RORMSG")
+39 IF ENDT1<0
SET RC=ENDT1
QUIT
End DoDot:2
QUIT
End DoDot:1
if RC<0
QUIT $$DBS^RORERR("RORMSG",-9)
+40 ;
+41 ;--- Invalid time frame
+42 IF (STDT1'>0)!(ENDT1'>0)!(STDT1>ENDT1)
Begin DoDot:1
+43 SET RC=$$ERROR^RORERR(-88,,,,"DATE_RANGE",STDT1_"-"_ENDT1)
End DoDot:1
QUIT RC
+44 ;
+45 ;--- Success
+46 SET STDT=STDT1
SET ENDT=ENDT1
+47 QUIT 0