refactor: Healthcare Module Page
This commit is contained in:
parent
c4b2dceb01
commit
06d1b047e0
@ -2,131 +2,68 @@ from __future__ import unicode_literals
|
|||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
def get_data():
|
def get_data():
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
|
||||||
"label": _("Consultation"),
|
|
||||||
"icon": "icon-star",
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"type": "doctype",
|
|
||||||
"name": "Patient Appointment",
|
|
||||||
"label": _("Patient Appointment"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "doctype",
|
|
||||||
"name": "Patient Encounter",
|
|
||||||
"label": _("Patient Encounter"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "doctype",
|
|
||||||
"name": "Vital Signs",
|
|
||||||
"label": _("Vital Signs"),
|
|
||||||
"description": _("Record Patient Vitals"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "page",
|
|
||||||
"name": "patient_history",
|
|
||||||
"label": _("Patient History"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "page",
|
|
||||||
"name": "appointment-analytic",
|
|
||||||
"label": _("Appointment Analytics"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "doctype",
|
|
||||||
"name": "Clinical Procedure",
|
|
||||||
"label": _("Clinical Procedure"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "doctype",
|
|
||||||
"name": "Inpatient Record",
|
|
||||||
"label": _("Inpatient Record"),
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": _("Laboratory"),
|
|
||||||
"icon": "icon-list",
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"type": "doctype",
|
|
||||||
"name": "Lab Test",
|
|
||||||
"label": _("Lab Test"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "doctype",
|
|
||||||
"name": "Sample Collection",
|
|
||||||
"label": _("Sample Collection"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "report",
|
|
||||||
"name": "Lab Test Report",
|
|
||||||
"is_query_report": True,
|
|
||||||
"label": _("Lab Test Report"),
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"label": _("Masters"),
|
"label": _("Masters"),
|
||||||
"icon": "icon-list",
|
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"type": "doctype",
|
"type": "doctype",
|
||||||
"name": "Patient",
|
"name": "Patient",
|
||||||
"label": _("Patient"),
|
"label": _("Patient"),
|
||||||
"onboard": 1,
|
"onboard": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "doctype",
|
"type": "doctype",
|
||||||
"name": "Healthcare Practitioner",
|
"name": "Healthcare Practitioner",
|
||||||
"label": _("Healthcare Practitioner"),
|
"label": _("Healthcare Practitioner"),
|
||||||
"onboard": 1,
|
"onboard": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "doctype",
|
"type": "doctype",
|
||||||
"name": "Practitioner Schedule",
|
"name": "Practitioner Schedule",
|
||||||
"label": _("Practitioner Schedule"),
|
"label": _("Practitioner Schedule"),
|
||||||
},
|
"onboard": 1
|
||||||
{
|
|
||||||
"type": "doctype",
|
|
||||||
"name": "Medical Code Standard",
|
|
||||||
"label": _("Medical Code Standard"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "doctype",
|
|
||||||
"name": "Medical Code",
|
|
||||||
"label": _("Medical Code"),
|
|
||||||
"onboard": 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "doctype",
|
|
||||||
"name": "Healthcare Service Unit",
|
|
||||||
"label": _("Healthcare Service Unit")
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": _("Settings"),
|
|
||||||
"icon": "icon-cog",
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"type": "doctype",
|
|
||||||
"name": "Healthcare Settings",
|
|
||||||
"label": _("Healthcare Settings"),
|
|
||||||
"onboard": 1,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "doctype",
|
"type": "doctype",
|
||||||
"name": "Medical Department",
|
"name": "Medical Department",
|
||||||
"label": _("Medical Department"),
|
"label": _("Medical Department"),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "doctype",
|
||||||
|
"name": "Healthcare Service Unit Type",
|
||||||
|
"label": _("Healthcare Service Unit Type")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "doctype",
|
||||||
|
"name": "Healthcare Service Unit",
|
||||||
|
"label": _("Healthcare Service Unit")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "doctype",
|
||||||
|
"name": "Medical Code Standard",
|
||||||
|
"label": _("Medical Code Standard")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "doctype",
|
||||||
|
"name": "Medical Code",
|
||||||
|
"label": _("Medical Code")
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Consultation Setup"),
|
||||||
|
"items": [
|
||||||
{
|
{
|
||||||
"type": "doctype",
|
"type": "doctype",
|
||||||
"name": "Appointment Type",
|
"name": "Appointment Type",
|
||||||
"label": _("Appointment Type"),
|
"label": _("Appointment Type"),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "doctype",
|
||||||
|
"name": "Clinical Procedure Template",
|
||||||
|
"label": _("Clinical Procedure Template")
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "doctype",
|
"type": "doctype",
|
||||||
"name": "Prescription Dosage",
|
"name": "Prescription Dosage",
|
||||||
@ -137,6 +74,36 @@ def get_data():
|
|||||||
"name": "Prescription Duration",
|
"name": "Prescription Duration",
|
||||||
"label": _("Prescription Duration")
|
"label": _("Prescription Duration")
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "doctype",
|
||||||
|
"name": "Antibiotic",
|
||||||
|
"label": _("Antibiotic")
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Consultation"),
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"type": "doctype",
|
||||||
|
"name": "Patient Appointment",
|
||||||
|
"label": _("Patient Appointment")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "doctype",
|
||||||
|
"name": "Clinical Procedure",
|
||||||
|
"label": _("Clinical Procedure")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "doctype",
|
||||||
|
"name": "Patient Encounter",
|
||||||
|
"label": _("Patient Encounter")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "doctype",
|
||||||
|
"name": "Vital Signs",
|
||||||
|
"label": _("Vital Signs")
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "doctype",
|
"type": "doctype",
|
||||||
"name": "Complaint",
|
"name": "Complaint",
|
||||||
@ -147,40 +114,104 @@ def get_data():
|
|||||||
"name": "Diagnosis",
|
"name": "Diagnosis",
|
||||||
"label": _("Diagnosis")
|
"label": _("Diagnosis")
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "doctype",
|
||||||
|
"name": "Fee Validity",
|
||||||
|
"label": _("Fee Validity")
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Settings"),
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"type": "doctype",
|
||||||
|
"name": "Healthcare Settings",
|
||||||
|
"label": _("Healthcare Settings"),
|
||||||
|
"onboard": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Laboratory Setup"),
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"type": "doctype",
|
||||||
|
"name": "Lab Test Template",
|
||||||
|
"label": _("Lab Test Template")
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "doctype",
|
"type": "doctype",
|
||||||
"name": "Lab Test Sample",
|
"name": "Lab Test Sample",
|
||||||
"label": _("Lab Test Sample"),
|
"label": _("Lab Test Sample")
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "doctype",
|
"type": "doctype",
|
||||||
"name": "Lab Test UOM",
|
"name": "Lab Test UOM",
|
||||||
"label": _("Lab Test UOM")
|
"label": _("Lab Test UOM")
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "doctype",
|
|
||||||
"name": "Antibiotic",
|
|
||||||
"label": _("Antibiotic")
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "doctype",
|
"type": "doctype",
|
||||||
"name": "Sensitivity",
|
"name": "Sensitivity",
|
||||||
"label": _("Sensitivity")
|
"label": _("Sensitivity")
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Laboratory"),
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"type": "doctype",
|
||||||
|
"name": "Lab Test",
|
||||||
|
"label": _("Lab Test")
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "doctype",
|
"type": "doctype",
|
||||||
"name": "Lab Test Template",
|
"name": "Sample Collection",
|
||||||
"label": _("Lab Test Template")
|
"label": _("Sample Collection")
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "doctype",
|
"type": "doctype",
|
||||||
"name": "Clinical Procedure Template",
|
"name": "Dosage Form",
|
||||||
"label": _("Clinical Procedure Template"),
|
"label": _("Dosage Form")
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Records and History"),
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"type": "page",
|
||||||
|
"name": "patient_history",
|
||||||
|
"label": _("Patient History"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "doctype",
|
"type": "doctype",
|
||||||
"name": "Healthcare Service Unit Type",
|
"name": "Patient Medical Record",
|
||||||
"label": _("Healthcare Service Unit Type")
|
"label": _("Patient Medical Record")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "doctype",
|
||||||
|
"name": "Inpatient Record",
|
||||||
|
"label": _("Inpatient Record")
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Reports"),
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"type": "report",
|
||||||
|
"is_query_report": True,
|
||||||
|
"name": "Patient Appointment Analytics",
|
||||||
|
"doctype": "Patient Appointment"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "report",
|
||||||
|
"is_query_report": True,
|
||||||
|
"name": "Lab Test Report",
|
||||||
|
"doctype": "Lab Test",
|
||||||
|
"label": _("Lab Test Report")
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -108,8 +108,8 @@ frappe.ui.form.on('Patient Appointment', {
|
|||||||
}, __('Create'));
|
}, __('Create'));
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe.db.get_value('Healthcare Settings', {name: 'Healthcare Settings'}, 'automate_appointment_invoicing', (settings) => {
|
frappe.db.get_value('Healthcare Settings', {name: 'Healthcare Settings'}, ['automate_appointment_invoicing'], (settings) => {
|
||||||
if (settings.automate_appointment_invoicing) {
|
if (settings.automate_appointment_invoicing == 1) {
|
||||||
frm.set_df_property('mode_of_payment', 'hidden', 0);
|
frm.set_df_property('mode_of_payment', 'hidden', 0);
|
||||||
frm.set_df_property('paid_amount', 'hidden', 0);
|
frm.set_df_property('paid_amount', 'hidden', 0);
|
||||||
frm.set_df_property('mode_of_payment', 'reqd', 1);
|
frm.set_df_property('mode_of_payment', 'reqd', 1);
|
||||||
|
|||||||
@ -320,7 +320,7 @@ def set_invoiced(item, method, ref_invoice=None):
|
|||||||
else:
|
else:
|
||||||
manage_fee_validity(item.reference_dn, method, ref_invoice)
|
manage_fee_validity(item.reference_dn, method, ref_invoice)
|
||||||
dt_from_appointment = 'Patient Encounter'
|
dt_from_appointment = 'Patient Encounter'
|
||||||
manage_doc_for_appoitnment(dt_from_appointment, item.reference_dn, invoiced)
|
manage_doc_for_appointment(dt_from_appointment, item.reference_dn, invoiced)
|
||||||
|
|
||||||
elif item.reference_dt == 'Lab Prescription':
|
elif item.reference_dt == 'Lab Prescription':
|
||||||
manage_prescriptions(invoiced, item.reference_dt, item.reference_dn, 'Lab Test', 'lab_test_created')
|
manage_prescriptions(invoiced, item.reference_dt, item.reference_dn, 'Lab Test', 'lab_test_created')
|
||||||
@ -380,7 +380,7 @@ def manage_fee_validity(appointment_name, method, ref_invoice=None):
|
|||||||
fee_validity = create_fee_validity(appointment_doc.practitioner, appointment_doc.patient, appointment_doc.appointment_date, ref_invoice)
|
fee_validity = create_fee_validity(appointment_doc.practitioner, appointment_doc.patient, appointment_doc.appointment_date, ref_invoice)
|
||||||
|
|
||||||
visited = fee_validity.visited
|
visited = fee_validity.visited
|
||||||
mark_appointments_as_invoiced(fee_validity, ref_invoice, method, appointment_doc)
|
mark_appointments_as_invoiced(fee_validity, ref_invoice, method, appointment_doc, visited)
|
||||||
|
|
||||||
if method == 'on_cancel':
|
if method == 'on_cancel':
|
||||||
ref_invoice_in_fee_validity = frappe.db.get_value('Fee Validity', fee_validity.name, 'ref_invoice')
|
ref_invoice_in_fee_validity = frappe.db.get_value('Fee Validity', fee_validity.name, 'ref_invoice')
|
||||||
@ -388,7 +388,7 @@ def manage_fee_validity(appointment_name, method, ref_invoice=None):
|
|||||||
frappe.delete_doc('Fee Validity', fee_validity.name)
|
frappe.delete_doc('Fee Validity', fee_validity.name)
|
||||||
|
|
||||||
|
|
||||||
def mark_appointments_as_invoiced(fee_validity, ref_invoice, method, appointment_doc):
|
def mark_appointments_as_invoiced(fee_validity, ref_invoice, method, appointment_doc, visited):
|
||||||
if method == 'on_cancel':
|
if method == 'on_cancel':
|
||||||
invoiced = True
|
invoiced = True
|
||||||
else:
|
else:
|
||||||
@ -405,13 +405,13 @@ def mark_appointments_as_invoiced(fee_validity, ref_invoice, method, appointment
|
|||||||
visited = 0
|
visited = 0
|
||||||
frappe.db.set_value('Fee Validity', fee_validity.name, 'visited', visited)
|
frappe.db.set_value('Fee Validity', fee_validity.name, 'visited', visited)
|
||||||
frappe.db.set_value('Patient Appointment', appointment.name, 'invoiced', False)
|
frappe.db.set_value('Patient Appointment', appointment.name, 'invoiced', False)
|
||||||
manage_doc_for_appoitnment('Patient Encounter', appointment.name, False)
|
manage_doc_for_appointment('Patient Encounter', appointment.name, False)
|
||||||
elif method == 'on_submit' and int(fee_validity.max_visits) > visit:
|
elif method == 'on_submit' and int(fee_validity.max_visits) > visit:
|
||||||
if ref_invoice == fee_validity.ref_invoice:
|
if ref_invoice == fee_validity.ref_invoice:
|
||||||
visited += 1
|
visited += 1
|
||||||
frappe.db.set_value('Fee Validity', fee_validity.name, 'visited', visited)
|
frappe.db.set_value('Fee Validity', fee_validity.name, 'visited', visited)
|
||||||
frappe.db.set_value('Patient Appointment', appointment.name, 'invoiced', True)
|
frappe.db.set_value('Patient Appointment', appointment.name, 'invoiced', True)
|
||||||
manage_doc_for_appoitnment('Patient Encounter', appointment.name, True)
|
manage_doc_for_appointment('Patient Encounter', appointment.name, True)
|
||||||
if ref_invoice == fee_validity.ref_invoice:
|
if ref_invoice == fee_validity.ref_invoice:
|
||||||
visit = visit + 1
|
visit = visit + 1
|
||||||
|
|
||||||
@ -432,7 +432,7 @@ def appointments_valid_in_fee_validity(appointment, invoiced):
|
|||||||
}, order_by='appointment_date', limit=int(max_visits)-1)
|
}, order_by='appointment_date', limit=int(max_visits)-1)
|
||||||
|
|
||||||
|
|
||||||
def manage_doc_for_appoitnment(dt_from_appointment, appointment, invoiced):
|
def manage_doc_for_appointment(dt_from_appointment, appointment, invoiced):
|
||||||
dn_from_appointment = frappe.db.get_value(
|
dn_from_appointment = frappe.db.get_value(
|
||||||
dt_from_appointment,
|
dt_from_appointment,
|
||||||
filters={'appointment': appointment}
|
filters={'appointment': appointment}
|
||||||
@ -525,7 +525,7 @@ def get_patient_vitals(patient, from_date=None, to_date=None):
|
|||||||
vitals = frappe.db.get_all('Vital Signs', {
|
vitals = frappe.db.get_all('Vital Signs', {
|
||||||
'docstatus': 1,
|
'docstatus': 1,
|
||||||
'patient': patient
|
'patient': patient
|
||||||
}, order_by='signs_date signs_time')
|
}, order_by='signs_date, signs_time')
|
||||||
|
|
||||||
if len(vitals):
|
if len(vitals):
|
||||||
return vitals
|
return vitals
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user