improvement
parent
be9976cb6e
commit
c8b1ea1ca8
|
@ -6,6 +6,7 @@
|
|||
<field name="date"/>
|
||||
<field name="location_from_id"/>
|
||||
<field name="location_to_id"/>
|
||||
<field name="note"/>
|
||||
<field name="patient_type_id"/>
|
||||
<field name="state"/>
|
||||
<field name="note"/>
|
||||
</form>
|
||||
|
|
|
@ -163,6 +163,7 @@ class NewPatient(Model):
|
|||
|
||||
vals={
|
||||
'patient_id': patient_id,
|
||||
'patient_type_id': patient.type_id.id,
|
||||
'location_from_id': obj.location_from_id.id,
|
||||
'location_to_id': obj.location_to_id.id,
|
||||
'state': 'new',
|
||||
|
|
|
@ -12,6 +12,7 @@ class PatientMove(Model):
|
|||
|
||||
_fields={
|
||||
'patient_id': fields.Many2One('clinic.patient','Patient',search=True, required=True),
|
||||
'patient_type_id': fields.Many2One("clinic.patient.type","Patient Type"),
|
||||
'date': fields.Date("Date", required=True,search=True),
|
||||
'location_from_id': fields.Many2One("clinic.department","Location From",search=True,required=True),
|
||||
'location_to_id': fields.Many2One("clinic.department","Location To",search=True,required=True),
|
||||
|
@ -35,6 +36,7 @@ class PatientMove(Model):
|
|||
data.update({
|
||||
'location_from_id': location_from_id,
|
||||
'location_to_id': location_to_id,
|
||||
'patient_type_id': patient.type_id.id,
|
||||
})
|
||||
return data
|
||||
|
||||
|
@ -76,12 +78,16 @@ class PatientMove(Model):
|
|||
['date','<=','%s-%s-%s'%(y,str(m).zfill(2),day_month)],
|
||||
['location_to_id','=', department_id],
|
||||
]
|
||||
|
||||
cond=cond1+[['state','=','normal']]
|
||||
ids=self.search(cond)
|
||||
move_ids=ids
|
||||
|
||||
prev_month=len(ids)
|
||||
|
||||
cond=cond1+[['state','=','new']]
|
||||
ids=self.search(cond)
|
||||
move_ids+=ids
|
||||
current_month=len(ids)
|
||||
current_items=[]
|
||||
for index, val in enumerate(self.read(ids)):
|
||||
|
@ -91,12 +97,35 @@ class PatientMove(Model):
|
|||
|
||||
cond=cond1+[['state','=','dispose']]
|
||||
ids=self.search(cond)
|
||||
dispose_ids=ids
|
||||
dispose_month=len(ids)
|
||||
dispose_items=[]
|
||||
for index, val in enumerate(self.read(ids)):
|
||||
val['no']=index+1
|
||||
dispose_items.append(val)
|
||||
|
||||
move_ids=[id for id in move_ids if id not in dispose_ids]
|
||||
|
||||
# group by type
|
||||
types={}
|
||||
for move in get_model("clinic.patient.move").browse(move_ids):
|
||||
type_name=move.patient_type_id.name
|
||||
types.setdefault(type_name,0)
|
||||
types[type_name]+=1
|
||||
|
||||
patient_types={}
|
||||
for pt in get_model("clinic.patient.type").search_browse([]):
|
||||
patient_types[pt.name]=types.get(pt.name, '')
|
||||
|
||||
type_lines=[]
|
||||
type_names=sorted(patient_types.keys())
|
||||
for type_name in type_names:
|
||||
qty=patient_types[type_name]
|
||||
type_lines.append({
|
||||
'name': type_name,
|
||||
'qty': qty,
|
||||
})
|
||||
|
||||
next_month=prev_month+current_month-dispose_month
|
||||
|
||||
prev_m=m-1
|
||||
|
@ -125,6 +154,7 @@ class PatientMove(Model):
|
|||
|
||||
'next_month': next_month,
|
||||
'next_month_thai': next_month_thai,
|
||||
'type_lines': type_lines,
|
||||
}
|
||||
return res
|
||||
|
||||
|
@ -178,6 +208,7 @@ class PatientMove(Model):
|
|||
'location_from_id': obj.location_from_id.id,
|
||||
'location_to_id': obj.location_to_id.id,
|
||||
'patient_id': obj.patient_id.id,
|
||||
'patient_type_id': obj.patient_type_id.id,
|
||||
'date': date,
|
||||
}
|
||||
self.create(vals)
|
||||
|
@ -202,6 +233,7 @@ class PatientMove(Model):
|
|||
'location_from_id': locations[locs[0]], #first
|
||||
'location_to_id': locations[locs[-1]], #last
|
||||
'patient_id': obj.id,
|
||||
'patient_type_id': obj.type_id.id,
|
||||
'note': obj.note,
|
||||
'date': date,
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ class ReportHDCaseSummaryV2(Model):
|
|||
|
||||
def get_report_data(self, ids, context={}):
|
||||
user_id=get_active_user()
|
||||
user=get_model('base.user').browse(user_id)
|
||||
defaults=self.default_get(context=context)
|
||||
month=defaults.get("month")
|
||||
y,m,d=month.split("-")
|
||||
|
@ -96,7 +97,10 @@ class ReportHDCaseSummaryV2(Model):
|
|||
'titles': medical_titles,
|
||||
'date': month,
|
||||
'can_edit': False,
|
||||
'date_print': time.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
'user_name': user.name,
|
||||
}
|
||||
#TODO separate next month by patient type
|
||||
data2=get_model("clinic.patient.move").get_data(date=month, department_id=department_id)
|
||||
data.update(data2)
|
||||
|
||||
|
@ -105,9 +109,6 @@ class ReportHDCaseSummaryV2(Model):
|
|||
data.update({
|
||||
'can_edit': True,
|
||||
})
|
||||
|
||||
from pprint import pprint
|
||||
pprint(data)
|
||||
return data
|
||||
|
||||
ReportHDCaseSummaryV2.register()
|
||||
|
|
Binary file not shown.
|
@ -43,17 +43,22 @@
|
|||
<td>จำนวนครั้งการทำ Hemodialysis</td><td>{{month_thai}}</td><td>เท่ากับ</td><td class="text-right">{{total_hdcase}}</td><td class="text-center">ครั้ง</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>จำนวนผู้ป่วยยกมาจากเดือน</td><td>{{prev_month_thai}}</td><td>เท่ากับ</td><td class="text-right">{{prev_month}}</td><td class="text-center">ครั้ง</td>
|
||||
<td>จำนวนผู้ป่วยยกมาจากเดือน</td><td>{{prev_month_thai}}</td><td>เท่ากับ</td><td class="text-right">{{prev_month}}</td><td class="text-center">คน</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>จำนวนผู้ป่วยรับใหม่เดือน</td><td>{{current_month_thai}}</td><td>เท่ากับ</td><td class="text-right">{{current_month}}</td><td class="text-center">ครั้ง</td>
|
||||
<td>จำนวนผู้ป่วยรับใหม่เดือน</td><td>{{current_month_thai}}</td><td>เท่ากับ</td><td class="text-right">{{current_month}}</td><td class="text-center">คน</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>จำนวนผู้ป่วยจำหน่ายเดือน</td><td>{{dispose_month_thai}}</td><td>เท่ากับ</td><td class="text-right">{{dispose_month}}</td><td class="text-center">ครั้ง</td>
|
||||
<td>จำนวนผู้ป่วยจำหน่ายเดือน</td><td>{{dispose_month_thai}}</td><td>เท่ากับ</td><td class="text-right">{{dispose_month}}</td><td class="text-center">คน</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>จำนวนผู้ป่วยยกไปเดือน</td><td>{{next_month_thai}}</td><td>เท่ากับ</td><td class="text-right">{{next_month}}</td><td class="text-center">ครั้ง</td>
|
||||
<td>จำนวนผู้ป่วยยกไปเดือน</td><td>{{next_month_thai}}</td><td>เท่ากับ</td><td class="text-right">{{next_month}}</td><td class="text-center">คน</td>
|
||||
</tr>
|
||||
{{#each type_lines}}
|
||||
<tr>
|
||||
<td>{{name}}</td><td></td><td>เท่ากับ</td><td class="text-right">{{qty}}</td><td class="text-center">คน</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
</tfoot>
|
||||
|
|
Loading…
Reference in New Issue