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

IBDFQB.m

Go to the documentation of this file.
  1. IBDFQB ;ALB/MAF - MAIN QUEUE JOB FOR ENCOUNTER FORM PRINTING - FEB 2 1995
  1. ;;3.0;AUTOMATED INFO COLLECTION SYS;**15**;APR 24, 1997
  1. ;
  1. EN ;
  1. ; -- Goes through the "SEQ" cross reference to print the
  1. ; highest priority jobs first (lowest sequence number).
  1. N IBDFQUE,IBDFQDT,IBDFQD,IBDFQT,IBDFTSTP
  1. S IBDFQUE=1,IBDFTSTP=1
  1. S (IBDFNUM,IBDFNAME,IBDFIFN,IBDFSEQ,QUIT)=0
  1. D NOW^%DTC S IBDFQDT=%,IBDFQD=$P(%,"."),IBDFQT=$E($P(%,".",2),1,4)
  1. ;
  1. F S IBDFSEQ=$O(^IBD(357.09,"SEQ",IBDFSEQ)) Q:IBDFSEQ']"" F S IBDFNUM=$O(^IBD(357.09,"SEQ",IBDFSEQ,IBDFNUM)) Q:IBDFNUM']"" F S IBDFIFN=$O(^IBD(357.09,"SEQ",IBDFSEQ,IBDFNUM,IBDFIFN)) Q:IBDFIFN']"" N IBDFARY D UP($$QUEUE(IBDFIFN))
  1. ;
  1. ; -- send forms pending pages to PCE automatically
  1. D BCKGRND^IBDFFRFT
  1. ;
  1. G EXIT
  1. ;
  1. ;
  1. UP(IBTASK) ; -- store results of tasking
  1. Q:'$G(IBTASK)
  1. D TASK
  1. Q
  1. ;
  1. ;
  1. QUEUE(IBDFIFN) ; -- Set up Queue variables
  1. N ZTSK,ZTDTH,ZTRTN,ZTDESC,ZTSAVE,ZTION,X,Y
  1. K ^TMP("IBDF",$J,"C"),^TMP("IBDF",$J,"D")
  1. D SET
  1. G:('$D(^TMP("IBDF",$J)))!QUIT CLEAR
  1. ;
  1. ; -- check if already tasked and running?
  1. ;I $P(IBDFNODE,"^",11)]"" S ZTSK=$P(IBDFNODE,"^",11) D STAT^%ZTLOAD I "^1^2^"[ZTSK(1) S QUIT=1 G CLEAR
  1. ;I $P(IBDFNODE,"^",11)]"" S ZTSK=$P(IBDFNODE,"^",11) W !,ZTSK,! B
  1. S $P(^IBD(357.09,IBDFNUM,"Q",IBDFIFN,0),"^",14)=$P(IBDFNODE,"^",11)
  1. ;
  1. F IBDT=0:0 S IBDT=$O(IBDFARY(IBDT)) Q:'IBDT D
  1. .S ZTDTH=$S('$D(ZTDTH):$H,$D(ZTDTH)&(ZTDTH]""):ZTDTH,1:$H)
  1. .S ZTRTN="DQ^IBDFQB",ZTDESC="IBD - Encounter Forms for"_IBDFNAME,ZTSAVE("^TMP(""IBDF"",$J,")="",ZTSAVE("IB*")="",ZTIO=$S($P(IBDFNODE,"^",9)]"":$P(IBDFNODE,"^",9),1:"") D ^%ZTLOAD D HOME^%ZIS
  1. ;
  1. ; -- after queing, delete start and stop times and add task
  1. ; -- once started add start time
  1. ; -- once finished add stop time, delete task no.
  1. ;
  1. S IBZTSK=ZTSK
  1. I '$D(ZTQUEUED) D ^%ZISC S QUIT=1
  1. ;
  1. ;
  1. CLEAR ; -- Clean up variables if task is not queued
  1. K ^TMP("IBDF",$J),^TMP("IB",$J)
  1. ;
  1. I QUIT D
  1. .I $D(ZTSK),$D(ZTSK(1)) I "^1^2^"[ZTSK(1) K ZTSK
  1. .S IBZTSK=$S($D(ZTSK):ZTSK,1:"")
  1. ;
  1. S QUIT=0
  1. Q $G(IBZTSK)
  1. ;
  1. DQ ; -- Generic entry points to edit
  1. ; -- only called by jobs tasked by this routine
  1. S IBDFFLD=".02" D UPDT
  1. D ^IBDF1B1
  1. S IBDFFLD=".03" D UPDT
  1. S IBTASK="@" D TASK
  1. Q
  1. ;
  1. UPDT ; -- Update start and finish times
  1. N DIE,DA,DR
  1. D NOW^%DTC S IBDFX=$E(%,1,12),DA=IBDFIFN,DA(1)=IBDFNUM,DIE="^IBD(357.09,"_DA(1)_","_"""Q"""_",",DR=IBDFFLD_"///"_"^S X=IBDFX" D ^DIE Q
  1. ;
  1. ;
  1. TASK ; -- Update Task number and last date printed
  1. N DA,DR,DIE
  1. S DA=IBDFIFN,DA(1)=IBDFNUM,DIE="^IBD(357.09,"_DA(1)_","_"""Q"""_",",DR=".11///"_IBTASK_";.12///"_IBDT D ^DIE
  1. I $D(IB1FLAG) S IB1TASK=IBTASK
  1. Q
  1. ;
  1. ;
  1. EXIT K IBADDONS,IBCLN,IBDFDAY,IBDFIFN,IBDFINST,IBDFNAME,IBDFNODE,IBDFNOW,IBDFNUM,IBDFSEQ,IBDIV,IBDT,IBREPRNT,IBSRT,IBSTRTDV,IBDFDAY1,IBDFLAST,IBDFONE,IBDFQ,IBDFXX,IBZTSK,QUIT
  1. I $D(ZTQUEUED) S ZTREQ="@" Q
  1. D ^%ZISC
  1. Q
  1. ;
  1. ;
  1. SET ; -- Set up variables needed for priniting of forms
  1. S IBDFNODE=$G(^IBD(357.09,IBDFNUM,"Q",IBDFIFN,0))
  1. I $P(IBDFNODE,"^",4)=""!($P(IBDFNODE,"^",5)="")!($P(IBDFNODE,"^",6)="")!($P(IBDFNODE,"^",7)="")!($P(IBDFNODE,"^",8)="")!($P(IBDFNODE,"^",9)="")!($P(IBDFNODE,"^",10)="") D I QUIT Q
  1. .I '$D(IBDFQUE) W !!,"PRINT QUEUE ABORTED.... missing required parameters!!!!" D PAUSE^VALM1
  1. .S QUIT=1
  1. .Q
  1. I $P(IBDFNODE,"^",8)="N" D I QUIT Q
  1. .I '$D(IBDFQUE) W !!,"PRINT QUEUE ABORTED.....not an active print job... check Special Instructions" D PAUSE^VALM1
  1. .S QUIT=1
  1. .Q
  1. S IBSRT=$P(IBDFNODE,"^",4),SELECTBY="C",IBADDONS=$P(IBDFNODE,"^",5),IBREPRNT="",IBSTRTDV=""
  1. D ENTRY Q:QUIT D
  1. .N GROUPS,IEN
  1. .; -- GET PRINT MANAGER GROUPS
  1. .S GROUPS=""
  1. .S GROUPS($P(IBDFNODE,"^",6))="" D
  1. ..S GROUPS=0 F S GROUPS=$O(GROUPS(GROUPS)) Q:'GROUPS D
  1. ...S IEN=0 F S IEN=$O(^IBD(357.99,GROUPS,10,IEN)) Q:'IEN S IBCLN=+$G(^IBD(357.99,GROUPS,10,IEN,0)) S:IBCLN ^TMP("IBDF",$J,"C",IBCLN)=""
  1. ...S IEN=0 F S IEN=$O(^IBD(357.99,GROUPS,11,IEN)) Q:'IEN S IBDIV=+$G(^IBD(357.99,GROUPS,11,IEN,0)) S:IBDIV ^TMP("IBDF",$J,"D",IBDIV)=""
  1. Q
  1. ;
  1. ;
  1. ENTRY ; -- Calc date and do checks on special instructions
  1. K IBDFARY
  1. N IBDFNOW,IBDFINST,IBDFDATE,IBDFDAYS,IBDFCTR,IBDFQTIM
  1. ;S IBDFNOW=$P($$NOW^XLFDT(),"."),IBDFINST=$P(IBDFNODE,"^",8),IBDFQTIM=$S($P(IBDFNODE,"^",13)]"":$P(IBDFNODE,"^",13),1:$E($P($$NOW^XLFDT(),".",2),1,4))
  1. S IBDFNOW=$P($$NOW^XLFDT(),"."),IBDFINST=$P(IBDFNODE,"^",8),IBDFQTIM=$S($P(IBDFNODE,"^",13)]"":$P(IBDFNODE,"^",13),1:IBDFQT)
  1. D:'$D(IBDFSING) ZTDTH
  1. ;
  1. ; -- if ignoring weekends and/or holidays, check current date
  1. I IBDFINST["W" I $$WEEKEND(IBDFNOW) S QUIT=1 Q
  1. I IBDFINST["H" I $$HOLIDAY(IBDFNOW) S QUIT=1 Q
  1. I IBDFINST["I" I $$WEEKEND(IBDFNOW)!($$HOLIDAY(IBDFNOW)) S QUIT=1 Q
  1. ;
  1. ; -- find date to return - returned in IBDFARY(date) array
  1. ; -- loop adds 1 day and checks if day is restricted
  1. ; -- if not, it adds it as a printable day and compares it
  1. ; -- with the number of printable days ahead the user wants to prn
  1. S IBDFDATE=IBDFNOW,IBDFCTR=0,IBDFDAYS=+$P(IBDFNODE,"^",7)
  1. F Q:IBDFCTR=IBDFDAYS D
  1. .S IBDFDATE=$$FMADD^XLFDT(IBDFDATE,1)
  1. .I IBDFINST["W" Q:$$WEEKEND(IBDFDATE)
  1. .I IBDFINST["H" Q:$$HOLIDAY(IBDFDATE)
  1. .I IBDFINST["I" Q:$$WEEKEND(IBDFDATE)!($$HOLIDAY(IBDFDATE))
  1. .S IBDFCTR=IBDFCTR+1
  1. S IBDFARY(IBDFDATE)=""
  1. Q
  1. ;
  1. WEEKEND(DATE) ;
  1. ; -- DATE (defaulted to current date if not passed)
  1. ; -- output = 1 if date is a weekend
  1. I '$G(DATE) S DATE=$P($$NOW^XLFDT(),".")
  1. I 60[$$DOW^XLFDT(DATE,1) Q 1
  1. Q 0
  1. ;
  1. HOLIDAY(DATE) ;
  1. ; -- DATE (defaulted to current date if not passed)
  1. ; -- output = 1 if date is a holiday
  1. I '$G(DATE) S DATE=$P($$NOW^XLFDT(),".")
  1. N X,Y,DIC
  1. S DIC="^HOLIDAY(",DIC(0)="",X=+$P(DATE,".")
  1. D ^DIC I +Y>0 Q 1
  1. Q 0
  1. ZTDTH ; -- Set up the variable ZTDTH to pass the queue date time of the
  1. ; queued job.
  1. N IBDFJQ
  1. I IBDFQT=2400!(IBDFQT=0000) D G DTIME
  1. .I IBDFQTIM=2400 S IBDFQTIM="0000"
  1. .I IBDFQTIM=IBDFQT S IBDFJQ=IBDFQDT Q
  1. .S IBDFJQ=IBDFQD_"."_IBDFQTIM
  1. I IBDFQTIM>IBDFQT S IBDFJQ=IBDFQD_"."_IBDFQTIM
  1. I IBDFQTIM<IBDFQT S X1=IBDFQDT,X2=1 D C^%DTC S IBDFJQ=$P(X,".")_"."_IBDFQTIM
  1. I IBDFQTIM=IBDFQT S IBDFJQ=IBDFQDT
  1. DTIME I IBDFJQ]"" S ZTDTH=$$FMTH^XLFDT(IBDFJQ)
  1. Q