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

APCDPG.m

Go to the documentation of this file.
APCDPG ; IHS/CMI/LAB - GOAL LIST UPDATE ;
 ;;2.0;IHS PCC SUITE;**7**;MAY 14, 2009
 ;; ;
START ;
 W:$D(IOF) @IOF
 F J=1:1:5 S X=$P($T(TEXT+J),";;",2) W !?80-$L(X)\2,X
 K X,J
 W !!
 S APCDPGPT="" F  D GETPAT Q:APCDPGPT=""  S DFN=APCDPGPT D EN1,FULL^VALM1,EXIT K APCDPGPT
 D EOJ
 Q
GETPAT ;get patient
 K ^TMP($J,"APCDPG")
 K APCDPGPT,APCDLOC,APCDPAT,APCDDATE,APCDPIEN,APCDAF,APCDPGI,APCDOVRR,APCDLOOK,APCDPDFN
 D KILL^AUPNPAT
 S APCDPGPT=""
 I '$P($G(^APCDSITE(DUZ(2),0)),U,34) S AUPNLK("INAC")=1
 W !
 S DIC="^AUPNPAT(",DIC(0)="AEMQ" D ^DIC K DIC
 Q:Y<0
 S APCDPGPT=+Y
 D INAC^APCDEA(APCDPGPT,.X) I 'X S APCDPGPT="" Q
 D DOD(APCDPGPT,.X) I 'X S APCDPGPT="" Q
 Q
GETLOC ;
 S APCDLOC="",DIC="^AUTTLOC(",DIC(0)="AEMQ",DIC("B")=$P(^DIC(4,$S($G(APCDLOC):APCDLOC,1:DUZ(2)),0),U),DIC("A")="Location where GOAL List update occurred: " D ^DIC K DIC
 Q:Y<0
 S APCDLOC=+Y
 Q
GETDATE ;
 S APCDDATE=""
 W !!,"Date GOAL List Updated: " R X:$S($D(DTIME):DTIME,1:300) S:'$T X=""
 Q:X=""!(X="^")
 S %DT="ET" D ^%DT G:Y<0 GETDATE
 I Y>DT W "  <Future dates not allowed>",$C(7),$C(7) K X G GETDATE
 S APCDDATE=Y
 Q
EOJ ;End of job cleanup
 D:$D(VALMWD) CLEAR^VALM1 ;clears out all list man stuff
 K ^TMP($J,"APCDPG")
 K XQORNEST,VALMKEY,VALM,VALMAR,VALMBCK,VALMBG,VALMCAP,VALMCNT,VALMOFF,VALMMCON,VALMDN,VALMEVL,VALMIOXY,VALMKEY,VALMLFT,VALMLST,VALMMENU,VALMSGR,VALMUP,VALMWD,VALMY,XQORS,XQORSPEW
 K APCDPGPT,APCDLOC,APCDPAT,APCDDATE,APCDPIEN,APCDAF,APCDPGI,APCDOVRR,APCDLOOK,APCDPDFN
 D KILL^AUPNPAT
 Q
EN1 ;PEP - requires DFN to be set to patient
 K ^TMP($J,"APCDPG")
 Q:'$G(DFN)
 S APCDPGPT=DFN
 Q:'$G(APCDPGPT)
 Q:'$D(^AUPNPAT(APCDPGPT))
 Q:'$D(^DPT(APCDPGPT))
 S Y=APCDPGPT D ^AUPNPAT
 D GETLOC
 I '$G(APCDLOC) D EXIT Q
 D GETDATE
 I '$G(APCDDATE) D EXIT Q
 S APCDOVRR=1
 D EN
 K APCDPGPT
 D FULL^VALM1
 D EXIT
 Q
EN2 ;PEP - can be called to update GOAL list, called from applications outside of PCC
 D GETPAT
 D EN
 D FULL^VALM1
 D EXIT
 Q
ENDE ;EP - for data entry PL call
 Q:'$G(DFN)
 S APCDPGPT=DFN
 Q:'$G(APCDPGPT)
 Q:'$D(^AUPNPAT(APCDPGPT))
 Q:'$D(^DPT(APCDPGPT))
 S Y=APCDPGPT D ^AUPNPAT
 S APCDLOC=APCDPLL
 I '$G(APCDLOC) D EXIT Q
 S APCDDATE=APCDPLD
 I '$G(APCDDATE) D EXIT Q
 S APCDV=$G(APCDPLV)
 S APCDOVRR=1
 D EN
 K APCDPGPT
 D FULL^VALM1
 D EXIT
 Q
EN ;PEP  main entry point for APCD PG GOAL LIST
 S VALMCC=1 ;1 means screen mode, 0 means scrolling mode
 D EN^VALM("APCD PG GOAL LIST")
 D CLEAR^VALM1
 Q
 ;
HDR ;EP -- header code
 S VALMHDR(1)=$TR($J(" ",80)," ","-")
 S VALMHDR(2)="Patient Name: "_IORVON_$P(^DPT(APCDPGPT,0),U)_IOINORM_"   DOB: "_$$FTIME^VALM1(AUPNDOB)_"   Sex: "_$P(^DPT(APCDPGPT,0),U,2)_"   HRN: "_$S($D(^AUPNPAT(APCDPGPT,41,DUZ(2),0)):$P(^AUPNPAT(APCDPGPT,41,DUZ(2),0),U,2),1:"????")
 S VALMHDR(3)="'Active Goals are listed first followed by Goals not set."
 S VALMHDR(4)="Inactive goals are not listed."
 S VALMHDR(5)=$TR($J(" ",80)," ","-")
 Q
 ;
INIT ; -- init variables and list array
 D GATHER ;gather up all GOALs
 S VALMCNT=APCDLINE ;this variable must be the total number of lines in list
 S APCDOVRR="" ;for provider narrative lookup
 Q
 ;
GATHER ;EP
 ;set up array containing list of GOALs
 ;**** see page 7 of List Manager Manual for info on how to
 ;**** set up the array that contains the list
 K APCDPG
 NEW APCDSX
 K APCDQUIT,APCDPG S APCDRCNT=0,APCDLINE=0
 I '$D(^AUPNGOAL("AC",APCDPGPT)) S APCDPG(1,0)="No GOALs currently on file",APCDPG("IDX",1,1)="" S APCDLINE=1 ;Q
 S APCDLINE=APCDLINE+1,APCDPG(APCDLINE,0)="  "
 S APCDRCNT=0
 S APCDAF="A" D GATHER1 S APCDAF="N" D GATHER1
 Q
GATHER1 ;
 S APCDF=0 F  S APCDF=$O(^AUPNGOAL("AA",APCDPGPT,APCDF)) Q:APCDF'=+APCDF  D
 .S APCDPGI="" F  S APCDPGI=$O(^AUPNGOAL("AA",APCDPGPT,APCDF,APCDPGI)) Q:APCDPGI=""  S APCDPIEN=$O(^(APCDPGI,"")),APCDP0=^AUPNGOAL(APCDPIEN,0) D
 ..Q:$P(^AUPNGOAL(APCDPIEN,0),U,11)="D"  ;NO DELETED
 ..;Q:$P(^AUPNGOAL(APCDPIEN,0),U,1)="N"
 ..Q:$P(^AUPNGOAL(APCDPIEN,0),U,11)="ME"
 ..Q:$P(^AUPNGOAL(APCDPIEN,0),U,11)="C"
 ..Q:$P(^AUPNGOAL(APCDPIEN,0),U,11)="S"
 ..I APCDAF="A" Q:$P(^AUPNGOAL(APCDPIEN,0),U,1)'="S"
 ..I APCDAF="N" Q:$P(^AUPNGOAL(APCDPIEN,0),U,1)'="N"
 ..S APCDRCNT=APCDRCNT+1,APCDLINE=APCDLINE+1,APCDPG("IDX",APCDLINE,APCDRCNT)=APCDPIEN,APCDX=""
 ..S APCDX=$$SETSTR^VALM1($J(APCDRCNT,2),APCDX,3,2),APCDX=$$SETSTR^VALM1(") GOAL ID: ",APCDX,5,11)
 ..S X=$S($P(^AUTTLOC(APCDF,0),U,7)]"":$J($P(^(0),U,7),4),1:"??")_$P(APCDP0,U,7),APCDX=$$SETSTR^VALM1(X,APCDX,16,10)
 ..S APCDX=$$SETSTR^VALM1("Status: ",APCDX,27,8),X=$$VAL^XBDIQ1(9000093,APCDPIEN,.01)_$S($P(APCDP0,U,11)]"":" - "_$$VAL^XBDIQ1(9000093,APCDPIEN,.11),1:""),APCDX=$$SETSTR^VALM1(X,APCDX,36,26)
 ..;S X="Created: "_$$DATE($P(APCDP0,U,3))_" By: "_$$VAL^XBDIQ1(9000093,APCDPIEN,.04)
 ..;S APCDX=$$SETSTR^VALM1(X,APCDX,63,20)
 ..S APCDPG(APCDLINE,0)=APCDX,APCDX="",APCDPG("IDX",APCDLINE,APCDRCNT)=APCDPIEN
 ..S APCDLINE=APCDLINE+1
 ..I $P(^AUPNGOAL(APCDPIEN,0),U,1)="S" S APCDX="      Goal Start Date: "_$$DATE($P(APCDP0,U,9))_"    Goal Follow up Date: "_$$DATE($P(APCDP0,U,10))
 ..I $P(^AUPNGOAL(APCDPIEN,0),U,1)="N" S APCDX="      Goal Created Date: "_$$DATE($P(APCDP0,U,3))
 ..S APCDPG(APCDLINE,0)=APCDX,APCDPG("IDX",APCDLINE,APCDRCNT)=APCDPIEN
 ..;goal name, reason
 ..S APCDLINE=APCDLINE+1
 ..S APCDX="      Goal Name: "_$$VAL^XBDIQ1(9000093,APCDPIEN,1101)
 ..S APCDPG(APCDLINE,0)=APCDX,APCDPG("IDX",APCDLINE,APCDRCNT)=APCDPIEN
 ..S APCDLINE=APCDLINE+1
 ..S APCDX=$S($P(^AUPNGOAL(APCDPIEN,0),U,1)="S":"      Goal Reason: ",1:"      Reason Goal Not Set: ")_$$VAL^XBDIQ1(9000093,APCDPIEN,1201)
 ..S APCDPG(APCDLINE,0)=APCDX,APCDPG("IDX",APCDLINE,APCDRCNT)=APCDPIEN
 ..S APCDLINE=APCDLINE+1
 ..S APCDX="      Provider: "_$$VAL^XBDIQ1(9000093,APCDPIEN,.08)
 ..S APCDPG(APCDLINE,0)=APCDX,APCDPG("IDX",APCDLINE,APCDRCNT)=APCDPIEN
 ..I $O(^AUPNGOAL(APCDPIEN,13,0)) S APCDX="      Review/Progress Notes on file, use DD to see full display." D
 ...S APCDLINE=APCDLINE+1,APCDPG(APCDLINE,0)=APCDX,APCDPG("IDX",APCDLINE,APCDRCNT)=APCDPIEN
STEP ..S APCDC=0 I $O(^AUPNGOAL(APCDPIEN,21,0)) D
 ...S (APCDC,APCDL)=0 F  S APCDL=$O(^AUPNGOAL(APCDPIEN,21,APCDL)) Q:APCDL'=+APCDL  I $O(^AUPNGOAL(APCDPIEN,21,APCDL,11,0)) S APCDLR=$P(^AUTTLOC($P(^AUPNGOAL(APCDPIEN,21,APCDL,0),U),0),U,7) D
 ....S APCDX=0 F  S APCDX=$O(^AUPNGOAL(APCDPIEN,21,APCDL,11,APCDX)) Q:APCDX'=+APCDX  D
 .....Q:$P(^AUPNGOAL(APCDPIEN,21,APCDL,11,APCDX,0),U,9)="D"
 .....S APCDC=APCDC+1 I APCDC=1 S X=IOINORM_"        "_IORVON_"Steps:"_IORVOFF S APCDLINE=APCDLINE+1,APCDPG(APCDLINE,0)=X,APCDPG("IDX",APCDLINE,APCDRCNT)=APCDPIEN
 .....S X="         "_APCDLR_" Step#"_APCDC,$E(X,25)=$P($G(^AUPNGOAL(APCDPIEN,21,APCDL,11,APCDX,11)),U,1)
 .....S APCDLINE=APCDLINE+1,APCDPG(APCDLINE,0)=X,APCDPG("IDX",APCDLINE,APCDRCNT)=APCDPIEN
 .....S X="",$E(X,12)="Status: "_$E($$SS($P($G(^AUPNGOAL(APCDPIEN,21,APCDL,11,APCDX,0)),U,9)),1,15)
 .....S $E(X,38)="Start Date: "_$$DATE($P(^AUPNGOAL(APCDPIEN,21,APCDL,11,APCDX,0),U,5)),$E(X,60)="F/U Date: "_$$DATE($P(^AUPNGOAL(APCDPIEN,21,APCDL,11,APCDX,0),U,6))
 .....S APCDLINE=APCDLINE+1,APCDPG(APCDLINE,0)=X,APCDPG("IDX",APCDLINE,APCDRCNT)=APCDPIEN
 ..Q
 .Q
 K APCDLR,APCDL,APCDX,APCDF
 Q
TEXT ;
 ;;Patient Care Component (PCC)
 ;;
 ;;***********************************
 ;;*  Update PCC Patient GOAL List   *
 ;;***********************************
 ;;
 Q
HELP ; -- help code
 S X="?" D DISP^XQORM1 W !!
 Q
 ;
EXIT ; -- exit code
 K ^TMP($J,"APCDPG")
 K APCDRCNT,APCDPG,APCDLINE,APCDX,APCDP0,APCDC,APCDL,APCDLR,APCDPIEN,APCDAF,APCDPGI,APCDOVRR,APCDLOOK,APCDPDFN,APCDLOC,APCDDATE
 K X,Y
 K VALMHDR
 Q
 ;
EXPND ; -- expand code
 Q
 ;
DATE(D) ;EP
 I D="" Q ""
 Q $E(D,4,5)_"/"_$E(D,6,7)_"/"_$E(D,2,3)
DOD(P,RETVAL) ;EP - called to check to see if patient is inactive
 S RETVAL=1
 I $P($G(^DPT(P,.35)),U,1)]"" D  Q
 .W !!,"***Warning***  You have selected a patient who is deceased.",!
 .K DIR S DIR(0)="Y",DIR("A")="Do you wish to continue to add data for this patient",DIR("B")="Y" KILL DA D ^DIR KILL DIR
 .I $D(DIRUT) S RETVAL=0
 .S RETVAL=Y
 Q
SS(%) ;EP
 I %="A" Q "ACTIVE"
 I %="MA" Q "MAINTAINING STEP"
 I %="ME" Q "STEP MET"
 I %="S" Q "STEP STOPPED"
 I %="D" Q "DELETED"
 Q "??"