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

AMHPHQM.m

Go to the documentation of this file.
AMHPHQM ; IHS/CMI/LAB - PHQ - MULTIPLE PATS 10 Dec 2008 9:28 AM ;
 ;;4.0;IHS BEHAVIORAL HEALTH;**4,6,8**;JUN 02, 2010;Build 7
 ;
 ;
START ;
 W:$D(IOF) @IOF
 D EN^XBVK("AMH")
 W !,$$CTR^AMHLEIN("PHQ-2, PHQ-9 and PHQ-9T Depression Outcomes - Scores for Multiple Patients",80),!!
 W !,"This option is used to list PHQ-2, PHQ-9 and PHQ-9T Scores for multiple "
 W !,"patients sorted by patient.",!
WHICH ;
 W !!,"Please note:  Only visits with PHQ-2/PHQ-9/PHQ-9T scores recorded will display",!,"on this list.",!
 D DBHUSR^AMHUTIL
DATES ;
 K AMHED,AMHBD
 K DIR W ! S DIR(0)="D^::EXP",DIR("A")="Enter Beginning Date of Visit"
 D ^DIR
 G:$D(DIRUT) XIT
 S AMHBD=Y
 K DIR S DIR(0)="D^::EXP",DIR("A")="Enter Ending Date of Visit"
 D ^DIR
 G:$D(DIRUT) DATES
 S AMHED=Y
 ;
 I AMHED<AMHBD D  G DATES
 . W !!,$C(7),"Sorry, Ending Date MUST not be earlier than Beginning Date."
 S AMHSD=$$FMADD^XLFDT(AMHBD,-1)_".9999"
CLINIC ;
 K AMHRCLNT
 S DIR(0)="S^C:Visits to Selected Clinics;A:Visits to All Clinics",DIR("A")="Clinic Selection",DIR("B")="A" KILL DA D ^DIR KILL DIR
 I $D(DIRUT) G DATES
 I Y="A" K AMHRCLNT G PROV
CLINIC1 ;
 S X="CLINIC",DIC="^AMQQ(5,",DIC(0)="FM",DIC("S")="I $P(^(0),U,14)" D ^DIC K DIC,DA I Y=-1 W "OOPS - QMAN NOT CURRENT - QUITTING" G XIT
 D PEP^AMQQGTX0(+Y,"AMHRCLNT(")
 I '$D(AMHRCLNT) G CLINIC
 I $D(AMHRCLNT("*")) K AMHRCLNT
PROV ;
 K AMHPROVT
 S DIR(0)="S^C:Visits to Selected Providers;A:Visits to All Providers",DIR("A")="Provider Selection",DIR("B")="A" KILL DA D ^DIR KILL DIR
 I $D(DIRUT) G CLINIC
 I Y="A" K AMHPROVT G DEMO
PROV1 ;
 S X="PRIMARY PROVIDER",DIC="^AMQQ(5,",DIC(0)="FM",DIC("S")="I $P(^(0),U,14)" D ^DIC K DIC,DA I Y=-1 W "OOPS - QMAN NOT CURRENT - QUITTING" G XIT
 D PEP^AMQQGTX0(+Y,"AMHPROVT(")
 I '$D(AMHPROVT) G CLINIC
 I $D(AMHPROVT("*")) K AMHPROVT
DEMO ;
 D DEMOCHK^AMHUTIL1(.AMHDEMO)
 I AMHDEMO=-1 G PROV
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^AMHPHQM",XBRP="PRINT^AMHPHQM",XBNS="AMH",XBRX="XIT^AMHPHQM"
 D ^XBDBQUE
XIT ;
 K ZTSK,Y,AMHBD,AMHED,IO("Q")
 D EN^XBVK("AMH")
 Q
 ;
BROWSE ;
 S XBRP="VIEWR^XBLM(""PRINT^AMHPHQM"")"
 S XBNS="AMH",XBRC="PROC^AMHPHQM",XBRX="XIT^AMHPHQM",XBIOP=0 D ^XBDBQUE
 Q
 ;
PROC ;
 ;loop through visits and check PHQ score
 D XTMP^AMHUTIL("AMHPHQM","BH - PHQ SCORES MULT PATS")
 S (AMHBT,AMHBTH)=$H,AMHJOB=$J
 F  S AMHSD=$O(^AMHREC("B",AMHSD)) Q:AMHSD=""!($P(AMHSD,".")>$P(AMHED,"."))  D
 .S AMHVIEN=0 F  S AMHVIEN=$O(^AMHREC("B",AMHSD,AMHVIEN)) Q:AMHVIEN'=+AMHVIEN  D
 ..S AMHV0=$G(^AMHREC(AMHVIEN,0))
 ..Q:AMHV0=""
 ..S DFN=$P(AMHV0,U,8)
 ..Q:DFN=""
 ..I '$$HASPHQ^AMHPHQO(AMHVIEN) Q  ;no PHQ score
 ..Q:'$$ALLOWVI^AMHUTIL(DUZ,AMHVIEN)
 ..Q:$$DEMO^AMHUTIL1(DFN,$G(AMHDEMO))
 ..S AMHVPP=$$PPINT^AMHUTIL(AMHVIEN)
 ..I AMHVPP="",$D(AMHPROVT) Q  ;PRIM PROV blank and want certain PRIM PROVS
 ..I $D(AMHPROVT),'$D(AMHPROVT(AMHVPP)) Q  ;not a PRIM PROV we want
 ..S AMHVCC=$P(^AMHREC(AMHVIEN,0),U,25)
 ..I $D(AMHRCLNT),AMHVCC="" Q
 ..I $D(AMHRCLNT),'$D(AMHRCLNT(AMHVCC)) Q
 ..S ^XTMP("AMHPHQM",AMHJOB,AMHBTH,"PATS",$P(^DPT(DFN,0),U,1),DFN,$P((9999999-AMHSD),"."),"BH",AMHVIEN)=""
 ..Q
 .Q
 ;now get all PCC Visits
 S AMHSD=$$FMADD^XLFDT(AMHBD,-1)_".9999"
 F  S AMHSD=$O(^AUPNVSIT("B",AMHSD)) Q:AMHSD=""!($P(AMHSD,".")>$P(AMHED,"."))  D
 .S AMHVIEN=0 F  S AMHVIEN=$O(^AUPNVSIT("B",AMHSD,AMHVIEN)) Q:AMHVIEN'=+AMHVIEN  D
 ..Q:'$$HASPHQV^AMHPHQO(AMHVIEN)
 ..Q:$D(^AMHREC("AVISIT",AMHVIEN))
 ..S DFN=$P(^AUPNVSIT(AMHVIEN,0),U,5)
 ..Q:DFN=""
 ..S AMHVPP=$$PRIMPROV^APCLV(AMHVIEN,"I")
 ..I AMHVPP="",$D(AMHPROVT) Q
 ..I $D(AMHPROVT),'$D(AMHPROVT(AMHVPP)) Q
 ..S AMHVCC=$P(^AUPNVSIT(AMHVIEN,0),U,8)
 ..I AMHVCC="",$D(AMHRCLNT) Q
 ..I $D(AMHRCLNT),'$D(AMHRCLNT(AMHVCC)) Q
 ..S ^XTMP("AMHPHQM",AMHJOB,AMHBTH,"PATS",$P(^DPT(DFN,0),U,1),DFN,$P((9999999-AMHSD),"."),"PCC",AMHVIEN)=""
 Q
PRINT ;EP - called from xbdbque
 S AMHPG=0 K AMHQ D HEADER
 I '$D(^XTMP("AMHPHQM",AMHJOB,AMHBTH)) W !!,"NO PATIENTS/PHQ SCORES TO REPORT" G DONE
 S AMHNAME="" F  S AMHNAME=$O(^XTMP("AMHPHQM",AMHJOB,AMHBTH,"PATS",AMHNAME)) Q:AMHNAME=""!($D(AMHQ))  D
 .S DFN=0 F  S DFN=$O(^XTMP("AMHPHQM",AMHJOB,AMHBTH,"PATS",AMHNAME,DFN)) Q:DFN'=+DFN!($D(AMHQ))  D
 ..W ! S AMHDATE="" F  S AMHDATE=$O(^XTMP("AMHPHQM",AMHJOB,AMHBTH,"PATS",AMHNAME,DFN,AMHDATE)) Q:AMHDATE=""!($D(AMHQ))  D
 ...S AMHT="" F  S AMHT=$O(^XTMP("AMHPHQM",AMHJOB,AMHBTH,"PATS",AMHNAME,DFN,AMHDATE,AMHT)) Q:AMHT=""!($D(AMHQ))  D
 ....S AMHV=0 F  S AMHV=$O(^XTMP("AMHPHQM",AMHJOB,AMHBTH,"PATS",AMHNAME,DFN,AMHDATE,AMHT,AMHV)) Q:AMHV'=+AMHV!($D(AMHQ))  D PRINT1
DONE ;
 K ^XTMP("AMHPHQM",AMHJOB,AMHBTH),AMHJOB,AMHBTH
 I $E(IOST)="C",IO=IO(0) S DIR(0)="EO",DIR("A")="End of report.  PRESS RETURN" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
 Q
 ;
PRINT1 ;
 I $Y>(IOSL-3) D HEADER Q:$D(AMHQ)
 W !,$E(AMHNAME,1,15),?17,$$HRN^AUPNPAT(DFN,DUZ(2)) ;$$D^AMHLEIN((9999999-AMHDATE))
 I AMHT="BH" W ?24,$$D^AMHLEIN($P($P(^AMHREC(AMHV,0),U,1),"."))
 I AMHT="PCC" W ?24,$$D^AMHLEIN($$VD^APCLV(AMHV))
 S X=0,Y="",Z="",T="",J=""
 I AMHT="BH" D
 .F  S X=$O(^AMHRMSR("AD",AMHV,X)) Q:X'=+X  D
 ..S Y=$$VAL^XBDIQ1(9002011.12,X,.01)
 ..I Y="PHQ2" S T=T_$P(^AMHRMSR(X,0),U,4)_" "
 ..I Y="PHQ9" S Z=Z_$P(^AMHRMSR(X,0),U,4)_" "
 ..I Y="PHQT" S J=J_$P(^AMHRMSR(X,0),U,4)_" "
 I AMHT="PCC" D
 .F  S X=$O(^AUPNVMSR("AD",AMHV,X)) Q:X'=+X  D
 ..S Y=$$VAL^XBDIQ1(9000010.01,X,.01) D
 ..I Y="PHQ2" S T=T_$P(^AUPNVMSR(X,0),U,4)_" "
 ..I Y="PHQ9" S Z=Z_$P(^AUPNVMSR(X,0),U,4)_" "
 ..I Y="PHQT" S J=J_$P(^AUPNVMSR(X,0),U,4)_" "
 W ?34,T,?38,Z,?43,J
 I AMHT="BH" D
 .W ?48,$E($$PPNAME^AMHUTIL(AMHV),1,9),?58,$E($$VAL^XBDIQ1(9002011,AMHV,.25),1,5)
 .S X=$O(^AMHRPRO("AD",AMHV,0))
 .I X W ?65,$$VAL^XBDIQ1(9002011.01,X,.01)_"-"_$E($$VAL^XBDIQ1(9002011.01,X,.04),1,6)
 I AMHT="PCC" D
 .W ?48,$E($$PRIMPROV^APCLV(AMHV),1,9),?58,$E($$VAL^XBDIQ1(9000010,AMHV,.08),1,5)
 .S X=$O(^AUPNVPOV("AD",AMHV,0))
 .I X W ?65,$$VAL^XBDIQ1(9000010.07,X,.01)_"-"_$E($$VAL^XBDIQ1(9000010.07,X,.04),1,6)
 Q
 ;----------
 G:'AMHPG HEADER1
 K DIR 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
HEADER1 ;
 W:$D(IOF) @IOF S AMHPG=AMHPG+1
 W !?3,$P(^VA(200,DUZ,0),U,2),?35,$$FMTE^XLFDT(DT),?70,"Page ",AMHPG,!
 W !,$$CTR^AMHLEIN("PHQ-2, PHQ-9 and PHQ-9T SCORES FOR MULTIPLE PATIENTS",80),!
 S X="Visit Dates: "_$$FMTE^XLFDT(AMHBD)_" to "_$$FMTE^XLFDT(AMHED) W $$CTR^AMHLEIN(X,80),!
 S X=$S($D(AMHRCLNT):"Clinics:  Selected",1:"Clinic: ALL Clinics") W $$CTR^AMHLEIN(X,80),!
 S X=$S($D(AMHPROVT):"Providers: Selected",1:"Providers: ALL Providers") W $$CTR^AMHLEIN(X,80),!
 W !,"PATIENT NAME",?17,"HRN",?24,"Date",?33,"PHQ2",?38,"PHQ9",?43,"PHQT",?48,"Provider",?58,"CLINIC",?65,"Diagnosis/POV"
 ;W !?33,"-2",?37,"-9",?41,"-T"
 W !,$TR($J("",80)," ","-")
 Q