conv_bal
chayut.s 2014-10-08 11:53:35 +07:00
commit 9da2803fcd
44 changed files with 1413 additions and 243 deletions

View File

@ -1,6 +1,6 @@
<action> <action>
<field name="name">clinic_board</field> <field name="name">clinic_board</field>
<field name="string">Clinic Board</field> <field name="string">Visit Board</field>
<field name="view_cls">board</field> <field name="view_cls">board</field>
<field name="view_xml">clinic_board</field> <field name="view_xml">clinic_board</field>
<field name="menu">clinic_menu</field> <field name="menu">clinic_menu</field>

View File

@ -1,8 +1,8 @@
<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"]]],["Cancelled",[["state","=","cancelled"]]]]</field> <field name="tabs">[["All",[]],["New",[["state","=","new"]]],["Active",[["state","=","active"]]],["Drop",[["state","=","drop"]]],["Expire",[["state","=","expire"]]],["Cancelled",[["state","=","cancelled"]]]]</field>
<field name="modes">list,page,form</field> <field name="modes">list,page,form</field>
<field name="menu">clinic_menu</field> <field name="menu">clinic_menu</field>
</action> </action>

View File

@ -1,8 +1,8 @@
<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"]]],["In Progress",[["state","=","in_progress"]]],["Completed",[["state","=","completed"]]],["Uncompleted",[["state","=","uncompleted"]]]]</field>
<field name="modes">list,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,6 @@
<action>
<field name="string">Reason</field>
<field name="view_cls">form_popup</field>
<field name="model">clinic.hd.case.discont</field>
<field name="target">_popup</field>
</action>

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

@ -0,0 +1,6 @@
<action>
<field name="string">Schedule</field>
<field name="view_cls">multi_view</field>
<field name="model">clinic.schedule</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

@ -0,0 +1,6 @@
<action>
<field name="type">report_odt</field>
<field name="model">clinic.visit</field>
<field name="method">get_data</field>
<field name="template">visit</field>
</action>

View File

@ -24,8 +24,7 @@
<foot> <foot>
<button string="Confirm" type="success" states="new" method="confirm"/> <button string="Confirm" type="success" states="new" method="confirm"/>
<button string="Drop" type="danger" states="active" method="drop"/> <button string="Drop" type="danger" states="active" method="drop"/>
<button string="Cancel" type="default" states="active" method="cancel"/> <button string="Renew" type="primary" states="active" method="renew"/>
<button string="Renew" type="primary" states="cancelled" method="renew"/>
</foot> </foot>
<related> <related>
<field name="pickings" click_action="view_picking"/> <field name="pickings" click_action="view_picking"/>

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,7 @@
<form model="clinic.hd.case.discont">
<field name="hd_case_id" invisible="1"/>
<field name="note" nolabel="1" width="550" height="200"/>
<foot>
<button string="OK" type="success" method="do_discontinue"/>
</foot>
</form>

View File

@ -1,37 +1,70 @@
<form model="clinic.hd.case" attrs='{"readonly":[["state","in",["cancelled","validated"]]]}' show_company="1"> <form model="clinic.hd.case" attrs='{"readonly":[["state","in",["uncompleted","completed"]]]}' show_company="1">
<head> <head>
<field name="state"/> <field name="state"/>
<button string="Options" dropdown="1"> <button string="Options" dropdown="1">
<item string="Journal Report" method="journal_report"/> <item string="New Visit" method="new_visit"/>
</button> </button>
</head> </head>
<separator string="Healthy Information"/> <group span="6" columns="1">
<field name="wh_start"/> <field name="number"/>
<field name="wh_stop"/> <field name="date"/>
<field name="bp_start"/> <field name="time_start"/>
<field name="bp_stop"/> <field name="total_time"/>
<field name="per_bp_start"/> <field name="visit_id"/>
<field name="per_bp_stop"/> </group>
<field name="epo_tn"/> <group span="6" columns="1">
<field name="epo_unit"/> <field name="patient_id" onchange="onchange_patient"/>
<field name="hct" onchange="onchange_htc"/> <field name="doctor_id"/>
<separator string="Dialyzer"/> <field name="time_stop"/>
<field name="dialyzers" nolabel="1"> <field name="nurse_id"/>
<list> <field name="department_id"/>
<field name="dialyzer_id"/> </group>
<field name="use_time"/> <tabs>
<field name="max_use_time"/> <tab string="Dialyzer">
<field name="member_type"/> <field name="dialyzers" nolabel="1">
<field name="dialyzer_type"/> <list>
<field name="bid_flow_rate"/> <field name="dialyzer_id" domain="[['patient_id','=',parent.patient_id]]" onchange="onchange_dialyzer"/>
<field name="ultrafittration"/> <field name="description"/>
</list> <field name="use_time"/>
</field> <field name="max_use_time"/>
<!--<separator string="Choose Payment"/> <field name="member_type"/>
<field name="check_goverment_pay"/> <field name="dialyzer_type"/>
<field name="check_personal_pay"/>--> <field name="bid_flow_rate"/>
<separator string="Others Payment"/> <field name="ultrafittration"/>
<field name="lines" count="4" nolabel="1"> <field name="state"/>
</list>
</field>
</tab>
<tab string="Notes">
<field name="wh_start"/>
<field name="wh_stop"/>
<field name="bp_start"/>
<field name="per_bp_start"/>
<field name="bp_stop"/>
<field name="per_bp_stop"/>
<field name="epo_tn"/>
<field name="epo_unit"/>
<field name="hct" onchange="onchange_htc"/>
</tab>
<tab string="Next Visit">
<separator string="Click Options-> New Visit"/>
<field name="planes" nolabel="1" domain="[['state','=','open']]">
<list>
<field name="date" onchange="onchange_dateplane"/>
<field name="time_start"/>
<field name="time_stop"/>
<field name="state"/>
</list>
</field>
</tab>
<tab string="Others">
<field name="note"/>
<field name="paid" readonly="1"/>
</tab>
</tabs>
<separator string="Other Expenses"/>
<field name="lines" count="3" nolabel="1">
>>>>>>> e1240368c0b451851115891dd7ace7423682a225
<list> <list>
<field name="product_id" onchange="onchange_product"/> <field name="product_id" onchange="onchange_product"/>
<field name="description"/> <field name="description"/>
@ -62,15 +95,15 @@
<field name="amount"/> <field name="amount"/>
</group> </group>
<foot> <foot>
<button string="Confirm" type="success" method="confirm" states="draft" /> <button string="Confirm" type="success" method="confirm" states="draft"/>
<button string="Validate" type="success" method="approve" states="confirmed"/> <button string="Complete" type="success" method="complete" states="in_progress"/>
<!--<button string="Validate" type="success" method="validate" states="confirmed" />--> <!--<button string="Discontinue" type="danger" method="discontinue" states="in_progress"/>-->
<button string="Pay" type="success" method="paid" states="approved" /> <button string="Discontinue" type="danger" action="clinic_hd_case_distcont" states="in_progress"/>
</foot> </foot>
<related> <related>
<field name="invoices" click_action="view_invoice"/> <field name="invoices" click_action="view_invoice"/>
<field name="payments" click_action="view_payment"/>
<field name="pickings" click_action="view_picking"/> <field name="pickings" click_action="view_picking"/>
<field name="payments" click_action="view_payment"/>
<field name="comments"/> <field name="comments"/>
</related> </related>
</form> </form>

View File

@ -1,7 +1,7 @@
<list model="clinic.hd.case"> <list model="clinic.hd.case">
<field name="number"/> <field name="number"/>
<field name="date_start"/> <field name="time_start"/>
<field name="date_stop"/> <field name="time_stop"/>
<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

@ -0,0 +1,59 @@
<form model="clinic.import.payment" attrs='{"readonly":[["state","in",["close"]]]}'>
<head>
<field name="state"/>
</head>
<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>
<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>

View File

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

View File

@ -0,0 +1,6 @@
<form model="clinic.input.data">
<field name="doc_date"/>
<field name="name"/>
<field name="hn"/>
<field name="amount"/>
</form>

View File

@ -0,0 +1,6 @@
<list model="clinic.input.data">
<field name="doc_date"/>
<field name="name"/>
<field name="hn"/>
<field name="amount"/>
</list>

View File

@ -3,25 +3,33 @@
<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> <item string="Dialyzers" action="clinic_dialyzer"/>
<item string="Visits" action="clinic_visit"/> <item string="Schedules" action="clinic_schedule"/>
<item string="Treatments" action="clinic_hd_case"/> <divider/>
<item string="Dialyzer" action="clinic_dialyzer"/> <header string="OPTIONS"/>
<item string="Reports">
<item string="Report1" action="report_clinic_round"/>
</item>
<item string="Config/Import">
<item string="Account (TB, Unpaid AP and AR)" action="report1"/>
</item>
<item string="Settings">
<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="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="Cause Chronics" action="clinic_cause_chronic"/>
<item string="Comorbidities" action="clinic_comorbidity"/> <item string="Comorbidities" action="clinic_comorbidity"/>
<item string="Morbidities" action="clinic_morbidity"/> <item string="Morbidities" action="clinic_morbidity"/>
</item>
<item string="Visits" action="clinic_visit"/>
<item string="Treatments" action="clinic_hd_case"/>
<!--<item string="Planings">-->
<!--<item string="Visit" action="clinic_visit"/>-->
<!--</item>-->
<item string="Reports">
<item string="Clinic Round(Testing)" action="report_clinic_round"/>
</item>
<item string="Imports">
<item string="Import Payments" action="clinic_import_payment"/>
</item>
<item string="Settings">
<item string="Departments" action="clinic_department"/>
<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

@ -9,15 +9,14 @@
<!--<field name="type" onchange="onchange_type"/>--> <!--<field name="type" onchange="onchange_type"/>-->
<field name="type"/> <field name="type"/>
<field name="name"/> <field name="name"/>
<field name="hn"/>
<field name="reg_date"/> <field name="reg_date"/>
<field name="job"/>
<field name="salary"/>
<field name="gender"/>
<field name="marital_status"/>
<field name="partner_id"/> <field name="partner_id"/>
<tabs> <tabs>
<tab string="General Information"> <tab string="General Information">
<group span="6" columns="1"> <group span="6" columns="1">
<field name="gender"/>
<field name="marital_status"/>
<field name="card_type"/> <field name="card_type"/>
<field name="card_no"/> <field name="card_no"/>
<field name="card_exp"/> <field name="card_exp"/>
@ -28,6 +27,8 @@
<field name="email"/> <field name="email"/>
</group> </group>
<group span="6" columns="1"> <group span="6" columns="1">
<field name="job"/>
<field name="salary"/>
<field name="nation_id"/> <field name="nation_id"/>
<field name="race_id"/> <field name="race_id"/>
<field name="grad_id"/> <field name="grad_id"/>
@ -81,6 +82,9 @@
</list> </list>
</field> </field>
</tab> </tab>
<tab string="Schedules">
<field name="schedules"/>
</tab>
</tabs> </tabs>
<related> <related>
<field name="visits"/> <field name="visits"/>

View File

@ -1,5 +1,6 @@
<list model="clinic.patient"> <list model="clinic.patient">
<field name="number"/> <field name="number"/>
<field name="hn"/>
<field name="name"/> <field name="name"/>
<field name="reg_date"/> <field name="reg_date"/>
<field name="type"/> <field name="type"/>

View File

@ -0,0 +1,4 @@
<form model="clinic.schedule">
<field name="name"/>
<field name="code"/>
</form>

View File

@ -0,0 +1,4 @@
<list model="clinic.schedule">
<field name="name"/>
<field name="code"/>
</list>

View File

@ -1,14 +1,21 @@
<form model="clinic.setting" title="Financial Settings"> <form model="clinic.setting" title="Financial Settings">
<separator string="Account Setting Medical Govelopment"/> <tabs>
<field name="mg_partner_id" /> <tab string="Schedule">
<field name="ar_mg_id" /> <button string="Gen Schedule" method="gen_schedule" icon="arrow-right" type="success" />
<field name="ap_mg_id" /> </tab>
<separator string="Account Setting NHSO 30B"/> <tab string="Accounting">
<field name="nhso_partner_id" /> <separator string="Account Setting Medical Govelopment"/>
<field name="ar_nhso_id" /> <field name="mg_partner_id" />
<field name="ap_nhso_id" /> <field name="ar_mg_id" />
<separator string="Account Setting Social Security"/> <field name="ap_mg_id" />
<field name="sc_partner_id" /> <separator string="Account Setting NHSO 30B"/>
<field name="ar_sc_id" /> <field name="nhso_partner_id" />
<field name="ap_sc_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" />
</tab>
</tabs>
</form> </form>

View File

@ -1,4 +1,5 @@
<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="date_visit" colors='{"#090":[["cycle","=",1]],"#2400ff":[["cycle","=",2]],"#ebff00":[["cycle","=",3]],"#f20000":[["cycle","=",4]]}'>-->
<calendar model="clinic.visit" states='waiting_treatment' date_field="date_visit" start_field="time_start" end_field="time_stop" colors='{"#090":[["cycle","=",1]],"#2400ff":[["cycle","=",2]],"orange":[["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

@ -1,33 +1,65 @@
<form model="clinic.visit" attrs='{"readonly":[["state","in",["cancelled","confirmed"]]]}' show_company="1"> <form model="clinic.visit" attrs='{"readonly":[["state","in",["treatment"]]]}' show_company="1">
<head> <head>
<field name="state"/> <field name="state"/>
<button string="Print" icon="print" action="report_visit_form"/> <button string="Print" icon="print" action="report_visit_form"/>
<button string="Options" dropdown="1"> <button string="Options" dropdown="1">
<item string="Copy" method="copy"/> <item string="Copy" method="copy"/>
<item string="Create Dialyzer" method="create_dialyzer"/>
</button> </button>
</head> </head>
<tabs> <tabs>
<tab string="Visit"> <tab string="General">
<group span="6" columns="1"> <group span="6" columns="1">
<field name="number"/> <field name="number"/>
<field name="visit_date"/> <field name="date_visit" onchange="onchange_date_visit"/>
<field name="cycle"/> <field name="cycle"/>
<field name="time_use"/>
</group> </group>
<group span="6" columns="1"> <group span="6" columns="1">
<field name="department_id"/>
<field name="patient_id" onchange="onchange_patient"/> <field name="patient_id" onchange="onchange_patient"/>
<field name="doctor_id"/> <field name="doctor_id" attrs='{"required":[["state","=","waiting_treatment"]]}'/>
<field name="nurse_id"/> <field name="nurse_id" attrs='{"required":[["state","=","waiting_treatment"]]}'/>
<field name="department_id"/>
</group> </group>
</tab> </tab>
<tab string="Planing">
<field name="time_start" attrs='{"required":[["state","=","waiting_treatment"]]}'/>
<field name="time_stop" attrs='{"required":[["state","=","waiting_treatment"]]}'/>
<field name="time_use" onchange="onchange_timeuse"/>
<separator string="Next Visit"/>
<field name="planes" nolabel="1">
<list>
<field name="date" onchange="onchange_dateplane"/>
<field name="time_start"/>
<field name="time_stop"/>
<field name="state"/>
</list>
</field>
</tab>
</tabs> </tabs>
<group attrs='{"invisible": [["state","not in",["waiting_treatment"]]]}'>
<separator string="Select Dialyzer -> Click Do Treatment"/>
<field name="dialyzers" nolabel="1" count="3">
<list>
<field name="dialyzer_id" domain="[['state','=','active'],['patient_id','=',parent.patient_id]]" onchange="onchange_dialyzer"/>
<field name="description"/>
<field name="use_time"/>
<field name="max_use_time"/>
<field name="member_type"/>
<field name="dialyzer_type"/>
<field name="bid_flow_rate"/>
<field name="ultrafittration"/>
<field name="state"/>
</list>
</field>
</group>
<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="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" />
</foot> </foot>
<related> <related>
<field name="hd_cases" readonly="1"/>
<field name="comments"/> <field name="comments"/>
</related> </related>
</form> </form>

View File

@ -1,6 +1,7 @@
<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="date_visit"/>
<field name="cycle"/> <field name="cycle"/>
<field name="patient_id"/> <field name="patient_id"/>
<field name="doctor_id"/> <field name="doctor_id"/>

View File

@ -1,15 +1,25 @@
from . import comorbidity from . import comorbidity
from . import morbidity from . import morbidity
from . import education
from . import setting
from . import graduation
from . import nation
from . import race
from . import cause_chronic
from . import schedule
from . import patient from . import patient
from . import patient_schedule
from . import patient_cause_line from . import patient_cause_line
from . import patient_comorbidity_line from . import patient_comorbidity_line
from . import patient_morbidity_line from . import patient_morbidity_line
from . import department
from . import doctor from . import doctor
from . import nurse from . import nurse
from . import visit from . import visit
from . import visit_plan
from . import hd_case from . import hd_case
from . import hd_case_dialyzer
from . import hd_case_line from . import hd_case_line
from . import hd_case_discont
from . import dialyzer from . import dialyzer
from . import department from . import department
from . import education from . import education
@ -19,3 +29,6 @@ from . import nation
from . import race from . import race
from . import cause_chronic from . import cause_chronic
from . import clinic_round from . import clinic_round
from . import dialyzer_line
from . import import_payment
from . import file_sheet

View File

@ -16,16 +16,18 @@ class Dialyzer(Model):
"use_time": fields.Integer("Use Time"), "use_time": fields.Integer("Use Time"),
"max_use_time": fields.Integer("Max Use Time"), "max_use_time": fields.Integer("Max Use Time"),
"exp_date": fields.Date("Expiry Date",search=True), "exp_date": fields.Date("Expiry Date",search=True),
"patient_id": fields.Many2One("clinic.patient","Patient"),
"member_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"), "member_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"),
"dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Dialyzer Type"), "dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Dialyzer Type"),
"bid_flow_rate": fields.Integer("Bid Flow Rate (ml/min)",search=True), "bid_flow_rate": fields.Integer("Bid Flow Rate (ml/min)",search=True),
"ultrafittration": fields.Float("Ultrafittration Kg.",search=True), "ultrafittration": fields.Float("Ultrafittration Kg.",search=True),
"state": fields.Selection([("new","New"),("active","Active"),("drop","Drop"),('cancelled','Cancelled')],"Status"), "state": fields.Selection([("new","New"),("active","Active"),("drop","Drop"),("expire","Expire"),('cancelled','Cancelled')],"Status"),
"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"),
'product_id': fields.Many2One("product", "Product",required=True), 'product_id': fields.Many2One("product", "Product",required=True),
"pickings": fields.One2Many("stock.picking","related_id","Pickings"), "pickings": fields.One2Many("stock.picking","related_id","Pickings"),
"patient_id": fields.Many2One("clinic.patient","Patient"),
"visit_id": fields.Many2One("clinic.visit","Visit"),
"hd_case_id": fields.Many2One("clinic.hd.case","HD Case"),
} }
def _get_number(self,context={}): def _get_number(self,context={}):
@ -160,6 +162,10 @@ class Dialyzer(Model):
def renew(self,ids,context={}): def renew(self,ids,context={}):
obj=self.browse(ids[0]) obj=self.browse(ids[0])
# XXX
if obj.use_time > obj.max_use_time:
raise Exception("No long to use it (use time > max use time")
obj.cancel()
obj.write({"state": "new"}) obj.write({"state": "new"})
def drop(self,ids,context={}): def drop(self,ids,context={}):

View File

@ -0,0 +1,20 @@
from netforce.model import Model, fields
class DialyzerLine(Model):
_name="clinic.dialyzer.line"
_fields={
"hd_case_id": fields.Many2One("clinic.hd.case","HdCase",on_delete="cascade"),
"visit_id": fields.Many2One("clinic.visit","Visit",on_delete="cascade"),
"dialyzer_id": fields.Many2One("clinic.dialyzer","Dialzer",search=True),
"description": fields.Char("Description",search=True),
"use_time":fields.Integer("Use time"),
"max_use_time":fields.Integer("Max use time"),
"member_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Member Type"),
"dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Member Type"),
"bid_flow_rate": fields.Integer("Bid Flow Rate (ml/min)"),
"ultrafittration": fields.Float("Ultrafittration Kg."),
"state":fields.Selection([("draft","New"),("active","Active"),("drop","Drop")],"Status"),
}
DialyzerLine.register()

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

@ -0,0 +1,14 @@
from netforce.model import Model, fields
class FileSheet(Model):
_name="clinic.file.sheet"
_string="File Sheet"
_fields={
'name': fields.Char("Name"),
'index': fields.Integer("Index"),
"select": fields.Selection([("yes","Yes"),("no","No")],"Select"),
'imp_id': fields.Many2One("clinic.import.payment","Import Payment"),
}
FileSheet.register()

View File

@ -1,5 +1,5 @@
import time import time
from datetime import datetime from datetime import datetime, timedelta
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
@ -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
@ -17,7 +17,7 @@ class HDcase(Model):
res={} res={}
fmt="%Y-%m-%d %H:%M:%S" fmt="%Y-%m-%d %H:%M:%S"
for obj in self.browse(ids): for obj in self.browse(ids):
diff=datetime.strptime(obj.date_stop,fmt)-datetime.strptime(obj.date_start,fmt) diff=datetime.strptime(obj.time_stop,fmt)-datetime.strptime(obj.time_start,fmt)
total_time=round(diff.seconds/3600,2) total_time=round(diff.seconds/3600,2)
res[obj.id]=total_time res[obj.id]=total_time
return res return res
@ -42,7 +42,9 @@ class HDcase(Model):
"check_goverment_pay" : fields.Boolean("The Government Pay"), "check_goverment_pay" : fields.Boolean("The Government Pay"),
"check_personal_pay" : fields.Boolean("Pay yourself"), "check_personal_pay" : fields.Boolean("Pay yourself"),
"state": fields.Selection([("draft","Draft"),("confirmed","Confirmed"),("approved","Approved"),("cancelled","Cancelled"),("paid","Paid")],"Status",required=True), "state": fields.Selection([("draft","Draft"),("confirmed","Confirmed"),("approved","Approved"),("cancelled","Cancelled"),("paid","Paid")],"Status",required=True),
"dialyzers": fields.One2Many("clinic.hd.case.dialyzer","hd_case_id","Dializers"), "hct": fields.Integer("HCT %"),
"state": fields.Selection([("draft","Draft"),("in_progress","In Progress"),("completed","Completed"),("discountinued","Discountinued"),("uncompleted","Uncompleted")],"Status",required=True),
"dialyzers": fields.One2Many("clinic.dialyzer.line","hd_case_id","Dializers"),
"lines": fields.One2Many("clinic.hd.case.line","hd_case_id","Lines"), "lines": fields.One2Many("clinic.hd.case.line","hd_case_id","Lines"),
"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"),
@ -56,7 +58,13 @@ class HDcase(Model):
'visit_id': fields.Many2One("clinic.visit", "Visit"), 'visit_id': fields.Many2One("clinic.visit", "Visit"),
'total_time': fields.Integer("Total Time(Hrs)",function="get_hrs"), 'total_time': fields.Integer("Total Time(Hrs)",function="get_hrs"),
"fee_type": fields.Selection([("mg","Medical Government"),("sc","Social Security"),("nhso","NHSO (30฿)"),("personal","Personal"),("others","Others")],"Fee Type"), "fee_type": fields.Selection([("mg","Medical Government"),("sc","Social Security"),("nhso","NHSO (30฿)"),("personal","Personal"),("others","Others")],"Fee Type"),
'fee_partner_id': fields.Many2One("partner","Fee Contact"), 'fee_partner_id': fields.Many2One("partner","Contact Fee"),
'paid': fields.Boolean("Paid"),
"time_start": fields.DateTime("Time start",required=True,search=True),
"time_stop": fields.DateTime("Time stop",required=True,search=True),
"date": fields.Date("Date Treatment",required=True),
'planes': fields.One2Many("clinic.visit.plane","hd_case_id","Planning"),
'note': fields.Text("Note"),
} }
def _get_number(self,context={}): def _get_number(self,context={}):
@ -83,24 +91,25 @@ class HDcase(Model):
_defaults={ _defaults={
"state": "draft", "state": "draft",
"date_start": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"), "date": lambda *a: time.strftime("%Y-%m-%d"),
"date_stop": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"), "time_start": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
"time_stop": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
'nurse_id': _get_nurse, 'nurse_id': _get_nurse,
"number": _get_number, "number": _get_number,
"company_id": lambda *a: get_active_company(), "company_id": lambda *a: get_active_company(),
"fee": 1500, "fee": 1500,
} }
_order="date_start desc,number desc" _order="date desc,number desc"
def onchange_dialyzer(self,context={}): def onchange_dialyzer(self,context={}):
data=context["data"] data=context["data"]
path=context["path"] path=context["path"]
line=get_data_path(data,path,parent=True) line=get_data_path(data,path,parent=True)
dialyzer_id=line.get("dialzer_id") dialyzer_id=line.get("dialyzer_id")
if not dialyzer_id: if not dialyzer_id:
return {} return {}
dialyzer=get_model("clinic.dialyzer").browse(dialyzer_id) dialyzer=get_model("clinic.dialyzer").browse(dialyzer_id)
line["detail"]=dialyzer.detail line["description"]=dialyzer.description or ""
line["use_time"]=dialyzer.use_time line["use_time"]=dialyzer.use_time
line["max_use_time"]=dialyzer.max_use_time line["max_use_time"]=dialyzer.max_use_time
line["member_type"]=dialyzer.member_type line["member_type"]=dialyzer.member_type
@ -114,6 +123,7 @@ class HDcase(Model):
data=context['data'] data=context['data']
patient_id=data['patient_id'] patient_id=data['patient_id']
hd_cases=self.search_browse([['patient_id','=',patient_id]]) hd_cases=self.search_browse([['patient_id','=',patient_id]])
# TODO reset dialyzer
if hd_cases: if hd_cases:
hd_case=hd_cases[-1] hd_case=hd_cases[-1]
data['doctor_id']=hd_case.doctor_id.id data['doctor_id']=hd_case.doctor_id.id
@ -168,17 +178,18 @@ class HDcase(Model):
def make_invoices(self,ids,context={}): def make_invoices(self,ids,context={}):
setting=get_model("settings").browse(1) setting=get_model("settings").browse(1)
currency_id=setting.currency_id.id currency_id=setting.currency_id.id
#
account_receivable_id=setting.account_receivable_id.id account_receivable_id=setting.account_receivable_id.id
company_id=get_active_company() company_id=get_active_company()
uom=get_model("uom").search_browse([['name','ilike','%Unit%']]) uom=get_model("uom").search_browse([['name','ilike','%Unit%']])
if not uom: if not uom:
raise Exception("Unit not found in uom") raise Exception("Unit not found in uom")
obj=self.browse(ids[0]) obj=self.browse(ids[0])
due_date=obj.date_start[0:10] due_date=obj.date[0:10]
# XXX # XXX
context['type']='out' context['type']='out'
context['inv_type']='invoice' context['inv_type']='invoice'
if obj.lines: if obj.lines and obj.total:
# XXX need to split function prepare invoice # XXX need to split function prepare invoice
vals={ vals={
"type": "out", "type": "out",
@ -197,6 +208,9 @@ class HDcase(Model):
raise Exception("No contact for patient %s"%obj.patient_id.name) raise Exception("No contact for patient %s"%obj.patient_id.name)
vals["partner_id"]=partner.id vals["partner_id"]=partner.id
for line in obj.lines: for line in obj.lines:
account_id=line.product_id.sale_account_id.id or account_receivable_id
if not account_id:
raise Exception("%s not found account recievable %s"%partner.name)
line={ line={
"product_id": line.product_id.id, "product_id": line.product_id.id,
"description": line.description, "description": line.description,
@ -204,10 +218,12 @@ class HDcase(Model):
"uom_id": line.uom_id.id, "uom_id": line.uom_id.id,
"unit_price": line.price, "unit_price": line.price,
"amount": line.amount, "amount": line.amount,
'account_id': line.product_id.sale_account_id.id or account_receivable_id, 'account_id': account_id,
} }
vals['lines'].append(('create',line)) vals['lines'].append(('create',line))
inv_id=get_model("account.invoice").create(vals,context) inv_id=get_model("account.invoice").create(vals,context)
# create picking
obj.make_pickings()
if obj.fee: if obj.fee:
vals={ vals={
"type": "out", "type": "out",
@ -222,8 +238,13 @@ class HDcase(Model):
"company_id": company_id, "company_id": company_id,
} }
vals["partner_id"]=obj.fee_partner_id.id vals["partner_id"]=obj.fee_partner_id.id
if obj.fee_partner_id.account_payable_id: # XXX
account_receivable_id=obj.fee_partner_id.account_payable_id.id #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={ line={
"product_id": None, "product_id": None,
"description": "Fee", "description": "Fee",
@ -231,11 +252,69 @@ class HDcase(Model):
"uom_id": uom[0].id, "uom_id": uom[0].id,
"unit_price": obj.fee, "unit_price": obj.fee,
"amount": obj.fee, "amount": obj.fee,
'account_id': account_receivable_id, 'account_id': account_id,
} }
vals['lines'].append(('create',line)) vals['lines'].append(('create',line))
inv_id=get_model("account.invoice").create(vals,context) inv_id=get_model("account.invoice").create(vals,context)
def make_pickings(self,ids,context={}):
obj=self.browse(ids[0])
# no picking
if not obj.lines:
return
partner=obj.patient_id.partner_id
if not partner:
raise Exception("Contact not for this patient")
ship_address_id=None
for address in partner.addresses:
if address.type=="shipping":
ship_address_id=address.id
break
if not ship_address_id:
raise Exception("contact %s dont'have address with type shipping"%partner.name)
pick_vals={
"type": "out",
"ref": obj.number,
"related_id": "clinic.hd.case,%s"%obj.id,
"partner_id": obj.patient_id.partner_id.id,
"ship_address_id": ship_address_id,
"state": "draft",
"lines": [],
}
res=get_model("stock.location").search([["type","=","customer"]])
if not res:
raise Exception("Customer location not found")
cust_loc_id=res[0]
for line in obj.lines:
prod=line.product_id
if prod.type != 'stock':
continue
wh_loc_id=prod.location_id.id
if not wh_loc_id:
res=get_model("stock.location").search([["type","=","internal"]])
if not res:
raise Exception("Warehouse not found")
wh_loc_id=res[0]
line_vals={
"product_id": prod.id,
"qty": 1,
"uom_id": prod.uom_id.id,
"location_from_id": wh_loc_id,
"location_to_id": cust_loc_id,
}
pick_vals["lines"].append(("create",line_vals))
if not pick_vals["lines"]:
return {
"flash": "Nothing left to deliver",
}
picking_obj=get_model("stock.picking")
pick_id=picking_obj.create(pick_vals,context={"pick_type": "out"})
pick=picking_obj.browse(pick_id)
pick.set_done([pick_id])
def post_invoices(self,ids,context={}): def post_invoices(self,ids,context={}):
obj=self.browse(ids[0]) obj=self.browse(ids[0])
for inv in obj.invoices: for inv in obj.invoices:
@ -244,112 +323,30 @@ class HDcase(Model):
def confirm(self,ids,context={}): def confirm(self,ids,context={}):
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
obj.write({"state":"confirmed"}) obj.write({"state":"in_progress"})
def paid(self,ids,context={}): def discontinue(self,ids,context={}):
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
obj.write({"state":"paid"}) # TODO pop to note
obj.write({"state":"uncompleted"})
def approve(self,ids,context={}): def complete(self,ids,context={}):
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
obj.make_invoices() obj.make_invoices()
obj.post_invoices() obj.post_invoices()
obj.write({"state":"approved"}) obj.write({
"state":"completed",
#'paid': True,
})
return { return {
'next': { 'next': {
'name': 'clinic_hd_case', 'name': 'clinic_hd_case',
'mode': 'form', 'mode': 'form',
'active_id': obj.id, 'active_id': obj.id,
}, },
'flash': '%s has been approved'%obj.number, 'flash': '%s is completed'%obj.number,
} }
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={}): def journal_report(self,ids,context={}):
obj=self.browse(ids[0]) obj=self.browse(ids[0])
move_id = get_model("account.move").search([["narration","=",obj.number]]) move_id = get_model("account.move").search([["narration","=",obj.number]])
@ -402,4 +399,106 @@ class HDcase(Model):
data['fee']=0.0 data['fee']=0.0
return data return data
def new_visit(self,ids,context={}):
obj=self.browse(ids[0])
skip_plan_id=0
plane=None
for plane in obj.planes:
if plane.state=='close':
continue
break
# XXX
if not plane or plane.state=='close':
raise Exception("No Planing")
print("found plane ",plane)
vals={
'date_visit': plane.date,
'time_start': plane.time_start,
'time_stop': plane.time_stop,
'patient_id': obj.patient_id.id,
'doctor_id': obj.doctor_id.id,
'nurse_id': obj.nurse_id.id,
'department_id': obj.department_id.id,
'planes': [],
'dialyzers': [],
#'state': 'waiting_treatment',
'state': 'draft', # XXX need to gen new doc
}
plane.write({
'state': 'close',
})
visit_id=get_model("clinic.visit").create(vals)
visit=get_model('clinic.visit').browse(visit_id)
skip_plan_id=plane.id
# copy remaining plane to new visit
new_planes=[]
for pl in obj.planes:
# XXX
if skip_plan_id==pl.id:
continue
if pl.state=='close':
continue
print("pl state ", pl.state)
line={
'date': pl.date,
'time_start': pl.time_start,
'time_stop': pl.time_stop,
'visit_id': visit_id,
}
new_planes.append(('create',line))
new_dialyzers=[]
for dlz in obj.dialyzers:
if dlz.use_time > dlz.dialyzer_id.max_use_time:
continue
use_time=(dlz.use_time or 0)+1
line={
"visit_id": visit_id,
"dialyzer_id": dlz.dialyzer_id.id,
"description": dlz.description,
"use_time": use_time,
"max_use_time": dlz.max_use_time,
"member_type": dlz.member_type,
"dialyzer_type": dlz.dialyzer_type,
"bid_flow_rate": dlz.bid_flow_rate,
"ultrafittration": dlz.ultrafittration,
}
new_dialyzers.append(('create',line))
vals={
'planes': new_planes,
'dialyzers': new_dialyzers,
}
visit.write(vals)
return {
'next': {
'name': "clinic_visit",
'mode': 'form',
'active_id': visit_id,
},
'flash': "New visit is created",
}
def onchange_dateplane(self,context={}):
data=context["data"]
path=context["path"]
line=get_data_path(data,path,parent=True)
start_date=line.get("date")
if not start_date:
return {}
timenow=time.strftime("%H:%M:%S")
timevisit=timenow
# XXX
timevisit=data['time_start'][11:20]
fmt_date="%Y-%m-%d %H:%M:%S"
fix_hrs=data['total_time'] or 0 # XXX
time_start=datetime.strptime("%s %s"%(start_date,timevisit),fmt_date)
seconds=fix_hrs*3600
time_stop=time_start+timedelta(seconds=seconds)
line['time_start']=time_start.strftime(fmt_date)
line['time_stop']=time_stop.strftime(fmt_date)
if not line.get('state'):
line['state']='open'
return data
HDcase.register() HDcase.register()

View File

@ -8,10 +8,10 @@ class HdcaseDialyzer(Model):
"description": fields.Char("Description",search=True), "description": fields.Char("Description",search=True),
"use_time":fields.Integer("Use time"), "use_time":fields.Integer("Use time"),
"max_use_time":fields.Integer("Max use time"), "max_use_time":fields.Integer("Max use time"),
"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"),
"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")],"Member Type"),
"bid_flow_rate": fields.Integer("Bid Flow Rate (ml/min)",required=True,search=True), "bid_flow_rate": fields.Integer("Bid Flow Rate (ml/min)"),
"ultrafittration": fields.Float("Ultrafittration Kg.",required=True,search=True), "ultrafittration": fields.Float("Ultrafittration Kg."),
"state":fields.Selection([("draft","New"),("active","Active"),("drop","Drop")],"Status"), "state":fields.Selection([("draft","New"),("active","Active"),("drop","Drop")],"Status"),
} }

View File

@ -0,0 +1,39 @@
from netforce.model import Model, fields, get_model
class HDCaseDiscont(Model):
_name="clinic.hd.case.discont"
_transient=True
_fields={
"hd_case_id": fields.Many2One("clinic.hd.case","HdCase",required=True,on_delete="cascade"),
"note": fields.Text("Description"),
}
def _get_hd_case_id(self,context={}):
hd_case_id=context.get("refer_id")
if not hd_case_id:
return None
return int(hd_case_id)
_defaults={
'hd_case_id': _get_hd_case_id,
}
def do_discontinue(self,ids,context):
obj=self.browse(ids)[0]
hd_case=get_model("clinic.hd.case").browse(obj.hd_case_id.id)
hd_case.write({
'note': obj.note,
'state': 'uncompleted',
})
return {
'next': {
'name': 'clinic_hd_case',
'mode': 'form',
'active_id': hd_case.id,
},
'flash': '%s has been cancelled'%hd_case.number,
}
HDCaseDiscont.register()

View File

@ -0,0 +1,423 @@
import re
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
from netforce.database import get_connection
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"),
"type": fields.Selection([("mg","Medical Government"),("sc","Social Security"),("nhso","NHSO (30฿)")],"Type"),
'date_import': fields.DateTime("Date"),
'file': fields.File("File"),
'sheets': fields.One2Many("clinic.file.sheet","imp_id", "Sheets"),
'mg_payment_id': fields.Many2One("account.payment","Payment"),
'mg_move_id': fields.Many2One("account.move","Journal Entry"),
'sc_payment_id': fields.Many2One("account.payment","Payment"),
'sc_move_id': fields.Many2One("account.move","Journal Entry"),
'nhso_payment_id': fields.Many2One("account.payment","Payment"),
'nhso_move_id': fields.Many2One("account.move","Journal Entry"),
"state": fields.Selection([("draft","Draft"),("success","Succes"),("fail","Fail"),('close','Close')],"Status"),
'note': fields.Text("Note"),
'partner_id': fields.Many2One("partner","Contact"),
}
_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',
'type': 'mg',
}
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))
def load_sheet(self,ids,context={}):
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)
sheets=wb.sheet_names()
index=0
# XXX clear old sheet
for sheet in obj.sheets:
sheet.delete()
vals={
'sheets': [],
}
for sheet in sheets:
line={
'index': index,
'name': sheet,
}
vals["sheets"].append(("create",line))
#vals['state']='sheet_loaded'
obj.write(vals)
return {
'next': {
'name': "clinic_import_payment",
'mode': 'form',
'active_id': obj.id,
},
'flash': "Load sheet successfully",
}
def onchange_sheet(self,context={}):
data=context["data"]
path=context["path"]
line=get_data_path(data,path,parent=True)
for sheet in data['sheets']:
if sheet['name']!=line['name']:
sheet['select']=None
return data
def onchange_file(self,context={}):
data=context['data']
data['sheets']=[]
print("data ", data)
return data
def clear_sheet(self,ids,context={}):
obj=self.browse(ids)[0]
for sheet in obj.sheets:
sheet.delete()
return {
'next': {
'name': 'clinic_import_payment',
'mode': 'form',
'active_id': obj.id,
},
'flash': "Clear Sheet OK",
}
def find_invoice(self,ids,context={}):
# return invoice line
obj=self.browse(ids[0])
partner_id=None
setting=get_model("clinic.setting").browse(1)
if obj.type=='sc':
partner_id=setting.sc_partner_id.id
elif obj.type=='mg':
partner_id=setting.mg_partner_id.id
elif obj.type=='nhso':
partner_id=setting.nhso_partner_id.id
if not partner_id:
raise Exception("No partner")
# XXX
if obj.payment_lines:
for line in obj.payment_lines:
line.delete()
dom=[]
dom.append(['state','=','waiting_payment'])
dom.append(['partner_id','=',partner_id])
invoice_lines=[]
for invoice in get_model("account.invoice").search_browse(dom):
print(invoice)
line={
'invoice_id': invoice.id,
'amount': invoice.amount_total,
}
#invoice_lines.append(('create',line))
invoice_lines.append(('create',line))
return invoice_lines
def make_payment(self,ids,context={}):
obj=self.browse(ids[0])
company_id=get_active_company()
timenow=time.strftime("%Y-%m-%d")
setting=get_model("clinic.setting").browse(1)
account_id=None
partner_id=None
if obj.type=='sc':
account_id=setting.ar_sc_id.id
partner_id=setting.sc_partner_id.id
elif obj.type=='mg':
account_id=setting.ar_mg_id.id
partner_id=setting.mg_partner_id.id
elif obj.type=='nhso':
account_id=setting.ar_nhso_id.id
partner_id=setting.nhso_partner_id.id
vals={
"partner_id": partner_id,
"company_id": company_id,
"type": "in",
"pay_type": "invoice",
"date": timenow,
"account_id": account_id,
'lines': [], # TODO find invoice matching
}
#db=get_connection()
if obj.type=='sc':
if not obj.sc_payment_id:
payment_id=get_model("account.payment").create(vals,context={'type': 'in'})
obj.write({
'sc_payment_id': payment_id,
})
## XX
#sql="update clinic_import_payment set sc_payment_id=%s where id = %s" % (payment_id,obj.id)
#import pdb; pdb.set_trace()
#db.query(sql)
#db.commit()
invoice_lines=obj.find_invoice()
print("="*30)
for line in invoice_lines:
print(line)
print("="*30)
# TODO update payment
# remove invoice, udpate invoice
if invoice_lines:
if obj.sc_payment_id.invoice_lines:
# clear old invoice lines
for line in obj.sc_payment_id.invoice_lines:
line.delete()
# update new
obj.sc_payment_id.write({
'invoice_lines': invoice_lines,
})
elif obj.type=='mg':
if not obj.mg_payment_id:
payment_id=get_model("account.payment").create(vals,context={'type': 'in'})
obj.write({
'mg_payment_id': payment_id,
})
invoice_lines=obj.find_invoice()
print("="*30)
for line in invoice_lines:
print(line)
print("="*30)
if invoice_lines:
# clear old invoice lines
if obj.mg_payment_id.invoice_lines:
for line in obj.mg_payment_id.invoice_lines:
line.delete()
# update new
obj.mg_payment_id.write({
'invoice_lines': invoice_lines,
})
elif obj.type=='nhso':
if not obj.nhso_payment_id:
payment_id=get_model("account.payment").create(vals,context={'type': 'in'})
obj.write({
'nhso_payment_id': payment_id,
})
invoice_lines=obj.find_invoice()
if invoice_lines:
# clear old invoice lines
if obj.nhso_payment_id.invoice_lines:
for line in obj.nhso_payment_id.invoice_lines:
line.delete()
# update new
obj.nhso_payment_id.write({
'invoice_lines': invoice_lines,
})
def import_payment(self,ids,context={}):
obj=self.browse(ids)[0]
obj.make_payment()
return {
'next': {
'name': 'clinic_import_payment',
'mode': 'form',
'active_id': obj.id,
},
'flash': 'Import Payment OK',
}
def post_mg(self,ids,context={}):
obj=self.browse(ids)[0]
payment_id=obj.mg_payment_id
if not payment_id:
raise Exception("Payment not create yet.")
if payment_id.state=='posted':
raise Exception("%s has been posted."%payment_id.number)
payment_id.post()
# XXX
db=get_connection()
res=db.query("select move_id from account_payment where id =%s"%payment_id.id)
if res:
move_id=res[0]['move_id']
obj.write({
'mg_move_id': move_id,
})
return {
'next': {
'name': 'clinic_import_payment',
'mode': 'form',
'active_id': obj.id,
},
'flash': "%s has been posted"%payment_id.number,
}
pass
def undo_mg(self,ids,context={}):
obj=self.browse(ids)[0]
move_id=obj.mg_move_id
payment_id=obj.mg_payment_id
if not move_id:
raise Exception("%s is not post yet"%(payment_id.number or "Payment"))
payment_id.to_draft()
obj.write({
'mg_move_id': None,
})
return {
'next': {
'name': 'clinic_import_payment',
'mode': 'form',
'active_id': obj.id,
},
'flash': "Undo OK",
}
pass
def post_sc(self,ids,context={}):
obj=self.browse(ids)[0]
payment_id=obj.sc_payment_id
if not payment_id:
raise Exception("Payment not create yet.")
if payment_id.state=='posted':
raise Exception("%s has been posted."%payment_id.number)
payment_id.post()
# XXX
db=get_connection()
res=db.query("select move_id from account_payment where id =%s"%payment_id.id)
if res:
move_id=res[0]['move_id']
obj.write({
'sc_move_id': move_id,
})
return {
'next': {
'name': 'clinic_import_payment',
'mode': 'form',
'active_id': obj.id,
},
'flash': "%s has been posted"%payment_id.number,
}
def undo_sc(self,ids,context={}):
obj=self.browse(ids)[0]
move_id=obj.sc_move_id
payment_id=obj.sc_payment_id
if not move_id:
raise Exception("%s is not post yet"%(payment_id.number or "Payment"))
payment_id.to_draft()
obj.write({
'sc_move_id': None,
})
return {
'next': {
'name': 'clinic_import_payment',
'mode': 'form',
'active_id': obj.id,
},
'flash': "Undo OK",
}
def post_nhso(self,ids,context={}):
obj=self.browse(ids)[0]
payment_id=obj.nhso_payment_id
if not payment_id:
raise Exception("Payment not create yet.")
if payment_id.state=='posted':
raise Exception("%s has been posted."%payment_id.number)
payment_id.post()
# XXX
db=get_connection()
res=db.query("select move_id from account_payment where id =%s"%payment_id.id)
if res:
move_id=res[0]['move_id']
obj.write({
'nhso_move_id': move_id,
})
return {
'next': {
'name': 'clinic_import_payment',
'mode': 'form',
'active_id': obj.id,
},
'flash': "%s has been posted"%payment_id.number,
}
pass
def undo_nhso(self,ids,context={}):
obj=self.browse(ids)[0]
move_id=obj.nhso_move_id
payment_id=obj.nhso_payment_id
if not move_id:
raise Exception("%s is not post yet"%(payment_id.number or "Payment"))
payment_id.to_draft()
obj.write({
'nhso_move_id': None,
})
return {
'next': {
'name': 'clinic_import_payment',
'mode': 'form',
'active_id': obj.id,
},
'flash': "Undo OK",
}
pass
def close(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({'state': 'close'})
def to_draft(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({'state': 'draft'})
def onchange_type(self,context={}):
data=context['data']
# find partner and set to partner_id
return data
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

@ -31,6 +31,7 @@ class Patient(Model):
_fields={ _fields={
"type": fields.Selection([("mg","Medical Government"),("sc","Social Security"),("nhso","NHSO (30฿)"),("personal","Personal"),("others","Others")],"Patient Type",required=True), "type": fields.Selection([("mg","Medical Government"),("sc","Social Security"),("nhso","NHSO (30฿)"),("personal","Personal"),("others","Others")],"Patient Type",required=True),
"number": fields.Char("Patient No.",required=True,search=True), "number": fields.Char("Patient No.",required=True,search=True),
"hn": fields.Char("HN",search=True),
"name": fields.Char("Name",required=True,search=True), "name": fields.Char("Name",required=True,search=True),
"reg_date": fields.Date("Register Date",required=False,search=True), "reg_date": fields.Date("Register Date",required=False,search=True),
"birthday": fields.Date("Birthday",required=False,search=True), "birthday": fields.Date("Birthday",required=False,search=True),
@ -75,6 +76,7 @@ class Patient(Model):
"hd_cases": fields.One2Many("clinic.hd.case","patient_id","HD Cases"), "hd_cases": fields.One2Many("clinic.hd.case","patient_id","HD Cases"),
"partner_id": fields.Many2One("partner","Contact"), "partner_id": fields.Many2One("partner","Contact"),
"dialyzers": fields.One2Many("clinic.dialyzer","patient_id","Dialyzers"), "dialyzers": fields.One2Many("clinic.dialyzer","patient_id","Dialyzers"),
'schedules': fields.Many2Many("clinic.schedule","Schedule"),
} }
def _get_number(self,context={}): def _get_number(self,context={}):
@ -91,11 +93,16 @@ class Patient(Model):
return num return num
get_model("sequence").increment_number(seq_id,context=context) get_model("sequence").increment_number(seq_id,context=context)
def _get_cause_line(self,context={}):
cause_ids=get_model("clinic.cause.chronic").search([])
return cause_ids
_defaults={ _defaults={
"type": "mg", "type": "mg",
"reg_date": lambda *a: time.strftime("%Y-%m-%d"), "reg_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(),
#'cause_lines': _get_cause_line,
} }
_order="date desc,number desc" _order="date desc,number desc"

View File

@ -0,0 +1,15 @@
import time
from netforce.model import Model, fields
class PatientSchedule(Model):
_name="clinic.patient.schedule"
_string="Patient Schedule"
_fields={
"patient_id": fields.Many2One("clinic.patient","Patient",required=True,on_delete="cascade"),
}
_defaults={
}
PatientSchedule.register()

View File

@ -0,0 +1,13 @@
from netforce.model import Model, fields
class Schedule(Model):
_name="clinic.schedule"
_string="Schedule"
_fields={
'name': fields.Char("Name"),
'code': fields.Char("Code"),
'patients': fields.Many2Many("clinic.patient","Patients"),
}
Schedule.register()

View File

@ -3,6 +3,7 @@ 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, set_active_user from netforce.access import get_active_company, get_active_user, set_active_user
from netforce.utils import get_data_path
class Visit(Model): class Visit(Model):
_name="clinic.visit" _name="clinic.visit"
@ -10,18 +11,38 @@ 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={}
#oneday=datetime.timedelta(days=1)
#yesterday=datetime.datetime.now()-oneday
datenow=time.strftime("%Y-%m-%d")
for obj in self.browse(ids):
late=0
if datenow > obj.date_visit 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),
"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),
"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("Fix Hour"),
'late_visit': fields.Integer("Late Vist",function="_get_visit_late"),
"dialyzers": fields.One2Many("clinic.dialyzer.line","visit_id","Dialyzers"),
"date_visit": fields.Date("Visit Date",required=True,search=True),
"time_start": fields.DateTime("Time Start"),
"time_stop": fields.DateTime("Time Stop"),
'planes': fields.One2Many("clinic.visit.plane","visit_id","Planning"),
'hd_cases': fields.One2Many('clinic.hd.case','visit_id',"HD Cases",readonly=True),
} }
def _get_number(self,context={}): def _get_number(self,context={}):
@ -46,44 +67,72 @@ class Visit(Model):
return nurse_ids[0] return nurse_ids[0]
return None return None
def _get_time_start(self,context={}):
now=datetime.datetime.now()
starttime=now.strftime("%Y-%m-%d %H:%M:%S")
return starttime
def _get_time_stop(self,context={}):
hr=datetime.timedelta(seconds=3600)
now=datetime.datetime.now()
stoptime=(now+hr).strftime("%Y-%m-%d %H:%M:%S")
return stoptime
_defaults={ _defaults={
"state": "pending", "state": "draft",
"cycle": "1", "cycle": "1",
'visit_date': time.strftime("%Y-%m-%d"), 'date_visit': lambda *a: time.strftime("%Y-%m-%d"),
"number": _get_number, 'time_start': _get_time_start,
'time_stop': _get_time_stop,
"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="date,cycle" _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" datenow=dt.now().strftime("%Y-%m-%d")
timenow=dt.now().strftime("%H:%M:%S")
date_from=dt.strptime("%s %s"%(obj.visit_date,timenow),fmt_date) obj=self.browse(ids)[0]
seconds=(obj.time_use or 1)*3600 # cannot treatment if current date is not same visit date
date_to=date_from+datetime.timedelta(seconds=seconds) if obj.date_visit!=datenow:
date_to=date_to.strftime(fmt_date) raise Exception("Today is not treament date!")
date_from=date_from.strftime(fmt_date) if not obj.dialyzers:
raise Exception("Please select dialyzer!")
if len(obj.dialyzers)>1:
raise Exception("Can select only 1 dialyzer!")
include_fee=obj.patient_id.type in ('mg','sc','nhso') and True or False include_fee=obj.patient_id.type in ('mg','sc','nhso') and True or False
vals={ vals={
'patient_id': obj.patient_id.id, 'patient_id': obj.patient_id.id,
'doctor_id': obj.doctor_id.id, 'doctor_id': obj.doctor_id.id,
'nurse_id': obj.nurse_id.id, 'nurse_id': obj.nurse_id.id,
'department_id': obj.department_id.id, 'department_id': obj.department_id.id,
'date_start': date_from, 'time_start': obj.time_start,
'date_stop': date_to, 'time_stop': obj.time_stop,
'visit_id': obj.id, 'visit_id': obj.id,
'fee': include_fee and 1500.00 or 0.0, 'fee': include_fee and 1500.00 or 0.0,
'fee_type': obj.patient_id.type, 'fee_type': obj.patient_id.type,
'lines':[], 'lines':[],
'dialyzers': [], 'dialyzers': [],
'state': 'in_progress',
} }
patient_type={ patient_type={
@ -107,20 +156,21 @@ class Visit(Model):
break break
# find dialyser # find dialyser
for dlz in get_model("clinic.dialyzer").search_browse([['patient_id','=',obj.patient_id.id],['state','=','active']]): if not obj.dialyzers:
vals['dialyzers'].append({ raise Exception("%s don't have dialyzer for treatment yet" % obj.patient_id.name)
"dialzer_id": dlz.id, hd_case_id=hd_case_obj.create(vals)
"description": dlz.description, for dlz in obj.dialyzers:
"use_time": dlz.use_time, # TODO check max time and expire day also
"max_use_time": dlz.max_use_time, dlz.dialyzer_id.write({'use_time': dlz.use_time}) # count use time
"member_type": dlz.member_type, dlz.write({
"dialyzer_type": dlz.dialyzer_type, 'hd_case_id': hd_case_id,
"bid_flow_rate": dlz.bid_flow_rate,
"ultrafittration": dlz.ultrafittration,
}) })
hd_case_id=hd_case_id=hd_case_obj.create(vals) for plan in obj.planes:
obj.write({"state":"confirmed"}) plan.write({
'hd_case_id': hd_case_id,
})
obj.write({"state":"treatment"})
return { return {
'next': { 'next': {
'name': 'clinic_hd_case', 'name': 'clinic_hd_case',
@ -130,24 +180,29 @@ class Visit(Model):
'flash': 'Visit %s has been confirmed'%obj.number, 'flash': 'Visit %s has been confirmed'%obj.number,
} }
def cancel(self,ids,context={}): def discard(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={}): 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']
patient_id=data['patient_id'] patient_id=data['patient_id']
visits=self.search_browse([['patient_id','=',patient_id]]) visits=self.search_browse([['patient_id','=',patient_id]],order="number desc")
if visits: if visits:
visit=visits[-1] #print([(v.id, v.date_visit,v.cycle) for v in visits])
visit=visits[0]
data['doctor_id']=visit.doctor_id.id data['doctor_id']=visit.doctor_id.id
data['department_id']=visit.department_id.id data['department_id']=visit.department_id.id
cycle=int(visit.cycle)+1
data['cycle']=str(cycle)
if cycle>4:
data['cycle']='1'
else: else:
data['patient_id']=None data['doctor_id']=None
data['department_id']=None data['department_id']=None
return data return data
@ -159,6 +214,14 @@ class Visit(Model):
'nurse_id': obj.nurse_id.id, 'nurse_id': obj.nurse_id.id,
'department_id': obj.department_id.id, 'department_id': obj.department_id.id,
} }
# XXX update cycle
visits=self.search_browse([['patient_id','=',obj.patient_id.id]],order="number desc")
if visits:
visit=visits[0] # order desc already
cycle=int(visit.cycle)+1
vals['cycle']=str(cycle)
if cycle>4:
vals['cycle']='1'
new_id=self.create(vals,context=context) new_id=self.create(vals,context=context)
new_obj=self.browse(new_id) new_obj=self.browse(new_id)
return { return {
@ -182,4 +245,107 @@ class Visit(Model):
} }
return data return data
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)
def get_data(self,context={}):
ref_id=context.get("refer_id")
if not ref_id:
return {}
ref_id=int(ref_id)
obj=self.browse(ref_id)
cycle_list={'1': 'One','2': 'Two','3': 'Tree','4': 'Four'}
data={
'number': obj.number,
'date_visit': obj.date_visit,
'department_name': obj.department_id.name or "",
'patient_name': obj.patient_id.name or "",
'doctor_name': obj.doctor_id.name or "",
'nurse_name': obj.nurse_id.name or "",
'cycle': cycle_list.get(obj.cycle,""),
'print_date': time.strftime("%d/%m/%Y"),
}
return data
def onchange_dialyzer(self,context={}):
data=context["data"]
path=context["path"]
line=get_data_path(data,path,parent=True)
dialyzer_id=line.get("dialyzer_id")
if not dialyzer_id:
return {}
dialyzer=get_model("clinic.dialyzer").browse(dialyzer_id)
use_time=dialyzer.use_time or 0
use_time+=1
line["description"]=dialyzer.description or ""
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
line["bid_flow_rate"]=dialyzer.bid_flow_rate
line["ultrafittration"]=dialyzer.ultrafittration
line["state"]=dialyzer.state
return data
def onchange_timeuse(self,context={}):
data=context["data"]
time_start=data['time_start']
fmt_date="%Y-%m-%d %H:%M:%S"
time_start=datetime.datetime.strptime(time_start,fmt_date)
time_use=data['time_use']
seconds=(time_use or 1)*3600
time_stop=time_start+datetime.timedelta(seconds=seconds)
data['time_stop']=time_stop.strftime(fmt_date)
return data
def onchange_date_visit(self,context={}):
data=context["data"]
timenow=time.strftime("%H:%M:%S")
date_visit=data['date_visit']
fmt_date="%Y-%m-%d %H:%M:%S"
time_start=datetime.datetime.strptime("%s %s"%(date_visit,timenow),fmt_date)
print("time_start ", time_start)
time_use=data['time_use']
seconds=(time_use or 1)*3600
time_stop=time_start+datetime.timedelta(seconds=seconds)
data['time_start']=time_start.strftime(fmt_date)
data['time_stop']=time_stop.strftime(fmt_date)
return data
def onchange_dateplane(self,context={}):
data=context["data"]
path=context["path"]
line=get_data_path(data,path,parent=True)
start_date=line.get("date")
if not start_date:
return {}
timenow=time.strftime("%H:%M:%S")
timevisit=timenow
# XXX
timevisit=data['time_start'][11:20]
if not timevisit:
timevisit=timenow
fmt_date="%Y-%m-%d %H:%M:%S"
fix_hrs=data['time_use'] or 0
time_start=datetime.datetime.strptime("%s %s"%(start_date,timevisit),fmt_date)
seconds=fix_hrs*3600
time_stop=time_start+datetime.timedelta(seconds=seconds)
line['time_start']=time_start.strftime(fmt_date)
line['time_stop']=time_stop.strftime(fmt_date)
if not line.get('state'):
line['state']='open'
return data
def create_dialyzer(self,ids,context={}):
return {
'next': {
'name': 'clinic_dialyzer',
'mode': 'form',
},
}
Visit.register() Visit.register()

View File

@ -0,0 +1,22 @@
from netforce.model import Model, fields
class VisitPlane(Model):
_name="clinic.visit.plane"
_string="Visit Plan"
_fieldname="visit_id"
_fields={
'visit_id': fields.Many2One("clinic.visit","Visit"),
'hd_case_id': fields.Many2One("clinic.hd.case","HD Case"),
"date": fields.Date("Date"),
"time_start": fields.DateTime("Time Start"),
"time_stop": fields.DateTime("Time Stop"),
"state": fields.Selection([("open","Open"),("close","Close")],"Status"),
'active': fields.Boolean("Active"), # to hide
}
_defaults={
'state': 'open',
'active': True,
}
VisitPlane.register()

Binary file not shown.

View File

@ -1,3 +1,102 @@
===== todo
monday:
- A, B, C, D
tueday:
========
Account Receivable -> invoice
find account id
1. partner
2. product line
3. settings
Account Payable -> payment
!!! import data
- remove payment
set account payable
issue:
date of visit is not copy after click from calendar
======
!!! this night
- import payment
setting account
- debit
- credit
patient
- type
-nhso สปสช
- center office of healthcare information
- sc ประักนสังคม
- mg
task
1. find invoice
2. match invoice
- date, number for patient (HN)
3. if have invoice create payment if not review input data again
4. post payment to journal
===========================
- 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
- one2many
- visit
-> split date and time ->ok
-> state
- draft
- confirmed
- should select dialyzer before treament
- buttons -> ok
- confirm
- state : draft -> waiting treatment
- do treatment
- state : waiting treatment ->
- cancel visit -> ok
- print visit -> ok
- treament
- visit planing
- find visit of patient which state is close
- print invoice
- pay for normal person
-> how ???
- make payment
- time start/stop -> ok
- only time
- date treament ->ok
- color (check state)
- if fail -> red
- cancelled
- make next appointment -> ok
- state
- ready to treatment
- paid -> no because not realte to accounting
- many2one for dializer
- list show percent of progress bar
- plaining visit !!!
- select next day to visit
- copy data to visit
- after click complete
- day [monday, tueday, wedsday, thursday, friday]
- time
- dialyzer
- import payment
- import
- create payment with invoice that found
- post
- undo
=======
sequence (support multi company) -> ok sequence (support multi company) -> ok
- visit - visit
- hd case - hd case
@ -11,4 +110,29 @@ question?
- how cycle running? - how cycle running?
- treatment - treatment
- 1 cycle take how long ? - 1 cycle take how long ?
issue:
hd case should link only 1 dialyzer -> should not copy 2 time
create journal entry
-> ok
sunday
todo:
- need to close all issue:
https://docs.google.com/spreadsheets/d/1GDl9vCswHlD1MMfVwRS504keIz9NYL8VhUZlSPDEJvk/edit?usp=drive_web
payment
- personal
- government
set visible for each staus
======= import data
- flow
1. select sheet
2. select columns
3. load data -> load payment
4. review data -> review payment
5. import data -> post payment
6. done
- issue
load excel is very slow