confirm visit -> hd case

conv_bal
watcha.h 2014-10-02 09:02:22 +07:00
parent fb9633027f
commit d4d79da4ca
5 changed files with 53 additions and 10 deletions

View File

@ -9,6 +9,7 @@
<field name="number"/> <field name="number"/>
<field name="date_start"/> <field name="date_start"/>
<field name="date_stop"/> <field name="date_stop"/>
<field name="visit_id"/>
</group> </group>
<group span="6" columns="1"> <group span="6" columns="1">
<field name="patient_id" onchange="onchange_patient"/> <field name="patient_id" onchange="onchange_patient"/>

View File

@ -1,4 +1,4 @@
<form model="clinic.visit"> <form model="clinic.visit" attrs='{"readonly":[["state","in",["cancelled","confirmed"]]]}' show_company="1">
<head> <head>
<field name="state"/> <field name="state"/>
<button string="Print" icon="print" action="print_visit"/> <button string="Print" icon="print" action="print_visit"/>
@ -8,18 +8,23 @@
</head> </head>
<tabs> <tabs>
<tab string="Visit"> <tab string="Visit">
<field name="number"/> <group span="6" columns="1">
<field name="department_id"/> <field name="number"/>
<field name="visit_date"/> <field name="visit_date"/>
<field name="cycle"/> <field name="cycle"/>
<field name="patient_id" onchange="onchange_patient"/> </group>
<field name="doctor_id"/> <group span="6" columns="1">
<field name="nurse_id"/> <field name="department_id"/>
<field name="patient_id" onchange="onchange_patient"/>
<field name="doctor_id"/>
<field name="nurse_id"/>
</group>
</tab> </tab>
</tabs> </tabs>
<foot> <foot>
<button string="Confirm" type="success" method="confirm" states="pending" /> <button string="Confirm" type="success" method="confirm" states="pending" />
<button string="Cancel" type="danger" method="cancel" confirm="Are you sure to cancel HD case?"/> <button string="Reopen" type="default" method="reopen" states="cancelled" />
<button string="Cancel" type="danger" method="cancel" states="confirmed" confirm="Are you sure to cancel HD case?"/>
</foot> </foot>
<related> <related>
<field name="comments"/> <field name="comments"/>

View File

@ -37,6 +37,7 @@ class HDcase(Model):
"invoices": fields.One2Many("account.invoice","related_id","Invoices"), "invoices": fields.One2Many("account.invoice","related_id","Invoices"),
"pickings": fields.One2Many("stock.picking","related_id","Pickings"), "pickings": fields.One2Many("stock.picking","related_id","Pickings"),
"payments": fields.One2Many("account.payment","related_id","Payments"), "payments": fields.One2Many("account.payment","related_id","Payments"),
'visit_id': fields.Many2One("clinic.visit", "Visit"),
} }
def _get_number(self,context={}): def _get_number(self,context={}):

View File

@ -1,4 +1,5 @@
import time import time
import datetime
from netforce.model import Model, fields, get_model from netforce.model import Model, fields, get_model
from netforce.access import get_active_company, get_active_user from netforce.access import get_active_company, get_active_user
@ -53,12 +54,42 @@ class Visit(Model):
def confirm(self,ids,context={}): def confirm(self,ids,context={}):
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
hd_case_obj=get_model("clinic.hd.case")
dt=datetime.datetime
fmt_date="%Y-%m-%d %H:%M:%S"
timenow=dt.now().strftime("%H:%M:%S")
date_from=dt.strptime("%s %s"%(obj.visit_date,timenow),fmt_date)
to=3600
date_to=date_from+datetime.timedelta(seconds=to)
date_to=date_to.strftime(fmt_date)
date_from=date_from.strftime(fmt_date)
hd_case_id=hd_case_obj.create({
'patient_id': obj.patient_id.id,
'doctor_id': obj.doctor_id.id,
'nurse_id': obj.nurse_id.id,
'department_id': obj.department_id.id,
'date_start': date_from,
'date_stop': date_to,
'visit_id': obj.id,
})
obj.write({"state":"confirmed"}) obj.write({"state":"confirmed"})
return {
'next': {
'name': 'clinic_hd_case',
'mode': 'form',
'active_id': hd_case_id,
},
'flash': 'Visit %s confirmed'%obj.number,
}
def cancel(self,ids,context={}): def cancel(self,ids,context={}):
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
obj.write({"state":"cancelled"}) obj.write({"state":"cancelled"})
def reopen(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({"state":"pending"})
def onchange_patient(self,context={}): def onchange_patient(self,context={}):
data=context['data'] data=context['data']
patient_id=data['patient_id'] patient_id=data['patient_id']

View File

@ -1,7 +1,12 @@
sequence (support multi company) sequence (support multi company) -> ok
- visit - visit
- hd case - hd case
- doctor - doctor
- nurse - nurse
- patient - patient
create new hd case after confirm visit
question?
- how cycle running?
- treatment
- 1 cycle take how long ?