def test_inpatient_medication_orders_report(self):
        filters = {
            'company': '_Test Company',
            'from_date': getdate(),
            'to_date': getdate(),
            'patient': '_Test IPD Patient',
            'service_unit': '_Test Service Unit Ip Occupancy - _TC'
        }

        report = execute(filters)

        expected_data = [{
            'patient':
            '_Test IPD Patient',
            'inpatient_record':
            self.ip_record.name,
            'practitioner':
            None,
            'drug':
            'Dextromethorphan',
            'drug_name':
            'Dextromethorphan',
            'dosage':
            1.0,
            'dosage_form':
            'Tablet',
            'date':
            getdate(),
            'time':
            datetime.timedelta(seconds=32400),
            'is_completed':
            0,
            'healthcare_service_unit':
            '_Test Service Unit Ip Occupancy - _TC'
        }, {
            'patient':
            '_Test IPD Patient',
            'inpatient_record':
            self.ip_record.name,
            'practitioner':
            None,
            'drug':
            'Dextromethorphan',
            'drug_name':
            'Dextromethorphan',
            'dosage':
            1.0,
            'dosage_form':
            'Tablet',
            'date':
            getdate(),
            'time':
            datetime.timedelta(seconds=50400),
            'is_completed':
            0,
            'healthcare_service_unit':
            '_Test Service Unit Ip Occupancy - _TC'
        }, {
            'patient':
            '_Test IPD Patient',
            'inpatient_record':
            self.ip_record.name,
            'practitioner':
            None,
            'drug':
            'Dextromethorphan',
            'drug_name':
            'Dextromethorphan',
            'dosage':
            1.0,
            'dosage_form':
            'Tablet',
            'date':
            getdate(),
            'time':
            datetime.timedelta(seconds=75600),
            'is_completed':
            0,
            'healthcare_service_unit':
            '_Test Service Unit Ip Occupancy - _TC'
        }]

        self.assertEqual(expected_data, report[1])

        filters = frappe._dict(from_date=getdate(),
                               to_date=getdate(),
                               from_time='',
                               to_time='')
        ipme = create_ipme(filters)
        ipme.submit()

        filters = {
            'company': '_Test Company',
            'from_date': getdate(),
            'to_date': getdate(),
            'patient': '_Test IPD Patient',
            'service_unit': '_Test Service Unit Ip Occupancy - _TC',
            'show_completed_orders': 0
        }

        report = execute(filters)
        self.assertEqual(len(report[1]), 0)
    def test_inpatient_medication_orders_report(self):
        filters = {
            "company": "_Test Company",
            "from_date": getdate(),
            "to_date": getdate(),
            "patient": "_Test IPD Patient",
            "service_unit": "_Test Service Unit Ip Occupancy - _TC",
        }

        report = execute(filters)

        expected_data = [
            {
                "patient": "_Test IPD Patient",
                "inpatient_record": self.ip_record.name,
                "practitioner": None,
                "drug": "Dextromethorphan",
                "drug_name": "Dextromethorphan",
                "dosage": 1.0,
                "dosage_form": "Tablet",
                "date": getdate(),
                "time": datetime.timedelta(seconds=32400),
                "is_completed": 0,
                "healthcare_service_unit":
                "_Test Service Unit Ip Occupancy - _TC",
            },
            {
                "patient": "_Test IPD Patient",
                "inpatient_record": self.ip_record.name,
                "practitioner": None,
                "drug": "Dextromethorphan",
                "drug_name": "Dextromethorphan",
                "dosage": 1.0,
                "dosage_form": "Tablet",
                "date": getdate(),
                "time": datetime.timedelta(seconds=50400),
                "is_completed": 0,
                "healthcare_service_unit":
                "_Test Service Unit Ip Occupancy - _TC",
            },
            {
                "patient": "_Test IPD Patient",
                "inpatient_record": self.ip_record.name,
                "practitioner": None,
                "drug": "Dextromethorphan",
                "drug_name": "Dextromethorphan",
                "dosage": 1.0,
                "dosage_form": "Tablet",
                "date": getdate(),
                "time": datetime.timedelta(seconds=75600),
                "is_completed": 0,
                "healthcare_service_unit":
                "_Test Service Unit Ip Occupancy - _TC",
            },
        ]

        self.assertEqual(expected_data, report[1])

        filters = frappe._dict(from_date=getdate(),
                               to_date=getdate(),
                               from_time="",
                               to_time="")
        ipme = create_ipme(filters)
        ipme.submit()

        filters = {
            "company": "_Test Company",
            "from_date": getdate(),
            "to_date": getdate(),
            "patient": "_Test IPD Patient",
            "service_unit": "_Test Service Unit Ip Occupancy - _TC",
            "show_completed_orders": 0,
        }

        report = execute(filters)
        self.assertEqual(len(report[1]), 0)