示例#1
0
 def POST(self, kind):
     f = forms.journal[kind]()
     if f.validates():
         pt = model.get_pt(int(f.patientid.get_value()))
         model.new_journal(pt, kind, f)
         raise web.seeother('/patient/%d' % pt.id)
     else:
         inp = web.input(pt=0)
         pt = model.get_pt(inp.pt)
         return render.journal(pt, kind, f)
示例#2
0
 def POST(self, id=''):
     if id:
         journal = model.get_journal_entry(int(id))
     else:
         journal = None
     if not journal or journal.kind == 'appointment':
         inp = web.input(txs=list()) # to pickup the custom txs field
         form = forms.journal['appointment']()
         if form.validates():
             if journal:
                 appt = model.get_appointment(journal.id)
                 if appt.status == 'posted':
                     form.status.note = 'cannot modify posted appointments'
                     return view_handlers.appointment(journal, form)
             if id:
                 model.update_appt(journal.id, form)
             else:
                 pt = model.get_pt(int(form.patientid.get_value()))
                 journalid = model.new_journal(pt, 'appointment', form)
                 journal = model.get_journal_entry(journalid)
             txs = list()
             for txid in inp.txs:
                 txs.append(int(txid))
             model.appt_tx_set(journal.id, txs)
             if inp.submit == 'post':
                 if model.load_datetime(journal.ts) > model.current_time():
                     form.ts.note = 'cannot post appointments in the future'
                     return view_handlers.appointment(journal, form)
                 model.post_appointment(appt, journal, map(int, txs))
             return view_handlers.appointment(model.get_journal_entry(journal.id))
         else:
             return view_handlers.appointment(journal, form)
     else:
         return getattr(view_handlers, journal.kind)(journal)