source: FOIAVistA/trunk/r/IFCAP-PRC-PRX--PRCA--PRCN/PRCHLO.m@ 1226

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

initial load of FOIAVistA 6/30/08 version

File size: 4.5 KB
Line 
1PRCHLO ;WOIFO/RLL-EXTRACT ROUTINE CLO REPORT SERVER ; 7/31/06 12:33pm
2V ;;5.1;IFCAP;**83,104**; Oct 20, 2000
3 ; Per VHA Directive 10-93-142, this routine should not be modified
4 ;
5 ; PRCHLO* routines are used to build the extract files from
6 ; file 442 for the clinical logistics report server.
7 ; PRCHLO thru PRCHLO5 perform the following:
8 ; 1. Initialize environment
9 ; 2. Get parameters for the month being run
10 ; 3. Pull data from file 442 for month being run
11 ; 4. Create multiple "^" delimited flat files for report server
12 ; 5. At the completion of extracts FTP files to report server
13 ; 6. Clean up / remove any temp files
14 ; 7. logout
15 ; CALC is the programmer entry point used to test the extract
16 ; options for the first iteration of coding
17 ;
18 Q
19INIT ; Initialize environment
20 ;
21 ;
22 ; Get todays date
23 N %
24 S %=$P(($$NOW^XLFDT),".",1)
25 ; (old logic)
26 ; Always start from the 1st of the month to the end of month
27 ; and at least 45 days prior to todays date
28 ;
29 ; (new logic)
30 ; Always start from the beginning of the Fiscal Year and run
31 ; the extract up until the Date of the extract run (NOW)
32 ;
33 ; The CALC entry point is used for testing from programmer mode
34 ; and allows the programmer to pass a specific date
35 ; in the variable %=FM date format
36 ;
37CALC ;test entry point, set %I to FM date
38 ;
39 N CLO1,CLO2,CLO2B,CLO2E,CLO3,CLOBGN,CLOEND,POND1,POND2,CLO1A
40 N MTHRUN,YRRUN,PYRRUN
41 S CLO1=$E(%,1,3)
42 ;
43 S CLO2=$E(%,4,5)
44 S YRRUN=+(CLO1)
45 S PYRRUN=YRRUN-1 ; previous Year Run
46 S MTHRUN=+(CLO2)
47 I +CLO2>2 D
48 . S CLO2B=CLO2-2
49 . I $L(CLO2B)<2 S CLO2B=0_CLO2B
50 . S CLO2E=CLO2-1
51 . I $L(CLO2E)<2 S CLO2E=0_CLO2E
52 . S CLOBGN=+(CLO1_(CLO2B)_"00")
53 . S CLOEND=+(CLO1_(CLO2E)_"01")
54 . Q
55 ;
56 ; check for January run, and Feb run
57 I +CLO2=1 D
58 . S CLO1=CLO1-1
59 . S CLOBGN=+(CLO1_11_"00") ; Start date is Nov 1st
60 . S CLOEND=+(CLO1_12_"01") ; End date is Dec 1st
61 . Q
62 I +CLO2=2 D
63 . S CLO1A=CLO1-1 ; Need to get Dec, previous year
64 . S CLOBGN=+(CLO1A_12_"00") ; Start date is Dec 1st
65 . S CLOEND=+(CLO1_"01"_"01") ; End date is Jan 1st
66 . Q
67 ;
68 ; (Begin new logic)
69FYRNOW ; Changes added 07/31/06 RLL for new extract date range.
70 ; CLOBGN will always be the beginning of the Fiscal Year (Oct 1st)
71 ; This will be the start range for each extract.
72 ; This routine is called through the option :
73 ; [PRCHLO CLO PROCUREMENT] which is queued to run in TaskMan
74 ; This option should be queued to run 2 hours AFTER
75 ; [PRCHLO GIP OPTION] and should be run on the same day
76 ; (after midnight) as the [PRCHLO GIP OPTION]. As an example:
77 ; 1. Que [PRCHLO GIP OPTION] to run 12:00am the 1st of the month
78 ; 2. Que [PRCHLO CLO PROCUREMENT] to run 1:00am the 1st of the month
79 ;
80 ;
81 ; The following new Variables were added to the CALC entry point:
82 ; YRRUN ; year option run
83 ; PYRRUN ; previous year option run
84 ; MTHRUN ; MONTHRUN
85 ; listed below are 3 examples:
86 ;
87 ; Month Option Run | Date Range for Run | # of months of data
88 ; Dec 1st, 2005 | Oct 1, 2005 to Dec 1st 2005| 2
89 ; Apr 1st, 2006 | Oct 1, 2005 to Apr 1st 2006| 6
90 ; Oct 1st, 2006 | Oct 1, 2005 to Oct 1st 2006| 12
91 ;
92STCLOBGN ; Set CLOBGN to Beginning of Fiscal Year (Oct. 1)
93 ;
94 I MTHRUN=12!(MTHRUN=11) D
95 . ; For Nov or Dec, CLOBGN set to Begin of FY(Oct 1st) in same year
96 . S CLOBGN=+(YRRUN_"10"_"00")
97 . S CLOEND=% ; CLOEND is Date Extract Run
98 . Q
99 I (MTHRUN<11) D ; (CLOBGN set to Prev FY for all other conditions)
100 . S CLOBGN=+(PYRRUN_"10"_"00")
101 . S CLOEND=% ; CLOEND is Date Extract Run
102 . Q
103 ; (End new logic)
104 ;
105DEBUGFY ; Debug Fiscal Year logic by uncommenting code below 7/31/06 RLL
106 ; W !,"CLOBGN is ",CLOBGN," CLOEND is ",CLOEND,! ; Write date range
107 ; Q ; Quit added here for debugging 7/31/06 RLL
108 ;
109 D GPARM
110 ; Make sure ^TMP($J) is set with data, otherwise return error
111 N CKTP
112 S CKTP=$O(^TMP($J,0))
113 I CKTP="" D
114 . S CLRSERR=1 ; error flag indicates no data in ^TMP($J)
115 . Q
116 Q
117 ;
118GPARM ; Get parameters for monthly extract
119 ;
120 ; need to set monthyear for data file
121 ;
122 N MNTHYR,FMDT1,MYRVAL
123 S FMDT1=$P(($$NOW^XLFDT),".",1)
124 S MYRVAL=$$FMTE^XLFDT(FMDT1)
125 S MNTHYR=$P(MYRVAL," ",1)_","_$P(MYRVAL," ",3)
126 ;
127 ; $O through the "AB" x-ref based on CLOBGN and CLOEND
128 ;
129 S CLO1=CLOBGN,CLO2="",CLO3=""
130 F S CLO1=$O(^PRC(442,"AB",CLO1)) Q:CLO1="" D
131 . F S CLO2=$O(^PRC(442,"AB",CLO1,CLO2)) Q:CLO2="" D
132 . . Q:CLO1>(CLOEND-1)
133 . . D GKEY
134 . . Q
135 . Q
136 Q
137EXTR ; Extract the data, create files
138 ;
139GKEY ; get key for all tables
140 N POID,POND0,POND1,POCRDAT
141 S POND0=$G(^PRC(442,CLO2,0))
142 S POND1=$G(^PRC(442,CLO2,1))
143 S POID=CLO2
144 S POCRDAT=CLO1 ; PO Date from x-ref value
145 D GPOMAST^PRCHLO1 ;
146 Q
Note: See TracBrowser for help on using the repository browser.