feat: Lab Test Report Summary and Chart
This commit is contained in:
parent
c5ccf38cdf
commit
b6675f8dd4
@ -14,7 +14,7 @@ def execute(filters=None):
|
|||||||
lab_test_list = get_lab_tests(filters)
|
lab_test_list = get_lab_tests(filters)
|
||||||
|
|
||||||
if not lab_test_list:
|
if not lab_test_list:
|
||||||
msgprint(_("No records found"))
|
msgprint(_('No records found'))
|
||||||
return columns, lab_test_list
|
return columns, lab_test_list
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
@ -34,83 +34,85 @@ def execute(filters=None):
|
|||||||
})
|
})
|
||||||
data.append(row)
|
data.append(row)
|
||||||
|
|
||||||
return columns, data
|
chart = get_chart_data(data)
|
||||||
|
report_summary = get_report_summary(data)
|
||||||
|
return columns, data, None, chart, report_summary
|
||||||
|
|
||||||
|
|
||||||
def get_columns():
|
def get_columns():
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"fieldname": "test",
|
'fieldname': 'test',
|
||||||
"label": _("Lab Test"),
|
'label': _('Lab Test'),
|
||||||
"fieldtype": "Link",
|
'fieldtype': 'Link',
|
||||||
"options": "Lab Test",
|
'options': 'Lab Test',
|
||||||
"width": "120"
|
'width': '120'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "template",
|
'fieldname': 'template',
|
||||||
"label": _("Lab Test Template"),
|
'label': _('Lab Test Template'),
|
||||||
"fieldtype": "Link",
|
'fieldtype': 'Link',
|
||||||
"options": "Lab Test Template",
|
'options': 'Lab Test Template',
|
||||||
"width": "120"
|
'width': '120'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "company",
|
'fieldname': 'company',
|
||||||
"label": _("Company"),
|
'label': _('Company'),
|
||||||
"fieldtype": "Link",
|
'fieldtype': 'Link',
|
||||||
"options": "Company",
|
'options': 'Company',
|
||||||
"width": "120"
|
'width': '120'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "patient",
|
'fieldname': 'patient',
|
||||||
"label": _("Patient"),
|
'label': _('Patient'),
|
||||||
"fieldtype": "Link",
|
'fieldtype': 'Link',
|
||||||
"options": "Patient",
|
'options': 'Patient',
|
||||||
"width": "120"
|
'width': '120'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "patient_name",
|
'fieldname': 'patient_name',
|
||||||
"label": _("Patient Name"),
|
'label': _('Patient Name'),
|
||||||
"fieldtype": "Data",
|
'fieldtype': 'Data',
|
||||||
"width": "120"
|
'width': '120'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "practitioner",
|
'fieldname': 'employee',
|
||||||
"label": _("Requesting Practitioner"),
|
'label': _('Lab Technician'),
|
||||||
"fieldtype": "Link",
|
'fieldtype': 'Link',
|
||||||
"options": "Healthcare Practitioner",
|
'options': 'Employee',
|
||||||
"width": "120"
|
'width': '120'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "employee",
|
'fieldname': 'status',
|
||||||
"label": _("Lab Technician"),
|
'label': _('Status'),
|
||||||
"fieldtype": "Link",
|
'fieldtype': 'Data',
|
||||||
"options": "Employee",
|
'width': '100'
|
||||||
"width": "120"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "status",
|
'fieldname': 'invoiced',
|
||||||
"label": _("Status"),
|
'label': _('Invoiced'),
|
||||||
"fieldtype": "Data",
|
'fieldtype': 'Check',
|
||||||
"width": "100"
|
'width': '100'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "invoiced",
|
'fieldname': 'result_date',
|
||||||
"label": _("Invoiced"),
|
'label': _('Result Date'),
|
||||||
"fieldtype": "Check",
|
'fieldtype': 'Date',
|
||||||
"width": "100"
|
'width': '100'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "result_date",
|
'fieldname': 'practitioner',
|
||||||
"label": _("Result Date"),
|
'label': _('Requesting Practitioner'),
|
||||||
"fieldtype": "Date",
|
'fieldtype': 'Link',
|
||||||
"width": "100"
|
'options': 'Healthcare Practitioner',
|
||||||
|
'width': '120'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "department",
|
'fieldname': 'department',
|
||||||
"label": _("Medical Department"),
|
'label': _('Medical Department'),
|
||||||
"fieldtype": "Link",
|
'fieldtype': 'Link',
|
||||||
"options": "Medical Department",
|
'options': 'Medical Department',
|
||||||
"width": "100"
|
'width': '100'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -139,3 +141,71 @@ def get_conditions(filters):
|
|||||||
conditions[key] = value
|
conditions[key] = value
|
||||||
|
|
||||||
return conditions
|
return conditions
|
||||||
|
|
||||||
|
def get_chart_data(data):
|
||||||
|
if not data:
|
||||||
|
return None
|
||||||
|
|
||||||
|
labels = ['Completed', 'Approved', 'Rejected']
|
||||||
|
|
||||||
|
status_wise_data = {
|
||||||
|
'Completed': 0,
|
||||||
|
'Approved': 0,
|
||||||
|
'Rejected': 0
|
||||||
|
}
|
||||||
|
|
||||||
|
datasets = []
|
||||||
|
|
||||||
|
for entry in data:
|
||||||
|
status_wise_data[entry.status] += 1
|
||||||
|
|
||||||
|
datasets.append({
|
||||||
|
'name': 'Lab Test Status',
|
||||||
|
'values': [status_wise_data.get('Completed'), status_wise_data.get('Approved'), status_wise_data.get('Rejected')]
|
||||||
|
})
|
||||||
|
|
||||||
|
chart = {
|
||||||
|
'data': {
|
||||||
|
'labels': labels,
|
||||||
|
'datasets': datasets
|
||||||
|
},
|
||||||
|
'type': 'donut',
|
||||||
|
'height': 300,
|
||||||
|
}
|
||||||
|
|
||||||
|
return chart
|
||||||
|
|
||||||
|
|
||||||
|
def get_report_summary(data):
|
||||||
|
if not data:
|
||||||
|
return None
|
||||||
|
|
||||||
|
total_lab_tests = len(data)
|
||||||
|
invoiced_lab_tests, unbilled_lab_tests = 0, 0
|
||||||
|
|
||||||
|
for entry in data:
|
||||||
|
if entry.invoiced:
|
||||||
|
invoiced_lab_tests += 1
|
||||||
|
else:
|
||||||
|
unbilled_lab_tests += 1
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
'value': total_lab_tests,
|
||||||
|
'indicator': 'Blue',
|
||||||
|
'label': 'Total Lab Tests',
|
||||||
|
'datatype': 'Int',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'value': invoiced_lab_tests,
|
||||||
|
'indicator': 'Green',
|
||||||
|
'label': 'Invoiced Lab Tests',
|
||||||
|
'datatype': 'Int',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'value': unbilled_lab_tests,
|
||||||
|
'indicator': 'Red',
|
||||||
|
'label': 'Unbilled Lab Tests',
|
||||||
|
'datatype': 'Int',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user