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

AMHRP4P.m

Go to the documentation of this file.
AMHRP4P ; IHS/CMI/LAB - print active client list (using case open/close) 03 Jun 2009 12:10 PM ;
 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
 ;
 ;
PRINT ;
START ;
 S X1=DT,X2=-365 D C^%DTC S AMHBD=X,AMHED=DT
 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("AMHRP4",AMHJOB,AMHBTH)) W !!,"NO PATIENTS TO REPORT" G DONE
 S DFN="" K AMHQ
 S AMHNAME="" F  S AMHNAME=$O(^XTMP("AMHRP4",AMHJOB,AMHBTH,"CASES",AMHNAME)) Q:AMHNAME=""!($D(AMHQ))  D
 .S DFN=0 F  S DFN=$O(^XTMP("AMHRP4",AMHJOB,AMHBTH,"CASES",AMHNAME,DFN)) Q:DFN'=+DFN!($D(AMHQ))  D DFN
 G:$D(AMHQ) DONE
 W !!,"Total Number of Patients: ",AMHPCNT,!
 W "Total Number of Cases: ",AMHCCNT,!
DONE D DONE^AMHLEIN,^AMHEKL
 K ^XTMP("AMHRP4",AMHJOB,AMHBTH),AMHJOB,AMHBTH
 Q
DFN ;
 S AMHCASE=0 F  S AMHCASE=$O(^XTMP("AMHRP4",AMHJOB,AMHBTH,"CASES",AMHNAME,DFN,AMHCASE)) Q:AMHCASE'=+AMHCASE!($D(AMHQ))  D PRN
 Q
PRN ;
 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
 S AMHX=^AMHPCASE(AMHCASE,0)
 W ?26,$P(^DPT(DFN,0),U,2) S Y=$P(^DPT(DFN,0),U,3) W ?28,$E(Y,4,5),"/",$E(Y,6,7),"/",$E(Y,2,3)
 S Y=$P(AMHX,U) W ?38,$E(Y,4,5),"/",$E(Y,6,7),"/",$E(Y,2,3)
 S Y=$P(AMHX,U,4) I Y]"" W ?48,$E(Y,4,5),"/",$E(Y,6,7),"/",$E(Y,2,3)
VSTS ; process visits
 K AMHRLOC,AMHPRV,AMHPROB
 S AMHR=0,AMHBDO=9999999-AMHBD,AMHEDO=9999999-AMHED,AMHSD=AMHED-1,AMHSD=AMHSD_".9999",AMHRCNT=0
 F  S AMHSD=$O(^AMHREC("AE",DFN,AMHSD)) Q:$P(AMHSD,".")>AMHBDO!(AMHSD="")  D
 .S AMHR=0 F  S AMHR=$O(^AMHREC("AE",DFN,AMHSD,AMHR)) Q:AMHR'=+AMHR  D
 ..S AMHRCNT=AMHRCNT+1 ;COUNT # VISITS
 ..;TABLE LOC SEEN
 ..I $P(^AMHREC(AMHR,0),U,4)]"",'$D(AMHRLOC($P(^DIC(4,$P(^(0),U,4),0),U))) S AMHRLOC($P(^DIC(4,$P(^AMHREC(AMHR,0),U,4),0),U))=""
 ..;TABLE PROVIDERS
 ..S AMHP=0 F  S AMHP=$O(^AMHRPROV("AD",AMHR,AMHP)) Q:AMHP'=+AMHP  S P=$P(^AMHRPROV(AMHP,0),U),AMHPRV($P(^VA(200,P,0),U))=""
 ..;TABLE PROBLEMS
 ..S AMHP=0 F  S AMHP=$O(^AMHRPRO("AD",AMHR,AMHP)) Q:AMHP'=+AMHP  S P=$P(^AMHRPRO(AMHP,0),U),AMHPROB($P(^AMHPROB(P,0),U))=""
 ..Q
 .Q
 K AMHLINE,AMHPRNT,AMHPRNM
 S AMHLINE(1)=""
 K AMHPRNM S X="",C=0,K=11 F  S X=$O(AMHPRV(X)) Q:X=""  S C=C+1,AMHPRNM(C)=X
 D LINE
 K AMHPRNM S X="",C=0,K=7 F  S X=$O(AMHPROB(X)) Q:X=""  S C=C+1,AMHPRNM(C)=X
 D LINE
 S X=0 F  S X=$O(AMHLINE(X)) Q:X'=+X  W ?60,AMHLINE(X),!
 I $Y>(IOSL-3) D HEAD Q:$D(AMHQ)
 W ?2,"Case Provider: ",$$VAL^XBDIQ1(9002011.58,AMHCASE,.08),?50,"Next Case Review: ",$S($P(AMHX,U,12)]"":$$FMTE^XLFDT($P(AMHX,U,12),"2E"),1:""),!
 Q
LINE ;
 I '$D(AMHPRNM) S AMHPRNT="--" D
 .S AMHPRNT=$E(AMHPRNT,1,10) D
 ..S J=$L(AMHPRNT),AMHLINE(1)=AMHLINE(1)_AMHPRNT F I=J:1:K S AMHLINE(1)=AMHLINE(1)_" "
 S X=0 F  S X=$O(AMHPRNM(X)) Q:X'=+X  D
 .I X=1 D  Q
 ..S AMHPRNT=$E(AMHPRNM(1),1,10) D
 ...S J=$L(AMHPRNT),AMHLINE(1)=AMHLINE(1)_AMHPRNT F I=J:1:K S AMHLINE(1)=AMHLINE(1)_" "
 .S AMHPRNT=$E(AMHPRNM(X),1,10) D
 ..I '$D(AMHLINE(X)) S AMHLINE(X)="",$P(AMHLINE(X)," ",($L(AMHLINE(1))-K))=""
 ..S J=$L(AMHPRNT),AMHLINE(X)=AMHLINE(X)_AMHPRNT F I=J:1:K S AMHLINE(X)=AMHLINE(X)_" "
 S X=1 F  S X=$O(AMHLINE(X)) Q:X'=+X  I $L(AMHLINE(X))<$L(AMHLINE(1)) S K=$L(AMHLINE(X))+1,J=$L(AMHLINE(1)) F I=K:1:J S AMHLINE(X)=AMHLINE(X)_" "
 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 ?15,"Encounter Dates: ",AMHBDD," to ",AMHEDD,!
 I AMHPROG]"" S X="Program: "_$$EXTSET^XBFUNC(9002011.58,.03,AMHPROG) W $$CTR(X,80),!
 W ?10,"ACTIVE CLIENT LIST (CASE OPEN DATE WITH NO CASE CLOSED DATE)"
PIH W !,"PATIENT NAME",?18,"CHART",?25,"SEX",?31,"DOB",?38,"CASE OPEN",?48,"CASE ADMIT",?60,"PROVIDER",?72,"PROBLEM"
 W !?18,"NUMBER",?38,"DATE",?48,"DATE",?60,"SEEN",?72,"CODES",!,AMH80D
 Q
CTR(X,Y) ;EP - Center X in a field Y wide.
 Q $J("",$S($D(Y):Y,1:IOM)-$L(X)\2)_X
 ;----------