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

AMHRE2.m

Go to the documentation of this file.
AMHRE2 ; IHS/CMI/LAB - PLACEMENT TO RESIDENTIAL ;
 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
 ;
 I '$D(IOF) D HOME^%ZIS
 W @(IOF),!!
 W "**********  RESIDENTIAL TREATMENT AFTERCARE REPORT  **********",!!
 W "This report will produce a list of patients who have residential treatment ",!,"placement in a date range you specify.",!
GETDATES ;
BD ;get beginning date
 W !,"Please enter the date range during which the patient had a placement.",!
 W ! S DIR(0)="D^:DT:EP",DIR("A")="Enter beginning Date" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
 I $D(DIRUT) G XIT
 S AMHBD=Y
ED ;get ending date
 W ! S DIR(0)="D^"_AMHBD_":DT:EP",DIR("A")="Enter ending Date" S Y=AMHBD D DD^%DT D ^DIR K DIR S:$D(DUOUT) DIRUT=1
 I $D(DIRUT) G BD
 S AMHED=Y
 S X1=AMHBD,X2=-1 D C^%DTC S AMHSD=X S Y=AMHBD D DD^%DT S AMHBDD=Y S Y=AMHED D DD^%DT S AMHEDD=Y
 ;
ZIS ;
 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) G XIT
 I $G(Y)="B" D BROWSE,XIT Q
 S XBRC="PROC^AMHRE2",XBRP="PRINT^AMHRE2",XBNS="AMH",XBRX="XIT^AMHRE2"
 D ^XBDBQUE
XIT ;
 D EN^XBVK("AMH")
 D KILL^AUPNPAT
 Q
 ;
BROWSE ;
 S XBRP="VIEWR^XBLM(""PRINT^AMHRE2"")"
 S XBNS="AMH",XBRC="PROC^AMHRE2",XBRX="XIT^AMHRE2",XBIOP=0 D ^XBDBQUE
 Q
PROC ;EP - entry point for processing
 S AMHJOB=$J,AMHBTH=$H,AMHTOT=0,DFN=0,AMHBT=$H
 K AMHTOTP,AMHTOTF
 D XTMP^AMHUTIL("AMHRE2","BH - PLACEMENT REPORT")
 S X1=AMHBD,X2=-1 D C^%DTC S AMHSD=X
 S AMHODAT=AMHSD_".9999" F  S AMHODAT=$O(^AMHREC("B",AMHODAT)) Q:AMHODAT=""!((AMHODAT\1)>AMHED)  D PROC1
 S AMHET=$H
 Q
PROC1 ;
 S (AMHR,AMHRCNT)=0 F  S AMHR=$O(^AMHREC("B",AMHODAT,AMHR)) Q:AMHR'=+AMHR  I $D(^AMHREC(AMHR,0)),$P(^AMHREC(AMHR,0),U,8)]"" D SET
 Q
SET ;
 I $P(^AMHREC(AMHR,0),U,17)'=3 Q
 S S1=$S($P(^AMHREC(AMHR,0),U,18)]"":$P(^AMHREC(AMHR,0),U,18),1:"UNKNOWN")
 S ^XTMP("AMHRE2",AMHJOB,AMHBTH,"PLACEMENTS",S1,$$VAL^XBDIQ1(9002011,AMHR,.08),AMHR)="",AMHTOT=AMHTOT+1
 Q
PRINT ;
 S Y=AMHBD D DD^%DT S AMHBDD=Y S Y=AMHED D DD^%DT S AMHEDD=Y
 S AMH80D="-------------------------------------------------------------------------------"
 S AMHPG=0 D HEAD
 I '$D(^XTMP("AMHRE2",AMHJOB,AMHBTH)) W !!,"NO PATIENTS TO REPORT" G DONE
 S AMHR="" K AMHQ
 S AMHF="" F  S AMHF=$O(^XTMP("AMHRE2",AMHJOB,AMHBTH,"PLACEMENTS",AMHF)) Q:AMHF=""!($D(AMHQ))  D
 .S AMHNAME="" F  S AMHNAME=$O(^XTMP("AMHRE2",AMHJOB,AMHBTH,"PLACEMENTS",AMHF,AMHNAME)) Q:AMHNAME=""!($D(AMHQ))  D
 ..S AMHR=0 F  S AMHR=$O(^XTMP("AMHRE2",AMHJOB,AMHBTH,"PLACEMENTS",AMHF,AMHNAME,AMHR)) Q:AMHR'=+AMHR!($D(AMHQ))  D PRINT1
DONE ;
 K ^XTMP("AMHRE2",AMHJOB,AMHBTH),AMHJOB,AMHBTH
 Q
PRINT1 ;
 I $Y>(IOSL-4) D HEAD Q:$D(AMHQ)
 S DFN=$P(^AMHREC(AMHR,0),U,8)
 W !,$E($P(^DPT(DFN,0),U),1,20),?22,$$HRN^AUPNPAT(DFN,DUZ(2)),?29,$E($$VAL^XBDIQ1(9002011.55,DFN,.02),1,15),?45,$E(AMHF,1,15),?62,$$D($P(^AMHREC(AMHR,0),U)),?72,$$D($$LVD^AMHDPEE(DFN,"ID"))
 Q
D(D) ;
 I $G(D)="" Q ""
 Q $E(D,4,5)_"/"_$E(D,6,7)_"/"_$E(D,2,3)
CTR(X,Y) ;EP - Center X in a field Y wide.
 Q $J("",$S($D(Y):Y,1:IOM)-$L(X)\2)_X
 ;----------
 I $E(IOST)="C",IO=IO(0) W ! S DIR(0)="EO" D ^DIR K DIR I Y=0!(Y="^")!($D(DTOUT)) S AMHQ="" Q
HEAD1 ;
 W:$D(IOF) @IOF S AMHPG=AMHPG+1
 W !?13,"********** CONFIDENTIAL PATIENT INFORMATION **********"
 W !,$P(^VA(200,DUZ,0),U,2),?72,"Page ",AMHPG,!
 W ?(80-$L($P(^DIC(4,DUZ(2),0),U))/2),$P(^DIC(4,DUZ(2),0),U),!
 W $$CTR("RESIDENTIAL PLACEMENTS"),!
 W ?15,"PLACEMENT DATES:  ",AMHBDD,"  TO  ",AMHEDD,!
PIH W !,"PATIENT NAME",?22,"HRN",?29,"DESG PROV",?45,"REFERRED TO",?62,"DATE PL",?71,"LAST SEEN",!,AMH80D
 Q