source: FOIAVistA/trunk/r/MENTAL_HEALTH-YS-RUCL-YI-YT/YSGAF.m@ 1801

Last change on this file since 1801 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 5.9 KB
Line 
1YSGAF ;ALB/ASF-GLOBAL ASSESSMENT OF FUNCTIONING ;11/10/97 16:17
2 ;;5.01;MENTAL HEALTH;**33,37,40,42,43,51,49**;Dec 30, 1994
3 Q
4CLENT ;
5 N %DT,DA,DIE,DIR,DIRUT,DLAYGO,DR,K,VA,VADM,X,X1,X2,Y,YSCLIN,YSCNAME,YSDA,YSDATE,YSDAYS,YSDD,YSDXEG,YSDXEL,YSDXEN,YSG,YSGAFLC,YSGAFLD,YSGAFLN,YSGC,YSGD,YSGN,YSGR,YSGT,YSLINE,YSN,YSONLY,YSOUT,YSPAGE,YSPTN,YSRULE,YSSTOP,YSGAFER
6 W @IOF,"Clinic Entry: Global Assessment of Functioning",!
7 D ONELOC^YSGAF1 Q:YSCLIN=""
8 D DATE^YSGAF1 Q:YSDATE<1
9 S YSDAYS=90
10 D ONLYREQ^YSGAF1 Q:YSONLY=""
11 D LP1^YSGAF1
12 I '$D(^TMP("YSGAF",$J)) W !,"No GAF's to enter" Q
13CE1 S YSN="",YSOUT=0 F S YSN=$O(^TMP("YSGAF",$J,"A",YSN)) Q:YSN=""!(YSOUT) S DFN=0 F S DFN=$O(^TMP("YSGAF",$J,"A",YSN,DFN)) Q:DFN'>0 D
14 .D RULE Q:('YSRULE)&(YSONLY)
15 .W !
16 .D DISP5,ADD5
17 Q
18RULE ;business rule for need dx
19 S YSRULE=0
20 D CK
21 I YSGAFLD'?7N.E S YSRULE=1 Q
22 S X1=DT,X2=YSGAFLD D ^%DTC
23 S:X>YSDAYS YSRULE=1
24 Q
25CK ;check last Axis 5
26 S (YSGAFLN,YSGAFLD,YSGAFLC,YSGAFER)=""
27 S YSDXEL=$O(^YSD(627.8,"AX5",DFN,-1))
28 Q:YSDXEL<1
29 S YSDXEN=$O(^YSD(627.8,"AX5",DFN,YSDXEL,-1))
30 Q:YSDXEN<1
31 S YSDXEG=$G(^YSD(627.8,YSDXEN,0))
32 S YSGAFLD=$P(YSDXEG,U,3),YSGAFLC=$P(YSDXEG,U,4)
33 S YSDXEG=$G(^YSD(627.8,YSDXEN,60))
34 S YSGAFLN=$P(YSDXEG,U,3)
35 S YSGAFER=$G(^YSD(627.8,YSDXEN,80,1,0))
36 Q
37PRINT ;
38 N %DT,DA,DIE,DIR,DIRUT,DLAYGO,DR,K,VA,VADM,X,X1,X2,Y,YSCLIN,YSCNAME,YSDA,YSDATE,YSDAYS,YSDD,YSDXEG,YSDXEL,YSDXEN,YSG,YSGAFLC,YSGAFLD,YSGAFLN,YSGC,YSGD,YSGN,YSGR,YSGT,YSLINE,YSN,YSONLY,YSOUT,YSPAGE,YSPTN,YSRULE,YSSTOP
39 S YSDAYS=90
40 D ONELOC^YSGAF1 Q:YSCLIN=""
41 D DATE^YSGAF1 Q:YSDATE<1
42 D ONLYREQ^YSGAF1 Q:YSONLY=""
43 ;ASK DEVICE
44 S %ZIS="QM"
45 D ^%ZIS
46 Q:$G(POP)
47 I $D(IO("Q")) D Q
48 .N ZTRTN,ZTDESC,ZTSAVE
49 .S ZTRTN="QPRT^YSGAF"
50 .S ZTDESC="YSGAF PRINT"
51 .F ZZ="YSONLY","YSDAYS","YSCLIN","YSCNAME","YSDATE" S ZTSAVE(ZZ)=""
52 .D ^%ZTLOAD
53 .D HOME^%ZIS
54 .Q
55 U IO
56QPRT ;Queued Task Entry Point
57 S:$D(ZTQUEUED) ZTREQ="@"
58 D LP1^YSGAF1
59 S YSPAGE=0 D TOP
60 I '$D(^TMP("YSGAF",$J)) W !,"No appointments found" Q
61PR1 S YSN="",YSOUT=1 F S YSN=$O(^TMP("YSGAF",$J,"A",YSN)) Q:YSN="" S DFN=0 F S DFN=$O(^TMP("YSGAF",$J,"A",YSN,DFN)) Q:DFN'>0 D D:$Y+4>IOSL BOT Q:YSOUT<1
62 . D CK,RULE
63 .Q:('YSRULE)&(YSONLY)
64 . D DEM^VADPT
65 .W !,$E(YSN,1,25),?26,VA("BID"),?32,$S($L(YSGAFER):"Er",YSGAFLN:YSGAFLN,1:"--")," ",$S(YSGAFLD:$$FMTE^XLFDT(YSGAFLD,"5ZD"),1:" ")
66 . W " "_$S(YSRULE:"**",1:" ")_"______ __________________"
67 D ^%ZISC
68 Q
69TOP ;print header
70 S YSPAGE=YSPAGE+1
71 I '$D(YSLINE) S YSLINE="",$P(YSLINE,"-",79)=""
72 W @IOF,"GAF List Clinic: ",YSCNAME," **= > than ",YSDAYS," days"
73 W !,"Appointment Date: ",$$FMTE^XLFDT(YSDATE,"5ZD")
74 W ?32,"Last GAF New",?65,"page: ",YSPAGE
75 W !?32,"GAF Date GAF Clinician",!,YSLINE
76 Q
77BOT ;page end
78 K DIR S YSOUT=1 I IOST'?1"C".E D TOP Q
79 W !! S DIR(0)="E" D ^DIR
80 S YSOUT=Y D:Y=1 TOP
81 Q
82PTENT ;patient entry
83 N %DT,DA,DIE,DIR,DIRUT,DLAYGO,DR,K,VA,VADM,X,X1,X2,Y,YSCLIN,YSCNAME,YSDA,YSDATE,YSDAYS,YSDD,YSDXEG,YSDXEL,YSDXEN,YSG,YSGAFLC,YSGAFLD,YSGAFLN,YSGC,YSGD,YSGN,YSGR,YSGT,YSLINE,YSN,YSONLY,YSOUT,YSPAGE,YSPTN,YSRULE,YSSTOP,YSGAFER
84 W @IOF,"Global Assessment of functioning"
85 F K DFN W ! D ^YSLRP Q:'$D(DFN) D DISP5,ADD5
86 Q
87DISP5 ;display last axis5
88 Q:'$D(DFN)
89 D DEM^VADPT
90 W !,VADM(1),?35,"SSN: ",VA("PID"),?55,"DOB: ",$P(VADM(3),U,2)
91DISP51 D CK
92 I YSGAFLN D
93 . W !?4,"Last GAF: ",YSGAFLN," on: "
94 . S Y=YSGAFLD X ^DD("DD") W Y
95 . W " by: ",$S(+$G(YSGAFLC):$P(^VA(200,YSGAFLC,0),U),1:"--> No provider entered for this GAF score")
96 . I $L(YSGAFER)>1 W !,YSGAFER
97 I YSGAFLN<1 W !?4,"no previous GAF"
98 Q
99ADD5 ;add axis 5 dx
100 W !!
101 K DIR S DIR(0)="N^1:100:0",DIR("A")="GAF Score",DIR("?")="Enter the Global Assessment of Functioning : 1 to 100",DIR("??")="YS-GAF SCALE"
102 ;I $D(YSGAFLN) S:YSGAFLN?1N.N DIR("B")=YSGAFLN
103 D ^DIR S YSGN=Y S:X?1"^^".E YSOUT=1
104 I $D(DIRUT) W !,"No GAF will be entered. Enter ^^ to end loop.",$C(7) Q
105 K DIR S DIR(0)="DA^2961001:NOW:TX",DIR("A")="Diagnosis date/time: ",DIR("B")="NOW"
106 D ^DIR S:Y>0 YSGD=Y
107 I $D(DIRUT) W !,"No GAF will be entered",$C(7) Q
108 K DIR,DIC S DIC="^VA(200,",DIC(0)="AEM",DIC("A")="Assessing Clinician: ",DIC("B")=$P(^VA(200,DUZ,0),U)
109 D ^DIC K DIC S:Y>0 YSGC=+Y
110 I Y<1 W !,"No GAF will be entered",$C(7) Q
111 K DD,DO,DA,DINUM
112 S X="NOW",%DT="TR" D ^%DT S X=Y
113 S DIC="^YSD(627.8,",DIC(0)="L",DLAYGO=627.8 D FILE^DICN Q:Y'>0 S YSDA=+Y
114 D PATSTAT^YSDX3B
115 S DIE="^YSD(627.8,",DA=YSDA,DR=".02////"_DFN_";.03////"_YSGD_";.04////"_YSGC_";.05////"_DUZ_";65////"_YSGN_";66////"_YSSTAT
116 L +^YSD(627.8,YSDA):9999 Q:'$T
117 D ^DIE
118 L -^YSD(627.8,YSDA)
119 D EN^YSGAFOBX(YSDA)
120 Q
121 ;
122RET(YSX) ;This extrinsic returns the most recent GAF score, GAF
123 ;diagnosis date and physician/provider performing the diagnosis,
124 ;for the internal entry number given (via variable YSX.) If no
125 ;GAF score data is on file for this internal entry number, -1 is
126 ;returned.
127 N YSHOLD
128 S (YSHOLD)=""
129 S YSHOLD=$O(^YSD(627.8,"C",YSX,""),-1)
130 IF YSHOLD D
131 .S YSZ=$P($G(^YSD(627.8,YSHOLD,60)),"^",3)
132 .S YSZ=YSZ_"^"_$P($G(^YSD(627.8,YSHOLD,0)),"^",3)
133 .S YSZ=YSZ_"^"_$P($G(^YSD(627.8,YSHOLD,0)),"^",4)
134 ELSE S YSZ=-1
135 Q YSZ
136 ;
137UPD(YSPN,YSGN,YSGD,YSGC,YSPT) ;Update GAF information
138 ; YSPN - Patient Name
139 ; YSGN - GAF Score (Axis 5)
140 ; YSGD - Date/Time of Diagnosis
141 ; YSGC - Diagnosis By
142 ; YSPT - Patient Type ('I'npatient or 'O'utpatient)
143 S YSERR=0
144 I '$G(YSPN) D
145 .W !," The Patient IEN is required!!!",!
146 .S YSERR=1
147 .Q
148 ;
149 I '$G(YSGN) D
150 .W !," The GAF Score is required!!!",!
151 .S YSERR=1
152 .Q
153 ;
154 I '$G(YSGD) D
155 .W " The Observation Date/Time is required!!!",!
156 .S YSERR=1
157 .Q
158 ;
159 I '$G(YSGC) D
160 .W " The Provider is required!!!",!
161 .S YSERR=1
162 .Q
163 ;
164 QUIT:YSERR ;---->
165 ;
166 K DD,DO,DA,DINUM
167 S DLAYGO=627.8,X="NOW",%DT="TR" D ^%DT S X=Y
168 S DIC="^YSD(627.8,",DIC(0)="L"
169 D FILE^DICN Q:Y'>0 S YSDA=+Y
170 S DFN=+YSPN
171 D PATSTAT^YSDX3B
172 S DIE="^YSD(627.8,",DA=YSDA
173 S DR=".02////"_YSPN_";.03////"_YSGD_";.04////"_YSGC_";.05////"_DUZ
174 S DR=DR_";65////"_YSGN_";66////"_YSSTAT
175 L +^YSD(627.8,YSDA):9999 Q:'$T
176 D ^DIE
177 L -^YSD(627.8,YSDA)
178 D EN^YSGAFOBX(YSDA)
179 K %DT,DA,DIC,DIE,DLAYGO,DR,X,Y,YSDA,YSPN,YSGN,YSGD,YSGC,YSSTAT
180 Q
Note: See TracBrowser for help on using the repository browser.