improve visit

conv_bal
watcha.h 2014-10-04 22:51:54 +07:00
parent b4b7d511a7
commit ffda3a2549
19 changed files with 214 additions and 32 deletions

View File

@ -1,5 +1,5 @@
<action> <action>
<field name="string">Dialyzer</field> <field name="string">Dialyzers</field>
<field name="view_cls">multi_view</field> <field name="view_cls">multi_view</field>
<field name="model">clinic.dialyzer</field> <field name="model">clinic.dialyzer</field>
<field name="tabs">[["All",[]],["New",[["state","=","new"]]],["Active",[["state","=","active"]]],["Drop",[["state","=","drop"]]],["Expire",[["state","=","expire"]]],["Cancelled",[["state","=","cancelled"]]]]</field> <field name="tabs">[["All",[]],["New",[["state","=","new"]]],["Active",[["state","=","active"]]],["Drop",[["state","=","drop"]]],["Expire",[["state","=","expire"]]],["Cancelled",[["state","=","cancelled"]]]]</field>

View File

@ -1,5 +1,5 @@
<action> <action>
<field name="string">HD Case Treatments</field> <field name="string">Treatments</field>
<field name="view_cls">multi_view</field> <field name="view_cls">multi_view</field>
<field name="model">clinic.hd.case</field> <field name="model">clinic.hd.case</field>
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Confirmed",[["state","=","confirmed"]]],["Approved",[["state","=","approved"]]],["Paid",[["state","=","paid"]]],["Cancelled",[["state","=","cancelled"]]]]</field> <field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Confirmed",[["state","=","confirmed"]]],["Approved",[["state","=","approved"]]],["Paid",[["state","=","paid"]]],["Cancelled",[["state","=","cancelled"]]]]</field>

View File

@ -0,0 +1,6 @@
<action>
<field name="string">Import Payments From Government</field>
<field name="view_cls">multi_view</field>
<field name="model">clinic.import.payment</field>
<field name="menu">clinic_menu</field>
</action>

View File

@ -2,7 +2,7 @@
<field name="string">Visits</field> <field name="string">Visits</field>
<field name="view_cls">multi_view</field> <field name="view_cls">multi_view</field>
<field name="model">clinic.visit</field> <field name="model">clinic.visit</field>
<field name="tabs">[["All",[]],["Pending",[["state","=","pending"]]],["Confirmed",[["state","=","confirmed"]]],["Cancelled",[["state","=","cancelled"]]]]</field> <field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Waiting Treatment",[["state","=","waiting_treatment"]]],["Treatment",[["state","=","treatment"]]],["Cancelled",[["state","=","cancelled"]]]]</field>
<field name="modes">list,calendar,form</field> <field name="modes">list,calendar,form</field>
<field name="menu">clinic_menu</field> <field name="menu">clinic_menu</field>
</action> </action>

View File

@ -13,8 +13,8 @@
<field name="name"/> <field name="name"/>
<field name="identification"/> <field name="identification"/>
<field name="expiry_card"/> <field name="expiry_card"/>
<field name="department_id"/>
<field name="birthday"/> <field name="birthday"/>
<field name="department_id"/>
</group> </group>
<group span="6" columns="1"> <group span="6" columns="1">
<field name="picture"/> <field name="picture"/>
@ -30,6 +30,9 @@
<field name="prof_license"/> <field name="prof_license"/>
<field name="prof_license_date"/> <field name="prof_license_date"/>
</tab> </tab>
<tab string="Others">
<field name="note"/>
</tab>
</tabs> </tabs>
<related> <related>
<field name="visits"/> <field name="visits"/>

View File

@ -0,0 +1,29 @@
<form model="clinic.import.payment" attrs='{"readonly":[["state","in",["success"]]]}'>
<head>
<field name="state"/>
</head>
<field name="name"/>
<field name="date_import"/>
<separator string="Medical Government"/>
<field name="mg_file"/>
<group span="6">
<field name="mg_payment_id" readonly="1"/>
<button string="Undo" type="danger" method="undo_mg" attrs='{"invisible":[["state","in",["success"]]]}'/>
</group>
<separator string="Social Security"/>
<field name="sc_file"/>
<group span="6">
<field name="sc_payment_id" readonly="1"/>
<button string="Undo" type="danger" method="undo_sc" attrs='{"invisible":[["state","in",["success"]]]}'/>
</group>
<separator string="NHSO (30฿)"/>
<field name="nhso_file"/>
<group span="6">
<field name="nhso_payment_id" readonly="1"/>
<button string="Undo" type="danger" method="undo_nhso" attrs='{"invisible":[["state","in",["success"]]]}'/>
</group>
<foot>
<button string="Import" type="success" icon="arrow-right" method="import_payment" attrs='{"invisible":[["state","in",["success"]]]}'/>
<button string="Close" type="danger" method="close_import" attrs='{"invisible":[["state","in",["success"]]]}'/>
</foot>
</form>

View File

@ -0,0 +1,5 @@
<list model="clinic.import.payment">
<field name="name"/>
<field name="date_import"/>
<field name="state"/>
</list>

View File

@ -3,25 +3,29 @@
<item string="Personal"> <item string="Personal">
<item string="Doctors" action="clinic_doctor"/> <item string="Doctors" action="clinic_doctor"/>
<item string="Nurses" action="clinic_nurse"/> <item string="Nurses" action="clinic_nurse"/>
</item>
<item string="Patients">
<item string="Patients" action="clinic_patient"/> <item string="Patients" action="clinic_patient"/>
<item string="Dialyzers" action="clinic_dialyzer"/>
<divider/>
<header string="OPTIONS"/>
<item string="Races" action="clinic_race"/>
<item string="Nationalities" action="clinic_nation"/>
<item string="Graduations" action="clinic_grade"/>
<item string="Cause Chronics" action="clinic_cause_chronic"/>
<item string="Comorbidities" action="clinic_comorbidity"/>
<item string="Morbidities" action="clinic_morbidity"/>
</item> </item>
<item string="Visits" action="clinic_visit"/> <item string="Visits" action="clinic_visit"/>
<item string="Treatments" action="clinic_hd_case"/> <item string="Treatments" action="clinic_hd_case"/>
<item string="Dialyzer" action="clinic_dialyzer"/>
<item string="Reports"> <item string="Reports">
<item string="Report1" action="report1"/> <item string="Report1" action="report1"/>
</item> </item>
<item string="Imports"> <item string="Imports">
<item string="JE" action="clinic_je"/> <item string="Import Payments" action="clinic_import_payment"/>
</item> </item>
<item string="Settings"> <item string="Settings">
<item string="Departments" action="clinic_department"/> <item string="Departments" action="clinic_department"/>
<item string="Graduations" action="clinic_grade"/>
<item string="Nationalities" action="clinic_nation"/>
<item string="Races" action="clinic_race"/>
<item string="Cause Chronics" action="clinic_cause_chronic"/>
<item string="Comorbidities" action="clinic_comorbidity"/>
<item string="Morbidities" action="clinic_morbidity"/>
<item string="Clinic Settings" action="clinic_setting"/> <item string="Clinic Settings" action="clinic_setting"/>
</item> </item>
</menu> </menu>

View File

@ -13,8 +13,8 @@
<field name="name"/> <field name="name"/>
<field name="identification"/> <field name="identification"/>
<field name="expiry_card"/> <field name="expiry_card"/>
<field name="department_id"/>
<field name="birthday"/> <field name="birthday"/>
<field name="department_id"/>
</group> </group>
<group span="6" columns="1"> <group span="6" columns="1">
<field name="picture"/> <field name="picture"/>
@ -30,6 +30,9 @@
<field name="prof_license"/> <field name="prof_license"/>
<field name="prof_license_date"/> <field name="prof_license_date"/>
</tab> </tab>
<tab string="Others">
<field name="note"/>
</tab>
</tabs> </tabs>
<related> <related>
<field name="visits"/> <field name="visits"/>

View File

@ -1,4 +1,4 @@
<calendar model="clinic.visit" states='pending' date_field="visit_date" colors='{"#090":[["cycle","=",1]],"#2400ff":[["cycle","=",2]],"#ebff00":[["cycle","=",3]],"#f20000":[["cycle","=",4]]}'> <calendar model="clinic.visit" states='waiting_treatment' date_field="visit_date" colors='{"#090":[["cycle","=",1]],"#2400ff":[["cycle","=",2]],"#ebff00":[["cycle","=",3]],"#f20000":[["cycle","=",4]]}'>
<field name="patient_id"/> <field name="patient_id"/>
<field name="cycle"/> <field name="cycle"/>
<field name="number"/> <field name="number"/>

View File

@ -23,9 +23,10 @@
</tab> </tab>
</tabs> </tabs>
<foot> <foot>
<button string="Confirm" type="success" method="confirm" states="pending" /> <button string="Confirm" type="success" method="confirm" states="draft" />
<button string="Reopen" type="default" method="reopen" states="cancelled" /> <button string="Do Treatment" type="success" method="do_treatment" icon="arrow-right" states="waiting_treatment" />
<button string="Cancel" type="danger" method="cancel" states="confirmed" confirm="Are you sure to cancel HD case?"/> <button string="Re Visit" type="default" method="reopen" states="cancelled" />
<button string="Cancel Visit" type="danger" method="cancel" states="waiting_treatment" confirm="Are you sure to cancel HD case?"/>
</foot> </foot>
<related> <related>
<field name="comments"/> <field name="comments"/>

View File

@ -1,4 +1,5 @@
<list model="clinic.visit"> <list model="clinic.visit" colors='{"#EF4D4D":[["late_visit","=",1]]}'>
<field name="late_visit" invisible="1"/>
<field name="number"/> <field name="number"/>
<field name="visit_date"/> <field name="visit_date"/>
<field name="cycle"/> <field name="cycle"/>

View File

@ -22,3 +22,4 @@ from . import je
from . import input_line from . import input_line
from . import file_sheet from . import file_sheet
from . import payment from . import payment
from . import import_payment

View File

@ -31,8 +31,8 @@ class Doctor(Model):
"mobile": fields.Char("Mobile",required=False,search=True), "mobile": fields.Char("Mobile",required=False,search=True),
"phone": fields.Char("Phone",search=True), "phone": fields.Char("Phone",search=True),
'email': fields.Char("Email"), 'email': fields.Char("Email"),
"prof_license" : fields.Char("Professional License."), "prof_license" : fields.Char("License."),
"prof_license_date" : fields.Date("Professional License Date"), "prof_license_date" : fields.Date("License Date"),
"birthday": fields.Date("BirthDay",search=True), "birthday": fields.Date("BirthDay",search=True),
"department_id": fields.Many2One("clinic.department", "Department",search=True), "department_id": fields.Many2One("clinic.department", "Department",search=True),
"patients": fields.Many2Many("clinic.patient","Patients"), "patients": fields.Many2Many("clinic.patient","Patients"),
@ -43,6 +43,7 @@ class Doctor(Model):
"company_id": fields.Many2One("company","Company"), "company_id": fields.Many2One("company","Company"),
"user_id": fields.Many2One("base.user","User"), "user_id": fields.Many2One("base.user","User"),
'picture': fields.File("Picture"), 'picture': fields.File("Picture"),
'note': fields.Text("Note"),
} }

View File

@ -8,7 +8,7 @@ from netforce.access import get_active_company
class HDcase(Model): class HDcase(Model):
_name="clinic.hd.case" _name="clinic.hd.case"
_string="HD Case Treatment" _string="Treatment"
_audit_log=True _audit_log=True
_name_field="number" _name_field="number"
_multi_company=True _multi_company=True

View File

@ -0,0 +1,48 @@
import time
import xlrd
from datetime import datetime
from netforce.model import Model, fields, get_model
from netforce.access import get_active_company
from netforce.access import get_active_user, set_active_user
from netforce.utils import get_file_path
from netforce.utils import get_data_path
PAMENT_TYPE={
"mg":"Medical Government",
"sc":"Social Security",
"nhso":"NHSO (30฿)",
"personal": "Personal",
"others": "Others",
}
class ImportPayment(Model):
_name="clinic.import.payment"
_string="Import Payment"
_fields={
'name': fields.Char("Name"),
'date_import': fields.DateTime("Date"),
'mg_file': fields.File("File"),
'sc_file': fields.File("File"),
'nhso_file': fields.File("File"),
'mg_payment_id': fields.Many2One("account.payment","Payment"),
'sc_payment_id': fields.Many2One("account.payment","Payment"),
'nhso_payment_id': fields.Many2One("account.payment","Payment"),
"state": fields.Selection([("draft","Draft"),("success","Succes"),("fail","Fail")],"Status"),
'note': fields.Text("Note"),
}
_order="date_import desc"
def _get_name(self,context={}):
timenow=time.strftime("%Y-%m-%d")
return 'Import Payment - %s'%timenow
_defaults={
'date_import': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
'name': _get_name,
'state': 'draft',
}
ImportPayment.register()

View File

@ -31,8 +31,8 @@ class Nurse(Model):
"mobile": fields.Char("Mobile",required=False,search=True), "mobile": fields.Char("Mobile",required=False,search=True),
"phone": fields.Char("Phone",search=True), "phone": fields.Char("Phone",search=True),
'email': fields.Char("Email"), 'email': fields.Char("Email"),
"prof_license" : fields.Char("Professional License."), "prof_license" : fields.Char("License."),
"prof_license_date" : fields.Date("Professional License Date"), "prof_license_date" : fields.Date("License Date"),
"birthday": fields.Date("BirthDay",search=True), "birthday": fields.Date("BirthDay",search=True),
"department_id": fields.Many2One("clinic.department", "Department",search=True), "department_id": fields.Many2One("clinic.department", "Department",search=True),
"patients": fields.Many2Many("clinic.patient","Patients"), "patients": fields.Many2Many("clinic.patient","Patients"),
@ -43,6 +43,7 @@ class Nurse(Model):
"company_id": fields.Many2One("company","Company"), "company_id": fields.Many2One("company","Company"),
"user_id": fields.Many2One("base.user","User"), "user_id": fields.Many2One("base.user","User"),
'picture': fields.File("Picture"), 'picture': fields.File("Picture"),
'note': fields.Text("Note"),
} }
def _get_number(self,context={}): def _get_number(self,context={}):

View File

@ -10,6 +10,17 @@ class Visit(Model):
_audit_log=True _audit_log=True
_name_field="number" _name_field="number"
_multi_company=True _multi_company=True
def _get_visit_late(self,ids,context={}):
res={}
datenow=time.strftime("%Y-%m-%d")
for obj in self.browse(ids):
late=0
if datenow > obj.visit_date and obj.state=='waiting_treatment':
late=1
res[obj.id]=late
return res
_fields={ _fields={
"number": fields.Char("Number",required=True,search=True), "number": fields.Char("Number",required=True,search=True),
"patient_id": fields.Many2One("clinic.patient","Patient",required=True,search=True), "patient_id": fields.Many2One("clinic.patient","Patient",required=True,search=True),
@ -18,10 +29,11 @@ class Visit(Model):
"visit_date": fields.Date("Visit Date",required=True,search=True), "visit_date": fields.Date("Visit Date",required=True,search=True),
"department_id": fields.Many2One("clinic.department", "Department",search=True), "department_id": fields.Many2One("clinic.department", "Department",search=True),
"cycle": fields.Selection([("1","One"),("2","Two"),("3","Tree"),("4","Four")],"Cycle",required=True), "cycle": fields.Selection([("1","One"),("2","Two"),("3","Tree"),("4","Four")],"Cycle",required=True),
"state": fields.Selection([("pending","Pending"),("confirmed","Confirmed"),("cancelled","Cancelled")],"Status",required=True), "state": fields.Selection([("draft","Draft"),("waiting_treatment","Waiting Treatment"),('treatment','Treatment'),("cancelled","Cancelled")],"Status",required=True),
"comments": fields.One2Many("message","related_id","Comments"), "comments": fields.One2Many("message","related_id","Comments"),
"company_id": fields.Many2One("company","Company"), "company_id": fields.Many2One("company","Company"),
'time_use': fields.Integer("Time Use(hrs)"), 'time_use': fields.Integer("Time Use(hrs)"),
'late_visit': fields.Integer("Late Vist",function="_get_visit_late"),
} }
def _get_number(self,context={}): def _get_number(self,context={}):
@ -47,25 +59,42 @@ class Visit(Model):
return None return None
_defaults={ _defaults={
"state": "pending", "state": "draft",
"cycle": "1", "cycle": "1",
'visit_date': time.strftime("%Y-%m-%d"), 'visit_date': time.strftime("%Y-%m-%d"),
"number": _get_number, "number": "/",
"company_id": lambda *a: get_active_company(), "company_id": lambda *a: get_active_company(),
'nurse_id': _get_nurse, 'nurse_id': _get_nurse,
'time_use': 1, 'time_use': 1,
} }
_order="number desc" _order="id desc"
def get_dialyzer(self): def get_dialyzer(self):
return return
def confirm(self,ids,context={}): def confirm(self,ids,context={}):
obj=self.browse(ids)[0] obj=self.browse(ids[0])
number=obj.number
if number=="/":
number=self._get_number(context)
vals={
'number': number,
'state': 'waiting_treatment',
}
obj.write(vals)
def do_treatment(self,ids,context={}):
hd_case_obj=get_model("clinic.hd.case") hd_case_obj=get_model("clinic.hd.case")
dt=datetime.datetime dt=datetime.datetime
fmt_date="%Y-%m-%d %H:%M:%S"
timenow=dt.now().strftime("%H:%M:%S") timenow=dt.now().strftime("%H:%M:%S")
datenow=dt.now().strftime("%Y-%m-%d")
obj=self.browse(ids)[0]
# cannot treatment if current date is not same visit date
if obj.visit_date!=datenow:
raise Exception("Today is not treament date!")
fmt_date="%Y-%m-%d %H:%M:%S"
date_from=dt.strptime("%s %s"%(obj.visit_date,timenow),fmt_date) date_from=dt.strptime("%s %s"%(obj.visit_date,timenow),fmt_date)
seconds=(obj.time_use or 1)*3600 seconds=(obj.time_use or 1)*3600
date_to=date_from+datetime.timedelta(seconds=seconds) date_to=date_from+datetime.timedelta(seconds=seconds)
@ -130,9 +159,9 @@ class Visit(Model):
"ultrafittration": dlz.ultrafittration, "ultrafittration": dlz.ultrafittration,
})) }))
if not vals['dialyzers']: if not vals['dialyzers']:
raise Exception("%s don't have dialyzer for treatment" % obj.patient_id.name) raise Exception("%s don't have dialyzer for treatment yet" % obj.patient_id.name)
hd_case_id=hd_case_obj.create(vals) hd_case_id=hd_case_obj.create(vals)
obj.write({"state":"confirmed"}) obj.write({"state":"treatment"})
return { return {
'next': { 'next': {
'name': 'clinic_hd_case', 'name': 'clinic_hd_case',
@ -148,7 +177,7 @@ class Visit(Model):
def reopen(self,ids,context={}): def reopen(self,ids,context={}):
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
obj.write({"state":"pending"}) obj.write({"state":"draft"})
def onchange_patient(self,context={}): def onchange_patient(self,context={}):
data=context['data'] data=context['data']
@ -195,5 +224,11 @@ class Visit(Model):
'flash': 'Visit %s is copy to %s'%(obj.number,new_obj.number), 'flash': 'Visit %s is copy to %s'%(obj.number,new_obj.number),
} }
def delete(self,ids,context={}):
for obj in self.browse(ids):
if obj.state!='draft':
raise Exception("Can not delete visit %s because state is not draft!"%obj.number)
super().delete(ids,context=context)
Visit.register() Visit.register()

View File

@ -1,3 +1,47 @@
======
- main
- create journal entry from file import
- detail (if have some time need to approve)
- defind state for each step
- visit
- treatment
- dializer
- defind flow of each step
- patient
- new
- load default data
- visit
-> state
- draft
- confirmed
- should dialyzer before treament
- buttons
- confirm
- state : draft -> waiting treatment
- do treatment
- state : waiting treatment ->
- cancel visit
- print visit
- plaining visit
- day [monday, tueday, wedsday, thursday, friday]
- time
- treament
- time start/stop
- only time
- date treament
- color (check state)
- if fail -> red
- cancelled
- make next appointment
- make payment
- state
- draft
- confirm
- many2one for dializer
- dialyzer
=======
sequence (support multi company) -> ok sequence (support multi company) -> ok
- visit - visit
- hd case - hd case