Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: PRCHLO

PRCHLO.m

Go to the documentation of this file.
  1. PRCHLO ;WOIFO/RLL-EXTRACT ROUTINE CLO REPORT SERVER ;12/30/10 14:34
  1. ;;5.1;IFCAP;**83,104,130,154**;Oct 20, 2000;Build 5
  1. ; Per VHA Directive 2004-038, this routine should not be modified
  1. ;
  1. ; PRCHLO* routines are used to build the extract files from
  1. ; file 410, 424, and 442 for the clinical logistics report server.
  1. ; PRCHLO thru PRCHLO6 perform the following:
  1. ; 1. Initialize environment
  1. ; 2. Get parameters for the month being run
  1. ; 3. Pull data from file 410, 424, and 442 for month being run
  1. ; 4. Create multiple "^" delimited flat files for report server
  1. ; 5. At the completion of extracts FTP files to report server
  1. ; 6. Clean up / remove any temp files
  1. ; 7. logout
  1. ; CALC is the programmer entry point used to test the extract
  1. ; options for the first iteration of coding
  1. ;
  1. Q
  1. INIT ; Initialize environment
  1. ;
  1. K ^TMP($J)
  1. ;
  1. ; Get todays date
  1. N %
  1. S %=$P(($$NOW^XLFDT),".",1)
  1. ; (old logic)
  1. ; Always start from the 1st of the month to the end of month
  1. ; and at least 45 days prior to todays date
  1. ;
  1. ; (new logic)
  1. ; Always start from the beginning of the Fiscal Year and run
  1. ; the extract up until the Date of the extract run (NOW)
  1. ;
  1. ; The CALC entry point is used for testing from programmer mode
  1. ; and allows the programmer to pass a specific date
  1. ; in the variable %=FM date format
  1. ;
  1. CALC ;test entry point, set %I to FM date
  1. ;
  1. N CLO1,CLO2,CLO2B,CLO2E,CLO3,CLOBGN,CLOEND,CLO1A
  1. N MTHRUN,YRRUN,PYRRUN
  1. S CLO1=$E(%,1,3)
  1. ;
  1. S CLO2=$E(%,4,5)
  1. S YRRUN=+(CLO1)
  1. S PYRRUN=YRRUN-1 ; previous Year Run
  1. S MTHRUN=+(CLO2)
  1. I +CLO2>2 D
  1. . S CLO2B=CLO2-2
  1. . I $L(CLO2B)<2 S CLO2B=0_CLO2B
  1. . S CLO2E=CLO2-1
  1. . I $L(CLO2E)<2 S CLO2E=0_CLO2E
  1. . S CLOBGN=+(CLO1_(CLO2B)_"00")
  1. . S CLOEND=+(CLO1_(CLO2E)_"01")
  1. . Q
  1. ;
  1. ; check for January run, and Feb run
  1. I +CLO2=1 D
  1. . S CLO1=CLO1-1
  1. . S CLOBGN=+(CLO1_11_"00") ; Start date is Nov 1st
  1. . S CLOEND=+(CLO1_12_"01") ; End date is Dec 1st
  1. . Q
  1. I +CLO2=2 D
  1. . S CLO1A=CLO1-1 ; Need to get Dec, previous year
  1. . S CLOBGN=+(CLO1A_12_"00") ; Start date is Dec 1st
  1. . S CLOEND=+(CLO1_"01"_"01") ; End date is Jan 1st
  1. . Q
  1. ;
  1. ; (Begin new logic)
  1. FYRNOW ; Changes added 07/31/06 RLL for new extract date range.
  1. ; CLOBGN will always be the beginning of the Fiscal Year (Oct 1st)
  1. ; This will be the start range for each extract.
  1. ; This routine is called through the option :
  1. ; [PRCHLO CLO PROCUREMENT] which is queued to run in TaskMan
  1. ; This option should be queued to run 2 hours AFTER
  1. ; [PRCHLO GIP OPTION] and should be run on the same day
  1. ; (after midnight) as the [PRCHLO GIP OPTION]. As an example:
  1. ; 1. Que [PRCHLO GIP OPTION] to run 12:00am the 1st of the month
  1. ; 2. Que [PRCHLO CLO PROCUREMENT] to run 1:00am the 1st of the month
  1. ;
  1. ;
  1. ; The following new Variables were added to the CALC entry point:
  1. ; YRRUN ; year option run
  1. ; PYRRUN ; previous year option run
  1. ; MTHRUN ; MONTHRUN
  1. ; listed below are 3 examples:
  1. ;
  1. ; Month Option Run | Date Range for Run | # of months of data
  1. ; Dec 1st, 2005 | Oct 1, 2005 to Dec 1st 2005| 2
  1. ; Apr 1st, 2006 | Oct 1, 2005 to Apr 1st 2006| 6
  1. ; Oct 1st, 2006 | Oct 1, 2005 to Oct 1st 2006| 12
  1. ;
  1. STCLOBGN ; Set CLOBGN to Beginning of Fiscal Year (Oct. 1)
  1. ;
  1. I MTHRUN=12!(MTHRUN=11) D
  1. . ; For Nov or Dec, CLOBGN set to Begin of FY(Oct 1st) in same year
  1. . S CLOBGN=+(YRRUN_"10"_"00")
  1. . S CLOEND=% ; CLOEND is Date Extract Run
  1. . Q
  1. I (MTHRUN<11) D ; (CLOBGN set to Prev FY for all other conditions)
  1. . S CLOBGN=+(PYRRUN_"10"_"00")
  1. . S CLOEND=% ; CLOEND is Date Extract Run
  1. . Q
  1. ; (End new logic)
  1. ;
  1. DEBUGFY ; Debug Fiscal Year logic by uncommenting code below 7/31/06 RLL
  1. ;
  1. D GPARM
  1. ; Make sure ^TMP($J) is set with data, otherwise return error
  1. N CKTP
  1. S CKTP=$O(^TMP($J,0))
  1. I CKTP="" D
  1. . S CLRSERR=1 ; error flag indicates no data in ^TMP($J)
  1. . Q
  1. Q
  1. ;
  1. GPARM ; Get parameters for monthly extract
  1. ;
  1. ; need to set monthyear for data file
  1. ;
  1. N MNTHYR,FMDT1,MYRVAL
  1. S FMDT1=$P(($$NOW^XLFDT),".",1)
  1. S MYRVAL=$$FMTE^XLFDT(FMDT1)
  1. S MNTHYR=$P(MYRVAL," ",1)_","_$P(MYRVAL," ",3)
  1. ;
  1. ; $O through the "AB" x-ref based on CLOBGN and CLOEND
  1. ;
  1. S CLO1=CLOBGN,CLO2="",CLO3=""
  1. F S CLO1=$O(^PRC(442,"AB",CLO1)) Q:CLO1="" D
  1. . F S CLO2=$O(^PRC(442,"AB",CLO1,CLO2)) Q:CLO2="" D
  1. . . Q:CLO1>(CLOEND-1)
  1. . . D GKEY
  1. . . Q
  1. . Q
  1. ; PRC*5.1*130 begin
  1. D GET410^PRCHLO6
  1. D GET424^PRCHLO6
  1. ; PRC*5.1*130 end
  1. D INVCOMPL^PRCHLO7 ;Compile Invoice Tracking
  1. Q
  1. EXTR ; Extract the data, create files
  1. ;
  1. GKEY ; get key for all tables
  1. N POID,POCRDAT
  1. S POID=CLO2
  1. S POCRDAT=CLO1 ; PO Date from x-ref value
  1. D GPOMAST^PRCHLO1 ;
  1. Q