add setting account clinic

conv_bal
CASH 2014-09-11 10:21:52 +07:00
parent 3373af9620
commit 9a34d2bee3
25 changed files with 236 additions and 41 deletions

View File

@ -11,6 +11,7 @@ clinic/models/clinic_dialyzer.py
clinic/models/clinic_doctor.py clinic/models/clinic_doctor.py
clinic/models/clinic_hd_case.py clinic/models/clinic_hd_case.py
clinic/models/clinic_hd_case_line.py clinic/models/clinic_hd_case_line.py
clinic/models/clinic_hd_case_line_detail.py
clinic/models/clinic_nurse.py clinic/models/clinic_nurse.py
clinic/models/clinic_patient.py clinic/models/clinic_patient.py
clinic/models/clinic_visit.py clinic/models/clinic_visit.py

Binary file not shown.

View File

@ -2,7 +2,7 @@
<field name="string">HD Case</field> <field name="string">HD Case</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"]]],["Pending",[["state","=","pending"]]],["Confirm",[["state","=","corfirmed"]]]]</field> <field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Confirm",[["state","=","corfirmed"]]],["Approved",[["state","=","approved"]]],["Validate",[["state","=","validate"]]],["Payment",[["state","=","payment"]]]]</field>
<field name="modes">list,page,form</field> <field name="modes">list,form</field>
<field name="menu">clinic_menu</field> <field name="menu">clinic_menu</field>
</action> </action>

View File

@ -0,0 +1,10 @@
<record model="action">
<field name="name">clinic_setting</field>
<field name="string">Settings</field>
<field name="view_cls">form_view</field>
<field name="model">clinic.setting</field>
<field name="modes">form</field>
<field name="active_id">1</field>
<field name="menu">clinic_menu</field>
</record>

View File

@ -2,7 +2,7 @@
<field name="string">Visit</field> <field name="string">Visit</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",[]],["Draft",[["state","=","draft"]]],["Pending",[["state","=","pending"]]],["Confirm",[["state","=","corfirmed"]]]]</field> <field name="tabs">[["All",[]],["Pending",[["state","=","pending"]]],["Confirm",[["state","=","corfirmed"]]],["Canceled",[["state","=","canceled"]]]]</field>
<field name="modes">list,calendar,page,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

@ -2,46 +2,56 @@
<head> <head>
<field name="state"/> <field name="state"/>
<button string="Options" dropdown="1"> <button string="Options" dropdown="1">
<item string="XXXX"/> <item string="Journal Report" method="journal_report"/>
</button> </button>
</head> </head>
<separator string="HD Case Info"/> <separator string="HD Case Info"/>
<field name="number"/> <field name="number" attrs='{"readonly":[["state","in",["canceled","approved","validate"]]]}'/>
<field name="patient_id"/> <field name="patient_id" attrs='{"readonly":[["state","in",["canceled","approved","validate"]]]}'/>
<field name="date_start"/> <field name="date_start" attrs='{"readonly":[["state","in",["canceled","approved","validate"]]]}'/>
<field name="date_stop"/> <field name="date_stop" attrs='{"readonly":[["state","in",["canceled","approved","validate"]]]}'/>
<field name="wh_start"/> <field name="wh_start" attrs='{"readonly":[["state","in",["canceled","approved","validate"]]]}'/>
<field name="wh_stop"/> <field name="wh_stop" attrs='{"readonly":[["state","in",["canceled","approved","validate"]]]}'/>
<field name="bp_start"/> <field name="bp_start" attrs='{"readonly":[["state","in",["canceled","approved","validate"]]]}'/>
<field name="per_bp_start"/> <field name="per_bp_start" attrs='{"readonly":[["state","in",["canceled","approved","validate"]]]}'/>
<field name="bp_stop"/> <field name="bp_stop" attrs='{"readonly":[["state","in",["canceled","approved","validate"]]]}'/>
<field name="per_bp_stop"/> <field name="per_bp_stop" attrs='{"readonly":[["state","in",["canceled","approved","validate"]]]}'/>
<field name="hct"/> <field name="hct" attrs='{"readonly":[["state","in",["canceled","approved","validate"]]]}'/>
<field name="doctor_id"/> <field name="doctor_id" attrs='{"readonly":[["state","in",["canceled","approved","validate"]]]}'/>
<field name="nurse_id"/> <field name="nurse_id" attrs='{"readonly":[["state","in",["canceled","approved","validate"]]]}'/>
<field name="department"/> <field name="department" attrs='{"readonly":[["state","in",["canceled","approved","validate"]]]}'/>
<field name="lines" nolabel="1"> <field name="lines" nolabel="0" attrs='{"readonly":[["state","in",["canceled","approved","validate"]]]}'>
<list> <list>
<field name="dialzer_id" onchange="onchange_dialyzer"/> <field name="dialzer_id" onchange="onchange_dialyzer"/>
<field name="detail"/> <field name="detail"/>
<field name="member_type"/> <field name="member_type"/>
<field name="bid_flow_rate"/>
<field name="dialyzer_type"/> <field name="dialyzer_type"/>
<field name="bid_flow_rate"/>
<field name="ultrafittration"/> <field name="ultrafittration"/>
<field name="use_time"/> <field name="use_time"/>
<field name="max_use_time"/> <field name="max_use_time"/>
<field name="state"/> <field name="state"/>
</list> </list>
</field> </field>
<field name="lines_detail" nolabel="1"> <field name="lines_detail" nolabel="0" attrs='{"readonly":[["state","in",["canceled","approved","validate"]]]}'>
<list> <list>
<field name="product_id" onchange="onchange_product"/> <field name="product_id" onchange="onchange_product"/>
<field name="detail"/> <field name="detail"/>
<field name="qty"/> <field name="qty"/>
<field name="uom_id"/> <field name="uom_id"/>
<field name="price"/> <field name="price"/>
<field name="total"/>
</list> </list>
</field> </field>
<field name="fee" span="2" offset="7" attrs='{"readonly":[["state","in",["canceled","approved","validate"]]]}'/>
<field name="total" span="2" offset="8"/>
<field name="amount" span="2" offset="8"/>
<foot>
<button string="Confirm" type="success" method="confirmed" states="draft" />
<button string="Approved" type="success" method="approved" states="confirmed"/>
<button string="Validate" type="success" method="validate" states="approved" />
<button string="Canceled" type="danger" method="canceled" confirm="You are sure to canceled hd case"/>
</foot>
<related> <related>
<field name="comments"/> <field name="comments"/>
</related> </related>

View File

@ -0,0 +1,14 @@
<form model="clinic.setting" title="Financial Settings">
<separator string="Account Setting Medical Govelopment"/>
<field name="mg_partner_id" />
<field name="ar_mg_id" />
<field name="ap_mg_id" />
<separator string="Account Setting NHSO 30B"/>
<field name="nhso_partner_id" />
<field name="ar_nhso_id" />
<field name="ap_nhso_id" />
<separator string="Account Setting Social Security"/>
<field name="sc_partner_id" />
<field name="ar_sc_id" />
<field name="ap_sc_id" />
</form>

View File

@ -1,6 +1,7 @@
<calendar model="clinic.visit" date_field="date" colors='{"#090":[["state","in",["pending"]]],"#999":[["state","=","canceled"]]}'> <calendar model="clinic.visit" states='pending' date_field="date" colors='{"#090":[["cycle","=",1]],"#2400ff":[["cycle","=",2]],"#ebff00":[["cycle","=",3]],"#f20000":[["cycle","=",4]]}'>
<field name="number"/>
<field name="patient_id"/> <field name="patient_id"/>
<field name="cycle"/>
<field name="number"/>
<field name="doctor_id"/> <field name="doctor_id"/>
<field name="nurse_id"/> <field name="nurse_id"/>
<field name="state"/> <field name="state"/>

View File

@ -9,13 +9,18 @@
<tab string="Visit"> <tab string="Visit">
<separator string="Visit Info"/> <separator string="Visit Info"/>
<field name="number"/> <field name="number"/>
<field name="department"/>
<field name="date"/> <field name="date"/>
<field name="cycle"/>
<field name="patient_id"/> <field name="patient_id"/>
<field name="doctor_id"/> <field name="doctor_id"/>
<field name="nurse_id"/> <field name="nurse_id"/>
<field name="department"/>
</tab> </tab>
</tabs> </tabs>
<foot>
<button string="Confirm" type="success" method="confirmed" states="pending" />
<button string="Canceled" type="danger" method="canceled" confirm="You are sure to canceled hd case"/>
</foot>
<related> <related>
<field name="comments"/> <field name="comments"/>
</related> </related>

View File

@ -1,6 +1,7 @@
<list model="clinic.visit"> <list model="clinic.visit">
<field name="number"/> <field name="number"/>
<field name="date"/> <field name="date"/>
<field name="cycle"/>
<field name="patient_id"/> <field name="patient_id"/>
<field name="doctor_id"/> <field name="doctor_id"/>
<field name="nurse_id"/> <field name="nurse_id"/>

View File

@ -6,3 +6,4 @@ from . import clinic_hd_case
from . import clinic_hd_case_line from . import clinic_hd_case_line
from . import clinic_hd_case_line_detail from . import clinic_hd_case_line_detail
from . import clinic_dialyzer from . import clinic_dialyzer
from . import clinic_setting

View File

@ -19,7 +19,7 @@ class Dialyzer(Model):
"exp_date": fields.Date("Expire Date",search=True), "exp_date": fields.Date("Expire Date",search=True),
"patient_id": fields.Many2One("clinic.patient","Patient"), "patient_id": fields.Many2One("clinic.patient","Patient"),
"member_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Member Type",required=True), "member_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Member Type",required=True),
"dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Member Type",required=True), "dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Dialyzer Type",required=True),
"bid_flow_rate": fields.Integer("Bid Flow Rate (ml/min)",required=True,search=True), "bid_flow_rate": fields.Integer("Bid Flow Rate (ml/min)",required=True,search=True),
"ultrafittration": fields.Float("Ultrafittration Kg.",required=True,search=True), "ultrafittration": fields.Float("Ultrafittration Kg.",required=True,search=True),
"state": fields.Selection([("draft","New"),("active","Active"),("drop","Drop")],"Status",required=True), "state": fields.Selection([("draft","New"),("active","Active"),("drop","Drop")],"Status",required=True),

View File

@ -1,7 +1,7 @@
from netforce.model import Model, fields, get_model from netforce.model import Model, fields, get_model
from netforce.utils import get_data_path from netforce.utils import get_data_path
import time import time
from netforce.access import get_active_user from netforce.access import get_active_user,set_active_user
from netforce.access import get_active_company from netforce.access import get_active_company
class Hdcase(Model): class Hdcase(Model):
@ -25,11 +25,15 @@ class Hdcase(Model):
"bp_stop": fields.Integer("BP mmHG stop",required=True,search=True), "bp_stop": fields.Integer("BP mmHG stop",required=True,search=True),
"per_bp_stop": fields.Integer("/Per stop",required=True,search=True), "per_bp_stop": fields.Integer("/Per stop",required=True,search=True),
"hct": fields.Integer("HCT %",required=True,search=True), "hct": fields.Integer("HCT %",required=True,search=True),
"state": fields.Selection([("draft","Draft"),("pending","Pending"),("confirmed","Confirmed"),("canceled","Canceled")],"Status",required=True), "state": fields.Selection([("draft","Draft"),("approved","Approved"),("confirmed","Confirmed"),("validate","Validate"),("canceled","Canceled"),("payment","Payment")],"Status",required=True),
"lines": fields.One2Many("clinic.hd.case.line","hd_case_id","Details"), "lines": fields.One2Many("clinic.hd.case.line","hd_case_id","Details"),
"lines_detail": fields.One2Many("clinic.hd.case.line.detail","hd_case_id","Detail"), "lines_detail": fields.One2Many("clinic.hd.case.line.detail","hd_case_id","Detail"),
"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"),
"fee": fields.Float("Fee",required=True),
"amount": fields.Float("Amount",function="get_total",readonly=True,function_multi=True),
"total": fields.Float("Total",function="get_total",readonly=True,function_multi=True),
"reconcile_id": fields.Many2One("account.reconcile","Reconcile Id",readonly=True),
} }
def _get_number(self,context={}): def _get_number(self,context={}):
@ -66,14 +70,137 @@ class Hdcase(Model):
"date_stop": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"), "date_stop": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
"number": _get_number, "number": _get_number,
"company_id": lambda *a: get_active_company(), "company_id": lambda *a: get_active_company(),
"fee": 1500,
} }
_order="date desc,number desc" _order="date_start desc,number desc"
def void(self,ids,context={}): def canceled(self,ids,context={}):
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
obj.write({"state":"voided"}) obj.write({"state":"canceled"})
def confirmed(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({"state":"confirmed"})
def payment(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({"state":"payment"})
def approved(self,ids,context={}):
for obj in self.browse(ids):
user_id=get_active_user()
try:
set_active_user(1)
settings=get_model("clinic.setting").browse(1)
reconcile_id=get_model("account.reconcile").create({})
if obj.patient_id.type == 'mg':
vals={
"narration": obj.number,
"lines": [
("create",{
"description": obj.number,
"account_id": settings.ar_mg_id.id,
"debit": obj.amount,
"credit": 0,
"partner_id": settings.mg_partner_id.id,
"due_date": obj.date,
"reconcile_id":reconcile_id,
}),
("create",{
"description": obj.number,
"account_id": settings.ap_mg_id.id,
"debit": 0,
"credit": obj.amount,
}),
],
"state": "posted",
"date_posted": obj.date,
"date": obj.date,
}
get_model("account.move").create(vals)
elif obj.patient_id.type == 'sc':
vals={
"narration": obj.number,
"lines": [
("create",{
"description": obj.number,
"account_id": settings.ar_sc_id.id,
"debit": obj.amount,
"credit": 0,
"partner_id": settings.sc_partner_id.id,
"due_date": obj.date,
"reconcile_id":reconcile_id,
}),
("create",{
"description": obj.number,
"account_id": settings.ap_sc_id.id,
"debit": 0,
"credit": obj.amount,
}),
],
"state": "posted",
"date_posted": obj.date,
"date": obj.date,
}
get_model("account.move").create(vals)
elif obj.patient_id.type == 'nhso':
vals={
"narration": obj.number,
"lines": [
("create",{
"description": obj.number,
"account_id": settings.ar_nhso_id.id,
"debit": obj.amount,
"credit": 0,
"partner_id": settings.nhso_partner_id.id,
"due_date": obj.date,
"reconcile_id":reconcile_id,
}),
("create",{
"description": obj.number,
"account_id": settings.ap_nhso_id.id,
"debit": 0,
"credit": obj.amount,
}),
],
"state": "posted",
"date_posted": obj.date,
"date": obj.date,
}
get_model("account.move").create(vals)
finally:
set_active_user(user_id)
obj.write({"state":"approved","reconcile_id":reconcile_id})
def journal_report(self,ids,context={}):
obj=self.browse(ids[0])
move_id = get_model("account.move").search([["narration","=",obj.number]])
if not move_id:
raise Exception("Order is not post or nove have jounal entry.")
return {
"next": {
"name": "journal_entry",
"mode":"form",
"active_id":move_id[0],
}
}
def get_total(self,ids,context={}):
vals={}
for obj in self.browse(ids):
total=0
amt=0
fee=obj.fee
for line in obj.lines_detail:
total+=line.total
amt=total+fee
vals[obj.id]={
"total": total,
"amount": amt,
}
return vals
Hdcase.register() Hdcase.register()

View File

@ -6,7 +6,7 @@ from netforce.access import get_active_company
class Patient(Model): class Patient(Model):
_name="clinic.patient" _name="clinic.patient"
_string="Partient" _string="Patient"
_audit_log=True _audit_log=True
_name_field="name" _name_field="name"
_multi_company=True _multi_company=True

View File

@ -0,0 +1,22 @@
from netforce.model import Model, fields, get_model
from netforce.utils import get_data_path
import time
from netforce.access import get_active_user
from netforce.access import get_active_company
class ClinicSetting(Model):
_name="clinic.setting"
_string="Setting"
_fields={
"mg_partner_id": fields.Many2One("partner","Partner Medical Govement"),
"ar_mg_id": fields.Many2One("account.account","Account Receivable Medical Govement"),
"ap_mg_id": fields.Many2One("account.account","Account Payment Medical Govement"),
"nhso_partner_id": fields.Many2One("partner","Partner NHSO 30B"),
"ar_nhso_id": fields.Many2One("account.account","Account Receiveble NHSO 30B"),
"ap_nhso_id": fields.Many2One("account.account","Account Payment NHSO 30B"),
"sc_partner_id": fields.Many2One("partner","Partner Social Security"),
"ar_sc_id": fields.Many2One("account.account","Account Receiveble Social Security"),
"ap_sc_id": fields.Many2One("account.account","Account Payment Social Security"),
}
ClinicSetting.register()

View File

@ -15,9 +15,10 @@ class Visit(Model):
"patient_id": fields.Many2One("clinic.patient","Patients",required=True,search=True), "patient_id": fields.Many2One("clinic.patient","Patients",required=True,search=True),
"doctor_id": fields.Many2One("clinic.doctor","Doctor",search=True), "doctor_id": fields.Many2One("clinic.doctor","Doctor",search=True),
"nurse_id": fields.Many2One("clinic.nurse","Nurse",search=True), "nurse_id": fields.Many2One("clinic.nurse","Nurse",search=True),
"date": fields.Date("Create Date",required=True,search=True), "date": fields.Date("Visit Date",required=True,search=True),
"department": fields.Char("Department",required=True,search=True), "department": fields.Char("Department",required=False,search=True),
"state": fields.Selection([("draft","Draft"),("pending","Pending"),("confirmed","Confirmed"),("canceled","Canceled")],"Status",required=True), "cycle": fields.Selection([("1","One"),("2","Two"),("3","Tree"),("4","Four")],"Cycle",required=True),
"state": fields.Selection([("pending","Pending"),("confirmed","Confirmed"),("canceled","Canceled")],"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"),
} }
@ -34,18 +35,20 @@ class Visit(Model):
_defaults={ _defaults={
"state": "draft", "state": "pending",
"date": lambda *a: time.strftime("%Y-%m-%d"),
"number": _get_number, "number": _get_number,
"company_id": lambda *a: get_active_company(), "company_id": lambda *a: get_active_company(),
} }
_order="date desc,number desc" _order="date asc,cycle asc"
def confirmed(self,ids,context={}):
def void(self,ids,context={}):
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
obj.write({"state":"voided"}) obj.write({"state":"confirmed"})
def canceled(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({"state":"canceled"})
Visit.register() Visit.register()