Ejemplo n.º 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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
 def GET(self, id=''):
     if id:
         journal = model.get_journal_entry(int(id))
         return getattr(view_handlers, journal.kind)(journal)
     else:
         return getattr(view_handlers, 'appointment')(None)