rm PATIENT_TYPE
parent
7054fcc183
commit
43494a02f1
|
@ -2,6 +2,7 @@
|
|||
<field name="string">Patients</field>
|
||||
<field name="view_cls">multi_view</field>
|
||||
<field name="model">clinic.patient</field>
|
||||
<field name="tabs">[["All",[]],["Archived",[["active","=","False"]]],["Social Security",[["type","=","sc"]]],["UC",[["type","=","uc"]]],["Others",[["type","=","others"]]]]</field>
|
||||
<!--<field name="tabs">[["All",[]],["Archived",[["active","=","False"]]],["Social Security",[["type","=","sc"]]],["UC",[["type","=","uc"]]],["Others",[["type","=","others"]]]]</field>-->
|
||||
<field name="tabs">[["All",[]],["Archived",[["active","=","False"]]]]</field>
|
||||
<field name="menu">clinic_menu</field>
|
||||
</action>
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<action>
|
||||
<field name="string">Patient Type</field>
|
||||
<field name="view_cls">multi_view</field>
|
||||
<field name="model">clinic.patient.type</field>
|
||||
<field name="menu">clinic_menu</field>
|
||||
</action>
|
|
@ -0,0 +1,6 @@
|
|||
<action>
|
||||
<field name="string">Vascular Access</field>
|
||||
<field name="view_cls">multi_view</field>
|
||||
<field name="model">clinic.vascular.access</field>
|
||||
<field name="menu">clinic_menu</field>
|
||||
</action>
|
|
@ -0,0 +1,6 @@
|
|||
<action>
|
||||
<field name="view_cls">form_view</field>
|
||||
<field name="model">clinic.import.hd.case</field>
|
||||
<field name="view_xml">import_clinic_hd_case</field>
|
||||
<field name="menu">clinic_menu</field>
|
||||
</action>
|
|
@ -1,6 +0,0 @@
|
|||
<action>
|
||||
<field name="view_cls">form_view</field>
|
||||
<field name="model">clinic.import.payment</field>
|
||||
<field name="view_xml">import_clinic_mg</field>
|
||||
<field name="menu">account_menu</field>
|
||||
</action>
|
|
@ -0,0 +1,6 @@
|
|||
<action>
|
||||
<field name="view_cls">form_view</field>
|
||||
<field name="model">clinic.import.patient</field>
|
||||
<field name="view_xml">import_clinic_patient</field>
|
||||
<field name="menu">clinic_menu</field>
|
||||
</action>
|
|
@ -0,0 +1,6 @@
|
|||
<action>
|
||||
<field name="view_cls">form_view</field>
|
||||
<field name="model">clinic.import.visit</field>
|
||||
<field name="view_xml">import_clinic_visit</field>
|
||||
<field name="menu">clinic_menu</field>
|
||||
</action>
|
|
@ -1,9 +1,9 @@
|
|||
<form model="clinic.gen.visit">
|
||||
<group form_layout="stacked">
|
||||
<field name="date_from" span="2"/>
|
||||
<field name="time_start" span="1"/>
|
||||
<field name="time_start" span="2"/>
|
||||
<field name="date_to" span="2"/>
|
||||
<field name="time_stop" span="1"/>
|
||||
<field name="time_stop" span="2"/>
|
||||
<field name="cycle_id" onchange="onchange_cycle" span="2"/>
|
||||
<field name="patient_categ_id" span="2"/>
|
||||
<field name="patient_type" span="2"/>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<field name="state"/>
|
||||
<button string="Options" dropdown="1">
|
||||
<item string="New Dialyzer" method="new_dialyzer" states="draft,waiting_treatment"/>
|
||||
<item string="To Draft" method="to_draft" states="in_progress,completed"/>
|
||||
<item string="To Draft" method="to_draft" states="waiting_treatment,in_progress,completed"/>
|
||||
</button>
|
||||
</head>
|
||||
<group form_layout="stacked">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<list model="clinic.hd.case" colors='{"#cfc":[["state","=","completed"]],"#f9e37d":[["state","=","in_progress"]],"#bcbbb9":[["state","=","cancelled"]],"#ACD1E9":[["state","=","waiting_payment"]]}'>
|
||||
<field name="number"/>
|
||||
<field name="ref"/>
|
||||
<!--<field name="ref"/>-->
|
||||
<field name="date"/>
|
||||
<field name="cycle_id"/>
|
||||
<field name="patient_id"/>
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
<item string="Dialyzers" action="clinic_dialyzer"/>
|
||||
<divider/>
|
||||
<header string="SETTINGS"/>
|
||||
<item string="Type" action="clinic_patient_type"/>
|
||||
<item string="Categories" action="clinic_patient_categ"/>
|
||||
<item string="Cause Chronics" action="clinic_cause_chronic"/>
|
||||
<item string="Comorbidities" action="clinic_comorbidity"/>
|
||||
|
@ -55,7 +56,13 @@
|
|||
<item string="Branch" action="clinic_branch"/>
|
||||
<item string="Departments" action="clinic_department"/>
|
||||
<item string="Nationalities" action="clinic_nation"/>
|
||||
<item string="Period" action="clinic_period"/>
|
||||
<!--<item string="Period" action="clinic_period"/>-->
|
||||
<item string="Valcular Access" action="clinic_vascular_access"/>
|
||||
<item string="Clinic Settings" action="clinic_setting"/>
|
||||
<divider/>
|
||||
<header string="IMPORT"/>
|
||||
<item string="Import Patient" action="import_clinic_patient"/>
|
||||
<item string="Import Visit" action="import_clinic_visit"/>
|
||||
<item string="Import HD Case" action="import_clinic_hd_case"/>
|
||||
</item>
|
||||
</menu>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
</button>
|
||||
</head>
|
||||
<field name="number"/>
|
||||
<field name="type"/>
|
||||
<field name="type_id"/>
|
||||
<field name="name"/>
|
||||
<field name="hn"/>
|
||||
<field name="reg_date"/>
|
||||
|
@ -96,7 +96,6 @@
|
|||
</tab>
|
||||
<tab string="Other">
|
||||
<field name="cycle_id"/>
|
||||
<field name="fee_partner_id"/>
|
||||
</tab>
|
||||
</tabs>
|
||||
<related>
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
<head>
|
||||
<button string="Generate Visit" action="clinic_gen_visit" type="success"/>
|
||||
</head>
|
||||
<field name="reg_date"/>
|
||||
<field name="number"/>
|
||||
<field name="hn"/>
|
||||
<field name="name"/>
|
||||
<field name="department_id"/>
|
||||
<field name="branch_id"/>
|
||||
<field name="reg_date"/>
|
||||
<!--<field name="resign_date"/>-->
|
||||
<field name="categ_id"/>
|
||||
<field name="type"/>
|
||||
<!--<field name="type"/>-->
|
||||
<field name="type_id"/>
|
||||
</list>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<form model="clinic.patient.type">
|
||||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
<field name="contact_id"/>
|
||||
</form>
|
|
@ -0,0 +1,5 @@
|
|||
<list model="clinic.patient.type">
|
||||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
<field name="contact_id"/>
|
||||
</list>
|
|
@ -63,22 +63,6 @@
|
|||
<separator string="Doctor"/>
|
||||
<field name="cost_per_case"/>
|
||||
</tab>
|
||||
<tab string="Period">
|
||||
<field name="period_id"/>
|
||||
</tab>
|
||||
|
||||
<tab string="Import Testing">
|
||||
<group form_layout="stacked">
|
||||
<field name="file" span="3"/>
|
||||
<newline/>
|
||||
<button string="Make Visit" method="make_visit" span="2"/>
|
||||
<newline/>
|
||||
<button string="Make HD Case" method="make_done" span="2"/>
|
||||
<newline/>
|
||||
<button string="Complete HD Case" method="make_complete" span="2"/>
|
||||
</group>
|
||||
</tab>
|
||||
|
||||
</tabs>
|
||||
<foot>
|
||||
</foot>
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<form model="clinic.vascular.access">
|
||||
<field name="name"/>
|
||||
<field name="note"/>
|
||||
</form>
|
|
@ -0,0 +1,4 @@
|
|||
<list model="clinic.vascular.access">
|
||||
<field name="name"/>
|
||||
<field name="note"/>
|
||||
</list>
|
|
@ -0,0 +1,9 @@
|
|||
<form title="HD Case">
|
||||
<field name="file" span="3"/>
|
||||
<field name="date" span="3" mode="month"/>
|
||||
<field name="hcode" span="3"/>
|
||||
<field name="max_row" span="3"/>
|
||||
<foot replace="1">
|
||||
<button string="Import" method="import_hd_case" type="primary" icon="arrow-right"/>
|
||||
</foot>
|
||||
</form>
|
|
@ -0,0 +1,9 @@
|
|||
<form title="Import Patient">
|
||||
<group form_layout="stacked">
|
||||
<field name="file" span="3"/>
|
||||
<field name="hcode" span="3"/>
|
||||
</group>
|
||||
<foot replace="1">
|
||||
<button string="Import" method="import_patient" type="primary" icon="arrow-right"/>
|
||||
</foot>
|
||||
</form>
|
|
@ -0,0 +1,9 @@
|
|||
<form title="Import Visit">
|
||||
<group form_layout="stacked">
|
||||
<field name="file" span="3"/>
|
||||
<field name="hcode" span="3"/>
|
||||
</group>
|
||||
<foot replace="1">
|
||||
<button string="Import" method="import_visit" type="primary" icon="arrow-right"/>
|
||||
</foot>
|
||||
</form>
|
|
@ -1,19 +0,0 @@
|
|||
<form title="Import Social Security">
|
||||
<group span="6" columns="1">
|
||||
<field name="file"/>
|
||||
<field name="hcode"/>
|
||||
</group>
|
||||
<group span="6" columns="1">
|
||||
<separator string="Result"/>
|
||||
<template>
|
||||
<a href="ui#name=clinic_data_sc" target="_blank"><span class="glyphicon glyphicon-arrow-right"></span> Review Data</a>
|
||||
</template>
|
||||
<field name="result" nolabel="1" height="240" width="540"/>
|
||||
</group>
|
||||
<foot replace="1">
|
||||
<button string="Import Data" method="import_sc" type="primary" icon="arrow-right"/>
|
||||
<!--<button string="Match Invoice" method="match_invoice_sc" icon="retweet" type="default"/>-->
|
||||
<button string="Approve" method="approve_sc" icon="ok" type="success"/>
|
||||
<button string="Clear" method="clear_sc" type="danger" icon="remove"/>
|
||||
</foot>
|
||||
</form>
|
|
@ -1,10 +0,0 @@
|
|||
<form title="Import UC">
|
||||
<group span="6" columns="1">
|
||||
<field name="file"/>
|
||||
</group>
|
||||
<group span="6" columns="1">
|
||||
</group>
|
||||
<foot replace="1">
|
||||
<button string="Import Data" method="import_uc" type="primary" icon="arrow-right"/>
|
||||
</foot>
|
||||
</form>
|
|
@ -12,6 +12,7 @@ from . import morbidity
|
|||
from . import nation
|
||||
from . import address
|
||||
from . import patient
|
||||
from . import patient_type
|
||||
from . import patient_categ
|
||||
from . import patient_cause
|
||||
from . import patient_comorbidity
|
||||
|
@ -25,10 +26,9 @@ from . import hd_case_staff
|
|||
from . import hd_case_gmline
|
||||
from . import hd_case_discont
|
||||
from . import hd_case_payment
|
||||
from . import hd_case_dialy
|
||||
from . import hd_case_daily
|
||||
from . import hd_case_dialyzer
|
||||
from . import dialyzer
|
||||
from . import import_payment
|
||||
from . import cycle
|
||||
from . import cycle_item
|
||||
from . import cycle_item_nurse
|
||||
|
@ -40,8 +40,6 @@ from . import cycle_monthly_line
|
|||
from . import gen_visit
|
||||
from . import gen_visit_line
|
||||
from . import fin_setting
|
||||
from . import import_data_uc
|
||||
from . import import_data_sc
|
||||
from . import payment
|
||||
from . import account_payment
|
||||
from . import account_invoice
|
||||
|
@ -66,3 +64,10 @@ from . import report_nurse_fee_detail
|
|||
from . import branch
|
||||
from . import period
|
||||
from . import period_line
|
||||
from . import import_payment
|
||||
from . import import_patient
|
||||
from . import import_visit
|
||||
from . import import_hd_case
|
||||
from . import import_data_uc
|
||||
from . import import_data_sc
|
||||
from . import vascular_access
|
||||
|
|
|
@ -6,7 +6,6 @@ from netforce.utils import get_data_path, get_file_path
|
|||
from netforce.access import get_active_user,set_active_user
|
||||
from netforce.access import get_active_company
|
||||
|
||||
from . import utils
|
||||
|
||||
class HDCase(Model):
|
||||
_name="clinic.hd.case"
|
||||
|
@ -69,7 +68,7 @@ class HDCase(Model):
|
|||
res={}
|
||||
for obj in self.browse(ids):
|
||||
patient=obj.patient_id
|
||||
res[obj.id]=patient.type
|
||||
res[obj.id]=patient.type_id.name
|
||||
return res
|
||||
|
||||
_fields={
|
||||
|
@ -79,14 +78,15 @@ class HDCase(Model):
|
|||
"time_stop": fields.DateTime("Finish Time",required=True,search=True),
|
||||
"date": fields.Date("Date",required=True,search=True),
|
||||
"patient_id": fields.Many2One("clinic.patient","Patient",required=True,search=True),
|
||||
"patient_type": fields.Selection([("sc","Social Security"),("uc","UC"),("others","Others")],"Service Type",function="_get_patient_type"),
|
||||
"vascular_acc": fields.Selection([("shunt","Shunt"),("graft","Graft"),("pem_cath","Pem Cath"),('temp_cash','Temp Cath')],"Vascular Ac."),
|
||||
"patient_type": fields.Char("Service Type",function="_get_patient_type"),
|
||||
"vascular_acc": fields.Many2One("clinic.vascular.access","Vascular Ac."),
|
||||
"nurse_id": fields.Many2One("clinic.staff","Approve By", domain=[['type','=','nurse']]),
|
||||
"staff_id": fields.Many2One("clinic.staff", "Staff"),
|
||||
"department_id": fields.Many2One("clinic.department", "Department",search=True),
|
||||
"wt_kg": fields.Float("Wt.kg."),
|
||||
"bp": fields.Integer("BP"),
|
||||
"mm_hg": fields.Integer("mmHG"),
|
||||
"hct": fields.Integer("Hct%(<40)"),
|
||||
"hct": fields.Integer("Hct%(<40)",required=True),
|
||||
"hct_msg" : fields.Char(""),
|
||||
"check_goverment_pay" : fields.Boolean("The Government Pay"),
|
||||
"check_personal_pay" : fields.Boolean("Pay yourself"),
|
||||
|
@ -191,11 +191,14 @@ class HDCase(Model):
|
|||
patient=get_model('clinic.patient').browse(patient_id)
|
||||
department=patient.department_id
|
||||
cycle=patient.cycle_id
|
||||
partner=patient.fee_partner_id
|
||||
partner=patient.type_id.contact_id
|
||||
data['department_id']=department.id
|
||||
data['patient_type']=patient.type
|
||||
data['cycle_id']=cycle.id
|
||||
data['fee_partner_id']=partner.id
|
||||
if partner:
|
||||
data['fee_partner_id']=partner.id
|
||||
else:
|
||||
data['fee_partner_id']=None
|
||||
data['patient_type']=patient.type_id.name or ""
|
||||
data['dialyzers']=[]
|
||||
|
||||
return data
|
||||
|
@ -565,7 +568,7 @@ class HDCase(Model):
|
|||
date=obj.date
|
||||
vals={
|
||||
"state":"completed",
|
||||
'time_stop': '%s %s'%(date,timenow),
|
||||
#'time_stop': '%s %s'%(date,timenow),
|
||||
}
|
||||
st=get_model("clinic.setting").browse(1)
|
||||
if st.waiting_approval:
|
||||
|
@ -789,19 +792,9 @@ class HDCase(Model):
|
|||
'qty': qty,
|
||||
'amount': amt,
|
||||
}))
|
||||
|
||||
categ_name=utils.PATIENT_TYPE.get(patient.type)
|
||||
categ_ids=get_model("partner.categ").search([['name','=',categ_name]])
|
||||
if not categ_ids:
|
||||
raise Exception("Partner Category: %s not found"%categ_name)
|
||||
partner_id=None
|
||||
if patient.type in ("mg","sc","uc"):
|
||||
partner_obj=get_model("partner")
|
||||
for partner in partner_obj.search_browse([]):
|
||||
if partner.categ_id.id in categ_ids:
|
||||
partner_id=partner.id
|
||||
vals['fee_partner_id']=partner_id
|
||||
break
|
||||
partner=patient.type_id.contact_id
|
||||
if partner:
|
||||
vals['fee_partner_id']=partner.id
|
||||
return vals
|
||||
|
||||
def get_invoice_policy(self,vals,patient_id=None):
|
||||
|
@ -827,8 +820,19 @@ class HDCase(Model):
|
|||
|
||||
def write(self,ids,vals,**kw):
|
||||
patient_id=vals.get('patient_id')
|
||||
vals=self.get_staff_line(vals,patient_id)
|
||||
# XXX import problem
|
||||
#vals=self.get_staff_line(vals,patient_id)
|
||||
vals=self.get_invoice_policy(vals,patient_id)
|
||||
obj=self.browse(ids)[0]
|
||||
for st in obj.staffs:
|
||||
if st.type=='doctor':
|
||||
doctor=st.staff_id
|
||||
vals['staff_id']=doctor.id
|
||||
#item=obj.cycle_item_id
|
||||
#for nurse in item.nurses:
|
||||
#nurse.write(('create',{
|
||||
#'hd_cases': '',
|
||||
#}))
|
||||
super().write(ids,vals,**kw)
|
||||
|
||||
def onchange_type(self,context={}):
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
import time
|
||||
import urllib.parse as urllib
|
||||
|
||||
from datetime import datetime
|
||||
from calendar import monthrange
|
||||
from netforce.model import Model, fields, get_model
|
||||
from netforce.access import get_active_company
|
||||
|
||||
from . import utils
|
||||
|
||||
class HDCaseDialy(Model):
|
||||
_name="clinic.hd.case.dialy"
|
||||
_string="HD Case Dialy"
|
||||
_name="clinic.hd.case.daily"
|
||||
_string="HD Case Daily"
|
||||
_transient=True
|
||||
|
||||
_fields={
|
||||
|
@ -39,7 +37,7 @@ class HDCaseDialy(Model):
|
|||
lines=[]
|
||||
|
||||
for obj in get_model("clinic.hd.case").search_browse(dom):
|
||||
patient_type=utils.PATIENT_TYPE[obj.patient_id.type]
|
||||
patient_type=obj.patient_id.type_id.name or ""
|
||||
dlz_number=""
|
||||
dlz_id=None
|
||||
for line in obj.dialyzers:
|
||||
|
@ -71,7 +69,6 @@ class HDCaseDialy(Model):
|
|||
|
||||
no=1
|
||||
slines=[]
|
||||
cycles=[]
|
||||
for line in sorted(lines,key=lambda x: (x['cycle_sequence'],x['hd_case_number'])):
|
||||
line['no']=no
|
||||
slines.append(line)
|
|
@ -0,0 +1,143 @@
|
|||
import time
|
||||
from calendar import monthrange
|
||||
|
||||
from netforce.model import Model, fields, get_model
|
||||
from netforce.utils import get_file_path
|
||||
from netforce.database import get_connection
|
||||
from . import utils
|
||||
|
||||
class ImportHDCase(Model):
|
||||
_name="clinic.import.hd.case"
|
||||
_transient=True
|
||||
|
||||
_fields={
|
||||
'date': fields.Date("Date"),
|
||||
'file': fields.File("File"),
|
||||
'hcode': fields.Char("Hospital Code"),
|
||||
'max_row': fields.Integer("Max Row"),
|
||||
}
|
||||
|
||||
def get_hcode(self,context={}):
|
||||
settings=get_model("settings").browse(1)
|
||||
hcode=settings.hospital_code or ""
|
||||
return hcode
|
||||
|
||||
_defaults={
|
||||
'date': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
'hcode': get_hcode,
|
||||
}
|
||||
|
||||
def import_hd_case(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
fname=obj.file
|
||||
fpath=get_file_path(fname)
|
||||
lines=utils.read_excel(fpath,show_datetime=True)
|
||||
if not lines:
|
||||
raise Exception("Wrong File")
|
||||
|
||||
st_lines=[]
|
||||
st=get_model("clinic.setting").browse(1)
|
||||
for st_prod in st.products:
|
||||
prod=st_prod.product_id
|
||||
if st_prod.patient_type=='sc':
|
||||
st_lines.append(('create',{
|
||||
'type': st_prod.type,
|
||||
'product_id': prod.id,
|
||||
'uom_id': prod.uom_id.id,
|
||||
'description': prod.name,
|
||||
'qty': 1,
|
||||
'price': st_prod.price,
|
||||
'amount': st_prod.price,
|
||||
}))
|
||||
policy=''
|
||||
option=''
|
||||
for st_policy in st.invoice_policies:
|
||||
if st_policy=='sc':
|
||||
policy=st_policy.invoice_policy
|
||||
option=st_policy.invoice_option
|
||||
|
||||
# make hd case
|
||||
# 1. create hd case
|
||||
# - add all expense, set policy
|
||||
# 2. find visit
|
||||
# 3. update visit (state: 'confirmed', hd_cases)
|
||||
print('total line ', len(lines))
|
||||
max_row=obj.max_row
|
||||
count=0
|
||||
for line in lines:
|
||||
name=line.get("name14")
|
||||
hn=line.get('hn',"")
|
||||
hct=line.get("hct","")
|
||||
hcode=line.get('hcode18','0')
|
||||
if not hcode:
|
||||
hcode='0'
|
||||
hcode=int(hcode)
|
||||
hcode=str(hcode)
|
||||
if not obj.hcode==hcode:
|
||||
continue
|
||||
dttran=line.get("dttran","")
|
||||
date=dttran[0:10]
|
||||
#time_stop=dttran[11:] # finish hd case
|
||||
pt_ids=get_model("clinic.patient").search([['name','=',name]])
|
||||
if not pt_ids:
|
||||
pt_ids=get_model("clinic.patient").search([['hn','=',hn]])
|
||||
|
||||
if count > max_row:
|
||||
#XXX timeout
|
||||
break
|
||||
|
||||
hlines=[]
|
||||
if pt_ids:
|
||||
prod_price=line.get("epopay27") # XXX
|
||||
prod_code=line.get("code31")
|
||||
prods=get_model("product").search_browse([['code','=',prod_code]])
|
||||
if prods:
|
||||
prod=prods[0]
|
||||
hlines=[('create',{
|
||||
'type': 'medicine',
|
||||
'product_id': prod.id,
|
||||
'uom_id': prod.uom_id.id,
|
||||
'description': prod.name,
|
||||
'price': prod_price or 0.0,
|
||||
'qty': 1,
|
||||
'amount': prod_price or 0.0,
|
||||
})]
|
||||
|
||||
patient_id=pt_ids[0]
|
||||
visit_obj=get_model("clinic.visit")
|
||||
visits=visit_obj.search_browse([['visit_date','=',date],['patient_id','=',patient_id],['state','=','draft']])
|
||||
if visits:
|
||||
count+=1
|
||||
print("confirming")
|
||||
hlines+=st_lines
|
||||
visit=visits[0]
|
||||
cycle=visit.cycle_id
|
||||
vals={
|
||||
'patient_id': patient_id,
|
||||
'hct': hct or 0,
|
||||
'invoice_policy': policy,
|
||||
'invoice_option': option,
|
||||
'date': visit.visit_date,
|
||||
'time_start': visit.time_start,
|
||||
'time_stop': visit.time_stop, # XXX
|
||||
'visit_id': visit.id,
|
||||
'cycle_id': cycle.id,
|
||||
'lines': hlines,
|
||||
}
|
||||
hd_case_obj=get_model("clinic.hd.case")
|
||||
hd_case_id=hd_case_obj.create(vals)
|
||||
visit.confirm()
|
||||
hd_case=hd_case_obj.browse(hd_case_id)
|
||||
hd_case.done()
|
||||
for inv in hd_case.invoices:
|
||||
inv.write({
|
||||
'date': inv.due_date,
|
||||
})
|
||||
print("confirm visit ", visit.number)
|
||||
else:
|
||||
print("not found visit for %s on %s"%(name,date))
|
||||
else:
|
||||
pass
|
||||
#print("XXXX ", name)
|
||||
|
||||
ImportHDCase.register()
|
|
@ -0,0 +1,54 @@
|
|||
import time
|
||||
|
||||
from netforce.model import Model, fields, get_model
|
||||
from netforce.utils import get_file_path
|
||||
from . import utils
|
||||
|
||||
class ImportPatient(Model):
|
||||
_name="clinic.import.patient"
|
||||
_transient=True
|
||||
|
||||
_fields={
|
||||
'date': fields.DateTime("Date"),
|
||||
'file': fields.File("File"),
|
||||
'result': fields.Text("Success"),
|
||||
'hcode': fields.Char("Hospital Code"),
|
||||
}
|
||||
|
||||
def get_hcode(self,context={}):
|
||||
settings=get_model("settings").browse(1)
|
||||
hcode=settings.hospital_code or ""
|
||||
return hcode
|
||||
|
||||
_defaults={
|
||||
'date': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
'hcode': get_hcode,
|
||||
}
|
||||
|
||||
def import_patient(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
fname=obj.file
|
||||
fpath=get_file_path(fname)
|
||||
lines=utils.read_excel(fpath,show_datetime=True)
|
||||
if not lines:
|
||||
raise Exception("Wrong File")
|
||||
for line in lines:
|
||||
hcode=line.get('hcode18','0')
|
||||
if not hcode:
|
||||
hcode='0'
|
||||
hcode=int(hcode)
|
||||
hcode=str(hcode)
|
||||
if obj.hcode==hcode:
|
||||
name=line.get("name14")
|
||||
hn=line.get('hn',"")
|
||||
patient_ids=get_model("clinic.patient").search([['name','=',name]])
|
||||
if not patient_ids:
|
||||
vals={
|
||||
'name': name,
|
||||
'hn': hn,
|
||||
'type': 'sc',
|
||||
}
|
||||
patient_id=get_model('clinic.patient').create(vals)
|
||||
print("create patient ", patient_id)
|
||||
|
||||
ImportPatient.register()
|
|
@ -0,0 +1,82 @@
|
|||
import time
|
||||
|
||||
from netforce.model import Model, fields, get_model
|
||||
from netforce.utils import get_file_path
|
||||
from . import utils
|
||||
|
||||
class ImportVisit(Model):
|
||||
_name="clinic.import.visit"
|
||||
_transient=True
|
||||
|
||||
_fields={
|
||||
'date': fields.DateTime("Date"),
|
||||
'file': fields.File("File"),
|
||||
'result': fields.Text("Success"),
|
||||
'hcode': fields.Char("Hospital Code"),
|
||||
}
|
||||
|
||||
def get_hcode(self,context={}):
|
||||
settings=get_model("settings").browse(1)
|
||||
hcode=settings.hospital_code or ""
|
||||
return hcode
|
||||
|
||||
_defaults={
|
||||
'date': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
'hcode': get_hcode,
|
||||
}
|
||||
|
||||
def import_visit(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
fname=obj.file
|
||||
fpath=get_file_path(fname)
|
||||
lines=utils.read_excel(fpath,show_datetime=True)
|
||||
if not lines:
|
||||
raise Exception("Wrong File")
|
||||
for line in lines:
|
||||
cycles=[(c['id'],'%s:00'%c['time_start'],'%s:00'%c['time_stop']) for c in get_model("clinic.cycle").search_read([[]],['time_start','time_stop'])]
|
||||
hcode=line.get('hcode18')
|
||||
if not hcode:
|
||||
hcode='0'
|
||||
hcode=int(hcode)
|
||||
hcode=str(hcode)
|
||||
if obj.hcode==hcode:
|
||||
name=line.get("name14")
|
||||
#hn=line.get('hn')
|
||||
patient_ids=get_model("clinic.patient").search([['name','=',name]])
|
||||
if patient_ids:
|
||||
patient_id=patient_ids[0]
|
||||
patient=get_model("clinic.patient").browse(patient_id)
|
||||
doctor=patient.doctor_id
|
||||
department=patient.department_id
|
||||
vals={
|
||||
'patient_id': patient.id,
|
||||
'doctor_id': doctor.id,
|
||||
'department_id': department.id,
|
||||
}
|
||||
# find cycle
|
||||
dttran=line.get("dttran")
|
||||
date=dttran[0:10]
|
||||
time=dttran[11:]
|
||||
cycle_id=None
|
||||
for cycle in cycles:
|
||||
time_start=cycle[1]
|
||||
time_stop=cycle[2]
|
||||
if time >= time_start:
|
||||
cycle_id=cycle[0]
|
||||
vals['cycle_id']=cycle_id
|
||||
vals['time_start']='%s %s'%(date,time_start)
|
||||
vals['time_stop']='%s %s'%(date,time_stop)
|
||||
if not cycle_id:
|
||||
raise Exception("not found cycle on this time %s"%(dttran))
|
||||
vals['visit_date']=date
|
||||
visit_ids=get_model("clinic.visit").search([['visit_date','=',date],['patient_id','=',patient_id]])
|
||||
if not visit_ids:
|
||||
visit_id=get_model('clinic.visit').create(vals)
|
||||
print('create visit ', visit_id, date)
|
||||
else:
|
||||
print('already ', date, ' ', name)
|
||||
else:
|
||||
print("found ", name)
|
||||
|
||||
|
||||
ImportVisit.register()
|
|
@ -3,8 +3,6 @@ import time
|
|||
from netforce.model import Model, fields, get_model
|
||||
from netforce.access import get_active_company, get_active_user, set_active_user
|
||||
|
||||
from . import utils
|
||||
|
||||
|
||||
class Patient(Model):
|
||||
_name="clinic.patient"
|
||||
|
@ -34,20 +32,9 @@ class Patient(Model):
|
|||
res[obj.id]=cycle_id
|
||||
return res
|
||||
|
||||
def _get_fee_partner(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
pt_type=utils.PATIENT_TYPE.get(obj.type)
|
||||
categ_ids=get_model("partner.categ").search([['name','=',pt_type]])
|
||||
partner_ids=get_model("partner").search([['categ_id','in',categ_ids]])
|
||||
partner_id=None
|
||||
if partner_ids:
|
||||
partner_id=partner_ids[0]
|
||||
res[obj.id]=partner_id
|
||||
return res
|
||||
|
||||
_fields={
|
||||
"type": fields.Selection([("sc","Social Security"),("uc","UC"),("others","Others")],"Type",required=True),
|
||||
'type_id': fields.Many2One("clinic.patient.type","Type",search=True,required=True),
|
||||
"number": fields.Char("Number",required=True,search=True),
|
||||
"hn": fields.Char("REF/HN",search=True),
|
||||
"name": fields.Char("Name",required=True,search=True),
|
||||
|
@ -104,7 +91,6 @@ class Patient(Model):
|
|||
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
||||
'department_id': fields.Many2One("clinic.department","Department"),
|
||||
'cycle_id': fields.Many2One("clinic.cycle","Last Cycle",function="_get_last_cycle"),
|
||||
'fee_partner_id': fields.Many2One("partner","Contact Fee",function="_get_fee_partner"),
|
||||
}
|
||||
|
||||
def _get_number(self,context={}):
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
from netforce.model import Model, fields
|
||||
|
||||
class PatientType(Model):
|
||||
_name="clinic.patient.type"
|
||||
_string="Patient Type"
|
||||
_key=['code','name']
|
||||
|
||||
_fields={
|
||||
"name": fields.Char("Name",required=True,search=True),
|
||||
"code": fields.Char("Code",required=True,search=True),
|
||||
'contact_id': fields.Many2One("partner","Contact",domain=[['type','=','org']]),
|
||||
}
|
||||
|
||||
PatientType.register()
|
|
@ -194,14 +194,7 @@ class ReportHDCaseSummary(Model):
|
|||
|
||||
context['defaults']={'date': date}
|
||||
|
||||
titles={
|
||||
'prod_name': 'ชื่อยา',
|
||||
'sc': utils.PATIENT_TYPE['sc'],
|
||||
'uc': utils.PATIENT_TYPE['uc'],
|
||||
'others': utils.PATIENT_TYPE['others'],
|
||||
}
|
||||
medicals=get_model("clinic.report.medical.summary").get_report_data(ids=[],context=context)['lines']
|
||||
|
||||
medicals=get_model("clinic.report.medical.summary").get_report_data(ids=[],context=context)
|
||||
year=year+543
|
||||
data={
|
||||
'date': date,
|
||||
|
@ -210,11 +203,11 @@ class ReportHDCaseSummary(Model):
|
|||
'lines': lines,
|
||||
'recent_patients': get_model("clinic.report.recent.patient").get_report_data(ids=[],context=context)['lines'],
|
||||
'resign_patients': get_model("clinic.report.discontinue.patient").get_report_data(ids=[],context=context)['lines'],
|
||||
'medicals': medicals,
|
||||
'medicals': medicals['lines'],
|
||||
'titles': medicals['titles'],
|
||||
'company_name': company.name or "",
|
||||
'parent_company_name': company.parent_id.name or "",
|
||||
}
|
||||
data.update(titles)
|
||||
return data
|
||||
|
||||
ReportHDCaseSummary.register()
|
||||
|
|
|
@ -50,15 +50,16 @@ class ReportMedicalSummary(Model):
|
|||
time_stop=obj.date_to
|
||||
|
||||
dom=[]
|
||||
#dom.append([['state','=','completed']])
|
||||
dom.append(['time_start','>=','%s 00:00:00'%time_start])
|
||||
dom.append(['time_stop','<=','%s 23:59:59'%time_stop])
|
||||
|
||||
products={}
|
||||
patient_types={t['id']: t['name'] for t in get_model('clinic.patient.type').search_read([[]],['name'],order="name")}
|
||||
print(patient_types)
|
||||
for prod in get_model("product").search_browse([['type','=','stock']]):
|
||||
products[prod.code]={}
|
||||
for patient_type in ('sc','uc','others'):
|
||||
products[prod.code][patient_type]={
|
||||
for patient_type_id,type_name in patient_types.items():
|
||||
products[prod.code][patient_type_id]={
|
||||
'qty': 0,
|
||||
'name': prod.name,
|
||||
'code': prod.code,
|
||||
|
@ -66,45 +67,55 @@ class ReportMedicalSummary(Model):
|
|||
}
|
||||
|
||||
for hd_case in get_model('clinic.hd.case').search_browse(dom):
|
||||
patient_type=hd_case.patient_id.type
|
||||
patient_type_id=hd_case.patient_id.type_id.id
|
||||
for line in hd_case.lines:
|
||||
prod=line.product_id
|
||||
if line.type=='fee' or prod.type=='service':
|
||||
continue
|
||||
products[prod.code][patient_type]['qty']+=line.qty
|
||||
products[prod.code][patient_type_id]['qty']+=line.qty
|
||||
|
||||
lines=[]
|
||||
|
||||
limit=25
|
||||
titles=[{'name': 'ชื่อยา'}]
|
||||
for patient_type_id,type_name in sorted(patient_types.items(), key=lambda x: x[0]):
|
||||
titles.append({
|
||||
'name':type_name,
|
||||
})
|
||||
for prod, records in products.items():
|
||||
prod_name=records['sc']['name'] or ""
|
||||
prod_name_org=records['sc']['name'] or ""
|
||||
prod_name=records[patient_type_id]['name'] or ""
|
||||
prod_name_org=records[patient_type_id]['name'] or ""
|
||||
prod_name=len(prod_name) > limit and '%s...' %prod_name[0:limit] or prod_name
|
||||
line={
|
||||
'prod_name': prod_name,
|
||||
'prod_name_org': prod_name_org,
|
||||
'prod_id': records[patient_type]['prod_id'],
|
||||
'total': 0,
|
||||
}
|
||||
for patient_type in ('sc','uc','others'):
|
||||
line.update({
|
||||
patient_type: records[patient_type]['qty'] or 0,
|
||||
|
||||
count=1
|
||||
total=0.0
|
||||
sub_lines=[]
|
||||
for patient_type_id,type_name in sorted(patient_types.items(), key=lambda x: x[0]):
|
||||
qty=records[patient_type_id]['qty'] or 0
|
||||
line={
|
||||
'prod_name': prod_name,
|
||||
'prod_name_org': prod_name_org,
|
||||
'prod_id': records[patient_type_id]['prod_id'],
|
||||
'total': 0,
|
||||
}
|
||||
sub_lines.append({
|
||||
'qty': qty,
|
||||
})
|
||||
line['total']+=line[patient_type]
|
||||
total+=qty
|
||||
count+=1
|
||||
sub_lines.append({
|
||||
'qty': total,
|
||||
})
|
||||
line['sub_lines']=sub_lines
|
||||
lines.append(line)
|
||||
titles.append({'name':'รวม'})
|
||||
|
||||
company_id=get_active_company()
|
||||
company=get_model('company').browse(company_id)
|
||||
month_str=utils.MONTHS['th_TH'][int(month)]
|
||||
|
||||
lines=sorted(lines, key=lambda x: x['prod_name'])
|
||||
titles={
|
||||
'prod_name': 'ชื่อยา',
|
||||
'sc': utils.PATIENT_TYPE['sc'],
|
||||
'uc': utils.PATIENT_TYPE['uc'],
|
||||
'others': utils.PATIENT_TYPE['others'],
|
||||
}
|
||||
year=int(year)+543
|
||||
|
||||
data={
|
||||
'company_name': company.name or "",
|
||||
'parent_company_name': company.parent_id.name or "",
|
||||
|
@ -113,7 +124,6 @@ class ReportMedicalSummary(Model):
|
|||
'month': month_str,
|
||||
'year': year,
|
||||
}
|
||||
data.update(titles)
|
||||
|
||||
return data
|
||||
|
||||
|
|
|
@ -1,9 +1,3 @@
|
|||
import time
|
||||
import random
|
||||
import datetime
|
||||
import xlrd
|
||||
import xmltodict
|
||||
|
||||
from netforce.model import Model, fields, get_model
|
||||
from netforce.utils import get_file_path, get_data_path
|
||||
from netforce.access import get_active_company
|
||||
|
@ -27,284 +21,6 @@ class ClinicSetting(Model):
|
|||
"company_id": lambda *a: get_active_company(),
|
||||
}
|
||||
|
||||
def read_excel(self,fpath=None):
|
||||
data={}
|
||||
if fpath:
|
||||
suffix=fpath.split(".")[-1]
|
||||
if suffix not in ('xls', 'xlsx'):
|
||||
raise Exception("ERROR : please should file xls or xlsx")
|
||||
wb=xlrd.open_workbook(fpath)
|
||||
sheet=wb.sheet_by_name("Sheet1")
|
||||
# read header values into the list
|
||||
keys = [sheet.cell(0, col_index).value for col_index in range(sheet.ncols)]
|
||||
data=[]
|
||||
for row_index in range(1, sheet.nrows):
|
||||
#d = {(keys[col_index] or "").lower(): sheet.cell(row_index, col_index).value for col_index in range(sheet.ncols)}
|
||||
d={}
|
||||
for col_index in range(sheet.ncols):
|
||||
ctype=sheet.cell(row_index,col_index).ctype
|
||||
if ctype==3:
|
||||
value=sheet.cell(row_index, col_index).value
|
||||
year, month, day, hour, minute, second = xlrd.xldate_as_tuple(value,wb.datemode)
|
||||
value=datetime.datetime(year, month, day, hour, minute,second)
|
||||
value=value.strftime("%Y-%m-%d")
|
||||
else:
|
||||
value=sheet.cell(row_index, col_index).value
|
||||
d.update({(keys[col_index] or "").lower():value})
|
||||
data.append(d)
|
||||
return data
|
||||
|
||||
def make_visit(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
fname=obj.file
|
||||
fpath=get_file_path(fname)
|
||||
lines=self.read_excel(fpath)
|
||||
if not lines:
|
||||
raise Exception("Wrong File")
|
||||
|
||||
for line in lines:
|
||||
hcode=line.get('hcode18','0')
|
||||
if not hcode:
|
||||
hcode='0'
|
||||
hcode=int(hcode)
|
||||
hcode=str(hcode)
|
||||
if obj.hcode==hcode:
|
||||
invno=line.get("invno","")
|
||||
name=line.get("name14")
|
||||
hn=line.get('hn',"")
|
||||
hct=line.get("HCT","")
|
||||
amount=line.get("amount23",0)
|
||||
dttran=line.get("dttran","")
|
||||
|
||||
#==== product =====
|
||||
prod_code=line.get("code31","")
|
||||
prod_name=line.get('eponame',"")
|
||||
prod_qty=line.get("qty",0)
|
||||
prod_unit=line.get("unit32","")
|
||||
prod_ids=get_model("product").search([['code','=',prod_code]])
|
||||
if not prod_ids:
|
||||
print('create')
|
||||
vals={
|
||||
'code': prod_code,
|
||||
'name': prod_name,
|
||||
'type': 'stock',
|
||||
}
|
||||
unit_ids=get_model("uom").search([['name','=',prod_unit]])
|
||||
if not unit_ids:
|
||||
prod_unit_id=get_model("uom").create({
|
||||
'name': prod_unit,
|
||||
'type': 'unit',
|
||||
})
|
||||
else:
|
||||
prod_unit_id=unit_ids[0]
|
||||
vals['uom_id']=prod_unit_id
|
||||
prod_id=get_model("product").create(vals)
|
||||
print("create product ", prod_id, prod_name)
|
||||
# ================
|
||||
print(dttran, invno, hcode, hn, name, hct, amount)
|
||||
return
|
||||
|
||||
def _make_visit(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
fname=obj.file
|
||||
fpath=get_file_path(fname)
|
||||
lines=self.read_excel(fpath)
|
||||
if not lines:
|
||||
raise Exception("Wrong File")
|
||||
medicals=[]
|
||||
patients=[]
|
||||
for line in lines:
|
||||
medical=line.get('medical') or line.get('eponame') or ""
|
||||
if not medical in medicals:
|
||||
medicals.append(medical)
|
||||
patient=line.get('hn','')
|
||||
name14=line.get('name14') or ""
|
||||
value=(patient,name14)
|
||||
if not value in patients:
|
||||
patients.append(value)
|
||||
products=[p['name'] for p in get_model("product").search_read([],['name'])]
|
||||
print('generate product')
|
||||
print("="*50)
|
||||
seq=6
|
||||
for md in medicals:
|
||||
md=md.replace(" ","")
|
||||
if not md:
|
||||
continue
|
||||
if not md in products:
|
||||
vals={
|
||||
'code': "m"+("%s"%seq).zfill(4),
|
||||
'name':md,
|
||||
'uom_id': 2,
|
||||
'type': 'stock',
|
||||
}
|
||||
seq+=1
|
||||
prod_id=get_model("product").create(vals)
|
||||
print(prod_id)
|
||||
|
||||
print("="*50)
|
||||
print('generate patient')
|
||||
hns=[pt['hn'] for pt in get_model("clinic.patient").search_read([],['hn'])]
|
||||
for hn, name in patients:
|
||||
hn=hn.replace(' ',"")
|
||||
if not hn:
|
||||
continue
|
||||
if not hn in hns:
|
||||
vals={
|
||||
'hn': hn,
|
||||
'name': name,
|
||||
'type': 'sc',
|
||||
}
|
||||
pt_id=get_model("clinic.patient").create(vals)
|
||||
print('hn ', pt_id)
|
||||
print("="*50)
|
||||
patients=get_model("clinic.patient").search_read([],['name','hn'])
|
||||
visits=get_model("clinic.visit").search_read([],['number','time_start','cycle_id','state'])
|
||||
doctor_ids=[dt['id'] for dt in get_model("clinic.staff").search_read([['type','=','doctor']],['name'])]
|
||||
nurse_ids=[ns['id'] for ns in get_model("clinic.staff").search_read([['type','=','nurse']],['name'])]
|
||||
cycle_ids=[cc['id'] for cc in get_model("clinic.cycle").search_read([],['name'])]
|
||||
department_ids=[dp['id'] for dp in get_model("clinic.department").search_read([],['name'])]
|
||||
#db=get_connection()
|
||||
def get_patient(hn):
|
||||
for pt in patients:
|
||||
if hn==pt['hn']:
|
||||
return pt
|
||||
return None
|
||||
|
||||
def get_visit(date,state=None):
|
||||
for visit in visits:
|
||||
if date==visit['time_start'][0:10]:
|
||||
if state:
|
||||
if visit['state']==state:
|
||||
return visit
|
||||
else:
|
||||
return None
|
||||
return visit
|
||||
print("="*50)
|
||||
print("create simple visit")
|
||||
timenow=time.strftime("%H:%M:%S")
|
||||
timenow2="%s:%s:%s" % (int(time.strftime("%H"))+1, time.strftime("%M"), time.strftime("%S"))
|
||||
time_start=timenow
|
||||
for line in lines:
|
||||
hn=line['hn']
|
||||
date=line['dttran']
|
||||
visit=get_visit(date)
|
||||
if not visit:
|
||||
patient=get_patient(hn)
|
||||
if patient:
|
||||
time_start="%s %s"%(date,timenow)
|
||||
time_stop="%s %s"%(date,timenow2)
|
||||
vals={
|
||||
'time_start': time_start,
|
||||
'time_stop': time_stop,
|
||||
'patient_id': patient['id'],
|
||||
'cycle_id': random.choice(cycle_ids),
|
||||
'nurse_id': random.choice(nurse_ids),
|
||||
'doctor_id': random.choice(doctor_ids),
|
||||
'department_id': random.choice(department_ids),
|
||||
}
|
||||
visit_id=get_model("clinic.visit").create(vals)
|
||||
print("create visit %s ", visit_id)
|
||||
print("="*50)
|
||||
print("visit with state is draft")
|
||||
return #XXXX
|
||||
count=0
|
||||
for line in lines:
|
||||
date=line['dttran']
|
||||
# prevent timeout
|
||||
if count > 10:
|
||||
break
|
||||
visit=get_visit(date=date,state='draft')
|
||||
print(date, ' ', visit)
|
||||
if visit:
|
||||
visit_id=visit['id']
|
||||
context['called']=True
|
||||
hd_case_id=get_model("clinic.visit").browse(visit_id).confirm(context=context)
|
||||
#allow37=line['allow37']
|
||||
hct=line.get('hct')
|
||||
medical=line.get('medical') or line.get("eponame") or ""
|
||||
vals={
|
||||
'hct': hct and hct or 0,
|
||||
}
|
||||
hd_case=get_model("clinic.hd.case").browse(hd_case_id)
|
||||
hd_case.write(vals)
|
||||
count+=1
|
||||
print("#%s write hd_case %s ok and visit %s" % (count,hd_case_id,hd_case.visit_id.number))
|
||||
print("="*50)
|
||||
print("Done")
|
||||
return
|
||||
|
||||
def make_done(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
fname=obj.file
|
||||
fpath=get_file_path(fname)
|
||||
lines=self.read_excel(fpath)
|
||||
if not lines:
|
||||
raise Exception("Wrong File")
|
||||
def get_line(hn,date):
|
||||
for line in lines:
|
||||
if hn==line['hn'] and date==line['dttran']:
|
||||
return line
|
||||
count=0
|
||||
for visit in get_model("clinic.visit").search_browse([['state','=','draft']]):
|
||||
if count > 200:
|
||||
break
|
||||
count+=1
|
||||
context['called']=True
|
||||
hd_case_id=visit.confirm(context=context)
|
||||
hn=visit.patient_id.hn
|
||||
date_visit=visit.time_start[0:10]
|
||||
line=get_line(hn,date_visit)
|
||||
if line:
|
||||
hct=line.get('hct')
|
||||
medical=line.get('medical') or line.get('eponame') or ""
|
||||
medical_cost=line.get('medical_cost') or line.get("allow37") or ""
|
||||
inject_service=line.get('inject_service') or line.get("EPOadm29") or ""
|
||||
vals={
|
||||
'hct': hct and hct or 0,
|
||||
}
|
||||
if medical:
|
||||
prods=get_model("product").search_browse([['name','=',medical]])
|
||||
if prods:
|
||||
prod=prods[0]
|
||||
vals['lines'].append(('create',{
|
||||
'type': 'fee',
|
||||
'product_id': prod.id,
|
||||
'description': prod.name,
|
||||
'uom_id': prod.uom_id.id,
|
||||
'qty': 1,
|
||||
'price': medical_cost,
|
||||
'amount': medical_cost,
|
||||
}))
|
||||
if inject_service:
|
||||
prod=get_model("product").browse(55)
|
||||
vals['lines'].append(('create',{
|
||||
'type': 'other',
|
||||
'product_id': 55, #XXX
|
||||
'description': prod.name,
|
||||
'uom_id': prod.uom_id.id,
|
||||
'qty': 1,
|
||||
'price': medical_cost,
|
||||
'amount': medical_cost,
|
||||
}))
|
||||
hd_case=get_model("clinic.hd.case").browse(hd_case_id)
|
||||
hd_case.write(vals)
|
||||
print("#%s make hd_case %s ok "%(count,hd_case.number))
|
||||
|
||||
def make_complete(self,ids,context={}):
|
||||
context['called']=True
|
||||
count=0
|
||||
for hd_case in get_model('clinic.hd.case').search_browse(['state','=','draft']):
|
||||
if count > 100:
|
||||
break
|
||||
if not hd_case.dialyzers:
|
||||
patient=hd_case.patient_id
|
||||
if not patient.addresses:
|
||||
patient.simple_address()
|
||||
hd_case.new_dialyzer(context=context)
|
||||
hd_case.complete()
|
||||
print("%s is completed"%hd_case.number)
|
||||
count+=1
|
||||
|
||||
def onchange_line(self,context={}):
|
||||
data=context['data']
|
||||
path=context['path']
|
||||
|
@ -331,7 +47,7 @@ class ClinicSetting(Model):
|
|||
line['description']=prod.name
|
||||
price=prod.sale_price or 0.0
|
||||
line['price']=price
|
||||
qty=line['qty'] or 0
|
||||
qty=1
|
||||
amt=qty*price
|
||||
line['amount']=amt
|
||||
return data
|
||||
|
|
|
@ -81,7 +81,7 @@ class Staff(Model):
|
|||
"comments": fields.One2Many("message","related_id","Comments"),
|
||||
"nurse_visits": fields.One2Many("clinic.visit","nurse_id","Visits"),
|
||||
"doctor_visits": fields.One2Many("clinic.visit","doctor_id","Visits"),
|
||||
"hd_cases": fields.One2Many("clinic.hd.case","nurse_id","HD Cases"),
|
||||
"hd_cases": fields.One2Many("clinic.hd.case","staff_id","HD Cases"),
|
||||
"company_id": fields.Many2One("company","Company"),
|
||||
"user_id": fields.Many2One("base.user","User"),
|
||||
'picture': fields.File("Picture"),
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
from datetime import datetime
|
||||
import xlrd
|
||||
import xmltodict
|
||||
|
||||
|
||||
DAYS={
|
||||
|
@ -36,6 +38,60 @@ TOPICS={
|
|||
'topic8': {'name': 'จำนวนผู้ป่วยจ่ายเอง', 'unit': 'คน'},
|
||||
}
|
||||
|
||||
def read_excel(fpath=None,show_datetime=False):
|
||||
data={}
|
||||
if fpath:
|
||||
suffix=fpath.split(".")[-1]
|
||||
if suffix not in ('xls', 'xlsx'):
|
||||
raise Exception("ERROR : please should file xls or xlsx")
|
||||
wb=xlrd.open_workbook(fpath)
|
||||
sheet=wb.sheet_by_name("Sheet1")
|
||||
keys = [sheet.cell(0, col_index).value for col_index in range(sheet.ncols)]
|
||||
data=[]
|
||||
for row_index in range(1, sheet.nrows):
|
||||
d={}
|
||||
for col_index in range(sheet.ncols):
|
||||
ctype=sheet.cell(row_index,col_index).ctype
|
||||
if ctype==3:
|
||||
value=sheet.cell(row_index, col_index).value
|
||||
year, month, day, hour, minute, second = xlrd.xldate_as_tuple(value,wb.datemode)
|
||||
value=datetime.datetime(year, month, day, hour, minute,second)
|
||||
if show_datetime:
|
||||
value=value.strftime("%Y-%m-%d %H:%M:%S")
|
||||
else:
|
||||
value=value.strftime("%Y-%m-%d")
|
||||
else:
|
||||
value=sheet.cell(row_index, col_index).value
|
||||
d.update({(keys[col_index] or "").lower():value})
|
||||
data.append(d)
|
||||
return data
|
||||
|
||||
def read_xml(fpath=None,node=""):
|
||||
data={}
|
||||
if not node:
|
||||
return data
|
||||
if fpath:
|
||||
suffix=fpath.split(".")[-1]
|
||||
if suffix not in ('xml'):
|
||||
raise Exception("ERROR : please should file xml")
|
||||
data=xmltodict.parse(open(fpath,"r").read())
|
||||
stmstm=data.get('STMSTM')
|
||||
if stmstm:
|
||||
hdbills=stmstm.get(node)
|
||||
if not hdbills:
|
||||
return {}
|
||||
lines=[]
|
||||
for k, v in hdbills.items():
|
||||
collections=v
|
||||
for collection in collections:
|
||||
if isinstance(collection,dict):
|
||||
line={}
|
||||
for i, j in collection.items():
|
||||
key=(i or "").lower()
|
||||
line[key]=j
|
||||
lines.append(line)
|
||||
return lines
|
||||
|
||||
def date2thai(date, format='%(BY)s-%(m)s-%(d)s', lang='th_TH'):
|
||||
'''
|
||||
>>> date2thai('2011-12-31', lang='th_TH')
|
||||
|
@ -59,7 +115,6 @@ def date2thai(date, format='%(BY)s-%(m)s-%(d)s', lang='th_TH'):
|
|||
|
||||
#dow = DateTime.Date(int(year), int(month), int(day)).day_of_week
|
||||
dow = datetime(int(year),int(month),int(day)).weekday()
|
||||
|
||||
return format % { 'BY': int(year) + 543
|
||||
, 'By': int(year[2:]) + 43
|
||||
, 'Tm': MONTHS[lang][int(month)]
|
||||
|
@ -67,3 +122,7 @@ def date2thai(date, format='%(BY)s-%(m)s-%(d)s', lang='th_TH'):
|
|||
, 'm': month
|
||||
, 'd': int(day) # XXX remove zero
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
from netforce.model import Model, fields
|
||||
|
||||
class VascularAccess(Model):
|
||||
_name="clinic.vascular.access"
|
||||
_string="Vascular Access"
|
||||
|
||||
_fields={
|
||||
"name": fields.Char("Name",required=True,search=True),
|
||||
'note': fields.Text("Note"),
|
||||
}
|
||||
|
||||
VascularAccess.register()
|
|
@ -67,6 +67,7 @@ class VisitBoard(Model):
|
|||
'details':'',
|
||||
}
|
||||
|
||||
patient_types={t['id']:t['name'] for t in get_model("clinic.patient.type").search_read([[]],['name'])}
|
||||
types={}
|
||||
no=1
|
||||
for visit in get_model("clinic.visit").search_browse(dom):
|
||||
|
@ -94,7 +95,7 @@ class VisitBoard(Model):
|
|||
'cycle_color': cycle.color,
|
||||
'patient_name': patient.name,
|
||||
'patient_id': patient.id,
|
||||
'patient_type': utils.PATIENT_TYPE.get(patient.type,''),
|
||||
'patient_type': patient.type_id.name or "",
|
||||
'doctor_name': visit.doctor_id.name,
|
||||
'doctor_id': visit.doctor_id.id,
|
||||
'hd_case_number': hd_case_number,
|
||||
|
@ -109,9 +110,9 @@ class VisitBoard(Model):
|
|||
no+=1
|
||||
if not types.get(visit_date):
|
||||
ptype={}
|
||||
[ptype.setdefault(t,0) for t in utils.PATIENT_TYPE.keys()]
|
||||
[ptype.setdefault(t,0) for t in patient_types.keys()]
|
||||
types[visit_date]=ptype
|
||||
types[visit_date][patient.type]+=1
|
||||
types[visit_date][patient.type_id.id]+=1
|
||||
|
||||
dates=[]
|
||||
index=0
|
||||
|
@ -123,7 +124,7 @@ class VisitBoard(Model):
|
|||
for qty in types[date].values():
|
||||
total_qty+=qty
|
||||
line['cycle_name']=utils.date2thai(date,format='%(Td)s %(d)s %(Tm)s',lang="th_TH2"),
|
||||
line['details']='รวม %s: %s'%(total_qty,', '.join('%s %s'%(utils.PATIENT_TYPE[k],v) for k,v in types[date].items()))
|
||||
line['details']='รวม %s: %s'%(total_qty,', '.join('%s %s'%(patient_types[k],v) for k,v in types[date].items()))
|
||||
lines.insert(index,line)
|
||||
dates.append(date)
|
||||
index+=1
|
||||
|
|
|
@ -134,11 +134,9 @@
|
|||
</span>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<th>{{prod_name}}</th>
|
||||
<th>{{sc}}</th>
|
||||
<th>{{uc}}</th>
|
||||
<th>{{others}}</th>
|
||||
<th>รวม</th>
|
||||
{{#each titles}}
|
||||
<th>{{name}}</th>
|
||||
{{/each}}
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each medicals}}
|
||||
|
@ -146,10 +144,9 @@
|
|||
<td>
|
||||
<a href="/ui#name=product&active_id={{prod_id}}&mode=form"> {{prod_name}} </a>
|
||||
</td>
|
||||
<td>{{sc}}</td>
|
||||
<td>{{uc}}</td>
|
||||
<td>{{others}}</td>
|
||||
<td>{{total}}</td>
|
||||
{{#each sub_lines}}
|
||||
<td>{{qty}}</td>
|
||||
{{/each}}
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
|
|
|
@ -9,11 +9,9 @@
|
|||
</center>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<th>{{prod_name}}</th>
|
||||
<th>{{sc}}</th>
|
||||
<th>{{uc}}</th>
|
||||
<th>{{others}}</th>
|
||||
<th>รวม</th>
|
||||
{{#each titles}}
|
||||
<th>{{name}}</th>
|
||||
{{/each}}
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each lines}}
|
||||
|
@ -21,10 +19,9 @@
|
|||
<td>
|
||||
<a href="/ui#name=product&active_id={{prod_id}}&mode=form"> {{prod_name}} </a>
|
||||
</td>
|
||||
<td>{{sc}}</td>
|
||||
<td>{{uc}}</td>
|
||||
<td>{{others}}</td>
|
||||
<td>{{total}}</td>
|
||||
{{#each sub_lines}}
|
||||
<td>{{qty}}</td>
|
||||
{{/each}}
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
hd case
|
||||
start / stop -> option udpate time
|
||||
======
|
||||
improval
|
||||
- type of patient
|
||||
=====
|
||||
|
@ -8,14 +11,17 @@ improval
|
|||
excel
|
||||
- social security
|
||||
- step
|
||||
1. create visit
|
||||
2. confirm visit -> hd case
|
||||
1. create visit -> OK
|
||||
2. confirm visit -> hd case -> still run script
|
||||
- after finish need to update invoice date related to hd case
|
||||
3. match payment
|
||||
- show wrong match
|
||||
- show how to solve
|
||||
|
||||
======
|
||||
bug:
|
||||
มีปัญหาการสร้าง address ของ contact จากผู้ป่วยโดยอัตโนมัติ เพราะมันไม่ได้ถูกเก็บไว้ที่ form
|
||||
- มีปัญหาการสร้าง address ของ contact จากผู้ป่วยโดยอัตโนมัติ เพราะมันไม่ได้ถูกเก็บไว้ที่ form
|
||||
- export excel in matrix mode
|
||||
=====
|
||||
first:
|
||||
match payment
|
||||
|
|
Loading…
Reference in New Issue