Esempio n. 1
0
    def test_do_not_bill_patient_encounters_for_inpatients(self):
        frappe.db.sql("""delete from `tabInpatient Record`""")
        setup_inpatient_settings(key="do_not_bill_inpatient_encounters",
                                 value=1)
        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())

        # Patient Encounter
        patient_encounter = create_patient_encounter()
        encounters = get_encounters_to_invoice(patient, "_Test Company")
        encounter_ids = [entry.reference_name for entry in encounters]
        self.assertFalse(patient_encounter.name in encounter_ids)

        # 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)
        mark_invoiced_inpatient_occupancy(ip_record)
        discharge_patient(ip_record)
        setup_inpatient_settings(key="do_not_bill_inpatient_encounters",
                                 value=0)
Esempio n. 2
0
def get_healthcare_services_to_invoice(patient, company):
    patient = frappe.get_doc('Patient', patient)
    items_to_invoice = []
    if patient:
        validate_customer_created(patient)
        # Customer validated, build a list of billable services
        items_to_invoice += get_appointments_to_invoice(patient, company)
        items_to_invoice += get_encounters_to_invoice(patient, company)
        items_to_invoice += get_lab_tests_to_invoice(patient, company)
        items_to_invoice += get_clinical_procedures_to_invoice(
            patient, company)
        items_to_invoice += get_inpatient_services_to_invoice(patient, company)
        items_to_invoice += get_therapy_sessions_to_invoice(patient, company)
        items_to_invoice += get_ip_services_to_invoice(patient, company)

        return items_to_invoice