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

AMHRPPD.m

Go to the documentation of this file.
AMHRPPD ; IHS/CMI/LAB - ACTIVE CLIENT LIST ;
 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
 ;
 I '$D(IOF) D HOME^%ZIS
 W @(IOF),!!
 W "**********  PLACEMENTS IN PAST YEAR BY SITE/PATIENT  **********",!!
 W "This report will produce a list of patients who have had a placement disposition",!,"recorded in a date range specified by the user.",!
 D DBHUSRP^AMHUTIL,DBHUSR^AMHUTIL
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
 ;
SORT ;
 S AMHSORT=""
 S DIR(0)="S^P:Alphabetically by Patient Name;S:Alphabetically by Site Referred to",DIR("A")="How would you like this report sorted",DIR("B")="P" KILL DA D ^DIR KILL DIR
 I $D(DIRUT) G BD
 S AMHSORT=Y
DEMO ;
 D DEMOCHK^AMHUTIL1(.AMHDEMO)
 I AMHDEMO=-1 G SORT
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^AMHRPPD",XBRP="PRINT^AMHRPPD",XBNS="AMH",XBRX="XIT^AMHRPPD"
 D ^XBDBQUE
XIT ;
 K A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,V,W,X,Y,Z
 D EN^XBVK("AMH")
 D KILL^AUPNPAT
 Q
 ;
BROWSE ;
 S XBRP="VIEWR^XBLM(""PRINT^AMHRPPD"")"
 S XBNS="AMH",XBRC="PROC^AMHRPPD",XBRX="XIT^AMHRPPD",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("AMHRPPD","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)=""&($P(^AMHREC(AMHR,0),U,18)="") Q
 Q:'$$ALLOWVI^AMHUTIL(DUZ,AMHR)
 I $P(^AMHREC(AMHR,0),U,8) Q:$$DEMO^AMHUTIL1($P(^AMHREC(AMHR,0),U,8),$G(AMHDEMO))
 S S=$S($P(^AMHREC(AMHR,0),U,17)]"":$$VAL^XBDIQ1(9002011,AMHR,.17),1:"???")
 S S1=$S($P(^AMHREC(AMHR,0),U,18)]"":$P(^AMHREC(AMHR,0),U,18),1:"???")
 S P=$$VAL^XBDIQ1(9002011,AMHR,.08)
 S DFN=$P(^AMHREC(AMHR,0),U,8)
 Q:'DFN
 Q:'$$ALLOWP^AMHUTIL(DUZ,DFN)
 I AMHSORT="S" S ^XTMP("AMHRPPD",AMHJOB,AMHBTH,"PLACEMENTS",S1,P,DFN,AMHR)="",AMHTOT=AMHTOT+1
 I AMHSORT="P" S ^XTMP("AMHRPPD",AMHJOB,AMHBTH,"PLACEMENTS",P,DFN,S1,AMHR)="",AMHTOT=AMHTOT+1
 S AMHTOTP(S)=$G(AMHTOTP(S))+1
 S AMHTOTF(S1)=$G(AMHTOTF(S1))+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("AMHRPPD",AMHJOB,AMHBTH)) W !!,"NO PATIENTS TO REPORT" G DONE
 S AMHR="" K AMHQ
 I AMHSORT="P" D PS G SUB
 S AMHF="" F  S AMHF=$O(^XTMP("AMHRPPD",AMHJOB,AMHBTH,"PLACEMENTS",AMHF)) Q:AMHF=""!($D(AMHQ))  D
 .S AMHPT="" F  S AMHPT=$O(^XTMP("AMHRPPD",AMHJOB,AMHBTH,"PLACEMENTS",AMHF,AMHPT)) Q:AMHPT=""!($D(AMHQ))  D
 ..S DFN=0 F  S DFN=$O(^XTMP("AMHRPPD",AMHJOB,AMHBTH,"PLACEMENTS",AMHF,AMHPT,DFN)) Q:DFN'=+DFN!($D(AMHQ))  D
 ...S AMHR=0 F  S AMHR=$O(^XTMP("AMHRPPD",AMHJOB,AMHBTH,"PLACEMENTS",AMHF,AMHPT,DFN,AMHR)) Q:AMHR'=+AMHR!($D(AMHQ))  D PRINT1
SUB ;
 G:$D(AMHQ) DONE
 I $Y>(IOSL-3) D HEAD I $D(AMHQ) G DONE
 W !!,"Subtotal by Placement Type:"
 S AMHX="" F  S AMHX=$O(AMHTOTP(AMHX)) Q:AMHX=""!($D(AMHQ))  D
 .I $Y>(IOSL-3) D HEAD Q:$D(AMHQ)
 .W !?5,AMHX,?40,AMHTOTP(AMHX)
 G:$D(AMHQ) DONE
 I $Y>(IOSL-3) D HEAD I $D(AMHQ) G DONE
 W !!,"Subtotal by Facility Referred to:"
 S AMHX="" F  S AMHX=$O(AMHTOTF(AMHX)) Q:AMHX=""!($D(AMHQ))  D
 .I $Y>(IOSL-3) D HEAD Q:$D(AMHQ)
 .W !?5,AMHX,?40,AMHTOTF(AMHX)
 I $Y>(IOSL-3) D HEAD I $D(AMHQ) G DONE
 W !!,"Total Number of Placements: ",AMHTOT
DONE ;
 K ^XTMP("AMHRPPD",AMHJOB,AMHBTH),AMHJOB,AMHBTH
 Q
PRINT1 ;
 I $Y>(IOSL-4) D HEAD Q:$D(AMHQ)
 W !,$E($P(^DPT(DFN,0),U),1,18),?20,$$HRN^AUPNPAT(DFN,DUZ(2)),?28,$$D^AMHLEIN($P(^AMHREC(AMHR,0),U)),?37,$$PRIMPOV^AMHUTIL1(AMHR,"C"),?44,$E($$VAL^XBDIQ1(9002011,AMHR,.17),1,14),?60,$E($$VAL^XBDIQ1(9002011,AMHR,.18),1,19)
 W !?3,"Placement Made by: ",$$PPNAME^AMHUTIL(AMHR)
 Q:'$D(^AMHPATR(DFN,0))
 I $P(^AMHPATR(DFN,0),U,2)]"" W !?3,"Designated MH Prov: ",$$VAL^XBDIQ1(9002011.55,DFN,.02)
 I $P(^AMHPATR(DFN,0),U,3)]"" W !?3,"Designated SS Prov: ",$$VAL^XBDIQ1(9002011.55,DFN,.03)
 I $P(^AMHPATR(DFN,0),U,4)]"" W !?3,"Designated A/SA/CD Prov: ",$$VAL^XBDIQ1(9002011.55,DFN,.04)
 Q
PS ;
 S AMHPT="" F  S AMHPT=$O(^XTMP("AMHRPPD",AMHJOB,AMHBTH,"PLACEMENTS",AMHPT)) Q:AMHPT=""!($D(AMHQ))  D
 .S DFN="" F  S DFN=$O(^XTMP("AMHRPPD",AMHJOB,AMHBTH,"PLACEMENTS",AMHPT,DFN)) Q:DFN=""!($D(AMHQ))  D
 ..S AMHF="" F  S AMHF=$O(^XTMP("AMHRPPD",AMHJOB,AMHBTH,"PLACEMENTS",AMHPT,DFN,AMHF)) Q:AMHF=""!($D(AMHQ))  D
 ...S AMHR=0 F  S AMHR=$O(^XTMP("AMHRPPD",AMHJOB,AMHBTH,"PLACEMENTS",AMHPT,DFN,AMHF,AMHR)) Q:AMHR'=+AMHR!($D(AMHQ))  D PRINT1
 Q
D(D) ;
 Q $E(D,4,5)_"/"_$E(D,6,7)_"/"_(1700+($E(D,1,3)))
 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 ?35,"PLACEMENTS",!
 W ?15,"PLACEMENT DATES:  ",AMHBDD,"  TO  ",AMHEDD,!
PIH W !,"PATIENT NAME",?20,"HRN",?27,"DATE",?38,"POV",?44,"PLACEMENT",?59,"FACILITY REFERRED TO",!,?27,"PLACED",!,AMH80D
 Q