source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SDC0.m@ 1147

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

initial load of WorldVistAEHR

File size: 4.7 KB
Line 
1SDC0 ;MAN/GRR,ALB/TMP/LDB - Continuation of SDC (cancel a clinic) ; 16 JUL 2003 1:27 pm
2 ;;5.3;Scheduling;**303,330,379,398,467,478**;Aug 13, 1993
3 ;
4 ;SD/467 - open matched EWL entries with canceled appointments
5 ;
6CHKEND G:NOAP END
7 S %=1,DTOUT=0 W !,"WANT TO AUTO-REBOOK APPOINTMENTS NOW" D YN^DICN I '% W !,"REPLY YES (Y) OR NO (N)" G CHKEND
8 S ANS=$S('(%-1):"Y",1:"N") I %<0 W " NO" Q:'DTOUT
9ASKL S SDLT1="",%=1,(SDLET,SDFORM)="" W !,"WANT LETTERS PRINTED NOW" D YN^DICN I '% W !,"REPLY YES (Y) OR NO (N)" G ASKL
10 W:%<0 " NO" S ALS=$S('(%-1):"Y",1:"N") G:ALS'["Y" AOR
11EN Q:($P(^SC(SC,0),"^",3)'="C")!($D(SDVAUTC(+SC))) S SDIV=$P(^SC(SC,0),"^",15),SDIV=$S(SDIV:SDIV,1:$O(^DG(40.8,0))) I $D(SDLT),SDIV'=SDV1 Q
12 K SDRE,SDIN I $D(SDLT)&($D(^SC(SC,"I"))) S SDIN=+^("I"),SDRE=+$P(^("I"),"^",2) I $D(SDIN),SDIN,SDIN'>SDBD&('$D(SDRE)!('SDRE)!(SDRE>SDED)) Q
13 S:'SDLT1 SDLET=$S($D(^SC(SC,"LTR")):$P(^("LTR"),"^",3),1:"") S ALS=$S(SDLET:"Y",1:"N")
14 I ALS="N"!(ANS="Y") S SDFFFF=1
15 I ALS="N" W !,"NO LETTERS ARE ASSIGNED TO THE ",$P(^SC(SC,0),"^")," CLINIC" Q:$D(SDLT)
16 I SDFORM="",$D(^DG(40.8,SDIV,"LTR")),^("LTR") S SDFORM=^("LTR")
17 I $D(SDLT),(ALS'="N") D CHK Q
18 Q:$D(SDLT)
19AOR G:ANS'["Y"&(ALS'["Y") END
20 I '$D(SDLT) S DGPGM="START^SDC0",DGVAR="SC^SI^CDATE^ALS^ANS^SDLET^SDTIME"_$S($D(SDIN):"^SDIN^SDRE",1:"")_"^SDFORM^SDV1^SDFFFF^AUTO#"
21 I '$D(SDLT) D FZIS^DGUTQ G:POP END
22START U IO I ANS'["Y"&('$D(SDLT)) D:ALS["Y" APP D END Q
23BEG1 N SDFIRST
24 I $D(SDLT) S SDAR=$S('VAUTC:"VAUTC",1:"^SC"),ANS="N",ALS="Y" D
25 .F SC=0:0 S SC=$O(@(SDAR_"("_SC_")")) Q:SC'>0 D
26 ..K SDOK1 D EN I $D(SDOK1),SDLET D
27 ...F SD=(SDBD-.1):0 S SD=$O(^SC(SC,"S",SD)) S CDATE=SD Q:SD>(SDED+.999999)!(SD'>0) D
28 ....D DUP
29 S SDFIRST=$S($G(SDFFFF)=1:0,1:1)
30 I $D(SDLT),$D(^UTILITY("SDLT",$J)) D PR^SDC3,END Q
31 Q:$D(SDLT) D ^SDAUT1
32 I MAX=0 W !,"AUTO-REBOOKING NOT ALLOWED FOR THIS CLINIC" G APP:ALS["Y",END
33 F GDATE=CDATE:0 S GDATE=$O(^SC(SC,"S",GDATE)) Q:GDATE=""!(GDATE>(CDATE+1)) F L=0:0 S L=$O(^SC(SC,"S",GDATE,1,L)) Q:L="" S A=^(L,0) I $D(^DPT(+A,"S",GDATE,0)),$P(^(0),"^",2)="C",$P(^(0),"^",14)=SDTIME D ^SDAUT2,^SDCCP
34 D:ALS["Y" APP
35END ;
36 D:$G(SC)>0&($G(CDATE)>0) RESOLVE
37 K %,%DT,%H,%I,%DT,%IS,%ZIS,A,ALS,ANS,BY,CDATE,CHAR,DA,DFN,DH,DHD,DIC,DIS,DO,DOW,FLDS,FR,GDATE,I,L,LET,MAX,NOAP,P,POP,SI,SL,SS,ST,SDSTRTDT,TO,X,Y,ADDR,B,CLIN,HX,L0,L1,L2,LL,PDAT,S,TIME,Z,D,ENDATE,J,SM,STIME,X1,X2,SDX1,SDX2,SDRE,SDRE1,SDIN,FSW
38 K ^TMP("SDC0",$J),SDAP,SDAPNUM
39 K SC,SD,Z0,Z5,DGPGM,DUPE,J2,MESS,NDATE,SDDIF,SDFORM,SDINP,SDFORM,SDLET,SDLT1,SDNODE,SDRT,SDSOH,SDST,SDV1,DGVAR,SD1,SD8,SD81,SDANS,SDCNT,SDERR,SDHTO,SDJ,SDTIME,SDZ,STARTDAY,SD82,SDOK,SDOK1,SDLE,SDZ,SDOK1,TST,W,^UTILITY("SD")
40 K SDFFFF,DIW,DIWF,DIWL,DIWR,DIWT,DN,DUPE,J2,MESS,NDATE,SDADD,SDC,SDCL,SDDAT,SDDIF,SDFORM,SDHX,SDINP,SDIV,SDLET,SDNODE,SDRT,SDSOH,SDST,SDT0,TST,SDV1,^TMP($J,"BADADD") D CLOSE^DGUTQ Q
41CHK K SDOK1 I $D(^SC(SC,"SL")) S SL=^("SL"),%=$P(SL,"^",6),SI=$S(%="":4,%<3:4,%:%,1:4) S SDOK1=1 K SL,% E W $P(^SC(SC,0),"^")," does not have an appointment length indicated."
42 Q
43RESOLVE ;evaluate canceled and rebooked appointments with relation to EWL
44 S GDATE=CDATE K ^TMP("SDWLREB",$J),^TMP($J,"SDWLPL")
45 F S GDATE=$O(^SC(SC,"S",GDATE)) Q:GDATE=""!(GDATE>(CDATE+1)) S L=0 F S L=$O(^SC(SC,"S",GDATE,1,L)) Q:L="" D
46 .S DFN=+^SC(SC,"S",GDATE,1,L,0)
47 .N RBFLG,SDTRB,SDCAN,SDREB S SDREB=0 D REBOOK^SDWLREB(DFN,GDATE,SC,.RBFLG,.SDTRB,.SDCAN) Q:SDCAN'=SDTIME
48 .I $E(RBFLG,1,2)'="CC" Q ;not canceled by clinic
49 .I RBFLG="CCR" S SDREB=1 D DISREB^SDWLREB(DFN,SDTRB,SC)
50 .D OPENEWL^SDWLREB(DFN,GDATE,SC,SDREB) K ^TMP($J,"APPT"),^TMP($J,"SDWLPL")
51 I $D(^TMP("SDWLREB",$J)) D MESS^SDWLREB
52 Q
53 ;
54DUP ;SCREEN FOR DUPLICATE PATIENTS - SD*5.3*379
55 S SDAP="" F S SDAP=$O(^SC(SC,"S",SD,SDAP)) Q:SDAP="" D
56 .S SDAPNUM="" F S SDAPNUM=$O(^SC(SC,"S",SD,SDAP,SDAPNUM)) Q:SDAPNUM="" D
57 ..I $D(^SC(SC,"S",SD,SDAP,SDAPNUM,0)) D
58 ...S A=$P(^SC(SC,"S",SD,SDAP,SDAPNUM,0),"^",1)
59 ...I '$D(^TMP("SDC0",$J,SD,A)) S ^TMP("SDC0",$J,SD,A)="" D ^SDC3
60 Q
61APP I $G(SDFFFF)=1 S SDFIRST=0
62 F GDATE=CDATE:0 S GDATE=$O(^SC(+SC,"S",GDATE)) Q:GDATE=""!(GDATE>(CDATE+1)) F L=0:0 S L=$O(^SC(+SC,"S",GDATE,1,L)) Q:L="" S A=^(L,0) D CHECK
63 I $D(^TMP($J,"BADADD")) D BADADD^SDLT K ^TMP($J,"BADADD")
64 Q
65CHK1 S (SDX,X)=GDATE D WRAPP^SDLT
66 I $P(S,"^",2)'["A" D REST^SDLT Q
67 S SDX=$P(S,"^",10) I '$D(^DPT(+A,"S",SDX,0)) D REST^SDLT Q
68 W !!,"The cancelled appointment(s) were rescheduled as follows:",!
69 S S=^DPT(+A,"S",SDX,0) D WRAPP^SDLT,REST^SDLT
70 Q
71CHECK I $$BADADR^DGUTL3(+A) S ^TMP($J,"BADADD",$P(^DPT(+A,0),"^"),+A)="" Q
72 ;
73 ;SCREEN FOR DUPLICATES - SD*5.3*379
74 ;
75 I $D(^TMP("SDC0",$J,GDATE,A)) Q
76 S ^TMP("SDC0",$J,GDATE,A)=""
77 I $S('$D(^DPT(+A,.35)):1,$P(^DPT(+A,.35),"^",1)']"":1,1:0),$D(^DPT(+A,"S",GDATE)),$P(^DPT(+A,"S",GDATE,0),"^",2)["C",$P(^(0),"^",14)=SDTIME!(SDTIME="*") S S=^DPT(+A,"S",GDATE,0) D ^SDLT,CHK1
Note: See TracBrowser for help on using the repository browser.