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

BDMPRT.m

Go to the documentation of this file.
BDMPRT ; IHS/CMI/LAB - PRINTS REPORTS USING REPORT TEMPLATE FILE ;
 ;;2.0;DIABETES MANAGEMENT SYSTEM;**2**;JUN 14, 2007
 ;
 ;CMI/TUCSON/LAB - patch 3 - 10/26/1998 - Y2K fixes
EN(BDMDFN,BDMROOT,BDMPD) ;PEP - create report
 I '$D(BDMROOT) W !,*7,"Global root not indicated!" Q
 I '$D(ZTQUEUED),$P(IOST,"-")="C" S BDMBRK="" W @IOF
 S BDMENDR=$E(BDMROOT,$L(BDMROOT)) I "(,"[BDMENDR S BDMROOT=$E(BDMROOT,1,($L(BDMROOT)-1))
 S BDMENDR=$E(BDMROOT,$L(BDMROOT)) I BDMENDR'=")",BDMROOT["(" S BDMROOT=BDMROOT_")"
 S (BDMOOP,BDMCNT,BDMSTP)=0 F  S BDMOOP=$O(^APCLRPT(BDMDFN,21,BDMOOP)) Q:'BDMOOP!BDMSTP  S BDML=0 S BDMLINE=^(BDMOOP,0) D  D BDMWRTE
 . F I=1:1 Q:$P(BDMLINE,"|",2,99)=""  S BDMN=+$P(BDMLINE,"|",2),BDMTMP=$P(BDMLINE,"|") S BDMV=$S($D(@BDMROOT@(BDMN)):@BDMROOT@(BDMN),1:"") D:BDMV="" CODE D:BDMV]""&($P($G(^APCLRPT(BDMDFN,31,BDMN,0)),U,2)="p") PCT D  K BDMCODE
 .. I ($L(BDMTMP)+$L(BDMV))>$S($D(BDMCODE):250,1:IOM) S BDML=BDML+1 S BDMWRTE(BDML)=BDMTMP S BDMLINE=BDMV_$P(BDMLINE,"|",3,999) Q
 .. S BDMTMP=BDMTMP_BDMV
 .. I ($L(BDMTMP)+$L($P(BDMLINE,"|",3,999)))>IOM S BDML=BDML+1 S BDMWRTE(BDML)=BDMTMP S BDMLINE=$P(BDMLINE,"|",3,999) Q
 .. S BDMLINE=BDMTMP_$P(BDMLINE,"|",3,999)
 . S BDML=BDML+1 S BDMWRTE(BDML)=BDMLINE
 I $D(BDMBRK),'BDMSTP D PAGE I 1
 E  W @IOF
 K BDMOOP,BDMBRK,BDMCNT,BDMI,BDMTMP,BDML,BDMLINE,BDMN,BDMV,BDMWRTE,BDMX,BDMENDR
 I '$D(BDMASK) K BDMSTP
 Q
 ;
CODE ; Get date or value from data fetcher
 NEW BDMDIS,BDMI,BDMSTP
 K BDMER
 I $G(BDMPD),$G(^APCLRPT(BDMDFN,31,BDMN,21))]"" S BDMCODE=^(21) D
 . I BDMCODE["*" S BDMV="Script error - '*' entered as a value!" Q
 . I $G(BDMDATE)]"",$P(BDMCODE,";",2)]"" S BDMV="Script error - date information entered!" Q
 . S BDMDIS=$S($P(BDMCODE," ")="DATE":"DATE",$P(BDMCODE," ")="VALUE"!("PATPT"[$P(BDMCODE," ")):"VALUE",1:"BOTH")
 . I $E($P(BDMCODE," "),1,3)["PAT"!($E($P(BDMCODE," "),1,2)["PT")
 . E  I BDMDIS="DATE"!(BDMDIS="VALUE") S BDMCODE=$P(BDMCODE," ",2,99)
 . I $E($P(BDMCODE," "),1,3)'="PAT",$E($P(BDMCODE," "),1,2)'="PT" S BDMCODE=BDMCODE_$G(BDMDATE)
 . S BDMX=BDMPD_"^"_BDMCODE,BDMY="BDMDF(" S BDMER=$$START1^APCLDF(BDMX,BDMY) K BDMX,BDMY
 . I BDMER S BDMV="Data Retrieval Error!" K BDMER Q
 . K BDMER
 . I '$D(BDMDF) S BDMV="None Found" K BDMDF Q
 . I BDMDIS="BOTH"!(BDMDIS="DATE") F BDMI=1:1 Q:'$D(BDMDF(BDMI))  D  Q:$G(BDMSTP)  D SET
 .. I ($L(BDMV)+6)>246 S BDMSTP=1,BDMV=BDMV_" ...etc."
 . I BDMDIS'="VALUE" K BDMDF Q
 . F BDMI=1:1 Q:'$D(BDMDF(BDMI))  D  Q:$G(BDMSTP)  S BDMV=$S(BDMI>1:BDMV_", ",1:$G(BDMV))_$P(BDMDF(BDMI),U,2)
 .. I ($L(BDMV)+6)>246 S BDMSTP=1,BDMV=BDMV_" ...etc."
 . K BDMDF,BDMPCE
 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(BDMDF(BDMI),U),Y=$E(Y,4,5)_"/"_$E(Y,6,7)_"/"_$E(Y,2,3) S BDMV=$S(BDMI>1:BDMV_", ",1:$G(BDMV))_$S(BDMDIS="BOTH":$P(BDMDF(BDMI),U,2)_" - "_Y,1:Y)
 S Y=$P(BDMDF(BDMI),U),Y=$E(Y,4,5)_"/"_$E(Y,6,7)_"/"_(1700+$E(Y,1,3)) S BDMV=$S(BDMI>1:BDMV_", ",1:$G(BDMV))_$S(BDMDIS="BOTH":$P(BDMDF(BDMI),U,2)_" - "_Y,1:Y) ;Y2000
 ;end Y2K fix
 Q
 ;
BDMWRTE ; Write line
 I BDMWRTE(1)="@",$D(BDMBRK) D PAGE G X1
 I BDMWRTE(1)="@" W @IOF S BDMCNT=0 G X1
 F BDMX=1:1:BDML Q:BDMSTP  W !,BDMWRTE(BDMX) S BDMCNT=BDMCNT+1 I $D(BDMBRK),(IOSL-3)<BDMCNT D PAGE
X2 K BDMWRTE
 Q
 ;
PAGE ; Page Control
 W !
 S DIR(0)="E" D ^DIR K DIR
 I Y S BDMCNT=0
 E  S BDMSTP=1
 W @IOF
 Q
 ;
PCT ; Determine BDM     
 S @("BDMV="_BDMV)
 S BDMV=BDMV*100,BDMV=$J(BDMV,3,0)_"%"
X1 Q
 ;