source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SDM2A.m@ 762

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

initial load of WorldVistAEHR

File size: 3.9 KB
Line 
1SDM2A ; OG - MAKE APPOINTMENT - overflow routine due to SACC 10K limit. ; Compiled August 28, 2007 16:08:18
2 ;;5.3;Scheduling;**446**;Aug 13 1993;Build 77
3WL(SC) ;Wait List Hook/teh patch 263 ;SD/327 passed 'SC'
4 N DA,DIE,DR,SBEG,SCSR,SDDIV,SDINST,SDPAR,SDWLDA,SDWLDFN,SDWLSCL
5 Q:$G(SC)'>0
6 I '$D(^SC(SC)) Q
7 S SDINST=$$GET1^DIQ(44,SC_",",3,"I") ; get Inst
8 I SDINST="" S SDDIV=$$GET1^DIQ(44,SC_",",3.5,"I") S:SDDIV'="" SDINST=$$GET1^DIQ(40.8,SDDIV_",",.07,"I")
9 I SDINST="" D Q ; sd/446
10 .N DIR
11 .D MESS2^SDWL120(SC)
12 .W !,"No Institution or Division is associated with this Clinic."
13 .W !,"Unable to create a Wait List Entry. Abandoning request."
14 .W !!,"A message is being sent to the administrators mail group"
15 .W !,"alerting them to the situation."
16 .S DIR(0)="E" D ^DIR
17 .Q
18 S SDPAR=0
19 ;create 409.32 entry
20 I $D(^SDWL(409.32,"B",SC)) S SDWLSCL=$O(^SDWL(409.32,"B",SC,""))
21 E D
22 .N DA,DIC,X,DIE,DR
23 .S DIC(0)="LX",X=SC,DIC="^SDWL(409.32," D FILE^DICN
24 .S SDWLSCL=DA
25 .S DIE="^SDWL(409.32,"
26 .S DR=".02////^S X=SDINST" D ^DIE
27 .S DR="1////^S X=DT"
28 .S DR=DR_";2////^S X=DUZ"
29 .D ^DIE S SDPAR=1 ; flag indicating clinic parameter entry
30 .; CREATE 409.3 with 120 flag
31 S DIC(0)="LX",(X,SDWLDFN)=DFN,DIC="^SDWL(409.3," D FILE^DICN
32 ; File just created so lock should never fail.
33 F L +^SDWL(409.3,DA):5 Q:$T W !,"Unable to acquire a lock on the Wait List file" Q
34 ; Update EWL variables.
35 S SDWLDA=DA D EN^SDWLE11 ; get enrollee both SDWLDA and SDWLDFN have to be defined
36 S DIE="^SDWL(409.3,"
37 S DR="1////^S X=DT"
38 S DR=DR_";2////^S X=SDINST"
39 S DR=DR_";4////^S X=4"
40 S DR=DR_";8////^S X=SDWLSCL"
41 S DR=DR_";9////^S X=DUZ"
42 S DR=DR_";10////^S X=""A"""
43 S DR=DR_";11////^S X=2" ; by patient for this entry to avoid asking for provider
44 S DR=DR_";14////^S X="""_$S($P($G(^DPT(SDWLDFN,.3)),U,1)="Y":$P(^DPT(SDWLDFN,.3),U,2),1:"")_""""
45 S DR=DR_";15////^S X="_$S($P($G(^DPT(SDWLDFN,.3)),U,1)="Y":1,1:0)
46 S DR=DR_";22////^S X=SDDATE"
47 S DR=DR_";23////^S X=""O"""
48 S DR=DR_";25////^S X="" > 120 days"""
49 S DR=DR_";36////^S X=1"
50 D ^DIE
51 L -^SDWL(409.3,DA)
52 S SDWLFLG=0 D MESS^SDWL120(SDWLDFN,SDWLDA,SDPAR)
53 Q
54 ;
55WLCL120(SC,DESDT) ; Is there clinic availability within 120 days of desired date ; sd/446
56 N SBEG,SD120
57 Q:$$GET1^DIQ(44,SC,2502,"I")="Y" 1 ; Non-count clinic. Allow > 120 days.
58 S SD120=0,SBEG=DESDT-1
59 F S SBEG=$O(^SC(SC,"ST",SBEG)) Q:SBEG="" I $$HASAVSL(^SC(SC,"ST",SBEG,1)) D Q
60 .N X,DESDTH
61 .S X=SBEG D H^%DTC S SBEG=%H
62 .S X=DESDT D H^%DTC S DESDTH=%H
63 .S SD120=(SBEG-DESDTH>120)
64 .Q
65 Q 'SD120
66 ;
67WLCL120A(SDWLAPDT,SDDATE1,SC) ;
68 N %DT,DIR,X,X1,X2,Y
69 Q:$$GET1^DIQ(44,SC,2502,"I")="Y" 1 ; Non-count clinic. Allow > 120 days.
70 S X=SDWLAPDT,%DT="TXF" D ^%DT
71 Q:Y=-1 1
72 S X1=Y,X2=SDDATE1 D ^%DTC
73 I X'>120 Q 1
74 S DIR(0)="Y",DIR("B")="YES"
75 S DIR("A")="Add to EWL",DIR("A",1)="The date is more than 120 days beyond the Desired Date"
76 W ! D ^DIR
77 I Y=1 D WL(SC)
78 Q 0
79 ;
80WLCLASK() ; No appointment availability warning. ; sd/446
81 N DIR
82 S DIR(0)="Y"
83 S DIR("A",1)="No appointments are available within 120 days of the Desired Date."
84 S DIR("A",2)="Do you want to place this patient on the Electronic Wait List"
85 S DIR("A",3)="or change the desired date?"
86 S DIR("A",4)=""
87 S DIR("A",5)="Enter ""Y"" to place on EWL, ""N"" to go back"
88 S DIR("A")="or ""^"" to return to the CLINIC: prompt. "
89 W ! D ^DIR
90 Q Y
91 ;
92HASAVSL(SCSR) ; Has available slots ; sd/446
93 ; Look at CLINIC PATTERN CURRENT AVAILABILITY string (44.005/1)
94 ; If there is 1-9,j-z within the [ ... ], there is availability for that day.
95 N DIC,F,SDOK,X,Y
96 ; Allow whatever if user has a key to overbook.
97 S DIC="^VA(200,"_DUZ_",51,",X="SDOB" D ^DIC Q:Y'=-1 1
98 S X="SDMOB" D ^DIC Q:Y'=-1 1
99 Q:SCSR'["[" 0 ; No slots.
100 S SCSR=$TR($E(SCSR,$F(SCSR,"[")-1,$L(SCSR))," |"),(SDOK,F)=0
101 F S F=$F(SCSR,"[",F) Q:'F D Q:SDOK
102 .N I,SCSR0,SL
103 .S SCSR0=$E(SCSR,F,$F(SCSR,"]",F)-2)
104 .F I=1:1:$L(SCSR0) S SL=$E(SCSR0,I) I $A(SL)>105&($A(SL)<123)!SL S SDOK=1 Q ; If SL=1-9,j-z slots are available
105 .Q
106 Q SDOK
Note: See TracBrowser for help on using the repository browser.