source: WorldVistAEHR/trunk/r/CLINICAL_CASE_REGISTRIES-ROR/RORTSK14.m@ 762

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

initial load of WorldVistAEHR

File size: 2.4 KB
Line 
1RORTSK14 ;HCIOFO/SG - PARSER FOR REPORT PARAMETERS (TOOLS) ; 4/25/07 2:48pm
2 ;;1.5;CLINICAL CASE REGISTRIES;**2**;Feb 17, 2006;Build 6
3 ;
4 Q
5 ;
6 ;***** CALCULATES START AND END DATES FROM DATE RANGE ATTRIBUTES
7 ;
8 ; .ATTR Reference to a local variable that contains
9 ; attributes of the <DATE_RANGE> element.
10 ;
11 ; .STDT Reference to a local variable where
12 ; the start date is returned to
13 ;
14 ; .ENDT Reference to a local variable where
15 ; the end date is returned to
16 ;
17 ; Return Values:
18 ; <0 Error code
19 ; 0 Ok
20 ;
21 ; NOTE: In case of an error the function does not change
22 ; values of the STDT and ENDT parameters.
23 ;
24DTRANGE(ATTR,STDT,ENDT) ;
25 N ENDT1,FISCAL,I,QUARTER,RC,RORMSG,STDT1,TMP,TYPE,YEAR
26 S (STDT1,ENDT1)="",TYPE=$G(ATTR("TYPE"))
27 S RC=0 D Q:RC<0 $$DBS^RORERR("RORMSG",-9)
28 . ;
29 . ;--- CUSTOM: StartDate, EndDate
30 . I TYPE="CUSTOM" D Q
31 . . S STDT1=$G(ATTR("START")),ENDT1=$G(ATTR("END"))
32 . ;
33 . ;--- CUTOFF: Cutoff
34 . I TYPE="CUTOFF" D Q
35 . . S ENDT1=$$DT^XLFDT,TMP=$$TRIM^XLFSTR($G(ATTR("CUTOFF")))
36 . . ;--- Strip "TODAY-" (or "T-") from the attribute value
37 . . S:TMP["-" TMP=$P(TMP,"-",2)
38 . . ;--- Calculate the start date
39 . . D DT^DILF("P","TODAY-"_TMP,.STDT1,-ENDT1,"RORMSG")
40 . . S:STDT1<0 RC=STDT1
41 . ;
42 . ;--- QUARTER: Quarter, Year, Fiscal
43 . I TYPE="QUARTER" D Q
44 . . S QUARTER=+$G(ATTR("QUARTER")),YEAR=+$G(ATTR("YEAR"))
45 . . S FISCAL=+$G(ATTR("FISCAL")) S:FISCAL QUARTER=QUARTER-1
46 . . S TMP=$P("10/01^01/01^04/01^07/01^10/01","^",QUARTER+1)
47 . . S TMP=TMP_"/"_$S(QUARTER:YEAR,1:YEAR-1)
48 . . D DT^DILF("P",TMP,.STDT1,,"RORMSG")
49 . . I STDT1<0 S RC=STDT1 Q
50 . . S TMP=$P("12/31^03/31^06/30^09/30^12/31","^",QUARTER+1)
51 . . S TMP=TMP_"/"_$S(QUARTER:YEAR,1:YEAR-1)
52 . . D DT^DILF("P",TMP,.ENDT1,STDT1,"RORMSG")
53 . . I ENDT1<0 S RC=ENDT1 Q
54 . ;
55 . ;--- YEAR: Year, Fiscal
56 . I TYPE="YEAR" D Q
57 . . S YEAR=+$G(ATTR("YEAR")),FISCAL=+$G(ATTR("FISCAL"))
58 . . S TMP=$S(FISCAL:"10/01/"_(YEAR-1),1:"01/01/"_YEAR)
59 . . D DT^DILF("P",TMP,.STDT1,,"RORMSG")
60 . . I STDT1<0 S RC=STDT1 Q
61 . . S TMP=$S(FISCAL:"09/30/"_YEAR,1:"12/31/"_YEAR)
62 . . D DT^DILF("P",TMP,.ENDT1,STDT1,"RORMSG")
63 . . I ENDT1<0 S RC=ENDT1 Q
64 ;
65 ;--- Invalid time frame
66 I (STDT1'>0)!(ENDT1'>0)!(STDT1>ENDT1) D Q RC
67 . S RC=$$ERROR^RORERR(-88,,,,"DATE_RANGE",STDT1_"-"_ENDT1)
68 ;
69 ;--- Success
70 S STDT=STDT1,ENDT=ENDT1
71 Q 0
Note: See TracBrowser for help on using the repository browser.