source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SDAL0.m@ 1703

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

initial load of WorldVistAEHR

File size: 7.4 KB
Line 
1SDAL0 ;ALB/GRR,TMP,MJK - APPOINTMENT LIST (CONTINUED FROM SDAL) ; 29 Jun 99 04:11PM
2 ;;5.3;Scheduling;**28,37,106,149,171,177,193,305,373,266**;Aug 13, 1993
3LOOP I 'VAUTC,$G(^SC(SC,"ST",SDD,1))["CANCELLED" D Q
4 .S SDPAGE=1 D HED^SDAL
5 .S SDPCT="Clinic cancelled for this date!"
6 .W !!?(IOM-$L(SDPCT)\2),SDPCT
7 I $$CHECK(),$$NCHECK(),$$ACTIVE() D
8 .;I VAUTC,SDCOPY>1 S VAUTC(SD)=SC
9 .S SDPAGE=1 D HED^SDAL Q:SDEND S SDPCT=0
10 .;S SDT=SDD F S SDT=$O(^SC(SC,"S",SDT)) Q:'SDT!(SDT\1-SDD)!SDEND D MORE
11 .;loop through sorted appointment data for the clinic
12 .N SDT,SDDFN,SDDATA,SDDATAC S SDT="" F S SDT=$O(^TMP($J,"SDAMA301","S",SC,SDT)) Q:'SDT D
13 ..S SDDFN="" F S SDDFN=$O(^TMP($J,"SDAMA301","S",SC,SDT,SDDFN)) Q:'SDDFN!SDEND D
14 ...;store appt data and comments for later reference
15 ...S SDDATA=$G(^TMP($J,"SDAMA301","S",SC,SDT,SDDFN)),SDDATAC=$G(^(SDDFN,"C"))
16 ...D MORE
17 .W ! D CCLK Q:SDEND
18 .I 'SDPCT S SDPCT="No activity found for this clinic date!" W !!?(IOM-$L(SDPCT)\2),SDPCT
19 S SDPAGE=1 Q
20 ;
21PTL N SDAPPT
22 ;S DFN=+^SC(SC,"S",SDT,1,K,0),SDOI=$P(^(0),"^",4)
23 S DFN=+$P(SDDATA,"^",4),SDOI=$G(SDDATAC)
24 ;S (SDAPPT,X)=$G(^DPT(DFN,"S",SDT,0))
25 ;Q:$S('X:1,$P(X,"^",2)="NT":0,$P(X,"^",2)["C"!($P(X,"^",2)["N"):1,1:0)
26 S SDAPPT=""
27 D ^VAUQWK,GETA
28 I ($Y+7>IOSL) D HED^SDAL Q:SDEND
29 I '$D(SDFS) S SDFS=1,X=PT D TM^SDROUT0 W !,$J(X,8)
30 N SDCLY D CL^SDCO21(DFN,SDT,"",.SDCLY)
31 N SDY S SDY=$Y
32 W ! D:SDBC BARC^SDAL(85,$P(VAQK(2),"^"))
33 ;check for Combat Vet
34 N SDCV
35 S SDCV=$$CVEDT^DGCV(DFN,$G(SDD))
36 S SDCV=$P(SDCV,U,3)
37 ;W !?3,$S($G(SDCV)=1:"(CV)",1:""),?9,$S($D(^SC(SC,"S",SDT,1,K,"OB")):"*",1:""),?10,$S(VAQK(1)]"":VAQK(1),1:"UNKNOWN PATIENT"),?41,$S(VAQK(2)]"":$E(VAQK(2),1,9),1:"")
38 W !?3,$S($G(SDCV)=1:"(CV)",1:""),?9,$S($P(SDDATA,"^",7)="Y":"*",1:""),?10,$S(VAQK(1)]"":VAQK(1),1:"UNKNOWN PATIENT"),?41,$S(VAQK(2)]"":$E(VAQK(2),1,9),1:"")
39 S INC=0 F SDZ=3,4,5 S X=SDZ(SDZ) D:X]"" TM^SDROUT0 S INC=SDZ#3*8+3 W ?48+INC,$J(X,8) W:INC<16 " "
40 I VAQK(12)]"" W !,?41,VAQK(12) W:VAQK(13)]"" !,?41,VAQK(13)
41 W:SDOI]"" !,?15,SDOI W:SDEM]"" !,?15,SDEM,$S($D(SDCP):$P(^SC(SDCP,0),"^"),1:$P(^SC(SC,0),"^")),!,?15,SDEM1
42 W !,?10,"Phone #: ",$P($G(^DPT(DFN,.13)),"^",1) ;Phone Number [Residence]
43 S SDX="" F I=7:1:9 I VAQK(I) S SDX=1 Q
44 ;Primary Care information
45 I +$G(SDPCMM) D TDATA^SDPPTEM(DFN,"",SDD,"P",15)
46 ;I SDPCMM D TDATA^SDPPTEM(DFN,"",SDD,"P",15)
47 ;I SDX W !,?15,"** Requires Special Survey Disposition **"
48 ;; GAF SCORE CHECK
49 N SDGAF,SDGAFST
50 ;I $$MHCLIN^SDUTL2(SC),'($$COLLAT^SDUTL2(+VAQK(6))!$P(SDAPPT,U,11)) D
51 ;use Appt Type here since COLLATERAL VISIT field not supported by encapsulation API
52 I $$MHCLIN^SDUTL2(SC),'($$COLLAT^SDUTL2(+VAQK(6))!$P($P(SDDATA,"^",10),";",2)["COLLATERAL OF VET") D
53 . S SDGAF=$$NEWGAF^SDUTL2(DFN),SDGAFST=$P(SDGAF,"^")
54 . W:SDGAFST !,?15,"** New GAF Score Required **"
55 ;;
56 I $O(SDCLY(0)) D
57 .N PCL
58 .S PCL=0
59 .W !,?15,"** Required for facility workload credit => "
60 .F S PCL=$O(SDCLY(PCL)) Q:'PCL D
61 .. W " ",SDCLAR(PCL)," "
62 .. I (SDCLAR(PCL)="SC")&($G(^DPT(DFN,0))]"") D
63 ... K SDELAR
64 ... S VAROOT="SDELAR"
65 ... D ELIG^VADPT
66 ... Q:'$P($G(SDELAR(3)),"^")
67 ... W $P(SDELAR(3),"^",2),"% "
68 ... K SDELAR,VAROOT
69 .W "**"
70 I $P(VAQK(11),"^",2)]"" W !,?15,"Means Test: ** ",$P(VAQK(11),"^",2)," **" W " Last Test: ",$$FDATE^SDUL1($P($$LST^DGMTU(DFN),U,2))
71 S SDCOPS=$$LST^DGMTU(DFN,DT,2) I +SDCOPS W !,?15,"Co-Pay Status: ","**"_$P(SDCOPS,U,3)_"**"," Last Test: ",$$FDATE^SDUL1($P(SDCOPS,U,2)) K SDCOPS
72 I $D(^DIC(8,+VAQK(6),0)),$P(^(0),U,9)=13 W !,?15,"** COLLATERAL **" G Q
73 ;I $P($G(^SC(SC,"S",SDT,1,K,0)),"^",10)]"" D I V W !,?15,"** COLLATERAL **" G Q
74 I +$P(SDDATA,"^",8)]"" D I V W !,?15,"** COLLATERAL **" G Q
75 .;S V=$P(^(0),"^",10),V=$S($D(^DIC(8,+V,0)):$P(^(0),"^",9)=13,1:0)
76 .S V=+$P(SDDATA,"^",8),V=$S($D(^DIC(8,+V,0)):$P(^(0),"^",9)=13,1:0)
77 ;I $P(SDAPPT,U,11) W !,?15,"** COLLATERAL VISIT **"
78 ;use Appt Type here since COLLATERAL VISIT field not supported by encapsulation API
79 I $P($P(SDDATA,"^",10),";",2)["COLLATERAL OF VET" W !,?15,"** COLLATERAL VISIT **"
80 ;S:($P($G(^SC(SC,"S",SDT,1,K,0)),"^",10)=0) V=0
81 I +$P($G(SDDATA),"^",8)=0 S V=0
82Q I SDBC,(SDY+5)>$Y F I=1:1 Q:(SDY+5)'>$Y W !
83 I SDBC W !?9,$E(SDASH,9,255)
84 S SDPCT=SDPCT+1 K V,SDX,SDMT,VAQK Q
85 ;
86GETA ;K SDCP S (SDZ(3),SDZ(4),SDZ(5))="" I $D(^DPT(DFN,"S",SDT,0)) F SDZ=3,4,5 S SDZ(SDZ)=$P(^(0),"^",SDZ)
87 K SDCP S SDZ(3)=$P($G(SDDATA),"^",21),SDZ(4)=$P($G(SDDATA),"^",20),SDZ(5)=$P($G(SDDATA),"^",19)
88 S SDEM="",SDEC=+VAQK(6) Q:'SDEC
89 S SDXX=$S('$D(^DIC(8,SDEC,0)):1,$P(^(0),"^",5)'="Y":1,$P(^(0),"^",4)=4:0,$P(^(0),"^",4)=5:0,1:1) Q:SDXX
90 I $D(^SC(SC,"SL")),$P(^("SL"),U,5)]"",$D(^SC($P(^("SL"),U,5),0)) S SDCP=$P(^SC(SC,"SL"),U,5)
91 S SDCP=$S($D(SDCP):SDCP,1:SC) I $D(^DPT(DFN,"DE","B",SDCP)),VAQK(12)']"" S SDEA=$O(^DPT(DFN,"DE","B",SDCP,0)) I $D(^DPT(DFN,"DE",+SDEA,0)),$P(^(0),"^",2)']"",$O(^(1,0))'="" D CKCED
92 Q
93 ;
94MORE ;K SDFS I $D(^SC(SC,"S",SDT,1)) S PT=SDT S K=0 F S K=$O(^SC(SC,"S",SDT,1,K)) Q:'K!SDEND I $P(^(K,0),"^",9)'["C" D PTL
95 K SDFS S PT=SDT D PTL
96 Q
97 ;
98CCLK S SDCC=0 F S SDCC=$O(^SC(SC,"C",SDD,1,SDCC)) Q:'SDCC!SDEND S SDPT0=$G(^DPT(+^(SDCC,0),0)) I $L(SDPT0) D
99 .I ($Y+4>IOSL) D HED^SDAL Q:SDEND W !
100 .W !,"CHART REQUEST: ",$P(SDPT0,"^",1),?34,$P(SDPT0,"^",9)
101 Q
102 ;
103CKCED S A=0 F S A=$O(^DPT(DFN,"DE",SDEA,1,A)) Q:'A I $P(^DPT(DFN,"DE",SDEA,1,A,0),"^",3)']"" D ENR Q
104 Q
105 ;
106ENR S SDEDT=$P(^(0),"^",1)\1,SDDIF=DT-SDEDT,SDREV=$P(^(0),"^",5),SDDIF1=$S(SDREV:DT-SDREV,1:"") ;NAKED REFERENCE - ^DPT(DFN,"DE",SDEA,1,A,0)
107 I $P(^DPT(DFN,"DE",SDEA,1,A,0),"^",2)="O",$S(SDDIF1']""&(SDDIF>10000):1,SDDIF1>10000:1,1:0) S SDEM="PATIENT HAS BEEN ENROLLED IN ",SDEM1="FOR MORE THAN 1 YEAR, PLEASE RE-EVALUATE"
108 Q
109 ;
110CHECK() I $D(^SC(SC,0)),$P(^(0),"^",3)="C",$S(VAUTD:1,$D(VAUTD(+$P(^(0),"^",15))):1,'$P(^(0),"^",15)&$D(VAUTD(+$O(^DG(40.8,0)))):1,1:0)
111 I $T,$D(^SC(SC,"ST",SDD,1)),^(1)'["**CANCELLED",$S('$D(^SC(SC,"I")):1,+^("I")'>0:1,+^("I")>SDD:1,+^("I")'>SDD&(+$P(^("I"),"^",2)>SDD!(+$P(^("I"),"^",2)=0)):0,1:1) Q 1
112 Q 0
113 ;
114NCOUNT ;COUNT, NON-COUNT, or BOTH FOR CLINIC SELECTION
115 W !,"Count, Non Count, or Both: C//" R SDCONC:DTIME
116 I '$T!(SDCONC="") S SDCONC="C" Q
117 Q:SDCONC=U
118 I $L(SDCONC)=1,$E(SDCONC)="?" W !,"Type C, N or B" G NCOUNT
119 I $E(SDCONC,1,2)="??" D G NCOUNT
120 . W !!,"Choosing ""C"" will limit the selection to COUNT clinics."
121 . W !," ""N"" will limit the selection to NON COUNT clinics."
122 . W !," ""B"" will give BOTH count and non count clinics.",!
123 S SDCONC=$E(SDCONC),SDCONC=$TR(SDCONC,"bcn","BCN")
124 I "BCN"'[SDCONC W !,"C, N or B" G NCOUNT
125 Q
126 ;
127NCHECK() ;EXTEND $T LOGIC COUNT, NO COUNT,or BOTH
128 N NOC S NOC=$P($G(^SC(SC,0)),U,17)
129 I SDCONC="B" Q 1
130 I SDCONC="C"&(NOC="N") Q 1
131 I SDCONC="N"&(NOC="Y") Q 1
132 Q 0
133 ;
134NCLINIC ;SCREEN CLINICS
135 N NOCC
136 I SDCONC="B" S NOCC="&1"
137 I SDCONC="N" S NOCC="&($P(^(0),U,17)=""Y"")"
138 I SDCONC="C" S NOCC="&($P(^(0),U,17)=""N"")"
139 S DIC="^SC(",DIC("S")="I $P(^(0),U,3)=""C""&'$G(^(""OOS""))"_NOCC_"&$S(VAUTD:1,$D(VAUTD(+$P(^(0),U,15))):1,'+$P(^(0),U,15)&$D(VAUTD(+$O(^DG(40.8,0)))):1,1:0)",VAUTSTR="clinic",VAUTVB="VAUTC" G FIRST^VAUTOMA
140 ;
141ACTIVE() ;Determine if clinic has activity to print
142 ;Output: '1' if activity or selected clinic, '0' otherwise
143 Q:'VAUTC 1 ;selected clinics
144 Q:$O(^SC(SC,"C",SDD,1,0)) 1 ;chart request list
145 ;N SDX S SDX=0 F SDT=SDD:0 S SDT=$O(^SC(SC,"S",SDT)) Q:'SDT!(SDT\1-SDD)!SDX D
146 ;.F K=0:0 S K=$O(^SC(SC,"S",SDT,1,K)) Q:'K!SDX I $P(^(K,0),"^",9)'["C" S SDX=1
147 ;.Q ;patient appointment activity
148 ;if clinic has no appts, return 0
149 S SDX=1 I '$D(^TMP($J,"SDAMA301",SC)) S SDX=0
150 Q SDX
Note: See TracBrowser for help on using the repository browser.