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

AMHRLKUP.m

Go to the documentation of this file.
AMHRLKUP ; IHS/CMI/LAB - lookup up record ;
 ;;4.0;IHS BEHAVIORAL HEALTH;**4,5**;JUN 02, 2010;Build 18
 ;
EN ;EP
 D EOJ
 K AMHR
 I AMHPAT,'$$ALLOWP^AMHUTIL(DUZ,AMHPAT) D NALLOWP^AMHUTIL Q
 I AMHPAT]"",'$D(^AMHREC("C",AMHPAT)) W !!,"No visits currently on file for ",$P(^DPT(AMHPAT,0),U),".",! Q
 I AMHLOC]"",'$D(^AMHREC("AA",AMHDATE,AMHLOC)) W !!,"No visits currently on file for ",$P(^DIC(4,AMHLOC,0),U),".",! Q
 S AMHDASH="--------------------------------------------------------------------------------"
 D COLLECT
 I AMHRCNT=1 S AMHR=AMHRRECS(1) D EOJ Q
 I AMHRCNT=0 K AMHR D EOJ Q
 D DISPRECS
 D SELECT
EOJ ;
 K AMHQUIT,AMHPG,AMHODAT,AMHRRECS,AMHP,AMHR0,AMHRCNT,AMHRCTR
 Q
 I 'AMHPG G HEAD1
 I $E(IOST)="C",IO=IO(0) W ! S DIR(0)="EO" D ^DIR K DIR I Y=0!(Y="^")!($D(DTOUT)) S AMHQUIT="" Q
HEAD1 ;
 S AMHPG=AMHPG+1
 W:$D(IOF) @IOF
 W !,AMHDASH
 W !?13,"Behavioral Health visits for " S Y=AMHDATE D DD^%DT W Y I AMHLOC]"" W !,"Location:  ",$P(^DIC(4,AMHLOC,0),U)
 W !,AMHDASH
 W !," #",?7,"PROVIDER",?18,"LOC",?23,"COMMUNITY",?33,"ACT",?37,"CONT",?42,"PATIENT",?55,"PROB",?64,"NARRATIVE",!,AMHDASH
 Q
SELECT ;
 W ! S DIR(0)="NO^1:"_AMHRCNT_":0",DIR("A")="Which record do you want to display" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
 I $D(DIRUT) W !,"No Records selected to display." D PAUSE^AMHLEIN Q
 I '$D(AMHRRECS(+Y)) W !,"Invalid selection!!" G SELECT
 S AMHR=AMHRRECS(+Y)
 Q
COLLECT ;
 S AMHODAT=(AMHDATE-1)_".9999",(AMHRCNT,AMHRIEN)=0 F  S AMHODAT=$O(^AMHREC("B",AMHODAT)) Q:AMHODAT=""!(AMHODAT>(AMHDATE_".9999"))!($D(AMHQUIT))  D
 .S AMHRIEN=0 F  S AMHRIEN=$O(^AMHREC("B",AMHODAT,AMHRIEN)) Q:AMHRIEN'=+AMHRIEN!($D(AMHQUIT))  S AMHR0=^AMHREC(AMHRIEN,0) D
 ..I AMHLOC]"",AMHLOC'=$P(AMHR0,U,4) Q
 ..I AMHPAT]"",AMHPAT'=$P(AMHR0,U,8) Q
 ..I $G(AMHEHR),'$P($G(^AMHREC(AMHRIEN,11)),U,10) Q
 ..I '$$ALLOWVI^AMHUTIL(DUZ,AMHRIEN) Q
 ..I $P(AMHR0,U,8),'$$ALLOWP^AMHUTIL(DUZ,$P(AMHR0,U,8)) Q  ;can user see this patient?
 ..S AMHRCNT=AMHRCNT+1,AMHRRECS(AMHRCNT)=AMHRIEN
 ..Q
 .Q
 Q
DISPRECS ;display visits for selection by user
 S (AMHPG,AMHRCTR,AMHRIEN)=0
 D HEAD
 F  S AMHRCTR=$O(AMHRRECS(AMHRCTR)) Q:AMHRCTR'=+AMHRCTR  S AMHRIEN=AMHRRECS(AMHRCTR),AMHR0=^AMHREC(AMHRIEN,0) D
 .I $Y>(IOSL-1) D HEAD Q:$D(AMHQUIT)
 .W !,AMHRCTR,?5,$E($$PPNAME^AMHUTIL(AMHRIEN),1,12)
 .W:$P(AMHR0,U,4) ?18,$S($P(^AUTTLOC($P(AMHR0,U,4),0),U,7)]"":$P(^(0),U,7),1:$E($P(^AUTTLOC($P(AMHR0,U,4),0),U),1,4))
 .W:$P(AMHR0,U,5) ?23,$E($P(^AUTTCOM($P(AMHR0,U,5),0),U),1,10)
 .W ?34,$S($P(AMHR0,U,6)]"":$P(^AMHTACT($P(AMHR0,U,6),0),U),1:""),?37,$S($P(AMHR0,U,7)]"":$E($P(^AMHTSET($P(AMHR0,U,7),0),U),1,4),1:"")
 .I $P(AMHR0,U,8)]""  D
 ..I $P(AMHR0,U,4),$D(^AUPNPAT($P(AMHR0,U,8),41,$P(AMHR0,U,4))) W ?42,$P(^AUTTLOC($P(AMHR0,U,4),0),U,7)," ",$P(^AUPNPAT($P(AMHR0,U,8),41,$P(AMHR0,U,4),0),U,2) Q
 ..I $D(^AUPNPAT($P(AMHR0,U,8),41,DUZ(2))) W ?42,$P(^AUTTLOC(DUZ(2),0),U,7)," ",$P(^AUPNPAT($P(AMHR0,U,8),41,DUZ(2),0),U,2)
 .E  W ?42,"-----"
 .S AMHP=$O(^AMHRPRO("AD",AMHRIEN,0)) I AMHP="" W ?55,"No Problems recorded." Q
 .W ?55,$P(^AMHPROB($P(^AMHRPRO(AMHP,0),U),0),U) W ?64,$E($$GET1^DIQ(9002011.01,AMHP,.04),1,15)
 .Q
 Q