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

APCHS82.m

Go to the documentation of this file.
APCHS82 ; IHS/CMI/LAB - PART 4 OF APCHS -- SUMMARY PRODUCTION COMPONENTS ; 12 Sep 2011  5:35 PM
 ;;2.0;IHS PCC SUITE;**7**;MAY 14, 2009
 ;
GOAL ; ******************** GOAL / STEPS  *********
AGOAL ;
 ; <SETUP>
COMMON Q:'$D(^AUPNGOAL("AC",APCHSPAT))  ;no goals so don't bother
 K APCHSDFT S APCHSNDF=0
 S APCHSFAC="" F APCHSQ=0:0 S APCHSFAC=$O(^AUPNGOAL("AA",APCHSPAT,APCHSFAC)) Q:'APCHSFAC  D GOALSCH
 X APCHSCKP G:$D(APCHSQIT) GOALX I 'APCHSNPG W ! X APCHSCKP G:$D(APCHSQIT) GOALX X:'APCHSNPG APCHSBRK
 I APCHSNDF=0 G COMMON1
 ; <DISPLAY>
 S APCHSTAT="" F  S APCHSTAT=$O(APCHSDFT(APCHSTAT)) Q:APCHSTAT=""!($D(APCHSQIT))  D
 .X APCHSCKP Q:$D(APCHSQIT)
 .I APCHSTAT="A" W "ACTIVE GOALS (ALL ACTIVE AND MAINTAINING GOALS)",!
 .I APCHSTAT="I" W !,"INACTIVE GOALS (ALL GOALS STOPPED OR MET IN PAST 12 MONTHS)",!
 .I APCHSTAT="N" W !,"GOALS NOT SET (LAST 5 OR 12 MONTHS)",!
 .S APCHSFPP="" F  S APCHSFPP=$O(APCHSDFT(APCHSTAT,APCHSFPP)) Q:APCHSFPP=""!($D(APCHSQIT))  D
 ..S APCHSIEN=APCHSDFT(APCHSTAT,APCHSFPP) D GOALDSP
COMMON1 ;
GOALX K APCHSDFT,APCHSNDF,APCHSFPP,APCHSFAC,APCHSPLN,APCHSPBN,APCHSDTM,APCHSDTN,APCHSPRB,APCHSTAT,APCHSNFP,APCHSNRQ,APCHSPNM,APCHSIEN,APCHSFCN,APCHSICD,APCHSDOO
 K APCHSICL,APCHSILN,APCHSN,APCHSNAR,APCHSNTE
 K APCHSNFL,APCHSNSH,APCHSNAB,APCHSVSC,APCHSITE,Y,APCHCSVD,APCHSX
 Q
GOALSCH ;
 S APCHSPRB="" F APCHSQ=0:0 S APCHSPRB=$O(^AUPNGOAL("AA",APCHSPAT,APCHSFAC,APCHSPRB)) Q:APCHSPRB=""  D
 .S APCHSTAT=""
 .S APCHSIEN=$O(^(APCHSPRB,""))
 .Q:$P(^AUPNGOAL(APCHSIEN,0),U,11)="D"  ;never display deleted goals
 .I $P(^AUPNGOAL(APCHSIEN,0),U,1)="S",$P(^AUPNGOAL(APCHSIEN,0),U,11)="A" S APCHSTAT="A"
 .I $P(^AUPNGOAL(APCHSIEN,0),U,1)="S",$P(^AUPNGOAL(APCHSIEN,0),U,11)="ME" S APCHSTAT="I"
 .I $P(^AUPNGOAL(APCHSIEN,0),U,1)="S",$P(^AUPNGOAL(APCHSIEN,0),U,11)="MA" S APCHSTAT="A"
 .I $P(^AUPNGOAL(APCHSIEN,0),U,1)="S",$P(^AUPNGOAL(APCHSIEN,0),U,11)="S" S APCHSTAT="I"
 .I $P(^AUPNGOAL(APCHSIEN,0),U,1)="N" S APCHSTAT="N"
 .I APCHSTAT="I",$$FMDIFF^XLFDT(DT,$P(^AUPNGOAL(APCHSIEN,0),U,3))>365 Q  ;ONLY DISPLAY IF INACTIVE AND STARTED IN PAST 12 MOS
 .I APCHSTAT=""  Q  ;?? CAN'T FIGURE OUT IF ACTIVE OR INACTIVE
 .S APCHSNDF=APCHSNDF+1
 .S APCHSTAT(APCHSTAT)=$G(APCHSTAT(APCHSTAT))+1
 .I APCHSTAT="N",APCHSTAT(APCHSTAT)>5 Q  ;ONLY DISPLAY LAST 5 OF Goals not set
 .S APCHSDFT(APCHSTAT,APCHSFAC_APCHSPRB)=APCHSIEN
 Q
GOALDSP ;
 ; <SETUP GOAL>
 S APCHSN=^AUPNGOAL(APCHSIEN,0)
 D STEPDSP
 Q
STEPDSP ;
 X APCHSCKP Q:$D(APCHSQIT)
 S APCHSFAC=$P(APCHSN,U,6)
 W !,"GOAL ID: "
 S X=$S($P(^AUTTLOC(APCHSFAC,0),U,7)]"":$J($P(^(0),U,7),4),1:"??")_$P(APCHSN,U,7)
 W X,?20,"Status: ",$S($P(APCHSN,U,1)="N":"GOAL NOT SET",1:$$VAL^XBDIQ1(9000093,APCHSIEN,.11)),!
 X APCHSCKP Q:$D(APCHSQIT)
 ;GOAL NAME
 K APCHWP
 D WP($$VAL^XBDIQ1(9000093,APCHSIEN,1101),70)
 S APCHX=0 F  S APCHX=$O(APCHWP(APCHX)) Q:APCHX'=+APCHX!($D(APCHSQIT))  D
 .X APCHSCKP Q:$D(APCHSQIT)
 .W ?9,APCHWP(APCHX),!
 Q:$D(APCHSQIT)
 X APCHSCKP Q:$D(APCHSQIT)
 I $P(^AUPNGOAL(APCHSIEN,0),U,1)="S" S X="Start: "_$$DATE^APCDPG($P(APCHSN,U,9))_"   Follow up: "_$$DATE^APCDPG($P(APCHSN,U,10))_"   Modified: "_$$DATE^APCDPG($P(APCHSN,U,5))
 I $P(^AUPNGOAL(APCHSIEN,0),U,1)="N" S X="Created: "_$$DATE^APCDPG($P(APCHSN,U,3))
 W ?9,X,!
 S APCHX=0,Y="" F  S APCHX=$O(^AUPNGOAL(APCHSIEN,10,APCHX)) Q:APCHX'=+APCHX  S X=$P(^AUPNGOAL(APCHSIEN,10,APCHX,0),U,1),X=$P(^APCDTPGT(X,0),U,1) S Y=Y_X_"  "
 K APCHWP
 D WP("Type: "_Y,59)
 S APCHX=0 F  S APCHX=$O(APCHWP(APCHX)) Q:APCHX'=+APCHX!($D(APCHSQIT))  D
 .X APCHSCKP Q:$D(APCHSQIT)
 .W ?9,APCHWP(APCHX),!
 Q:$D(APCHSQIT)
 ;GOAL NAME
 K APCHWP
 D WP("Goal Name: "_$$VAL^XBDIQ1(9000093,APCHSIEN,1101),59)
 S APCHX=0 F  S APCHX=$O(APCHWP(APCHX)) Q:APCHX'=+APCHX!($D(APCHSQIT))  D
 .X APCHSCKP Q:$D(APCHSQIT)
 .W ?9,APCHWP(APCHX),!
 Q:$D(APCHSQIT)
 ;REASON
 K APCHWP
 D WP("Reason: "_$$VAL^XBDIQ1(9000093,APCHSIEN,1201),59)
 S APCHX=0 F  S APCHX=$O(APCHWP(APCHX)) Q:APCHX'=+APCHX!($D(APCHSQIT))  D
 .X APCHSCKP Q:$D(APCHSQIT)
 .W ?9,APCHWP(APCHX),!
 Q:$D(APCHSQIT)
 X APCHSCKP Q:$D(APCHSQIT)
 W ?9,"Provider: ",$$VAL^XBDIQ1(9000093,APCHSIEN,.08),!
 ;display steps
STEP S APCHC=0 I $O(^AUPNGOAL(APCHSIEN,21,0)) D
 .S (APCHC,APCHL)=0,APCHSLR="" F  S APCHL=$O(^AUPNGOAL(APCHSIEN,21,APCHL)) Q:APCHL'=+APCHL!($D(APCHSQIT))  D
 ..I $O(^AUPNGOAL(APCHSIEN,21,APCHL,11,0)) S APCHSLR=$P(^AUTTLOC($P(^AUPNGOAL(APCHSIEN,21,APCHL,0),U),0),U,7) D
 ...S APCHX=0,APCDC=0 F  S APCHX=$O(^AUPNGOAL(APCHSIEN,21,APCHL,11,APCHX)) Q:APCHX'=+APCHX  D
 ....Q:$P(^AUPNGOAL(APCHSIEN,21,APCHL,11,APCHX,0),U,9)="D"
 ....X APCHSCKP Q:$D(APCHSQIT)
 ....S APCDC=APCDC+1
 ....S X=APCHSLR_" Step#"_APCDC,$E(X,20)="Status: "_$$SS($P($G(^AUPNGOAL(APCHSIEN,21,APCHL,11,APCHX,0)),U,9))
 ....W ?3,X,!
 ....K APCHWP
 ....D WP($P($G(^AUPNGOAL(APCHSIEN,21,APCHL,11,APCHX,11)),U,1),70)
 ....S APCHY=0 F  S APCHY=$O(APCHWP(APCHY)) Q:APCHY'=+APCHY!($D(APCHSQIT))  D
 .....X APCHSCKP Q:$D(APCHSQIT)
 .....W ?9,APCHWP(APCHY),!
 ....X APCHSCKP Q:$D(APCHSQIT)
 ....S X="Start: "_$$DATE^APCDPG($P(^AUPNGOAL(APCHSIEN,21,APCHL,11,APCHX,0),U,5))_"   Follow Up: "_$$DATE^APCDPG($P(^AUPNGOAL(APCHSIEN,21,APCHL,11,APCHX,0),U,6))  ;_"   Modified: "_$$DATE^APCDPG($P(^AUPNGOAL(APCHSIEN,21,APCHL,11,APCHX,0),U,8))
 ....W ?9,X,!
 ....X APCHSCKP Q:$D(APCHSQIT)
 ....S Y=$P(^AUPNGOAL(APCHSIEN,21,APCHL,11,APCHX,0),U,4) I Y S Y=$P(^APCDTPGT(Y,0),U,1)
 ....S P=$P(^AUPNGOAL(APCHSIEN,21,APCHL,11,APCHX,0),U,10) I P S P=$P(^VA(200,P,0),U,1)
 ....S X="Type: "_Y_"   Provider: "_P
 ....W ?9,X,!
DISPREVS ;
 Q:'$O(^AUPNGOAL(APCHSIEN,13,0))  ;no review/followups on file
 W ?3,"Followup/Reviews for GOAL : "_$S($P(^AUTTLOC(APCHSFAC,0),U,7)]"":$J($P(^(0),U,7),4),1:"??")_$P(APCHSN,U,7),!
 S (APCHC,APCHL)=0
 F  S APCHL=$O(^AUPNGOAL(APCHSIEN,13,APCHL)) Q:APCHL'=+APCHL!($D(APCHSQIT))  D
 .S X="Date: "_$$DATE^APCDPG($P(^AUPNGOAL(APCHSIEN,13,APCHL,0),U))_"  "_$P(^AUPNGOAL(APCHSIEN,13,APCHL,0),U,2)
 .K APCHWP
 .D WP(X,70)
 .S APCHY=0 F  S APCHY=$O(APCHWP(APCHY)) Q:APCHY'=+APCHY!($D(APCHSQIT))  D
 ..X APCHSCKP Q:$D(APCHSQIT)
 ..W ?9,APCHWP(APCHY),!
 Q
WP(X,R) ;EP - Entry point to print wp fields pass node in APCHWP
 NEW APCHG,APCHX,CNT
 K ^UTILITY($J,"W")
 S APCHX=0
 S DIWL=1,DIWR=R
 D ^DIWP
 S (Z,CNT)=0 F  S Z=$O(^UTILITY($J,"W",DIWL,Z)) Q:Z'=+Z  S CNT=CNT+1,APCHWP(CNT)=^UTILITY($J,"W",DIWL,Z,0)
 K DIWL,DIWR,DIWF,Z
 K ^UTILITY($J,"W"),APCHG,CNT,APCHX
 Q
SS(%) ;
 I %="A" Q "ACTIVE"
 I %="MA" Q "MAINTAINING STEP"
 I %="ME" Q "STEP MET"
 I %="S" Q "STEP STOPPED"
 I %="D" Q "DELETED"
 Q "??"