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

APCHPWHG.m

Go to the documentation of this file.
APCHPWHG ; IHS/CMI/LAB - PCC HEALTH SUMMARY ;
 ;;2.0;IHS PCC SUITE;**2,7,10**;MAY 14, 2009;Build 88
EN ;
 W !!,$$CTR("*** Patient Wellness Handout ***"),!!
SELTYP ;
 K DIADD,DLAYGO
 D ^XBFMK
 K DIC S DIC="^APCHPWHT(",DIC("A")="Select Patient Wellness Handout type: ",DIC(0)="AEQM"
 S X="" I DUZ(2),$D(^APCCCTRL(DUZ(2),0))#2 S X=$P(^(0),U,16)
 I $D(^DISV(DUZ,"^APCHPWHT(")) S Y=^("^APCHPWHT(") I $D(^APCHPWHT(Y,0)) S X=$P(^(0),U,1)
 S:X="" X="ADULT REGULAR"
 S DIC("B")=X
 D ^DIC K DIC
 I Y=-1 D EXIT Q
 S APCHPWHT=+Y
SELPT ;
 W !
 S DFN=""
 K DIC S DIC=9000001,DIC("A")="Select patient: ",DIC(0)="AEQM" D ^DIC K DIC
 I Y=-1 G SELTYP
 S DFN=+Y W:$D(^AUPNPAT(DFN,41,DUZ(2),0)) !,"Patient's chart number is ",$P(^(0),U,2),!
 ;I $$AGE^AUPNPAT(DFN,DT)<18 W !,"Warning:  This handout is designed for patients 18 and older.  This",!,"patient is under 18.  Please select a different patient." K DFN G SELPT
 ;.S APCHSQ=""
 ;.K DIR S DIR(0)="Y",DIR("A")="Do you wish to continue and print the handout",DIR("B")="N" KILL DA D ^DIR KILL DIR
 ;.I 'Y S APCHSQ=1
 ;.Q
 D ZIS
 D EXIT
 Q
 ;
EN2(APCHPWHT,P) ;EP
 NEW DFN
 S DFN=P
 D ZIS
 Q
 ;
ZIS ;EP
 W !! S DIR(0)="S^P:PRINT Output;B:BROWSE Output on Screen",DIR("A")="Do you wish to",DIR("B")="P" K DA D ^DIR K DIR
 I $D(DIRUT) D EXIT Q
 S APCHOPT=Y
 I Y="B" D BROWSE,EXIT Q
 S XBRP="PRINT^APCHPWHG",XBRC="",XBRX="EXIT^APCHPWHG",XBNS="APCH;DFN"
 D ^XBDBQUE
 D EXIT
 Q
 ;
EHR(DFN,APCHPWHT)  ;EP - CMI/GRL support for EHR
 I '$G(APCHPWHT) S APCHPWHT=$P($G(^APCCCTRL(DUZ(2),0)),U,16)
 I APCHPWHT="" S APCHPWHT=$O(^APCHPWHT("B","ADULT REGULAR",0))
 D EN^XBNEW("PRINT^APCHPWHG","DFN;APCHPWHT")
 Q
BROWSE ;
 S XBRP="VIEWR^XBLM(""PRINT^APCHPWHG"")"
 S XBRC="",XBRX="EXIT1^APCHPWHG",XBIOP=0 D ^XBDBQUE
 Q
EXIT ;
 D EN^XBVK("APCH")
 K DFN
 D ^XBFMK
 Q
 ;
 ;
EXIT1 ;
 D CLEAR^VALM1
 D FULL^VALM1
 K DFN
 D ^XBFMK
 Q
 ;
ENCOMP ;EP
 NEW T,APCHPWHT
 S APCHPWHT=$P($G(^APCCCTRL(DUZ(2),0)),U,16)
 I 'APCHPWHT S APCHPWHT=$O(^APCHPWHT("B","ADULT REGULAR",0))
 I 'APCHPWHT Q
 W:$D(IOF) @IOF
 D EHR(APCHSPAT,APCHPWHT)
 Q
 ;
EN1(APCHPWHT) ;EP
 NEW APCHOLD
 D PRINT
 Q
PRINT ;EP
 S APCHSCVD="S:Y]"""" Y=+Y,Y=$E(Y,4,5)_""/""_$S($E(Y,6,7):$E(Y,6,7)_""/"",1:"""")_$E(Y,2,3)"
 K ^TMP($J,"APCHPWH")
 I '$G(APCHITST) D UPDLOG(DFN,APCHPWHT,DUZ)  ;D UPDLOG(DFN,APCHPWHT,DUZ)
 D EP^APCHPWH1(DFN,APCHPWHT,1) ;gather up data in ^TMP
W ;write out array
 ;W:$D(IOF) @IOF
 K APCHQUIT
 S APCHPG=0 D HEADER
 Q:$D(APCHQUIT)
 S APCHX=0 F  S APCHX=$O(^TMP($J,"APCHPWH",APCHX)) Q:APCHX'=+APCHX!($D(APCHQUIT))  D
 .;find number of lines until next component
 .S C=0 I ^TMP($J,"APCHPWH",APCHX)["________________" S A=APCHX F  S A=$O(^TMP($J,"APCHPWH",A)) Q:A'=+A  Q:^TMP($J,"APCHPWH",A)["_______________"  S C=C+1
 .I $Y>(IOSL-$S(C<7:(C+3),1:3)) D HEADER Q:$D(APCHQUIT)
 .;I ^TMP($J,"APCHPWH",APCHX)[" INTAKE FORM" D HEADER Q:$D(APCHQUIT)
 .W !,^TMP($J,"APCHPWH",APCHX)
 .Q
 I $D(APCHQUIT) S APCHSQIT=1
 ;footer
 I $E(IOST)="C",IO=IO(0) W ! K DIR S DIR(0)="EO",DIR("A")="End of Report.  Press Enter." D ^DIR K DIR Q
 D EOJ
 Q
 ;
EOJ ;
 ;
 K ^TMP($J,"APCHPWH")
 D EN^XBVK("APCH")
 D EN^XBVK("APCD")
 D ^XBFMK
 K BIDLLID,BIDLLPRO,BIDLLRUN,BIRESULT,BISITE
 K AUPNDAYS,AUPNDOB,AUPNDOD,AUPNPAT,AUPNSEX
 K N,%,T,F,X,Y,B,C,E,F,H,J,L,N,P,T,W,ST,ST0
 Q
 G:APCHPG=0 HEAD1
 I $E(IOST)="C",IO=IO(0) W ! S DIR(0)="EO" D ^DIR K DIR I Y=0!(Y="^")!($D(DTOUT)) S APCHQUIT="" Q
HEAD1 ;
 W:$D(IOF) @IOF
 S APCHPG=APCHPG+1
 W !,"My Wellness Handout",?45,"Report Date: ",$$FMTE^XLFDT(DT),?72,"Page: ",APCHPG,!,$TR($J("",(IOM-2))," ","-"),!
 I APCHPG>1 W "********** CONFIDENTIAL PATIENT INFORMATION ["_$P(^VA(200,DUZ,0),U,2)_"]  "_$$FMTE^XLFDT(DT)_" **********",!
 Q
CTR(X,Y) ;EP - Center X in a field Y wide.
 Q $J("",$S($D(Y):Y,1:IOM)-$L(X)\2)_X
 ;----------
USR() ;EP - Return name of current user from ^VA(200.
 Q $S($G(DUZ):$S($D(^VA(200,DUZ,0)):$P(^(0),U),1:"UNKNOWN"),1:"DUZ UNDEFINED OR 0")
 ;----------
LOC() ;EP - Return location name from file 4 based on DUZ(2).
 Q $S($G(DUZ(2)):$S($D(^DIC(4,DUZ(2),0)):$P(^(0),U),1:"UNKNOWN"),1:"DUZ(2) UNDEFINED OR 0")
 ;---------- 
 ;
UPDLOG(P,T,D) ;EP - update pwh log
 I $G(P)="" Q
 I $G(T)="" Q
 I $T(LOG^BQINOTR)]"" D LOG^BQINOTR(P,"LETTER","","",T,"PWH","")  ;PER EMAIL 6/10/13
 NEW DIC,X,DD,DO,D0
 S X=P,DIC="^APCHPWHL(",DIC(0)="L",DIADD=1,DLAYGO=9001027
 S DIC("DR")=".02////"_T_";.03////"_D_";.04////"_DT_";.05///"_$$NOW^XLFDT_";.06////"_DUZ(2)
 K DD,D0,D0
 D FILE^DICN
 D ^XBFMK
 K DIADD,DLAYGO
 Q
 ;
UPDDEF ;EP - called from option to update default PWH for the site
 W !!,"This option is used to set the default Patient Wellness Handout"
 W !,"for a site."
 W !!
 K DIC S DIC="^APCCCTRL(",DIC("B")=$P(^DIC(4,DUZ(2),0),U),DIC(0)="AEMQ" D ^DIC K DIC
 I Y=-1 Q
 S DA=+Y,DIE="^APCCCTRL(",DR="[APCH PWH PARAMETERS]" D ^DIE
 D ^XBFMK
 Q
 ;