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

AMHRC3.m

Go to the documentation of this file.
AMHRC3 ; IHS/CMI/LAB - TIME IN GRP REPORT ;
 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
 ;
START ;
 I '$D(IOF) D HOME^%ZIS
 W @(IOF),!!
 W "**********  LISTING OF PATIENTS WHO HAVE SPENT TIME IN GROUP  **********",!!
 W "This report will produce a list of patients who have spent time in a group.",!,"It will list the patient, the primary provider, diagnoses and time",!,"spent in the group for a date range you enter.",!!
 D DBHUSR^AMHUTIL
GETDATES ;
BD ;get beginning date
 W !,"Please enter the date range during which the patient should be seen",!,"in a group.",!
 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
 ;
DEMO ;
 D DEMOCHK^AMHUTIL1(.AMHDEMO)
 I AMHDEMO=-1 G BD
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^AMHRC3",XBRP="PRINT^AMHRC3",XBNS="AMH",XBRX="XIT^AMHRC3"
 D ^XBDBQUE
XIT K ZTSK,Y,AMHBD,AMHED,IO("Q"),AMH80D,AMHBTH,AMHHRCN,AMHJOB,AMHLENG,AMHPCNT,AMHPG,AMHNUM,AMHX,DFN,DIC,DIR,DIRUT,DTOUT,DUOUT,XBNS,XBRC,XBRP,XBTX,D,AMHFOUN,AMHPOV,AMHRA,AMHRX,AMHRY
 K AMHPRNM,AMHPRNT,AMHPROB,AMHPRV,AMHR,AMHRCNT,AMHRLOC,AMHSD,AMHTOT,AMHBDD,AMHBT,AMHEDD,AMHEDO,AMHBDO,AMHBT,AMHFOUND,AMHHIT,AMHID,AMHLINE,AMHP
 Q
BROWSE ;
 S XBRP="VIEWR^XBLM(""PRINT^AMHRC3"")"
 S XBNS="AMH",XBRC="PROC^AMHRC3",XBRX="XIT^AMHRC3",XBIOP=0 D ^XBDBQUE
 Q
 ;
PROC ;EP - entry point for processing
 S AMHJOB=$J,AMHBTH=$H,AMHTOT=0,DFN=0,AMHBT=$H
 D XTMP^AMHUTIL("AMHRC3","BH - PTS WITH GROUP VISITS")
 S AMHSD=AMHSD_".9999"
 F  S AMHSD=$O(^AMHREC("B",AMHSD)) Q:AMHSD'=+AMHSD!($P(AMHSD,".")>AMHED)  D PROC1
 S AMHET=$H
 K DFN
 Q
PROC1 ;
 S AMHR=0 F  S AMHR=$O(^AMHREC("B",AMHSD,AMHR)) Q:AMHR'=+AMHR  D
 .Q:'$$ALLOWVI^AMHUTIL(DUZ,AMHR)
 .Q:$P($G(^AMHREC(AMHR,11)),U,4)=""
 .Q:$P(^AMHREC(AMHR,0),U,8)=""
 .S DFN=$P(^AMHREC(AMHR,0),U,8)
 .Q:'$$ALLOWP^AMHUTIL(DUZ,DFN)
 .Q:$$DEMO^AMHUTIL1(DFN,$G(AMHDEMO))
 .S AMHPROV=$$PPINT^AMHUTIL(AMHR) I AMHPROV="" S AMHPROV="Not Recorded"
 .S AMHDX=$O(^AMHRPRO("AD",AMHR,0)) Q:AMHDX=""
 .S AMHDX=$P(^AMHRPRO(AMHDX,0),U)
 .S AMHTSG=$P($G(^AMHREC(AMHR,11)),U,4)
 .S ^XTMP("AMHRC3",AMHJOB,AMHBTH,"INDS",$P(^DPT(DFN,0),U),DFN,$P(AMHSD,"."),AMHR,AMHPROV,AMHDX)=AMHTSG
 .S ^XTMP("AMHRC3",AMHJOB,AMHBTH,"PROV",DFN,AMHPROV)=$G(^XTMP("AMHRC3",AMHJOB,AMHBTH,"PROV",DFN,AMHPROV))+AMHTSG
 .S ^XTMP("AMHRC3",AMHJOB,AMHBTH,"TOTAL",DFN)=$G(^XTMP("AMHRC3",AMHJOB,AMHBTH,"TOTAL",DFN))+AMHTSG
 Q
 ;
PRINT ;
 S AMH80D="-------------------------------------------------------------------------------"
 S Y=AMHBD D DD^%DT S AMHBDD=Y S Y=AMHED D DD^%DT S AMHEDD=Y
 S AMHPG=0 D HEAD
 I '$D(^XTMP("AMHRC3",AMHJOB,AMHBTH)) W !!,"NO PATIENTS TO REPORT" G DONE
 S DFN="" K AMHQ
 S AMHNAME="" F  S AMHNAME=$O(^XTMP("AMHRC3",AMHJOB,AMHBTH,"INDS",AMHNAME)) Q:AMHNAME=""!($D(AMHQ))  D
 .S DFN=0 F  S DFN=$O(^XTMP("AMHRC3",AMHJOB,AMHBTH,"INDS",AMHNAME,DFN)) Q:DFN=""!($D(AMHQ))  D DFN
 G:$D(AMHQ) DONE
DONE D DONE^AMHLEIN,^AMHEKL
 K ^XTMP("AMHRC3",AMHJOB,AMHBTH),AMHJOB,AMHBTH
 Q
DFN ;
 I $Y>(IOSL-4) D HEAD Q:$D(AMHQ)
 S AMHHRCN=$S($D(^AUPNPAT(DFN,41,DUZ(2),0)):$P(^(0),U,2),1:"<none>")
 W !!,$E($P(^DPT(DFN,0),U),1,15),?18,AMHHRCN
 W ?26,$P(^DPT(DFN,0),U,2) S Y=$P(^DPT(DFN,0),U,3) W ?30,$E(Y,4,5),"/",$E(Y,6,7),"/",$E(Y,2,3)
VSTS ; process visits
 S AMHDATE=0,AMHRC=0 F  S AMHDATE=$O(^XTMP("AMHRC3",AMHJOB,AMHBTH,"INDS",AMHNAME,DFN,AMHDATE)) Q:AMHDATE'=+AMHDATE!($D(AMHQ))  D
 .S AMHRC=AMHRC+1
 .I AMHRC>1 W !
 .W ?40,$E(AMHDATE,4,5),"/",$E(AMHDATE,6,7),"/",$E(AMHDATE,2,3)
 .S AMHC=0,AMHR=0 F  S AMHR=$O(^XTMP("AMHRC3",AMHJOB,AMHBTH,"INDS",AMHNAME,DFN,AMHDATE,AMHR)) Q:AMHR'=+AMHR!($D(AMHQ))  D
 ..S AMHC=AMHC+1
 ..I AMHC>1 W !
 ..S AMHPROV=$O(^XTMP("AMHRC3",AMHJOB,AMHBTH,"INDS",AMHNAME,DFN,AMHDATE,AMHR,0))
 ..I AMHPROV W ?49,$E($P(^VA(200,AMHPROV,0),U),1,15)
 ..I 'AMHPROV W ?49,AMHPROV
 ..S AMHDX=$O(^XTMP("AMHRC3",AMHJOB,AMHBTH,"INDS",AMHNAME,DFN,AMHDATE,AMHR,AMHPROV,0))
 ..W ?65,$P(^AMHPROB(AMHDX,0),U,1)
 ..W ?74,^XTMP("AMHRC3",AMHJOB,AMHBTH,"INDS",AMHNAME,DFN,AMHDATE,AMHR,AMHPROV,AMHDX)
 Q:$D(AMHQ)
 S AMHPROV=0 F  S AMHPROV=$O(^XTMP("AMHRC3",AMHJOB,AMHBTH,"PROV",DFN,AMHPROV)) Q:AMHPROV'=+AMHPROV!($D(AMHQ))  D
 .W !?10,"Total with provider ",$S(AMHPROV:$E($P(^VA(200,AMHPROV,0),U),1,20),1:AMHPROV),?50,^XTMP("AMHRC3",AMHJOB,AMHBTH,"PROV",DFN,AMHPROV)
 Q:$D(AMHQ)
 W !?10,"Total for patient ",$E($P(^DPT(DFN,0),U,1),1,20),?50,^XTMP("AMHRC3",AMHJOB,AMHBTH,"TOTAL",DFN)
 Q
 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 ?22,"PATIENTS SEEN IN GROUPS WITH TIME SPENT IN GROUP",!
 W ?20,"DATES:  ",AMHBDD,"  TO  ",AMHEDD,!
PIH W !!,"PATIENT NAME",?18,"HRN",?25,"SEX",?30,"DOB",?40,"DATE",?49,"PROVIDER",?65,"PROBLEM",?74,"TIME",!,AMH80D
 Q