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

APCLPRT.m

Go to the documentation of this file.
APCLPRT ; IHS/CMI/LAB - PRINTS REPORTS USING REPORT TEMPLATE FILE ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;
 ;CMI/TUCSON/LAB - patch 3 - 10/26/1998 - Y2K fixes
EN(APCLDFN,APCLROOT,APCLPD) ;PEP - create report
 I '$D(APCLROOT) W !,*7,"Global root not indicated!" Q
 I '$D(ZTQUEUED),$P(IOST,"-")="C" S APCLBRK="" W @IOF
 S APCLENDR=$E(APCLROOT,$L(APCLROOT)) I "(,"[APCLENDR S APCLROOT=$E(APCLROOT,1,($L(APCLROOT)-1))
 S APCLENDR=$E(APCLROOT,$L(APCLROOT)) I APCLENDR'=")",APCLROOT["(" S APCLROOT=APCLROOT_")"
 S (APCLOOP,APCLCNT,APCLSTP)=0 F  S APCLOOP=$O(^APCLRPT(APCLDFN,21,APCLOOP)) Q:'APCLOOP!APCLSTP  S APCLL=0 S APCLLINE=^(APCLOOP,0) D  D APCLWRTE
 . F I=1:1 Q:$P(APCLLINE,"|",2,99)=""  S APCLN=+$P(APCLLINE,"|",2),APCLTMP=$P(APCLLINE,"|") S APCLV=$S($D(@APCLROOT@(APCLN)):@APCLROOT@(APCLN),1:"") D:APCLV="" CODE D:APCLV]""&($P($G(^APCLRPT(APCLDFN,31,APCLN,0)),U,2)="p") PCT D  K APCLCODE
 .. I ($L(APCLTMP)+$L(APCLV))>$S($D(APCLCODE):250,1:IOM) S APCLL=APCLL+1 S APCLWRTE(APCLL)=APCLTMP S APCLLINE=APCLV_$P(APCLLINE,"|",3,999) Q
 .. S APCLTMP=APCLTMP_APCLV
 .. I ($L(APCLTMP)+$L($P(APCLLINE,"|",3,999)))>IOM S APCLL=APCLL+1 S APCLWRTE(APCLL)=APCLTMP S APCLLINE=$P(APCLLINE,"|",3,999) Q
 .. S APCLLINE=APCLTMP_$P(APCLLINE,"|",3,999)
 . S APCLL=APCLL+1 S APCLWRTE(APCLL)=APCLLINE
 I $D(APCLBRK),'APCLSTP D PAGE I 1
 E  W @IOF
 K APCLOOP,APCLBRK,APCLCNT,APCLI,APCLTMP,APCLL,APCLLINE,APCLN,APCLV,APCLWRTE,APCLX,APCLENDR
 I '$D(APCLASK) K APCLSTP
 Q
 ;
CODE ; Get date or value from data fetcher
 NEW APCLDIS,APCLI,APCLSTP
 K APCLER
 I $G(APCLPD),$G(^APCLRPT(APCLDFN,31,APCLN,21))]"" S APCLCODE=^(21) D
 . I APCLCODE["*" S APCLV="Script error - '*' entered as a value!" Q
 . I $G(APCLDATE)]"",$P(APCLCODE,";",2)]"" S APCLV="Script error - date information entered!" Q
 . S APCLDIS=$S($P(APCLCODE," ")="DATE":"DATE",$P(APCLCODE," ")="VALUE"!("PATPT"[$P(APCLCODE," ")):"VALUE",1:"BOTH")
 . I $E($P(APCLCODE," "),1,3)["PAT"!($E($P(APCLCODE," "),1,2)["PT")
 . E  I APCLDIS="DATE"!(APCLDIS="VALUE") S APCLCODE=$P(APCLCODE," ",2,99)
 . I $E($P(APCLCODE," "),1,3)'="PAT",$E($P(APCLCODE," "),1,2)'="PT" S APCLCODE=APCLCODE_$G(APCLDATE)
 . S APCLX=APCLPD_"^"_APCLCODE,APCLY="APCLDF(" S APCLER=$$START1^APCLDF(APCLX,APCLY) K APCLX,APCLY
 . I APCLER S APCLV="Data Retrieval Error!" K APCLER Q
 . K APCLER
 . I '$D(APCLDF) S APCLV="None Found" K APCLDF Q
 . I APCLDIS="BOTH"!(APCLDIS="DATE") F APCLI=1:1 Q:'$D(APCLDF(APCLI))  D  Q:$G(APCLSTP)  D SET
 .. I ($L(APCLV)+6)>246 S APCLSTP=1,APCLV=APCLV_" ...etc."
 . I APCLDIS'="VALUE" K APCLDF Q
 . F APCLI=1:1 Q:'$D(APCLDF(APCLI))  D  Q:$G(APCLSTP)  S APCLV=$S(APCLI>1:APCLV_", ",1:$G(APCLV))_$P(APCLDF(APCLI),U,2)
 .. I ($L(APCLV)+6)>246 S APCLSTP=1,APCLV=APCLV_" ...etc."
 . K APCLDF,APCLPCE
 Q
 ;
SET ; Set Value and or Date from PCC SCRIPT
 ;beginning Y2K fix.   Modified line to use a 4 digit year rather than a 2 digit year.  Not sure is this was necessary but it will work either way.
 ;S Y=$P(APCLDF(APCLI),U),Y=$E(Y,4,5)_"/"_$E(Y,6,7)_"/"_$E(Y,2,3) S APCLV=$S(APCLI>1:APCLV_", ",1:$G(APCLV))_$S(APCLDIS="BOTH":$P(APCLDF(APCLI),U,2)_" - "_Y,1:Y)
 S Y=$P(APCLDF(APCLI),U),Y=$E(Y,4,5)_"/"_$E(Y,6,7)_"/"_(1700+$E(Y,1,3)) S APCLV=$S(APCLI>1:APCLV_", ",1:$G(APCLV))_$S(APCLDIS="BOTH":$P(APCLDF(APCLI),U,2)_" - "_Y,1:Y) ;Y2000
 ;end Y2K fix
 Q
 ;
APCLWRTE ; Write line
 I APCLWRTE(1)="@",$D(APCLBRK) D PAGE G X1
 I APCLWRTE(1)="@" W @IOF S APCLCNT=0 G X1
 F APCLX=1:1:APCLL Q:APCLSTP  W !,APCLWRTE(APCLX) S APCLCNT=APCLCNT+1 I $D(APCLBRK),(IOSL-3)<APCLCNT D PAGE
X2 K APCLWRTE
 Q
 ;
PAGE ; Page Control
 W !
 S DIR(0)="E" D ^DIR K DIR
 I Y S APCLCNT=0
 E  S APCLSTP=1
 W @IOF
 Q
 ;
PCT ; Determine APCL     
 S @("APCLV="_APCLV)
 S APCLV=APCLV*100,APCLV=$J(APCLV,3,0)_"%"
X1 Q
 ;