/
schedule.py
45 lines (38 loc) · 1.19 KB
/
schedule.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import datetime
import config
import hello
import model
import web
class oneday:
def GET(self, dtstring=''):
if dtstring:
dt = model.input_date(dtstring)
else:
dt = model.local_time()
appts = model.appts_on_day(dt)
pts = dict()
ps = list()
for a in appts:
if a.patientid not in pts:
p = model.get_pt(a.patientid)
pts[a.patientid] = p
return hello.render.oneday(dt, appts, pts)
class days:
def GET(self):
inp = web.input(first=model.display_date(model.local_time()),
last=model.display_date(model.local_time()))
first = model.input_date(inp.first)
last = model.input_date(inp.last)
if last < first:
last = first
curr = first
days = list()
pts = dict()
while curr <= last:
appts = model.appts_on_day(curr)
for a in appts:
if a.patientid not in pts:
pts[a.patientid] = model.get_pt(a.patientid)
days.append((curr, appts))
curr += datetime.timedelta(days=1)
return hello.render.days(days, pts)