def test_fee_validity(self): item = create_healthcare_service_items() healthcare_settings = frappe.get_single("Healthcare Settings") healthcare_settings.enable_free_follow_ups = 1 healthcare_settings.max_visits = 2 healthcare_settings.valid_days = 7 healthcare_settings.automate_appointment_invoicing = 1 healthcare_settings.op_consulting_charge_item = item healthcare_settings.save(ignore_permissions=True) patient, medical_department, practitioner = create_healthcare_docs() # appointment should not be invoiced. Check Fee Validity created for new patient appointment = create_appointment(patient, practitioner, nowdate()) invoiced = frappe.db.get_value("Patient Appointment", appointment.name, "invoiced") self.assertEqual(invoiced, 0) # appointment should not be invoiced as it is within fee validity appointment = create_appointment(patient, practitioner, add_days(nowdate(), 4)) invoiced = frappe.db.get_value("Patient Appointment", appointment.name, "invoiced") self.assertEqual(invoiced, 0) # appointment should be invoiced as it is within fee validity but the max_visits are exceeded appointment = create_appointment(patient, practitioner, add_days(nowdate(), 5), invoice=1) invoiced = frappe.db.get_value("Patient Appointment", appointment.name, "invoiced") self.assertEqual(invoiced, 1) # appointment should be invoiced as it is not within fee validity and the max_visits are exceeded appointment = create_appointment(patient, practitioner, add_days(nowdate(), 10), invoice=1) invoiced = frappe.db.get_value("Patient Appointment", appointment.name, "invoiced") self.assertEqual(invoiced, 1)
def test_status(self): plan = create_therapy_plan() self.assertEquals(plan.status, 'Not Started') session = make_therapy_session( plan.name, plan.patient, 'Basic Rehab', '_Test Company') frappe.get_doc(session).submit() self.assertEquals(frappe.db.get_value( 'Therapy Plan', plan.name, 'status'), 'In Progress') session = make_therapy_session( plan.name, plan.patient, 'Basic Rehab', '_Test Company') frappe.get_doc(session).submit() self.assertEquals(frappe.db.get_value( 'Therapy Plan', plan.name, 'status'), 'Completed') patient, medical_department, practitioner = create_healthcare_docs() appointment = create_appointment(patient, practitioner, nowdate()) session = make_therapy_session( plan.name, plan.patient, 'Basic Rehab', '_Test Company', appointment.name) session = frappe.get_doc(session) session.submit() self.assertEquals(frappe.db.get_value( 'Patient Appointment', appointment.name, 'status'), 'Closed') session.cancel() self.assertEquals(frappe.db.get_value( 'Patient Appointment', appointment.name, 'status'), 'Open')
def test_medical_record(self): patient, medical_department, practitioner = create_healthcare_docs() appointment = create_appointment(patient, practitioner, nowdate(), invoice=1) encounter = create_encounter(appointment) # check for encounter medical_rec = frappe.db.exists('Patient Medical Record', {'status': 'Open', 'reference_name': encounter.name}) self.assertTrue(medical_rec) vital_signs = create_vital_signs(appointment) # check for vital signs medical_rec = frappe.db.exists('Patient Medical Record', {'status': 'Open', 'reference_name': vital_signs.name}) self.assertTrue(medical_rec) appointment = create_appointment(patient, practitioner, nowdate(), invoice=1, procedure_template=1) procedure = create_procedure(appointment) procedure.start_procedure() procedure.complete_procedure() # check for clinical procedure medical_rec = frappe.db.exists('Patient Medical Record', {'status': 'Open', 'reference_name': procedure.name}) self.assertTrue(medical_rec) template = create_lab_test_template(medical_department) lab_test = create_lab_test(template.name, patient) # check for lab test medical_rec = frappe.db.exists('Patient Medical Record', {'status': 'Open', 'reference_name': lab_test.name}) self.assertTrue(medical_rec)
def test_procedure_template_item(self): patient, medical_department, practitioner = create_healthcare_docs() procedure_template = create_clinical_procedure_template() self.assertTrue(frappe.db.exists('Item', procedure_template.item)) procedure_template.disabled = 1 procedure_template.save() self.assertEquals(frappe.db.get_value('Item', procedure_template.item, 'disabled'), 1)
def test_procedure_template_item(self): patient, practitioner = create_healthcare_docs() procedure_template = create_clinical_procedure_template() self.assertTrue(frappe.db.exists("Item", procedure_template.item)) procedure_template.disabled = 1 procedure_template.save() self.assertEqual(frappe.db.get_value("Item", procedure_template.item, "disabled"), 1)
def test_consumables(self): patient, medical_department, practitioner = create_healthcare_docs() procedure_template = create_clinical_procedure_template() procedure_template.allow_stock_consumption = 1 consumable = create_consumable() procedure_template.append('items', { 'item_code': consumable.item_code, 'qty': 1, 'uom': consumable.stock_uom, 'stock_uom': consumable.stock_uom }) procedure_template.save() procedure = create_procedure(procedure_template, patient, practitioner) result = procedure.start_procedure() if result == 'insufficient stock': procedure.make_material_receipt(submit=True) result = procedure.start_procedure() self.assertEqual(procedure.status, 'In Progress') result = procedure.complete_procedure() # check consumption self.assertTrue(frappe.db.exists('Stock Entry', result))
def test_consumables(self): patient, practitioner = create_healthcare_docs() procedure_template = create_clinical_procedure_template() procedure_template.allow_stock_consumption = 1 consumable = create_consumable() procedure_template.append( "items", { "item_code": consumable.item_code, "qty": 1, "uom": consumable.stock_uom, "stock_uom": consumable.stock_uom, }, ) procedure_template.save() procedure = create_procedure(procedure_template, patient, practitioner) result = procedure.start_procedure() if result == "insufficient stock": procedure.make_material_receipt(submit=True) result = procedure.start_procedure() self.assertEqual(procedure.status, "In Progress") result = procedure.complete_procedure() # check consumption self.assertTrue(frappe.db.exists("Stock Entry", result))
def test_creation_on_encounter_submission(self): patient, practitioner = create_healthcare_docs() medical_department = create_medical_department() encounter = create_encounter(patient, medical_department, practitioner) self.assertTrue(frappe.db.exists('Therapy Plan', encounter.therapy_plan))