示例#1
0
 def plan(journal):
     plan = model.get_plan(journal.id)
     pt = model.get_pt(journal.patientid)
     carrier = model.get_carrier(plan.carrierid)
     insured = model.get_pt(plan.insuredid)
     if plan.secondaryto:
         primary = model.get_plan(plan.secondaryto)
     else:
         primary = None
     return render.plan(journal, plan, pt, carrier, insured, primary)
示例#2
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)
示例#3
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)
示例#4
0
 def POST(self, id):
     pt = model.get_pt(id)
     newtx = forms.newtx()
     if newtx.validates():
         try:
             new_tx(pt.id, newtx.tx.get_value())
         except ValueError, e:
             newtx.inputs[0].note = e.message
示例#5
0
 def claim(journal):
     pt = model.get_pt(journal.patientid)
     claim = model.get_claim(journal.id)
     form = forms.claim()
     form.summary.set_value(journal.summary)
     form.notes.set_value(claim.notes)
     plan = model.get_plan(claim.planid)
     txs = model.get_tx_for_claim(claim.journalid)
     return render.claim(pt, claim, form, plan, txs)
示例#6
0
 def GET(self, kind):
     inp = web.input(pt=0, secondaryto=None)
     patientid = int(inp.pt)
     form = forms.journal[kind]
     pt = model.get_pt(patientid)
     form.patientid.set_value(pt.id)
     if inp.secondaryto:
         form.secondaryto.set_value(inp.secondaryto)
     return render.journal(pt, kind, form)
示例#7
0
 def tx(journal):
     txs = model.get_posted_tx(journal.id)
     pt = model.get_pt(journal.patientid) # or tx.patientid
     appointments = dict()
     claims = dict()
     for tx in txs:
         if tx.appointmentid and tx.appointmentid not in appointments:
             appointments[tx.appointmentid] = model.get_appointment(tx.appointmentid)
         if tx.claimid and tx.claimid not in claims:
             claims[tx.claimid] = model.get_claim(tx.claimid)
     return render.tx(journal, pt, txs, appointments, claims)
示例#8
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)
示例#9
0
 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)
示例#10
0
    def GET(self, patientid=''):
        ptform = forms.patient()

        if patientid:
            patientid = int(patientid)
            journal = model.get_journal(patientid)
            pt = model.get_pt(patientid)
            for key in pt:
                ptform[key].set_value(pt[key])

            if pt.resparty:
                rp = model.get_pt(pt.resparty)
                ptform.resparty_text.set_value(model.pt_name(rp, first='lastname'))
            else:
                rp = None
                ptform.resparty_text.set_value(model.pt_name(pt, first='lastname'))
        else:
            pt = None
            journal = None
            rp = None

        return render.patient(pt, ptform, rp, journal)
示例#11
0
    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)
示例#12
0
 def Rx(journal):
     Rx = model.get_Rx(journal.id)
     pt = model.get_pt(journal.patientid)
     address = model.get_latest_address(pt.id)
     return render.Rx(journal, Rx, pt, address)
示例#13
0
 def contact(journal):
     contact = model.get_contact(journal.id)
     pt = model.get_pt(journal.patientid)
     return render.contact(journal, contact, pt)
示例#14
0
 def GET(self, id):
     pt = model.get_pt(id)
     newtx = forms.newtx()
     txplan = model.get_txplan(pt.id)
     return render.txplan(pt, newtx, txplan)
示例#15
0
 def progress(journal):
     progress = model.get_progress(journal.id)
     pt = model.get_pt(journal.patientid)
     return render.progress(journal, progress, pt)
示例#16
0
    def POST(self, claimid):
        claimid = int(claimid)
        journal = model.get_journal_entry(claimid)
        claim = model.get_claim(claimid)
        txs = model.get_tx_for_claim(claimid)
        pt = model.get_pt(journal.patientid)

        # validate form input
        inp = web.input()
        form = forms.claim()
        if not form.validates(inp):
            plan = model.get_plan(claim.planid)
            return hello.render.claim(pt, claim, form, plan, txs)

        # update the claim
        model.db.update('claim', where='journalid=%d' % journal.id,
                        notes=form.notes.get_value())

        # update the journal
        model.db.update('journal', where='id=%d' % journal.id,
                        summary=form.summary.get_value())

        # now go through and update the treatment
        deltains = 0.0
        deltapt = 0.0
        for tx in txs:
            fee = inp['fee%d' % tx.id]
            if fee:
                fee = float(fee)
            else:
                fee = 0.0
            allowed = inp['allowed%d' % tx.id]
            if allowed:
                allowed = float(allowed)
            else:
                allowed = None
            inspaid = inp['inspaid%d' % tx.id]
            if inspaid:
                inspaid = float(inspaid)
            else:
                inspaid = None
            ptpaid = inp['ptpaid%d' % tx.id]
            if ptpaid:
                ptpaid = float(ptpaid)
            else:
                ptpaid = None

            deltains += (inspaid or 0.0) - float(tx.inspaid or 0.0)
            deltapt += (ptpaid or 0.0) - float(tx.ptpaid or 0.0)

            model.db.update('tx', where='id=%d' % tx.id,
                            fee=fee,
                            allowed=allowed,
                            inspaid=inspaid,
                            ptpaid=ptpaid)

        if deltains >= 0.01:
            model.new_payment_for_pt(pt, 'insurance payment', -deltains)
        if deltapt >= 0.01:
            model.new_payment_for_pt(pt, 'patient payment', -deltapt)

        raise web.seeother('/journal/%d' % journal.id)
示例#17
0
def get_pt():
    res = {"data": model.get_pt(), "max_days": 10}
    return res