source: FOIAVistA/tag/r/SCHEDULING-SD-SC/SDAMWI.m@ 1641

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

initial load of FOIAVistA 6/30/08 version

File size: 3.4 KB
Line 
1SDAMWI ;ALB/MJK - Unscheduled Appointments ; 5/3/05 5:50pm
2 ;;5.3;Scheduling;**63,94,241,250,296,380,327**;Aug 13, 1993
3 ;
4EN(DFN,SC) ; -- main entry point
5 ; input: DFN ; SC := clinic#
6 ; returned: success or fail := 1/0
7 ;
8 N SDY,SDAPTYP,SDRE,SDRE1,SDIN,SDSL,SDD,SDALLE,SDATD,SDDECOD,SDEC,SDEMP,SDOEL,SDPL,SDRT,SDSC,SDTTM,COLLAT,SDX,SDSTART,ORDER,SDREP,SDDA,SDCL
9 D 2^VADPT I +VADM(6) W !!?5,*7,"o Patient has died!" D PAUSE^VALM1 S SDY=0 G ENQ
10 S SDCL=SC,SDSL=$S($D(^SC(SC,"SL")):+^("SL"),1:""),SDD=0
11 K SDRE,SDIN,SDRE1
12 I $D(^SC(SC,"I")) S Y=^("I"),SDIN=+Y,SDRE=+$P(Y,U,2),SDRE1=$$FDATE^VALM1(SDRE)
13 I $D(SDIN),SDIN,SDIN'>DT,SDRE,SDRE>DT W !!?5,*7,"o Clinic is inactive from ",$$FTIME^VALM1(SDIN)," to "_SDRE1 D PAUSE^VALM1 S SDY=0 G ENQ
14 I $D(SDIN),SDIN,SDIN'>DT,'SDRE W !!?5,*7,"o Clinic is inactive as of ",$$FTIME^VALM1(SDIN) D PAUSE^VALM1 S SDY=0 G ENQ
15 N SDRES S SDRES=$$CLNCK^SDUTL2(SC,1)
16 I 'SDRES W !,?5,*7,"o Clinic MUST be corrected before continuing." D PAUSE^VALM1 S SDY=0 G ENQ
17 I '$$TIME(.DFN,.SC,.SDT) D WL^SDM1(SC) S SDY=0 G ENQ ;SD/327
18 S Y=SDT D ^SDM4 I X="^" S SDY=0 G ENQ
19 ; ** SD*5.3*250 MT Blocking check removed
20 ;S X="EASMTCHK" X ^%ZOSF("TEST") I $T N EASACT S EASACT="W" I $$MT^EASMTCHK(DFN,+$G(SDAPTYP),EASACT) D PAUSE^VALM1 S SDY=0 G ENQ
21 ;-- get sub-category for appointment type
22 S SDXSCAT=$$SUB^DGSAUTL(SDAPTYP,2,"")
23 S SDY=$$MAKE^SDAMWI1(DFN,SDCL,SDT)
24 K SDXSCAT
25ENQ D KVAR^VADPT
26 Q SDY
27 ;
28TIME(DFN,SC,SDT) ; -- get appt date/time
29 ; input: DFN ; SC := clinic#
30 ; output: SDT := date/time of wi appt
31 ; returned: success or fail := 1/0
32 ;
33 N SDY,%DT
34ASK R !!,"APPOINTMENT TIME: NOW// ",X:DTIME S X=$$UPPER^VALM1(X)
35 I X["^"!('$T) S SDY=0 G TIMEQ
36 I X?.E1"?" D G ASK
37 .W !," Enter a time or date@time for the appointment or return for 'NOW'."
38 .W !,"The date must be today or earlier."
39 S:X=""!(X="N")!(X="NO") X="NOW"
40 I X'="NOW",X'["@" S X="T@"_X
41 S %DT="TEP",%DT(0)=-(DT+1) D ^%DT G ASK:Y<0 S SDT=Y
42 G:'$$CANCHK(.SC,.SDT) ASK
43 I $D(^DPT(DFN,"S",SDT,0)) W !?5,*7,"o Patient already has an appt on ",$$FTIME^VALM1(SDT) G ASK
44 S SDY=1
45TIMEQ Q SDY
46 ;
47CANCHK(SC,SDT) ; -- is clinic cancelled for date
48 ; input: SC := clinic# ; SDT := date/time of wi appt
49 ; returned: success or fail := 1/0
50 ;
51 N SDY
52 S SDY=1
53 I $D(^SC(SC,"ST",$P(SDT,"."))),'$D(^SC(SC,"ST",$P(SDT,"."),"CAN")) G CANCHKQ
54 I $D(^SC(SC,"ST",$P(SDT,"."),"CAN")),$G(^SC(SC,"ST",$P(SDT,"."),1))["CANCEL" W !?5,*7,"o This date's clinic has been cancelled!" S SDY=0 G CANCHKQ
55 I $D(^SC(SC,"ST",$P(SDT,"."),"CAN")),$G(^SC(SC,"ST",$P(SDT,"."),1))'["CANCEL" W !?5,*7,"o Warning: Part of this day's clinic has been cancelled!" G CANCHKQ
56 S SDY=$$AVAIL(.SC,.SDT)
57CANCHKQ Q SDY
58 ;
59AVAIL(SC,SDT) ; -- does clinic meet
60 ; input: SC := clinic# ; SDT := date/time of wi appt
61 ; returned: success or fail := 1/0
62 ;
63 N SDY
64 S X=$P(SDT,".") D DOW^SDM0
65 I $D(^SC(SC,"T"_Y)) S Z=$O(^SC(SC,"T"_Y,DT)) I Z'="",$D(^SC(SC,"T"_Y,Z,1)),^(1)]"" S SDY=1 G AVAILQ
66 W !?5,*7,"o Clinic does not meet on this date!" S SDY=0
67AVAILQ Q SDY
68 ;
69CL(DFN) ; -- make wi appt
70 ; input: DFN
71 ; returned: success or fail := 1/0
72 ;
73 S DIC="^SC(",DIC(0)="AEMQ",DIC("A")="Select Clinic: ",DIC("S")="I $P(^(0),U,3)=""C"",'$G(^(""OOS""))"
74 D ^DIC K DIC
75 I Y<0 S SDY=0 G CLQ
76 S SC=+Y S SDY=$$EN(.DFN,.SC)
77CLQ Q SDY
78 ;
79PT(SC) ;
80 ; input: SC := clinic#
81 ; returned: success or fail := 1/0
82 ;
83 S DIC="^DPT(",DIC(0)="AEMQ",DIC("A")="Select Patient: "
84 D ^DIC K DIC
85 I Y<0 S SDY=0 G PTQ
86 S DFN=+Y S SDY=$$EN(.DFN,.SC)
87PTQ Q SDY
88 ;
Note: See TracBrowser for help on using the repository browser.