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

AMHDPEE.m

Go to the documentation of this file.
AMHDPEE ; IHS/CMI/LAB - BROWSE VISITS ;
 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
 ;
 ;
START ;
 NEW AMHX,AMHY,AMHR0,DFN,AUPNPAT,AUPNDOB,AUPNDOD,AUPNDAYS,AUPNSEX,AMHV,AMHBD,AMHED
 NEW D,R
 K AMHV
 W:$D(IOF) @IOF
 W $$CTR("View/Update Designated Provider List",80)
PROV ;
 D ^XBFMK
 S AMHDP=""
 W !! S DIC("A")="Enter Designated Provider Name: ",DIC="^VA(200,",DIC(0)="AEMQ",DIC("B")=$P(^VA(200,DUZ,0),U) D ^DIC K DIC,DA,DR,DLAYGO,DIADD
 I Y<0 W !,"No Provider Selected." Q
 S AMHPROV=+Y
DEMO ;
 D DEMOCHK^AMHUTIL1(.AMHDEMO)
 I AMHDEMO=-1 G PROV
 D EN
END ;
 D EOJ
 K AMHP,AMHQUIT,AMHW
 Q
 ;
EN ; -- main entry point for AMH UPDATE PATIENT CASE DATA
 D EN^VALM("AMH VIEW/UPDATE DP LIST")
 K AMHCASE,AMHX,AMHD,AMHRCNT,AMHLINE,AMHCDATE
 Q
 ;
HDR ; -- header code
 S VALMHDR(1)=$TR($J(" ",80)," ","-")
 S VALMHDR(2)="Patients with Designated Provider: "_IORVON_$P(^VA(200,AMHPROV,0),U)_IOINORM
 S VALMHDR(3)=$TR($J(" ",80)," ","-")
 S VALMHDR(4)="#    HRN    PATIENT NAME              DOB          SEX LAST VISIT    PROV TYPE"
 Q
 ;
CTR(X,Y) ;EP - Center X in a field Y wide.
 Q $J("",$S($D(Y):Y,1:IOM)-$L(X)\2)_X
 ;----------
LVD(P,I) ;EP
 I $G(I)="" S I="D"
 I '$G(P) Q ""
 NEW D,A,B,C,G
 S G="",A=0 F  S A=$O(^AMHREC("AE",P,A)) Q:A'=+A!(G)  D
 .S (B,F)=0 F  S B=$O(^AMHREC("AE",P,A,B)) Q:B'=+B!(G)  D
 ..Q:'$D(^AMHREC(B,0))
 ..Q:'$$ALLOWVI^AMHUTIL(DUZ,B)
 ..S (F,C)=0 F  S C=$O(^AMHRPRO("AD",B,C)) Q:C'=+C  D
 ...S E=$P(^AMHRPRO(C,0),U),E=$S(E:$P(^AMHPROB(E,0),U),1:"")
 ...Q:E=""
 ...Q:E<8!(E>8.99999)
 ...S F=1 ;got a DNKA
 ...Q
 ..I 'F S G=B
 ..Q
 .Q
 I 'G Q ""
 I I="I" Q G
 S D=$P($P(^AMHREC(G,0),U),".") I I="ID" Q D
 Q $$FMTE^XLFDT(D)
INIT ; -- init variables and list array
 S VALMSG="?? for more actions  + next screen  - prev screen"
 D GATHER ;gather up all records for display
 S VALMCNT=AMHLINE
 Q
 ;
GATHER ;
 K ^TMP("AMHDPEE",$J),^TMP($J,"AMHDPEE")
 S AMHD=0 F  S AMHD=$O(^AMHPATR("AMH",AMHPROV,AMHD)) Q:AMHD'=+AMHD  I '$$DEMO^AMHUTIL1(AMHD,$G(AMHDEMO)) S ^TMP($J,"AMHDPEE",$P(^DPT(AMHD,0),U),AMHD,1)=""
 S AMHD=0 F  S AMHD=$O(^AMHPATR("ASS",AMHPROV,AMHD)) Q:AMHD'=+AMHD  I '$$DEMO^AMHUTIL1(AMHD,$G(AMHDEMO)) S ^TMP($J,"AMHDPEE",$P(^DPT(AMHD,0),U),AMHD,2)=""
 S AMHD=0 F  S AMHD=$O(^AMHPATR("AOT",AMHPROV,AMHD)) Q:AMHD'=+AMHD  I '$$DEMO^AMHUTIL1(AMHD,$G(AMHDEMO)) S ^TMP($J,"AMHDPEE",$P(^DPT(AMHD,0),U),AMHD,3)=""
 S AMHD=0 F  S AMHD=$O(^AMHPATR("AOTH",AMHPROV,AMHD)) Q:AMHD'=+AMHD  I '$$DEMO^AMHUTIL1(AMHD,$G(AMHDEMO)) S ^TMP($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HD,0),U,2),$E(Y,56)=$$LVD(AMHD),$E(Y,69)="OTH 2"
 ;.S ^TMP("AMHDPEE",$J,AMHLINE,0)=Y,^TMP("AMHDPEE",$J,"IDX",AMHLINE,AMHRCNT)=AMHD
 Q
EDDP ;EP - called from protocol
 D EN^VALM2(XQORNOD(0),"OS")
 I '$D(VALMY) W !,"No records selected." G EXIT
 S AMHR=$O(VALMY(0)) I 'AMHR K AMHR,VALMY,XQORNOD W !,"No record selected." G EXIT
 S AMHR=^TMP("AMHDPEE",$J,"IDX",AMHR,AMHR) I 'AMHR K AMHRDEL,AMHR D PAUSE^AMHLEA D EXIT Q
 I '$D(^AMHPATR(AMHR,0)) W !,"Not a valid PATIENT RECORD." K AMHRDEL,AMHR D PAUSE^AMHLEA D EXIT Q
 D FULL^VALM1
 W !,"Editing Designated Provider....."
 S DA=AMHR,DIE="^AMHPATR(",DR=".02;.03;.04;.12;.13" D ^DIE
 D EXIT
 Q
RMDP ;EP - called from protocol to remove DP entry
 D EN^VALM2(XQORNOD(0),"OS")
 I '$D(VALMY) W !,"No records selected." G EXIT
 S AMHR=$O(VALMY(0)) I 'AMHR K AMHR,VALMY,XQORNOD W !,"No record selected." G EXIT
 S AMHR=^TMP("AMHDPEE",$J,"IDX",AMHR,AMHR) I 'AMHR K AMHRDEL,AMHR D PAUSE^AMHLEA D EXIT Q
 I '$D(^AMHPATR(AMHR,0)) W !,"Not a valid PATIENT RECORD." K AMHRDEL,AMHR D PAUSE^AMHLEA D EXIT Q
 D FULL^VALM1
 W !,"Removing ",$P(^VA(200,AMHPROV,0),U)," as Designated Provider for ",!,$P(^DPT($P(^AMHPATR(AMHR,0),U),0),U)," ..."
 I $P(^AMHPATR(AMHR,0),U,2)=AMHPROV S DA=AMHR,DIE="^AMHPATR(",DR=".02///@" D ^DIE
 I $P(^AMHPATR(AMHR,0),U,3)=AMHPROV S DA=AMHR,DIE="^AMHPATR(",DR=".03///@" D ^DIE
 I $P(^AMHPATR(AMHR,0),U,4)=AMHPROV S DA=AMHR,DIE="^AMHPATR(",DR=".04///@" D ^DIE
 I $P(^AMHPATR(AMHR,0),U,12)=AMHPROV S DA=AMHR,DIE="^AMHPATR(",DR=".12///@" D ^DIE
 ;I $P(^AMHPATR(AMHR,0),U,13)=AMHPROV S DA=AMHR,DIE="^AMHPATR(",DR=".13///@" D ^DIE
CD ;
 S DIR(0)="Y",DIR("A")="Do you want to update the Case Status?",DIR("B")="N" KILL DA D ^DIR KILL DIR
 I $D(DIRUT) D EXIT Q
 I 'Y D EXIT Q
 D EP1^AMHLCD(AMHR)
 D EXIT
 Q
BV ;
 D ^AMHVD
 D EXIT
 Q
HS ;EP called from protocol to generate hs
 S DFN=""
 S DIC="^AUPNPAT(",DIC(0)="AEMQ" D ^DIC K DIC,DA,DR,DLAYGO,DIADD
 I Y<0 W !,"No Patient Selected." Q
 S DFN=+Y
 S Y=DFN D ^AUPNPAT
 I $G(AUPNDOD)]"" W !!?10,"***** PATIENT'S DATE OF DEATH IS ",$$FMTE^XLFDT(AUPNDOD),!! H 2
 D GETTYPE
 I '$G(APCHSTYP) D EN^XBVK("APCH") Q
 S APCHSPAT=DFN
 S %="PCC Health Summary for "_$P(^DPT(APCHSPAT,0),U)
 D VIEWR^XBLM("EN^APCHS",%)
 D EN^XBVK("APCH") K AMCHDAYS,AMCHDOB,%
 D EXIT
 Q
GETTYPE ;
 I $G(^AMHSITE(DUZ(2),0))="" D DEFAULT Q
 S APCHSTYP=$P(^AMHSITE(DUZ(2),0),U,4) I APCHSTYP="" D DEFAULT Q
 I '$D(^APCHSCTL(APCHSTYP)) W !,"Error in Site Parameter File!",$C(7),$C(7) S APCHSTYP="" Q
 Q
DEFAULT ;
 S APCHSTYP=""
 S X="BEHAVIORAL HEALTH",DIC(0)="",DIC="^APCHSCTL(" D ^DIC K DIC,DA
 I Y=-1 W !!,"PCC MENTAL HEALTH HEALTH SUMMARY TYPE IS MISSING!!  NOTIFY YOUR SUPERVISOR OR SITE MANAGER.",!! Q
 S APCHSTYP=+Y
 Q
ADDDP ;EP called from protocol to open a new case
 D FULL^VALM1
 W:$D(IOF) @IOF
 S AMHPAT=""
 S DIC="^AUPNPAT(",DIC(0)="AEMQ" D ^DIC K DIC,DA,DR,DLAYGO,DIADD
 I Y<0 W !,"No Patient Selected." Q
 S AMHPAT=+Y
 I '$D(^AMHPATR(AMHPAT)) S DIC="^AMHPATR(",DIC(0)="L",DLAYGO=9002011.55,X="`"_AMHPAT D ^DIC I Y=-1 D ^XBFMK K DLAYGO,DIADD W !!,"FAILED TO ADD PATIENT TO MHSS PATIENT DATA FILE" Q
 S DA=AMHPAT,DDSFILE=9002011.55,DR="[AMH PATIENT RELATED DATA]" D ^DDS
 I $D(DIMSG) W !!,"ERROR IN SCREENMAN FORM!!  ***NOTIFY PROGRAMMER***" S AMHQUIT=1 K DIMSG Q
 D EXIT
 Q
HELP ; -- help code
 S X="?" D DISP^XQORM1 W !!
 Q
 ;
EXIT ; -- exit code
 K AMHX,AMHCASE,AMHPC,AMHR1,AMHPAT,DFN
 D TERM^VALM0
 S VALMBCK="R"
 D GATHER
 S VALMCNT=AMHLINE
 D HDR
 K X,Y,Z,I
 Q
EOJ ;
 D EN^XBVK("AMH")
 K DFN
 K DDSFILE,DIPGM,Y
 K X,Y,%,DR,DDS,DA,DIC
 K AMHCASE,AMHX,AMHD,AMHRCNT,AMHLINE,AMHCDATE
 D:$D(VALMWD) CLEAR^VALM1
 K VALM,VALMHDR,VALMKEY,VALMMENU,VALMSGR,VALMUP,VALMWD,VALMLST,VALMVAR,VALMLFT,VALMBCK,VALMCC,VALMAR,VALMBG,VALMCAP,VALMCOFF,VALMCNT,VALMCON,BALMON,VALMEVL,VALMIOXY
 D KILL^AUPNPAT
 Q
 ;
EXPND ; -- expand code
 Q
 ;
AV ;EP add visit
 D FULL^VALM1
 D GETPAT^AMHLEA
 I 'AMHPAT W !,"NO Patient selected!",! D PAUSE^AMHLEA D EXIT Q
 S DFN=AMHPAT
 S AMHDPEEP=AMHPROV
 D CONTACT^AMHLEP1(AMHPAT,1)
 S AMHPROV=AMHDPEEP
 D PAUSE^AMHLEA
 D EXIT
 Q