test: Allow Discharge despite Unbilled Services
This commit is contained in:
parent
03b25be9e9
commit
7206e12c2f
@ -11,7 +11,7 @@ import json
|
||||
|
||||
class HealthcareSettings(Document):
|
||||
def validate(self):
|
||||
for key in ['collect_registration_fee', 'link_customer_to_patient', 'patient_name_by', 'allow_discharge_despite_unbilled_services',
|
||||
for key in ['collect_registration_fee', 'link_customer_to_patient', 'patient_name_by',
|
||||
'lab_test_approval_required', 'create_sample_collection_for_lab_test', 'default_medical_code_standard']:
|
||||
frappe.db.set_default(key, self.get(key, ""))
|
||||
|
||||
|
@ -158,7 +158,7 @@ def discharge_patient(inpatient_record):
|
||||
|
||||
|
||||
def validate_inpatient_invoicing(inpatient_record):
|
||||
if frappe.db.get_default("allow_discharge_despite_unbilled_services"):
|
||||
if frappe.db.get_single_value("Healthcare Settings", "allow_discharge_despite_unbilled_services"):
|
||||
return
|
||||
|
||||
pending_invoices = get_pending_invoices(inpatient_record)
|
||||
|
@ -40,6 +40,31 @@ class TestInpatientRecord(unittest.TestCase):
|
||||
self.assertEqual(None, frappe.db.get_value("Patient", patient, "inpatient_record"))
|
||||
self.assertEqual(None, frappe.db.get_value("Patient", patient, "inpatient_status"))
|
||||
|
||||
def test_allow_discharge_despite_unbilled_services(self):
|
||||
frappe.db.sql("""delete from `tabInpatient Record`""")
|
||||
setup_inpatient_settings()
|
||||
patient = create_patient()
|
||||
# Schedule Admission
|
||||
ip_record = create_inpatient(patient)
|
||||
ip_record.expected_length_of_stay = 0
|
||||
ip_record.save(ignore_permissions = True)
|
||||
|
||||
# Admit
|
||||
service_unit = get_healthcare_service_unit()
|
||||
admit_patient(ip_record, service_unit, now_datetime())
|
||||
|
||||
# Discharge
|
||||
schedule_discharge(frappe.as_json({"patient": patient}))
|
||||
self.assertEqual("Vacant", frappe.db.get_value("Healthcare Service Unit", service_unit, "occupancy_status"))
|
||||
|
||||
ip_record = frappe.get_doc("Inpatient Record", ip_record.name)
|
||||
# Should not validate Pending Invoices
|
||||
ip_record.discharge()
|
||||
|
||||
self.assertEqual(None, frappe.db.get_value("Patient", patient, "inpatient_record"))
|
||||
self.assertEqual(None, frappe.db.get_value("Patient", patient, "inpatient_status"))
|
||||
|
||||
|
||||
def test_validate_overlap_admission(self):
|
||||
frappe.db.sql("""delete from `tabInpatient Record`""")
|
||||
patient = create_patient()
|
||||
@ -63,6 +88,13 @@ def mark_invoiced_inpatient_occupancy(ip_record):
|
||||
inpatient_occupancy.invoiced = 1
|
||||
ip_record.save(ignore_permissions = True)
|
||||
|
||||
|
||||
def setup_inpatient_settings():
|
||||
settings = frappe.get_single("Healthcare Settings")
|
||||
settings.allow_discharge_despite_unbilled_services = 1
|
||||
settings.save()
|
||||
|
||||
|
||||
def create_inpatient(patient):
|
||||
patient_obj = frappe.get_doc('Patient', patient)
|
||||
inpatient_record = frappe.new_doc('Inpatient Record')
|
||||
@ -78,6 +110,7 @@ def create_inpatient(patient):
|
||||
inpatient_record.scheduled_date = today()
|
||||
return inpatient_record
|
||||
|
||||
|
||||
def get_healthcare_service_unit():
|
||||
service_unit = get_random("Healthcare Service Unit", filters={"inpatient_occupancy": 1})
|
||||
if not service_unit:
|
||||
@ -105,6 +138,7 @@ def get_healthcare_service_unit():
|
||||
return service_unit.name
|
||||
return service_unit
|
||||
|
||||
|
||||
def get_service_unit_type():
|
||||
service_unit_type = get_random("Healthcare Service Unit Type", filters={"inpatient_occupancy": 1})
|
||||
|
||||
@ -116,6 +150,7 @@ def get_service_unit_type():
|
||||
return service_unit_type.name
|
||||
return service_unit_type
|
||||
|
||||
|
||||
def create_patient():
|
||||
patient = frappe.db.exists('Patient', '_Test IPD Patient')
|
||||
if not patient:
|
||||
|
Loading…
x
Reference in New Issue
Block a user