cycle time start & stop
parent
03a84b98a0
commit
7054fcc183
|
@ -4,9 +4,12 @@
|
|||
</button>
|
||||
</head>
|
||||
<field name="name"/>
|
||||
<field name="duration"/>
|
||||
<field name="sequence"/>
|
||||
<field name="time_start"/>
|
||||
<field name="time_stop"/>
|
||||
<field name="color"/>
|
||||
<field name="duration"/>
|
||||
<field name="note"/>
|
||||
<related>
|
||||
<field name="cycle_items"/>
|
||||
<field name="visits"/>
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<list model="clinic.cycle">
|
||||
<field name="name"/>
|
||||
<field name="time_start"/>
|
||||
<field name="time_stop"/>
|
||||
<field name="duration"/>
|
||||
<field name="sequence"/>
|
||||
<!--<field name="color"/>-->
|
||||
|
|
|
@ -1,46 +1,41 @@
|
|||
<form model="clinic.gen.visit">
|
||||
<group form_layout="stacked">
|
||||
<field name="date_from" onchange="onchange_time" span="3"/>
|
||||
<field name="date_to" onchange="onchange_dateto" span="3"/>
|
||||
<!--<field name="duration" span="3"/>-->
|
||||
<field name="cycle_id" onchange="onchange_time" span="3"/>
|
||||
<field name="patient_categ_id" span="3"/>
|
||||
<field name="doctor_id" span="3"/>
|
||||
<field name="nurse_categ_id" span="3"/>
|
||||
<field name="department_id" span="3"/>
|
||||
<field name="patient_type" span="3"/>
|
||||
</group>
|
||||
<separator string="Select Days"/>
|
||||
<group form_layout="stacked">
|
||||
<field name="monday" span="3"/>
|
||||
<field name="tuesday" span="3"/>
|
||||
<field name="wednesday" span="3"/>
|
||||
<field name="thursday" span="3"/>
|
||||
<field name="friday" span="3"/>
|
||||
<field name="sathurday" span="3"/>
|
||||
<field name="sunday" span="3"/>
|
||||
</group>
|
||||
<separator string="Manual"/>
|
||||
<tabs>
|
||||
<tab string="Patients">
|
||||
<group form_layout="stacked">
|
||||
<field name="patient_lines" nolabel="1" span="6">
|
||||
<field name="date_from" span="2"/>
|
||||
<field name="time_start" span="1"/>
|
||||
<field name="date_to" span="2"/>
|
||||
<field name="time_stop" span="1"/>
|
||||
<field name="cycle_id" onchange="onchange_cycle" span="2"/>
|
||||
<field name="patient_categ_id" span="2"/>
|
||||
<field name="patient_type" span="2"/>
|
||||
<field name="doctor_id" span="2"/>
|
||||
<field name="department_id" span="2"/>
|
||||
<field name="nurse_categ_id" span="2"/>
|
||||
<separator string="Select Days"/>
|
||||
<field name="monday" span="2"/>
|
||||
<field name="tuesday" span="2"/>
|
||||
<field name="wednesday" span="2"/>
|
||||
<field name="thursday" span="2"/>
|
||||
<field name="friday" span="2"/>
|
||||
<field name="sathurday" span="2"/>
|
||||
<field name="sunday" span="2"/>
|
||||
<separator string="Manual"/>
|
||||
<tabs>
|
||||
<tab string="Patients">
|
||||
<field name="patient_lines" nolabel="1">
|
||||
<list>
|
||||
<field name="patient_id"/>
|
||||
</list>
|
||||
</field>
|
||||
</group>
|
||||
</tab>
|
||||
<tab string="Nurses">
|
||||
<group form_layout="stacked">
|
||||
<field name="nurse_lines" nolabel="1" span="6">
|
||||
</tab>
|
||||
<tab string="Nurses">
|
||||
<field name="nurse_lines" nolabel="1">
|
||||
<list>
|
||||
<field name="nurse_id"/>
|
||||
</list>
|
||||
</field>
|
||||
</group>
|
||||
</tab>
|
||||
</tabs>
|
||||
</tab>
|
||||
</tabs>
|
||||
</group>
|
||||
<foot>
|
||||
<button string="Generate" type="success" icon="arrow-right" method="gen_visit"/>
|
||||
<button string="Remove" type="danger" icon="remove" method="clear_visit"/>
|
||||
|
|
|
@ -86,10 +86,17 @@
|
|||
</field>
|
||||
</tab>
|
||||
<tab string="Note">
|
||||
<field name="note" nolabel="1"/>
|
||||
<field name="active"/>
|
||||
<field name="resign_date" readonly="1"/>
|
||||
<field name="rm_remain_visit" attrs='{"invisible":[["active","=","true"]]}'/>
|
||||
<group form_layout="stacked">
|
||||
<field name="active" span="2"/>
|
||||
<field name="rm_remain_visit" span="2" attrs='{"invisible":[["active","=","true"]]}'/>
|
||||
<field name="resign_date" span="2" readonly="1"/>
|
||||
<newline/>
|
||||
<field name="note" nolabel="1"/>
|
||||
</group>
|
||||
</tab>
|
||||
<tab string="Other">
|
||||
<field name="cycle_id"/>
|
||||
<field name="fee_partner_id"/>
|
||||
</tab>
|
||||
</tabs>
|
||||
<related>
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
<form title="Social Security">
|
||||
<group span="6" columns="1">
|
||||
<field name="file"/>
|
||||
</group>
|
||||
<group span="6" columns="1">
|
||||
<group form_layout="stacked">
|
||||
<field name="file" span="3"/>
|
||||
<field name="hcode" span="3"/>
|
||||
</group>
|
||||
<foot replace="1">
|
||||
<button string="Import" method="import_uc" type="primary" icon="arrow-right"/>
|
||||
<button string="Import" method="import_sc" type="primary" icon="arrow-right"/>
|
||||
</foot>
|
||||
</form>
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from datetime import datetime
|
||||
|
||||
from netforce.model import Model, fields
|
||||
from netforce.access import get_active_company
|
||||
|
||||
|
@ -5,17 +7,46 @@ class Cycle(Model):
|
|||
_name="clinic.cycle"
|
||||
_string="Cycle"
|
||||
_key=["name"]
|
||||
|
||||
def _get_duration(self,ids,context={}):
|
||||
res={}
|
||||
fmt="%Y-%m-%d %H:%M"
|
||||
date=datetime.now().strftime(fmt)[0:10]
|
||||
for obj in self.browse(ids):
|
||||
tstart=obj.time_start
|
||||
tstop=obj.time_stop
|
||||
if not tstart:
|
||||
tstart='00:00'
|
||||
if not tstop:
|
||||
tstop='00:00'
|
||||
# recheck
|
||||
tstart=tstart.replace(".",":")
|
||||
tstop=tstop.replace(".",":")
|
||||
if len(tstart.split(":"))!=2:
|
||||
tstart="00:00"
|
||||
if len(tstop.split(":"))!=2:
|
||||
tstop="00:00"
|
||||
dstart='%s %s'%(date,tstart)
|
||||
dstop='%s %s'%(date,tstop)
|
||||
|
||||
diff=datetime.strptime(dstop,fmt)-datetime.strptime(dstart,fmt)
|
||||
total_time=round(diff.seconds/3600,2)
|
||||
res[obj.id]=total_time
|
||||
return res
|
||||
|
||||
_fields={
|
||||
"name": fields.Char("Name",required=True,search=True),
|
||||
'duration': fields.Integer("Duration (hrs)"),
|
||||
'duration': fields.Integer("Duration(Hour)",function="_get_duration"),
|
||||
'sequence': fields.Integer("Sequence"),
|
||||
'time_start': fields.Char("Start Time"),
|
||||
'time_stop': fields.Char("End Time"),
|
||||
'company_id': fields.Many2One("company", "Company"),
|
||||
'hd_cases': fields.One2Many("clinic.hd.case","cycle_id", "HD Cases"),
|
||||
'visits': fields.One2Many("clinic.visit","cycle_id", "Visits"),
|
||||
'cycle_items': fields.One2Many("clinic.cycle.item","cycle_id", "Cycle Items"),
|
||||
'var_k': fields.Float("K"),
|
||||
'color': fields.Char("Color"),
|
||||
'note': fields.Text("Note"),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
|
|
|
@ -10,17 +10,11 @@ class GenVisit(Model):
|
|||
_name="clinic.gen.visit"
|
||||
_transient=True
|
||||
|
||||
|
||||
def _get_duration(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
duration=datetime.strptime(obj.date_to,FMT_DATETIME)-datetime.strptime(obj.date_from,FMT_DATETIME)
|
||||
res[obj.id]=duration.days
|
||||
return res
|
||||
|
||||
_fields={
|
||||
'date_from': fields.DateTime("From", required=True),
|
||||
'date_to': fields.DateTime("To", required=True),
|
||||
'date_from': fields.Date("From", required=True),
|
||||
'date_to': fields.Date("To", required=True),
|
||||
'time_start': fields.Char("Time start"),
|
||||
'time_stop': fields.Char("Time Stop"),
|
||||
'cycle_id': fields.Many2One("clinic.cycle","Cycle", required=True),
|
||||
'patient_lines': fields.One2Many("clinic.gen.visit.line","gen_id","Patient Lines"),
|
||||
'nurse_lines': fields.One2Many("clinic.gen.visit.line","gen_id","Nurse Lines"),
|
||||
|
@ -33,7 +27,6 @@ class GenVisit(Model):
|
|||
'sunday': fields.Boolean("Sunday"),
|
||||
'doctor_id': fields.Many2One("clinic.staff","Doctor",domain=[['type','=','doctor']]),
|
||||
'department_id': fields.Many2One("clinic.department","Department"),
|
||||
'duration': fields.Integer("Duration (hrs)", function="_get_duration"),
|
||||
"patient_type": fields.Selection([("sc","Social Security"),("uc","UC."),("others","Others")],"Patient Type"),
|
||||
'patient_categ_id': fields.Many2One("clinic.patient.categ", "Patient Category"),
|
||||
'nurse_categ_id': fields.Many2One("clinic.staff.categ", "Nurse Category", domain=[['type','=','nurse']]),
|
||||
|
@ -64,12 +57,32 @@ class GenVisit(Model):
|
|||
cycle_id=cycle_ids[0]
|
||||
return cycle_id or None
|
||||
|
||||
def _get_start(self,context={}):
|
||||
cycle_ids=get_model('clinic.cycle').search([],order="sequence")
|
||||
time_start="00:00"
|
||||
if cycle_ids:
|
||||
cycle_id=cycle_ids[0]
|
||||
cycle=get_model('clinic.cycle').browse(cycle_id)
|
||||
time_start=cycle.time_start
|
||||
return time_start
|
||||
|
||||
def _get_stop(self,context={}):
|
||||
cycle_ids=get_model('clinic.cycle').search([],order="sequence")
|
||||
time_stop="00:00"
|
||||
if cycle_ids:
|
||||
cycle_id=cycle_ids[0]
|
||||
cycle=get_model('clinic.cycle').browse(cycle_id)
|
||||
time_stop=cycle.time_stop
|
||||
return time_stop
|
||||
|
||||
_defaults={
|
||||
'patient_lines': _get_patient_lines,
|
||||
'date_from': lambda *a: datetime.now().strftime(FMT_DATETIME),
|
||||
'date_to': lambda *a: (datetime.now()+timedelta(days=7)).strftime(FMT_DATETIME),
|
||||
'date_from': lambda *a: datetime.now().strftime(FMT_DATE),
|
||||
'date_to': lambda *a: (datetime.now()+timedelta(days=7)).strftime(FMT_DATE),
|
||||
'time_start': _get_start,
|
||||
'time_stop': _get_stop,
|
||||
'nurse_id': _get_nurse,
|
||||
'duration': 1,
|
||||
'duration': 2,
|
||||
'cycle_id': _get_cycle,
|
||||
#'monday': True, # dynamic select weekday, use default_get
|
||||
}
|
||||
|
@ -89,24 +102,13 @@ class GenVisit(Model):
|
|||
vals[wds[wd]]=True
|
||||
return vals
|
||||
|
||||
def onchange_time(self,context={}):
|
||||
def onchange_cycle(self,context={}):
|
||||
data=context['data']
|
||||
cycle_id=data['cycle_id']
|
||||
duration=1
|
||||
if cycle_id:
|
||||
cycle=get_model('clinic.cycle').browse(cycle_id)
|
||||
duration=cycle.duration or 0
|
||||
seconds=duration*3600
|
||||
date_from=data['date_from']
|
||||
date_to=(datetime.strptime(date_from,FMT_DATETIME)+timedelta(seconds=seconds)).strftime(FMT_DATETIME)
|
||||
data['date_to']='%s %s'%(data['date_to'][0:10],date_to[11:])
|
||||
duration=(datetime.strptime(data['date_to'],FMT_DATETIME)-datetime.strptime(data['date_from'],FMT_DATETIME)).seconds/3600
|
||||
data['duration']=duration
|
||||
return data
|
||||
|
||||
def onchange_dateto(self,context={}):
|
||||
data=context['data']
|
||||
data['duration']=(datetime.strptime(data['date_to'],FMT_DATETIME)-datetime.strptime(data['date_from'],FMT_DATETIME)).seconds/3600
|
||||
data['time_start']=cycle.time_start
|
||||
data['time_stop']=cycle.time_stop
|
||||
return data
|
||||
|
||||
def gen_visit(self,ids,context):
|
||||
|
@ -125,8 +127,8 @@ class GenVisit(Model):
|
|||
if not days:
|
||||
raise Exception("Please select Day")
|
||||
visit_vals=[]
|
||||
date_from=datetime.strptime(obj.date_from,FMT_DATETIME)
|
||||
date_to=datetime.strptime(obj.date_to,FMT_DATETIME)
|
||||
date_from=datetime.strptime(obj.date_from,FMT_DATE)
|
||||
date_to=datetime.strptime(obj.date_to,FMT_DATE)
|
||||
patients=[p.patient_id.id for p in obj.patient_lines if p.patient_id]
|
||||
if not patients and obj.patient_type:
|
||||
patients=get_model("clinic.patient").search([['type','=',obj.patient_type]])
|
||||
|
@ -158,6 +160,10 @@ class GenVisit(Model):
|
|||
'level_id': nurse.level_id.id,
|
||||
})
|
||||
schedules={}
|
||||
cycle=obj.cycle_id
|
||||
cstart='%s:00'%cycle.time_start
|
||||
cstop='%s:00'%cycle.time_stop
|
||||
|
||||
for patient_id in patients:
|
||||
patient=get_model("clinic.patient").browse(patient_id)
|
||||
ntoday=1
|
||||
|
@ -175,13 +181,13 @@ class GenVisit(Model):
|
|||
tmp=start_date
|
||||
while count < day_total:
|
||||
tmp=start_date+timedelta(days=count)
|
||||
ttime_start="%s %s" % (tmp.strftime(FMT_DATE),date_from.strftime(FMT_DATETIME)[11:])
|
||||
ttime_stop="%s %s" % (tmp.strftime(FMT_DATE),date_to.strftime(FMT_DATETIME)[11:])
|
||||
ttime_start="%s %s" % (tmp.strftime(FMT_DATE),cstart)
|
||||
ttime_stop="%s %s" % (tmp.strftime(FMT_DATE),cstop)
|
||||
vals={
|
||||
'patient_id': patient_id,
|
||||
'doctor_id': obj.doctor_id.id or patient.doctor_id.id,
|
||||
'department_id': obj.department_id.id,
|
||||
'cycle_id': obj.cycle_id.id,
|
||||
'cycle_id': cycle.id,
|
||||
'time_start': ttime_start,
|
||||
'time_stop': ttime_stop,
|
||||
'state': 'draft',
|
||||
|
@ -205,12 +211,16 @@ class GenVisit(Model):
|
|||
'time_stop': ttime_stop,
|
||||
'state':'draft',
|
||||
}
|
||||
|
||||
start_date=tmp
|
||||
|
||||
user_id=get_active_user()
|
||||
staff_ids=get_model("clinic.staff").search([['type','=','type'],['user_id','=',user_id]])
|
||||
confirm_id=None
|
||||
if staff_ids:
|
||||
confirm_id=staff_ids[0]
|
||||
for vals in visit_vals:
|
||||
vals['nurse_id']=confirm_id
|
||||
visit_obj.create(vals)
|
||||
|
||||
|
||||
print("create schedule")
|
||||
print("="*50)
|
||||
for k, v in schedules.items():
|
||||
|
@ -263,8 +273,8 @@ class GenVisit(Model):
|
|||
]
|
||||
days=[day for day in days if day]
|
||||
visit_ids=[]
|
||||
date_from=datetime.strptime(obj.date_from,FMT_DATETIME)
|
||||
date_to=datetime.strptime(obj.date_to,FMT_DATETIME)
|
||||
date_from=datetime.strptime(obj.date_from,FMT_DATE)
|
||||
date_to=datetime.strptime(obj.date_to,FMT_DATE)
|
||||
# FIXME add more 1 week for make sure
|
||||
date_to2=(date_to+timedelta(days=7)).strftime(FMT_DATETIME)
|
||||
visit_obj=get_model("clinic.visit")
|
||||
|
@ -282,12 +292,16 @@ class GenVisit(Model):
|
|||
dom=[]
|
||||
dom.append(['time_start','>=','%s %s'%(obj.date_from[0:10],' 00:00:00')])
|
||||
dom.append(['time_stop','<=','%s %s'%(date_to2[0:10],' 23:59:59')])
|
||||
dom.append(['cycle_id','=',obj.cycle_id.id])
|
||||
dom.append(['state','=','draft'])
|
||||
vids=visit_obj.search(dom)
|
||||
visit_obj.delete(vids)
|
||||
schedule_obj=get_model("clinic.schedule")
|
||||
schedule_ids=schedule_obj.search(dom)
|
||||
schedules=schedule_obj.search_browse(dom)
|
||||
schedule_ids=[]
|
||||
for sch in schedules:
|
||||
for line in sch.lines:
|
||||
if obj.cycle_id.id==line.cycle_id.id:
|
||||
schedule_ids.append(sch.id)
|
||||
schedule_obj.delete(schedule_ids)
|
||||
return {
|
||||
'next': {
|
||||
|
|
|
@ -15,7 +15,7 @@ class HDCase(Model):
|
|||
_name_field="number"
|
||||
_multi_company=True
|
||||
|
||||
def get_hrs(self,ids,context={}):
|
||||
def _get_duration(self,ids,context={}):
|
||||
res={}
|
||||
fmt="%Y-%m-%d %H:%M:%S"
|
||||
for obj in self.browse(ids):
|
||||
|
@ -24,7 +24,7 @@ class HDCase(Model):
|
|||
res[obj.id]=total_time
|
||||
return res
|
||||
|
||||
def get_pay_amount(self,ids,context={}):
|
||||
def _get_pay_amount(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
res[obj.id]=obj.amount
|
||||
|
@ -101,7 +101,7 @@ class HDCase(Model):
|
|||
"payments": fields.One2Many("account.payment","related_id","Payments"),
|
||||
"payment_lines": fields.One2Many("clinic.payment","hd_case_id","Payment Lines"),
|
||||
'visit_id': fields.Many2One("clinic.visit", "Visit"),
|
||||
'duration': fields.Integer("Duration(Hours)",function="get_hrs"),
|
||||
'duration': fields.Integer("Duration(Hours)",function="_get_duration"),
|
||||
"total": fields.Float("Total",function="_get_total",readonly=True,function_multi=True),
|
||||
"fee_amount": fields.Float("Fee",function="_get_total",readonly=True,function_multi=True),
|
||||
"mdc_amount": fields.Float("Medicine",function="_get_total",readonly=True,function_multi=True),
|
||||
|
@ -112,7 +112,7 @@ class HDCase(Model):
|
|||
'complication': fields.Text("Complication"),
|
||||
"cycle_id": fields.Many2One("clinic.cycle","Cycle"),
|
||||
'cycle_item_id': fields.Many2One("clinic.cycle.item","Nurse Schedule"), # on_delete="cascade" -> will rm visit from cycle item
|
||||
'pay_amount': fields.Float("Amount",function="get_pay_amount"),
|
||||
'pay_amount': fields.Float("Amount",function="_get_pay_amount"),
|
||||
'pay_date': fields.Date("Pay Date"),
|
||||
'pay_account_id': fields.Many2One("account.account","Account"),
|
||||
'payment_id': fields.Many2One("account.payment","Payment"), # for print
|
||||
|
@ -187,13 +187,15 @@ class HDCase(Model):
|
|||
def onchange_patient(self,context={}):
|
||||
data=context['data']
|
||||
patient_id=data['patient_id']
|
||||
hd_cases=self.search_browse([['patient_id','=',patient_id]])
|
||||
if hd_cases:
|
||||
hd_case=hd_cases[-1]
|
||||
data['department_id']=hd_case.department_id.id
|
||||
else:
|
||||
data['department_id']=None
|
||||
#XXX
|
||||
if patient_id:
|
||||
patient=get_model('clinic.patient').browse(patient_id)
|
||||
department=patient.department_id
|
||||
cycle=patient.cycle_id
|
||||
partner=patient.fee_partner_id
|
||||
data['department_id']=department.id
|
||||
data['patient_type']=patient.type
|
||||
data['cycle_id']=cycle.id
|
||||
data['fee_partner_id']=partner.id
|
||||
data['dialyzers']=[]
|
||||
|
||||
return data
|
||||
|
|
|
@ -9,6 +9,8 @@ from netforce.utils import get_file_path
|
|||
from netforce.utils import get_data_path
|
||||
from netforce.database import get_connection
|
||||
|
||||
from pprint import pprint
|
||||
|
||||
class ImportPayment(Model):
|
||||
_name="clinic.import.payment"
|
||||
_transient=True
|
||||
|
@ -121,6 +123,49 @@ class ImportPayment(Model):
|
|||
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
|
||||
|
||||
data_sc=get_model("clinic.data.sc")
|
||||
sc_ids=data_sc.search([])
|
||||
data_sc.delete(sc_ids)
|
||||
|
@ -190,12 +235,6 @@ class ImportPayment(Model):
|
|||
obj.write({
|
||||
'result': msg,
|
||||
})
|
||||
|
||||
def import_mg(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
fname=obj.file
|
||||
fpath=get_file_path(fname)
|
||||
print("fpath ", fpath)
|
||||
|
||||
def clear_sc(self,ids,context={}):
|
||||
sc_ids=get_model("clinic.data.sc").search([])
|
||||
|
@ -254,5 +293,4 @@ class ImportPayment(Model):
|
|||
'flash': 'Paid',
|
||||
}
|
||||
|
||||
|
||||
ImportPayment.register()
|
||||
|
|
|
@ -3,11 +3,8 @@ import time
|
|||
from netforce.model import Model, fields, get_model
|
||||
from netforce.access import get_active_company, get_active_user, set_active_user
|
||||
|
||||
PATIENT_TYPE={
|
||||
"sc":"Social Security",
|
||||
"uc":"UC",
|
||||
"others": "Others",
|
||||
}
|
||||
from . import utils
|
||||
|
||||
|
||||
class Patient(Model):
|
||||
_name="clinic.patient"
|
||||
|
@ -26,6 +23,28 @@ class Patient(Model):
|
|||
age=year_now-year_bd
|
||||
res[obj.id]=age
|
||||
return res # -> {1: 30, 2: 45,.....}
|
||||
|
||||
def _get_last_cycle(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
cycle_id=None
|
||||
for vs in obj.visits:
|
||||
cycle=vs.cycle_id
|
||||
cycle_id=cycle.id
|
||||
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),
|
||||
|
@ -84,6 +103,8 @@ class Patient(Model):
|
|||
'rm_remain_visit': fields.Boolean("Auto Remove Remaining Visit"),
|
||||
'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={}):
|
||||
|
|
|
@ -55,6 +55,56 @@ class ClinicSetting(Model):
|
|||
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)
|
||||
|
|
|
@ -7,6 +7,12 @@ improval
|
|||
- uc
|
||||
excel
|
||||
- social security
|
||||
- step
|
||||
1. create visit
|
||||
2. confirm visit -> hd case
|
||||
3. match payment
|
||||
- show wrong match
|
||||
- show how to solve
|
||||
======
|
||||
bug:
|
||||
มีปัญหาการสร้าง address ของ contact จากผู้ป่วยโดยอัตโนมัติ เพราะมันไม่ได้ถูกเก็บไว้ที่ form
|
||||
|
|
Loading…
Reference in New Issue