示例#1
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)
示例#2
0
 def appointment(journal, form=None):
     if journal:
         appt = model.get_appointment(journal.id)
         pt = model.get_pt(journal.patientid)
         txs = model.get_tx_for_appointment(appt.journalid)
     else:
         inp = web.input(pt=0)
         appt = None
         pt = model.get_pt(int(inp.pt))
         txs = model.get_txplan(int(inp.pt))
     if not form:
         form = forms.journal['appointment']()
         if journal:
             form['patientid'].set_value(str(pt.id))
             form['journalid'].set_value(str(journal.id))
             form['ts'].set_value(model.display_datetime(model.load_datetime(journal.ts)))
             form['summary'].set_value(journal.summary)
             form['status'].set_value(appt.status)
             form['notes'].set_value(appt.notes)
             form['kind'].set_value(appt.kind)
             form['duration'].set_value(appt.duration)
     return render.appointment(journal, appt, pt, form, txs)