....
commit
57f74cb0c7
|
@ -2,7 +2,7 @@
|
|||
<field name="string">Treatments</field>
|
||||
<field name="view_cls">multi_view</field>
|
||||
<field name="model">clinic.hd.case</field>
|
||||
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["In Progress",[["state","=","in_progress"]]],["Completed",[["state","=","completed"]]],["Uncompleted",[["state","=","uncompleted"]]]]</field>
|
||||
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["In Progress",[["state","=","in_progress"]]],["Completed",[["state","=","completed"]]],["In Completed",[["state","=","in_completed"]]]]</field>
|
||||
<field name="modes">list,form</field>
|
||||
<field name="menu">clinic_menu</field>
|
||||
</action>
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<action>
|
||||
<field name="string">Payment</field>
|
||||
<field name="view_cls">form_popup</field>
|
||||
<field name="model">clinic.payment</field>
|
||||
<field name="target">_popup</field>
|
||||
</action>
|
|
@ -2,7 +2,7 @@
|
|||
<field name="string">Visits</field>
|
||||
<field name="view_cls">multi_view</field>
|
||||
<field name="model">clinic.visit</field>
|
||||
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Waiting Treatment",[["state","=","waiting_treatment"]]],["Treatment",[["state","=","treatment"]]],["Cancelled",[["state","=","cancelled"]]]]</field>
|
||||
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Confirmed",[["state","=","confirmed"]]],["Cancelled",[["state","=","cancelled"]]]]</field>
|
||||
<field name="modes">list,calendar,form</field>
|
||||
<field name="menu">clinic_menu</field>
|
||||
</action>
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
</group>
|
||||
<foot>
|
||||
<button string="Confirm" type="success" states="new" method="confirm"/>
|
||||
<button string="Drop" type="danger" states="active" method="drop"/>
|
||||
<button string="Renew" type="primary" states="active" method="renew"/>
|
||||
<button string="Drop" type="danger" icon="remove" states="active" method="drop"/>
|
||||
<button string="Renew" type="primary" icon="refresh" states="active" method="renew"/>
|
||||
</foot>
|
||||
<related>
|
||||
<field name="pickings" click_action="view_picking"/>
|
||||
|
|
|
@ -2,16 +2,15 @@
|
|||
<head>
|
||||
<field name="state"/>
|
||||
<button string="Options" dropdown="1">
|
||||
<item string="TODO" method="todo"/>
|
||||
<item string="Print Payment" method="print_payment"/>
|
||||
</button>
|
||||
</head>
|
||||
<group span="6" columns="1">
|
||||
<field name="number"/>
|
||||
<field name="time_start"/>
|
||||
<field name="cycle_id"/>
|
||||
<field name="nurse_id"/>
|
||||
<field name="visit_id"/>
|
||||
<field name="department_id"/>
|
||||
<field name="visit_id"/>
|
||||
</group>
|
||||
<group span="6" columns="1">
|
||||
<field name="patient_id" onchange="onchange_patient"/>
|
||||
|
@ -28,10 +27,10 @@
|
|||
<field name="per_bp_start"/>
|
||||
<field name="bp_stop"/>
|
||||
<field name="per_bp_stop"/>
|
||||
<field name="hct"/>
|
||||
<field name="hct" onchange="onchange_hct"/>
|
||||
<field name="dialyzers" nolabel="1">
|
||||
<list>
|
||||
<field name="dialyzer_id" domain="[['patient_id','=',parent.patient_id]]" onchange="onchange_dialyzer"/>
|
||||
<field name="dialyzer_id" domain="[['patient_id','=',parent.patient_id],['state','=','active']]" onchange="onchange_dialyzer"/>
|
||||
<field name="description"/>
|
||||
<field name="use_time"/>
|
||||
<field name="max_use_time"/>
|
||||
|
@ -43,6 +42,29 @@
|
|||
</list>
|
||||
</field>
|
||||
</tab>
|
||||
<tab string="Fees">
|
||||
<field name="gm_lines" count="3" nolabel="1">
|
||||
<list>
|
||||
<field name="product_id" onchange="onchange_gmproduct"/>
|
||||
<field name="description"/>
|
||||
<field name="qty" onchange="onchange_gmline"/>
|
||||
<field name="uom_id"/>
|
||||
<field name="price" onchange="onchange_gmline"/>
|
||||
<field name="amount"/>
|
||||
</list>
|
||||
</field>
|
||||
<group span="8" columns="1">
|
||||
<group span="6" columns="1">
|
||||
<field name="fee_partner_id" domain="[['type','=','org']]" attrs='{"required":[["fee_amount","!=",0]]}'/>
|
||||
</group>
|
||||
<group span="2" columns="1">
|
||||
</group>
|
||||
</group>
|
||||
<group span="4" columns="1">
|
||||
<field name="fee_total"/>
|
||||
<field name="fee_amount"/>
|
||||
</group>
|
||||
</tab>
|
||||
<tab string="Other Expenses">
|
||||
<field name="lines" count="3" nolabel="1">
|
||||
<list>
|
||||
|
@ -59,29 +81,7 @@
|
|||
<group span="4" columns="1">
|
||||
<field name="total"/>
|
||||
<field name="amount"/>
|
||||
</group>
|
||||
</tab>
|
||||
<tab string="Government Pays">
|
||||
<field name="gm_lines" count="3" nolabel="1">
|
||||
<list>
|
||||
<field name="product_id" onchange="onchange_gmproduct"/>
|
||||
<field name="description"/>
|
||||
<field name="qty" onchange="onchange_gmline"/>
|
||||
<field name="uom_id"/>
|
||||
<field name="price" onchange="onchange_gmline"/>
|
||||
<field name="amount"/>
|
||||
</list>
|
||||
</field>
|
||||
<group span="8" columns="1">
|
||||
<group span="6" columns="1">
|
||||
<field name="fee_partner_id" domain="[['type','=','org']]" attrs='{"required":[["fee_amount","!=",0]]}'/>
|
||||
</group>
|
||||
<group span="2" columns="1">
|
||||
</group>
|
||||
</group>
|
||||
<group span="4" columns="1">
|
||||
<field name="fee_total"/>
|
||||
<field name="fee_amount"/>
|
||||
<button string="Pay Now" span="2" size="small" action="clinic_payment" icon="arrow-right" type="success"/>
|
||||
</group>
|
||||
</tab>
|
||||
<tab string="Notes">
|
||||
|
@ -89,9 +89,10 @@
|
|||
</tab>
|
||||
</tabs>
|
||||
<foot>
|
||||
<button string="Confirm" type="success" method="confirm" states="draft"/>
|
||||
<button string="Complete" type="success" method="complete" states="in_progress"/>
|
||||
<button string="Discontinue" type="danger" action="clinic_hd_case_distcont" states="in_progress"/>
|
||||
<button string="Do Treatment" type="success" icon="arrow-right" method="do_treatment" states="draft"/>
|
||||
<button string="Complete" type="success" icon="ok" method="complete" states="in_progress"/>
|
||||
<button string="Discontinue" type="danger" icon="remove" action="clinic_hd_case_distcont" states="in_progress"/>
|
||||
<button string="Undo" type="default" icon="refresh" method="undo" states="completed"/>
|
||||
</foot>
|
||||
<related>
|
||||
<field name="invoices" click_action="view_invoice"/>
|
||||
|
|
|
@ -5,55 +5,9 @@
|
|||
<field name="name"/>
|
||||
<field name="date_import"/>
|
||||
<field name="type" required="1"/>
|
||||
<separator string="Select File -> Load Sheet -> Select Sheet(only one) -> Click Import"/>
|
||||
<group span="8" columns="1">
|
||||
<group span="12">
|
||||
<field name="file" nolabel="1" onchange="onchange_file"/>
|
||||
<button string="Load Sheet" size="small" type="warning" icon="download" method="load_sheet" attrs='{"invisible":[["state","in",["close"]]]}'/>
|
||||
<button string="Clear Sheet" size="small" type="danger" icon="remove" method="clear_sheet" attrs='{"invisible":[["state","in",["close"]]]}'/>
|
||||
</group>
|
||||
<field name="sheets" count="3" nolabel="1">
|
||||
<list>
|
||||
<field name="name"/>
|
||||
<field name="select" onchange="onchange_sheet"/>
|
||||
</list>
|
||||
</field>
|
||||
<group span="6">
|
||||
</group>
|
||||
<group span="6">
|
||||
<!--<button span="3" string="Import" type="success" icon="arrow-right" method="import_payment" attrs='{"invisible":[["state","in",["success"]]]}'/>-->
|
||||
<!--<button span="3" string="Close" type="danger" method="close_import" attrs='{"invisible":[["state","in",["success"]]]}'/>-->
|
||||
</group>
|
||||
</group>
|
||||
<group span="4" columns="1">
|
||||
<group attrs='{"invisible":[["type","!=","mg"]]}'>
|
||||
<separator string="Medical Government"/>
|
||||
<field name="mg_payment_id" readonly="1"/>
|
||||
<field name="mg_move_id" readonly="1"/>
|
||||
<button string="POST" size="small" type="success" method="post_mg" attrs='{"invisible":[["state","in",["close"]]]}'/>
|
||||
<button string="UNDO" size="small" type="danger" method="undo_mg" attrs='{"invisible":[["state","in",["close"]]]}'/>
|
||||
</group>
|
||||
|
||||
<group attrs='{"invisible":[["type","!=","sc"]]}'>
|
||||
<separator string="Social Security"/>
|
||||
<field name="sc_payment_id" readonly="1"/>
|
||||
<field name="sc_move_id" readonly="1"/>
|
||||
<button string="POST" size="small" type="success" method="post_sc" attrs='{"invisible":[["state","in",["close"]]]}'/>
|
||||
<button string="UNDO" size="small" type="danger" method="undo_sc" attrs='{"invisible":[["state","in",["close"]]]}'/>
|
||||
</group>
|
||||
|
||||
<group attrs='{"invisible":[["type","!=","nhso"]]}'>
|
||||
<separator string="NHSO (30฿)"/>
|
||||
<field name="nhso_payment_id" readonly="1"/>
|
||||
<field name="nhso_move_id" readonly="1"/>
|
||||
<button string="POST" size="small" type="success" method="post_nhso" attrs='{"invisible":[["state","in",["close"]]]}'/>
|
||||
<button string="UNDO" size="small" type="danger" method="undo_nhso" attrs='{"invisible":[["state","in",["close"]]]}'/>
|
||||
</group>
|
||||
|
||||
</group>
|
||||
<field name="input_id" readonly="1"/>
|
||||
<field name="mg_payment_id" readonly="1"/>
|
||||
<foot>
|
||||
<button span="3" string="Import" type="success" icon="arrow-right" method="import_payment" attrs='{"invisible":[["state","in",["close"]]]}'/>
|
||||
<button span="3" string="Close" type="danger" method="close" attrs='{"invisible":[["state","in",["close"]]]}'/>
|
||||
<button span="3" string="To Draft" icon="refresh" type="default" method="to_draft" attrs='{"invisible":[["state","in",["draft"]]]}'/>
|
||||
<button span="3" size="large" icon="arrow-right" string="Import" type="primary" method="import"/>
|
||||
</foot>
|
||||
</form>
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
<form model="clinic.import.payment" attrs='{"readonly":[["state","in",["close"]]]}'>
|
||||
<head>
|
||||
<field name="state"/>
|
||||
<button string="Report" icon="print" action="report"/>
|
||||
</head>
|
||||
<field name="name"/>
|
||||
<field name="date_import"/>
|
||||
<field name="type" required="1"/>
|
||||
<separator string="Select File -> Load DATA -> Click See Data"/>
|
||||
<group span="6" columns="1">
|
||||
<field span="6" name="file" onchange="onchange_file"/>
|
||||
<button span="6" string="Load DATA" size="small" type="warning" icon="download" method="load_data" attrs='{"invisible":[["state","in",["close"]]]}'/>
|
||||
<field span="6" name="input_id" readonly="1"/>
|
||||
</group>
|
||||
<group span="6" columns="1">
|
||||
<group attrs='{"invisible":[["type","!=","mg"]]}'>
|
||||
<separator string="Medical Government"/>
|
||||
<field name="mg_payment_id" readonly="1"/>
|
||||
<field name="mg_move_id" readonly="1"/>
|
||||
<button string="POST" size="small" type="success" method="post_mg" attrs='{"invisible":[["state","in",["close"]]]}'/>
|
||||
<button string="UNDO" size="small" type="danger" method="undo_mg" attrs='{"invisible":[["state","in",["close"]]]}'/>
|
||||
</group>
|
||||
|
||||
<group attrs='{"invisible":[["type","!=","sc"]]}'>
|
||||
<separator string="Social Security"/>
|
||||
<field name="sc_payment_id" readonly="1"/>
|
||||
<field name="sc_move_id" readonly="1"/>
|
||||
<button string="POST" size="small" type="success" method="post_sc" attrs='{"invisible":[["state","in",["close"]]]}'/>
|
||||
<button string="UNDO" size="small" type="danger" method="undo_sc" attrs='{"invisible":[["state","in",["close"]]]}'/>
|
||||
</group>
|
||||
|
||||
<group attrs='{"invisible":[["type","!=","nhso"]]}'>
|
||||
<separator string="NHSO (30฿)"/>
|
||||
<field name="nhso_payment_id" readonly="1"/>
|
||||
<field name="nhso_move_id" readonly="1"/>
|
||||
<button string="POST" size="small" type="success" method="post_nhso" attrs='{"invisible":[["state","in",["close"]]]}'/>
|
||||
<button string="UNDO" size="small" type="danger" method="undo_nhso" attrs='{"invisible":[["state","in",["close"]]]}'/>
|
||||
</group>
|
||||
|
||||
</group>
|
||||
<foot>
|
||||
<!--<button span="3" string="Import" type="success" icon="arrow-right" method="import_payment" attrs='{"invisible":[["state","in",["close"]]]}'/>-->
|
||||
<button span="3" string="Close" type="danger" method="close" attrs='{"invisible":[["state","in",["close"]]]}'/>
|
||||
<button span="3" string="To Draft" icon="refresh" type="default" method="to_draft" attrs='{"invisible":[["state","in",["draft"]]]}'/>
|
||||
</foot>
|
||||
</form>
|
|
@ -7,9 +7,9 @@
|
|||
<item string="Patients">
|
||||
<item string="Patients" action="clinic_patient"/>
|
||||
<item string="Dialyzers" action="clinic_dialyzer"/>
|
||||
<item string="Schedules" action="clinic_schedule"/>
|
||||
<!--<item string="Schedules" action="clinic_schedule"/>-->
|
||||
<divider/>
|
||||
<header string="OPTIONS"/>
|
||||
<header string="OTHERS"/>
|
||||
<item string="Races" action="clinic_race"/>
|
||||
<item string="Nationalities" action="clinic_nation"/>
|
||||
<item string="Graduations" action="clinic_grade"/>
|
||||
|
@ -26,11 +26,7 @@
|
|||
<item string="Daily" action="clinic_hd_report"/>
|
||||
<item string="Monthly" action="clinic_hd_report_monthly"/>
|
||||
</item>
|
||||
<item string="Imports">
|
||||
<item string="Import Payments" action="clinic_import_payment"/>
|
||||
</item>
|
||||
<item string="Settings">
|
||||
<!-- <item string="Cycle" action="clinic_cycle"/>-->
|
||||
<item string="Departments" action="clinic_department"/>
|
||||
<item string="Cycle" action="clinic_cycle"/>
|
||||
<item string="Clinic Settings" action="clinic_setting"/>
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<inherit inherit="account_menu">
|
||||
<item string="Settings" position="before">
|
||||
<item string="Ratchawat">
|
||||
<item string="Import Payments" action="clinic_import_payment"/>
|
||||
</item>
|
||||
</item>
|
||||
</inherit>
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<form model="clinic.payment">
|
||||
<field name="partner_id" />
|
||||
<field name="lines" nolabel="1">
|
||||
<list>
|
||||
<field name="description"/>
|
||||
<field name="qty"/>
|
||||
<field name="price"/>
|
||||
<field name="amount"/>
|
||||
</list>
|
||||
</field>
|
||||
<group span="4">
|
||||
</group>
|
||||
<group span="8">
|
||||
<field offset="6" name="total"/>
|
||||
</group>
|
||||
<foot>
|
||||
<button string="POST" type="success" method="post"/>
|
||||
</foot>
|
||||
</form>
|
|
@ -1,8 +1,5 @@
|
|||
<form model="clinic.setting" title="Financial Settings">
|
||||
<tabs>
|
||||
<tab string="Schedule">
|
||||
<button string="Gen Schedule" method="gen_schedule" icon="arrow-right" type="success" />
|
||||
</tab>
|
||||
<tab string="Accounting">
|
||||
<separator string="Account Setting Medical Govelopment"/>
|
||||
<field name="mg_partner_id" />
|
||||
|
|
|
@ -1,34 +1,32 @@
|
|||
<form model="clinic.visit" attrs='{"readonly":[["state","in",["treatment"]]]}' show_company="1">
|
||||
<form model="clinic.visit" attrs='{"readonly":[["state","in",["confirmed"]]]}' show_company="1">
|
||||
<head>
|
||||
<field name="state"/>
|
||||
<button string="Print" icon="print" action="report_visit_form"/>
|
||||
<button string="Options" dropdown="1">
|
||||
<item string="Copy" method="copy"/>
|
||||
<item string="Create Dialyzer" method="create_dialyzer"/>
|
||||
<item string="Generate Cycle" method="generate_cycle"/>
|
||||
<!--<item string="Create Dialyzer" method="create_dialyzer"/>-->
|
||||
<!--<item string="Generate Cycle" method="generate_cycle"/>-->
|
||||
</button>
|
||||
</head>
|
||||
<tabs>
|
||||
<tab string="General">
|
||||
<group span="6" columns="1">
|
||||
<field name="number"/>
|
||||
<field name="time_start" onchange="onchange_time" attrs='{"required":[["state","=","waiting_treatment"]]}'/>
|
||||
<field name="time_start" onchange="onchange_time"/>
|
||||
<field name="department_id"/>
|
||||
<field name="cycle_id" onchange="onchange_time" required="1"/>
|
||||
</group>
|
||||
<group span="6" columns="1">
|
||||
<field name="patient_id" onchange="onchange_patient"/>
|
||||
<field name="time_stop" attrs='{"required":[["state","=","waiting_treatment"]]}'/>
|
||||
<field name="time_stop"/>
|
||||
<field name="doctor_id"/>
|
||||
<field name="nurse_id" attrs='{"required":[["state","=","waiting_treatment"]]}'/>
|
||||
<field name="nurse_id"/>
|
||||
</group>
|
||||
</tab>
|
||||
</tabs>
|
||||
<foot>
|
||||
<button string="Confirm" type="success" method="confirm" states="draft" />
|
||||
<button string="Do Treatment" type="success" method="do_treatment" icon="arrow-right" states="waiting_treatment" />
|
||||
<button string="Dicard" type="warning" icon="trash" method="discard" states="waiting_treatment" confirm="Are you sure to cancel HD case?"/>
|
||||
<button string="Re Visit" type="default" attrs='{"invisible":[["state","=","treatment"]]}' icon="repeat" method="reopen" states="cancelled" />
|
||||
<button string="To Draft" type="default" icon="refresh" method="to_draft" states="confirmed" />
|
||||
</foot>
|
||||
<related>
|
||||
<field name="hd_cases" readonly="1"/>
|
||||
|
|
|
@ -32,3 +32,6 @@ from . import cycle
|
|||
from . import gen_visit
|
||||
from . import gen_visit_line
|
||||
from . import report_hd_monthly
|
||||
from . import payment
|
||||
from . import payment_line
|
||||
from . import input_data
|
||||
|
|
|
@ -152,6 +152,7 @@ class Dialyzer(Model):
|
|||
for obj in self.browse(ids):
|
||||
if obj.state != 'new':
|
||||
raise Exception("Can not delete Dializer %s because state is not 'new'"%obj.number)
|
||||
super().delete(ids)
|
||||
|
||||
def cancel(self,ids,context={}):
|
||||
obj=self.browse(ids[0])
|
||||
|
|
|
@ -29,11 +29,13 @@ class GenVisit(Model):
|
|||
'friday': fields.Boolean("Fridays"),
|
||||
'doctor_id': fields.Many2One("clinic.doctor","Doctor"),
|
||||
'nurse_id': fields.Many2One("clinic.nurse","Nurse"),
|
||||
'duration': fields.Integer("Duration", function="_get_duration"),
|
||||
'duration': fields.Integer("Duration (hrs)", function="_get_duration"),
|
||||
}
|
||||
|
||||
def _get_lines(self,context={}):
|
||||
ids=context.get("ids")
|
||||
if not ids:
|
||||
ids=[context.get("refer_id")]
|
||||
lines=[{'patient_id': id} for id in ids]
|
||||
return lines
|
||||
|
||||
|
@ -45,12 +47,20 @@ class GenVisit(Model):
|
|||
return nurse_ids[0]
|
||||
return None
|
||||
|
||||
def _get_cycle(self,context={}):
|
||||
cycle_ids=get_model('clinic.cycle').search([],order="sequence")
|
||||
if cycle_ids:
|
||||
cycle_id=cycle_ids[0]
|
||||
return cycle_id or None
|
||||
|
||||
_defaults={
|
||||
'lines': _get_lines,
|
||||
'date_from': lambda *a: datetime.now().strftime(FMT_DATETIME),
|
||||
'date_to': lambda *a: datetime.now().strftime(FMT_DATETIME),
|
||||
'nurse_id': _get_nurse,
|
||||
'duration': 1,
|
||||
'cycle_id': _get_cycle,
|
||||
'monday': True,
|
||||
}
|
||||
|
||||
def onchange_time(self,context={}):
|
||||
|
@ -64,17 +74,18 @@ class GenVisit(Model):
|
|||
date_from=data['date_from']
|
||||
date_to=(datetime.strptime(date_from,FMT_DATETIME)+timedelta(seconds=seconds)).strftime(FMT_DATETIME)
|
||||
data['date_to']='%s %s'%(data['date_to'][0:10],date_to[11:])
|
||||
data['duration']=(datetime.strptime(data['date_to'],FMT_DATETIME)-datetime.strptime(data['date_from'],FMT_DATETIME)).days+1
|
||||
duration=(datetime.strptime(data['date_to'],FMT_DATETIME)-datetime.strptime(data['date_from'],FMT_DATETIME)).seconds/3600
|
||||
data['duration']=duration
|
||||
return data
|
||||
|
||||
def onchange_dateto(self,context={}):
|
||||
data=context['data']
|
||||
data['duration']=(datetime.strptime(data['date_to'],FMT_DATETIME)-datetime.strptime(data['date_from'],FMT_DATETIME)).days+1
|
||||
data['duration']=(datetime.strptime(data['date_to'],FMT_DATETIME)-datetime.strptime(data['date_from'],FMT_DATETIME)).seconds/3600
|
||||
return data
|
||||
|
||||
def gen_visit(self,ids,context):
|
||||
obj=self.browse(ids)[0]
|
||||
time_stop=obj.date_to[11:]
|
||||
#time_stop=obj.date_to[11:]
|
||||
days=[
|
||||
obj.monday and 1 or 0,
|
||||
obj.tuesday and 2 or 0,
|
||||
|
@ -86,29 +97,46 @@ class GenVisit(Model):
|
|||
print("days ", days)
|
||||
if not days:
|
||||
raise Exception("Please select Day")
|
||||
duration=datetime.strptime(obj.date_to,FMT_DATETIME)-datetime.strptime(obj.date_from,FMT_DATETIME)
|
||||
for day in range(duration.days+1):
|
||||
date_from=(datetime.strptime(obj.date_from,FMT_DATETIME)+timedelta(days=day)).strftime(FMT_DATETIME)
|
||||
date_to="%s %s" % (obj.date_from[0:10],time_stop)
|
||||
# loop patient
|
||||
visit_vals=[]
|
||||
for line in obj.lines:
|
||||
# loop days in weekend
|
||||
for day in days:
|
||||
#duration=datetime.strptime(obj.date_to,FMT_DATETIME)-datetime.strptime(obj.date_from,FMT_DATETIME)
|
||||
# loop patient
|
||||
visit_vals=[]
|
||||
date_from=datetime.strptime(obj.date_from,FMT_DATETIME)
|
||||
date_to=datetime.strptime(obj.date_to,FMT_DATETIME)
|
||||
#total_days=(date_to-date_from).days
|
||||
for line in obj.lines:
|
||||
# loop days in weekend
|
||||
ntoday=1
|
||||
day_total=(date_to-date_from).days+ntoday
|
||||
for weekday in days:
|
||||
wd=date_from.weekday()
|
||||
start_date=date_from
|
||||
while wd != weekday-1:
|
||||
start_date+=timedelta(days=1)
|
||||
wd=start_date.weekday()
|
||||
|
||||
#XXX should gen only in scoop
|
||||
if start_date.strftime(FMT_DATE) > date_to.strftime(FMT_DATE):
|
||||
continue
|
||||
count=0
|
||||
while count < day_total:
|
||||
tmp=start_date+timedelta(days=count)
|
||||
vals={
|
||||
'patient_id': line.patient_id.id,
|
||||
'doctor_id': obj.doctor_id.id,
|
||||
'nurse_id': obj.nurse_id.id,
|
||||
'cycle_id': obj.cycle_id.id,
|
||||
'time_start': date_from,
|
||||
'time_stop': date_to,
|
||||
'time_start': "%s %s" % (tmp.strftime(FMT_DATE),date_from.strftime(FMT_DATETIME)[11:]),
|
||||
'time_stop': "%s %s" % (tmp.strftime(FMT_DATE),date_to.strftime(FMT_DATETIME)[11:]),
|
||||
'state': 'draft',
|
||||
}
|
||||
visit_vals.append(vals)
|
||||
count+=7
|
||||
start_date=tmp
|
||||
|
||||
if visit_vals:
|
||||
dom=[]
|
||||
dom.append(['time_start','>=','%s %s'%(obj.date_from[0:10],' 00:00:00')])
|
||||
dom.append(['time_stop','<=','%s %s'%(obj.date_to[0:10],' 23:59:59')])
|
||||
dom.append(['time_start','>=','%s %s'%(date_from.strftime(FMT_DATE)[0:10],' 00:00:00')])
|
||||
dom.append(['time_stop','<=','%s %s'%(start_date.strftime(FMT_DATE)[0:10],' 23:59:59')])
|
||||
# search patient
|
||||
dom.append(['state','=','draft'])
|
||||
patient_ids=[visit['patient_id'] for visit in visit_vals]
|
||||
|
@ -118,7 +146,7 @@ class GenVisit(Model):
|
|||
visit_ids=visit_obj.search(dom)
|
||||
# delete old visit (same duration)
|
||||
visit_obj.delete(visit_ids)
|
||||
for vas in visit_vals:
|
||||
for vals in visit_vals:
|
||||
visit_obj.create(vals)
|
||||
|
||||
return {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import time
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime
|
||||
|
||||
from netforce.model import Model, fields, get_model
|
||||
from netforce.utils import get_data_path
|
||||
|
@ -43,9 +43,8 @@ class HDcase(Model):
|
|||
"hct": fields.Integer("HCT %", required=True),
|
||||
"check_goverment_pay" : fields.Boolean("The Government Pay"),
|
||||
"check_personal_pay" : fields.Boolean("Pay yourself"),
|
||||
"state": fields.Selection([("draft","Draft"),("confirmed","Confirmed"),("approved","Approved"),("cancelled","Cancelled"),("paid","Paid")],"Status",required=True),
|
||||
"hct": fields.Integer("HCT %"),
|
||||
"state": fields.Selection([("draft","Draft"),("in_progress","In Progress"),("completed","Completed"),("discountinued","Discountinued"),("uncompleted","Uncompleted")],"Status",required=True),
|
||||
"hct": fields.Integer("HCT %(>39)"),
|
||||
"state": fields.Selection([("draft","Draft"),("in_progress","In Progress"),("completed","Completed"),("discountinued","Discountinued"),("in_completed","In completed")],"Status",required=True),
|
||||
"dialyzers": fields.One2Many("clinic.dialyzer.line","hd_case_id","Dialyzers"),
|
||||
"lines": fields.One2Many("clinic.hd.case.line","hd_case_id","Lines"),
|
||||
"gm_lines": fields.One2Many("clinic.hd.case.gm.line","hd_case_id","GM Lines"),
|
||||
|
@ -109,8 +108,16 @@ class HDcase(Model):
|
|||
if not dialyzer_id:
|
||||
return {}
|
||||
dialyzer=get_model("clinic.dialyzer").browse(dialyzer_id)
|
||||
use_time=dialyzer.use_time or 0
|
||||
max_time=dialyzer.max_use_time or 0
|
||||
if use_time > max_time:
|
||||
dialyzer.write({
|
||||
'state': 'expire',
|
||||
})
|
||||
raise Exception("%s is expired"%dialyzer.number)
|
||||
use_time+=1
|
||||
line["description"]=dialyzer.description or ""
|
||||
line["use_time"]=dialyzer.use_time
|
||||
line["use_time"]=use_time
|
||||
line["max_use_time"]=dialyzer.max_use_time
|
||||
line["member_type"]=dialyzer.member_type
|
||||
line["dialyzer_type"]=dialyzer.dialyzer_type
|
||||
|
@ -165,11 +172,11 @@ class HDcase(Model):
|
|||
return data
|
||||
|
||||
def onchange_hct(self,context={}):
|
||||
data=context['hct']
|
||||
data=context['data']
|
||||
hct=data['hct']
|
||||
if(hct<=39):
|
||||
raise Exception("Unit not found in uom")
|
||||
|
||||
data['hct']=0
|
||||
return data
|
||||
|
||||
def cancelled(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
|
@ -205,6 +212,9 @@ class HDcase(Model):
|
|||
data['fee_total']=total
|
||||
data['fee_amount']=total
|
||||
return data
|
||||
|
||||
def make_payment(self,ids,context={}):
|
||||
pass
|
||||
|
||||
def make_invoices(self,ids,context={}):
|
||||
setting=get_model("settings").browse(1)
|
||||
|
@ -217,11 +227,11 @@ class HDcase(Model):
|
|||
raise Exception("Unit not found in uom")
|
||||
obj=self.browse(ids[0])
|
||||
due_date=obj.date[0:10]
|
||||
# XXX
|
||||
|
||||
context['type']='out'
|
||||
context['inv_type']='invoice'
|
||||
# TODO payment without invoice
|
||||
if obj.lines and obj.total:
|
||||
# XXX need to split function prepare invoice
|
||||
vals={
|
||||
"type": "out",
|
||||
"inv_type": "invoice",
|
||||
|
@ -255,7 +265,7 @@ class HDcase(Model):
|
|||
inv_id=get_model("account.invoice").create(vals,context)
|
||||
# create picking
|
||||
obj.make_pickings()
|
||||
if obj.fee:
|
||||
if obj.fee_total:
|
||||
vals={
|
||||
"type": "out",
|
||||
"inv_type": "invoice",
|
||||
|
@ -270,22 +280,22 @@ class HDcase(Model):
|
|||
}
|
||||
vals["partner_id"]=obj.fee_partner_id.id
|
||||
# XXX
|
||||
#if obj.fee_partner_id.account_payable_id:
|
||||
#account_receivable_id=obj.fee_partner_id.account_payable_id.id
|
||||
if obj.fee_partner_id.account_receivable_id:
|
||||
account_id=obj.fee_partner_id.account_receivable_id.id or account_receivable_id
|
||||
if not account_receivable_id:
|
||||
raise Exception("%s not found account recievable %s"%obj.fee_partner_id.name)
|
||||
line={
|
||||
"product_id": None,
|
||||
"description": "Fee",
|
||||
"qty": 1,
|
||||
"uom_id": uom[0].id,
|
||||
"unit_price": obj.fee,
|
||||
"amount": obj.fee,
|
||||
'account_id': account_id,
|
||||
}
|
||||
vals['lines'].append(('create',line))
|
||||
for line in obj.gm_lines:
|
||||
prod=line.product_id
|
||||
inv_line={
|
||||
"product_id": prod.id,
|
||||
"description": prod.name,
|
||||
"qty": 1,
|
||||
"uom_id": prod.uom_id.id,
|
||||
"unit_price": line.price,
|
||||
"amount": line.amount,
|
||||
'account_id': account_id, # XXX
|
||||
}
|
||||
vals['lines'].append(('create',inv_line))
|
||||
inv_id=get_model("account.invoice").create(vals,context)
|
||||
|
||||
def make_pickings(self,ids,context={}):
|
||||
|
@ -321,7 +331,9 @@ class HDcase(Model):
|
|||
|
||||
for line in obj.lines:
|
||||
prod=line.product_id
|
||||
|
||||
if prod.type != 'stock':
|
||||
print("continue ")
|
||||
continue
|
||||
wh_loc_id=prod.location_id.id
|
||||
if not wh_loc_id:
|
||||
|
@ -352,21 +364,31 @@ class HDcase(Model):
|
|||
inv.post()
|
||||
print("Post!")
|
||||
|
||||
def confirm(self,ids,context={}):
|
||||
def do_treatment(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
if not obj.dialyzers:
|
||||
raise Exception("Can not do treatment without dialyzer!")
|
||||
obj.write({"state":"in_progress"})
|
||||
|
||||
def discontinue(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
# TODO pop to note
|
||||
obj.write({"state":"uncompleted"})
|
||||
|
||||
obj.write({"state":"in_completed"})
|
||||
|
||||
def update_usetime(self,ids,context={}):
|
||||
for obj in self.browse(ids):
|
||||
for dlz_line in obj.dialyzers:
|
||||
dlz=dlz_line.dialyzer_id
|
||||
dlz.write({
|
||||
'use_time': dlz_line.use_time,
|
||||
})
|
||||
return True
|
||||
|
||||
def complete(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
if not obj.dialyzers:
|
||||
raise Exception("Please enter dialyzer!")
|
||||
obj.make_invoices()
|
||||
obj.post_invoices()
|
||||
obj.update_usetime()
|
||||
obj.write({
|
||||
"state":"completed",
|
||||
})
|
||||
|
@ -439,4 +461,29 @@ class HDcase(Model):
|
|||
data['fee']=0.0
|
||||
return data
|
||||
|
||||
def undo(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
for inv in obj.invoices:
|
||||
inv.write({
|
||||
'state': 'draft',
|
||||
})
|
||||
inv.delete()
|
||||
for pick in obj.pickings:
|
||||
pick.write({
|
||||
'state': 'draft',
|
||||
})
|
||||
pick.delete()
|
||||
|
||||
obj.write({
|
||||
'state': 'draft',
|
||||
})
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_hd_case',
|
||||
'mode': 'form',
|
||||
'active_id': obj.id,
|
||||
},
|
||||
'flash': '%s has been undo'%obj.number,
|
||||
}
|
||||
|
||||
HDcase.register()
|
||||
|
|
|
@ -37,6 +37,7 @@ class ImportPayment(Model):
|
|||
"state": fields.Selection([("draft","Draft"),("success","Succes"),("fail","Fail"),('close','Close')],"Status"),
|
||||
'note': fields.Text("Note"),
|
||||
'partner_id': fields.Many2One("partner","Contact"),
|
||||
'input_id': fields.Many2One("clinic.input.data", "Data"),
|
||||
}
|
||||
|
||||
_order="date_import desc"
|
||||
|
@ -53,21 +54,42 @@ class ImportPayment(Model):
|
|||
}
|
||||
|
||||
def load_data(self,ids,context):
|
||||
records=[1,2,]
|
||||
del records[0]
|
||||
fmt1="%y-%m-%d"
|
||||
fmt2="%Y-%m-%d"
|
||||
for record in records:
|
||||
row=record.split(",")
|
||||
doc_date=row[0]
|
||||
if doc_date:
|
||||
#'%m/%d/%y
|
||||
pt="(\d+)/(\d+)/(\d+)"
|
||||
res=re.search(pt,doc_date)
|
||||
if res:
|
||||
doc_date="%s-%s-%s" % (res.group(3),res.group(1),res.group(2))
|
||||
newdate=datetime.strptime(doc_date,fmt1)
|
||||
print(newdate.strftime(fmt2))
|
||||
obj=self.browse(ids[0])
|
||||
fname=obj.file
|
||||
if not fname:
|
||||
raise Exception("Please select file!")
|
||||
fpath=get_file_path(fname)
|
||||
suffix=fpath.split(".")[-1]
|
||||
if suffix not in ('xls', 'xlsx'):
|
||||
raise Exception("ERROR : file support only xls, xlsx")
|
||||
wb=xlrd.open_workbook(fpath)
|
||||
worksheet=wb.sheet_by_name("Sheet1")
|
||||
num_rows=worksheet.nrows-1
|
||||
curr_row=-1
|
||||
cols={
|
||||
'hn': 38,
|
||||
'dttran': 71,
|
||||
'name14': 39,
|
||||
'hcode18': 65, # remove -1
|
||||
'amount23': 74,
|
||||
'cur': 91,
|
||||
'epoadm29': 93,
|
||||
'eponame': 98,
|
||||
'ln': 99,
|
||||
'st': 101,
|
||||
'allow37': 109,
|
||||
}
|
||||
|
||||
while curr_row < num_rows:
|
||||
curr_row +=1
|
||||
vals={
|
||||
'date': worksheet.cell_value(curr_row,cols['dttran']),
|
||||
'name': worksheet.cell_value(curr_row,cols['name14']),
|
||||
'hn': worksheet.cell_value(curr_row,cols['hn']),
|
||||
'amount': worksheet.cell_value(curr_row,cols['amount23']),
|
||||
'hct': worksheet.cell_value(curr_row,cols['amount23']),
|
||||
}
|
||||
|
||||
|
||||
def load_sheet(self,ids,context={}):
|
||||
obj=self.browse(ids[0])
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
from netforce.model import Model, fields, get_model
|
||||
|
||||
class InputData(Model):
|
||||
_name="clinic.input.data"
|
||||
_transient=True
|
||||
|
||||
_fields={
|
||||
'date': fields.Date("Date"),
|
||||
'name': fields.Char("Patient Name"),
|
||||
'hn': fields.Char("HN"),
|
||||
'amount': fields.Char("Amount"),
|
||||
'hct': fields.Char("HCT"),
|
||||
'medical_type': fields.Char("Medical Type"),
|
||||
'medical_cost': fields.Char("Medical Cost"),
|
||||
'other_cost': fields.Char("Other Cost"),
|
||||
}
|
||||
|
||||
InputData.register()
|
|
@ -0,0 +1,65 @@
|
|||
#from netforce.access import get_active_user
|
||||
from netforce.model import Model, fields, get_model
|
||||
|
||||
class Payment(Model):
|
||||
_name="clinic.payment"
|
||||
_transient=True
|
||||
|
||||
def _get_all(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
total=0.0
|
||||
for line in obj.lines:
|
||||
total+=line.amount or 0.0
|
||||
res[obj.id]={
|
||||
'total': total
|
||||
}
|
||||
return res
|
||||
|
||||
_fields={
|
||||
'partner_id': fields.Many2One("partner","Partner"),
|
||||
'lines': fields.One2Many("clinic.payment.line","payment_id", "Lines"),
|
||||
'total': fields.Float("Total", function="_get_all",function_multi=True),
|
||||
"state": fields.Selection([["draft","Draft"],['paid','Paid'],["cancelled","Cancelled"]],"Status",required=True),
|
||||
}
|
||||
|
||||
def _get_partner_id(self,context={}):
|
||||
refer_id=context.get("refer_id") # hd_case_id
|
||||
hd_case=get_model('clinic.hd.case').browse(refer_id)
|
||||
partner_id=hd_case.patient_id.partner_id.id or None
|
||||
return partner_id
|
||||
|
||||
def _get_lines(self,context={}):
|
||||
refer_id=context.get("refer_id") # hd_case_id
|
||||
hd_case=get_model('clinic.hd.case').browse(refer_id)
|
||||
lines=[]
|
||||
for line in hd_case.lines:
|
||||
vals={
|
||||
'description': line.description or '',
|
||||
'qty': line.qty or 0,
|
||||
'price': line.price,
|
||||
'amount': line.amount,
|
||||
}
|
||||
lines.append(vals)
|
||||
return lines
|
||||
|
||||
def _get_total(self,context={}):
|
||||
refer_id=context.get("refer_id")
|
||||
hd_case=get_model('clinic.hd.case').browse(refer_id)
|
||||
total=0.0
|
||||
for line in hd_case.lines:
|
||||
total+=line.amount
|
||||
print("total ", total)
|
||||
return total
|
||||
|
||||
_defaults={
|
||||
'partner_id': _get_partner_id,
|
||||
'lines': _get_lines,
|
||||
'total': _get_total,
|
||||
}
|
||||
|
||||
def paid(self,context={}):
|
||||
pass
|
||||
|
||||
|
||||
Payment.register()
|
|
@ -0,0 +1,17 @@
|
|||
from netforce.model import Model, fields, get_model
|
||||
|
||||
class PaymentLine(Model):
|
||||
_name="clinic.payment.line"
|
||||
_transient=True
|
||||
|
||||
_fields={
|
||||
'payment_id': fields.Many2One("clinic.payment","Payment"),
|
||||
'description': fields.Char("Description"),
|
||||
'qty': fields.Integer("Qty"),
|
||||
'price': fields.Float("Unit Price"),
|
||||
'account_id': fields.Many2One("account.account","Account"),
|
||||
'amount': fields.Float("Amount"),
|
||||
}
|
||||
|
||||
PaymentLine.register()
|
||||
|
|
@ -1,119 +0,0 @@
|
|||
import time
|
||||
|
||||
from netforce.model import Model, fields, get_model
|
||||
|
||||
class HDReport(Model):
|
||||
_name="clinic.hd.report"
|
||||
_string="HD Report"
|
||||
_transient=True
|
||||
|
||||
_fields={
|
||||
"date": fields.Date("Start-Date"),
|
||||
#"time_start": fields.DateTime("Time start",required=False,search=True),
|
||||
#"time_stop": fields.DateTime("Time stop",required=False,search=True),
|
||||
"cycle_id": fields.Many2One("clinic.cycle","Cycle"),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
||||
#'time_start': lambda *a: time.strftime("%Y-%m-%d"),
|
||||
#'time_stop': lambda *a: time.strftime("%Y-%m-%d"),
|
||||
}
|
||||
|
||||
_order="cycle_id desc"
|
||||
|
||||
|
||||
def get_report_data(self,ids,context={}):
|
||||
PATIENT_TYPE={
|
||||
"mg":"Medical Government",
|
||||
"sc":"Social Security",
|
||||
"nhso":"NHSO (30฿)",
|
||||
"personal": "Personal",
|
||||
"others": "Others",
|
||||
}
|
||||
#time_start=time.strftime("%Y-%m-%d")
|
||||
#time_stop=time.strftime("%Y-%m-%d")
|
||||
date=time.strftime("%Y-%m-%d")
|
||||
dom=[]
|
||||
dom.append(['state','=','completed'])
|
||||
if ids:
|
||||
obj=self.browse(ids)[0]
|
||||
if obj.date:
|
||||
date=obj.date
|
||||
if obj.cycle_id:
|
||||
dom.append([
|
||||
'cycle_id','=',obj.cycle_id.id,
|
||||
])
|
||||
dom.append(['time_start', ">=", obj.date+"00:00:00"])
|
||||
dom.append(['time_stop', "<=", obj.date+"23:59:59"])
|
||||
print("dom ", dom)
|
||||
lines=[]
|
||||
cycles=[]
|
||||
index=0
|
||||
no_patient=0
|
||||
for hd_case in get_model("clinic.hd.case").search_browse(dom,order="cycle_id.sequence"):
|
||||
patient_type=hd_case.patient_id.type
|
||||
patient_type=PATIENT_TYPE.get(patient_type)
|
||||
dialyzer_name=hd_case.dialyzers.id
|
||||
dialyzer_name=DIALYZER_NAME.get(dialyzer_name)
|
||||
cycle_name=hd_case.cycle_id.name or ""
|
||||
show_cycle=False
|
||||
if not cycle_name in cycles:
|
||||
cycles.append(cycle_name)
|
||||
show_cycle=True
|
||||
if index > 1:
|
||||
vals={
|
||||
'color': 'success',
|
||||
'show_cycle': False,
|
||||
'cycle' : "",
|
||||
'patient': "",
|
||||
'no_patient': no_patient,
|
||||
'patient_type' : "",
|
||||
'doctor' : "",
|
||||
'total' : "",
|
||||
'rc_no' : "",
|
||||
'dialyzer_name' : "",
|
||||
'nurse' : "",
|
||||
}
|
||||
lines.append(vals)
|
||||
no_patient=1
|
||||
else:
|
||||
no_patient+=1
|
||||
index+=1
|
||||
vals={
|
||||
'show_cycle': show_cycle,
|
||||
'cycle' : cycle_name,
|
||||
'patient': hd_case.patient_id.name,
|
||||
'patient_type' : patient_type,
|
||||
'no_patient': 0,
|
||||
'doctor' : hd_case.doctor_id.name,
|
||||
'total' : hd_case.fee,
|
||||
'rc_no' : hd_case.number,
|
||||
'dialyzer' : dialyzer_name,
|
||||
'nurse' : hd_case.nurse_id.name,
|
||||
}
|
||||
lines.append(vals)
|
||||
|
||||
# XXX
|
||||
if lines:
|
||||
vals={
|
||||
'color': 'success',
|
||||
'show_cycle': False,
|
||||
'cycle' : "",
|
||||
'patient': "",
|
||||
'no_patient': no_patient,
|
||||
'patient_type' : "",
|
||||
'doctor' : "",
|
||||
'total' : "",
|
||||
'rc_no' : "",
|
||||
'dialyzer_name' : "",
|
||||
'nurse' : "",
|
||||
}
|
||||
lines.append(vals)
|
||||
|
||||
data={
|
||||
'lines': lines,
|
||||
}
|
||||
return data
|
||||
|
||||
HDReport.register()
|
|
@ -14,16 +14,6 @@ class Visit(Model):
|
|||
_name_field="number"
|
||||
_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.date_visit or '') and obj.state=='waiting_treatment':
|
||||
late=1
|
||||
res[obj.id]=late
|
||||
return res
|
||||
|
||||
_fields={
|
||||
"number": fields.Char("Number",required=True,search=True),
|
||||
"time_start": fields.DateTime("Time Start",required=True),
|
||||
|
@ -32,12 +22,11 @@ class Visit(Model):
|
|||
"doctor_id": fields.Many2One("clinic.doctor","Doctor",search=True),
|
||||
"nurse_id": fields.Many2One("clinic.nurse","Nurse",search=True),
|
||||
"department_id": fields.Many2One("clinic.department", "Department",search=True),
|
||||
"state": fields.Selection([("draft","Draft"),("waiting_treatment","Waiting Treatment"),('treatment','Treatment'),("cancelled","Cancelled")],"Status",required=True),
|
||||
"comments": fields.One2Many("message","related_id","Comments"),
|
||||
"company_id": fields.Many2One("company","Company"),
|
||||
'hd_cases': fields.One2Many('clinic.hd.case','visit_id',"HD Cases",readonly=True),
|
||||
"cycle_id": fields.Many2One("clinic.cycle","Cycle"),
|
||||
"state": fields.Selection([("draft","Draft"),("waiting_treatment","Waiting Treatment"),('treatment','Treatment'),("cancelled","Cancelled")],"Status",required=True),
|
||||
"state": fields.Selection([["draft","Draft"],["confirmed","Confirmed"],["cancelled","Cancelled"]],"Status",required=True),
|
||||
"comments": fields.One2Many("message","related_id","Comments"),
|
||||
}
|
||||
|
||||
|
@ -97,21 +86,18 @@ class Visit(Model):
|
|||
number=self._get_number(context)
|
||||
vals={
|
||||
'number': number,
|
||||
'state': 'waiting_treatment',
|
||||
'state': 'confirmed',
|
||||
}
|
||||
obj.write(vals)
|
||||
|
||||
def do_treatment(self,ids,context={}):
|
||||
hd_case_obj=get_model("clinic.hd.case")
|
||||
dt=datetime
|
||||
datenow=dt.now().strftime("%Y-%m-%d")
|
||||
#dt=datetime
|
||||
#datenow=dt.now().strftime("%Y-%m-%d")
|
||||
obj=self.browse(ids)[0]
|
||||
date_visit=obj.time_start[0:10]
|
||||
#date_visit=obj.time_start[0:10]
|
||||
# cannot treatment if current date is not same visit date
|
||||
if date_visit!=datenow:
|
||||
raise Exception("Today is not treament date!")
|
||||
#if date_visit!=datenow:
|
||||
#raise Exception("Today is not treament date!")
|
||||
|
||||
#include_fee=obj.patient_id.type in ('mg','sc','nhso') and True or False
|
||||
vals={
|
||||
'patient_id': obj.patient_id.id,
|
||||
'doctor_id': obj.doctor_id.id,
|
||||
|
@ -122,13 +108,24 @@ class Visit(Model):
|
|||
'cycle_id' : obj.cycle_id.id,
|
||||
'visit_id': obj.id,
|
||||
'cycle_id': obj.cycle_id.id,
|
||||
#'fee': include_fee and 1500.00 or 0.0,
|
||||
'fee_type': obj.patient_id.type,
|
||||
'lines':[],
|
||||
'gm_lines':[],
|
||||
'dialyzers': [],
|
||||
'state': 'in_progress',
|
||||
'state': 'draft',
|
||||
}
|
||||
|
||||
products=get_model("product").search_browse([['code','=','FEE']])
|
||||
for product in products:
|
||||
vals['gm_lines'].append(('create',{
|
||||
'product_id': product.id,
|
||||
'description': product.name or "",
|
||||
'qty': 1,
|
||||
'price': product.sale_price or 0.0,
|
||||
'amount': product.sale_price or 0.0,
|
||||
'uom_id': product.uom_id.id,
|
||||
}))
|
||||
|
||||
patient_type={
|
||||
"mg":"Medical Government",
|
||||
"sc":"Social Security",
|
||||
|
@ -150,7 +147,6 @@ class Visit(Model):
|
|||
break
|
||||
|
||||
hd_case_id=hd_case_obj.create(vals)
|
||||
obj.write({"state":"treatment"})
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_hd_case',
|
||||
|
@ -239,5 +235,17 @@ class Visit(Model):
|
|||
time_start=data['time_start']
|
||||
data['time_stop']=(datetime.strptime(time_start,FMT_DATE)+timedelta(seconds=seconds)).strftime(FMT_DATE)
|
||||
return data
|
||||
|
||||
def to_draft(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
for hd_case in obj.hd_cases:
|
||||
# XXX
|
||||
hd_case.write({
|
||||
'state': 'draft',
|
||||
})
|
||||
hd_case.delete()
|
||||
obj.write({
|
||||
'state': 'draft',
|
||||
})
|
||||
|
||||
Visit.register()
|
||||
|
|
Loading…
Reference in New Issue