Ejemplo n.º 1
0
    def get(self):
        idName_fields = {
            'id': fields.Integer(default=None),
            'name': fields.String
        }

        details_fields = {'order_id': fields.Integer(), 'patient_id': fields.Integer(), 'service_id': fields.Integer(),
                          'doctor_id': fields.Integer(), 'performanceRatio': fields.Integer(),
                          'evaluation': fields.Integer(default=None), 'evaluationName': fields.String,
                          'state': fields.String, 'sessionDate': fields.DateTime(dt_format='iso8601'),
                          'startTime': fields.String, 'endTime': fields.String, 'notes': fields.String,
                          'service': fields.Nested(idName_fields), 'patient': fields.Nested(idName_fields),
                          'doctor': fields.Nested(idName_fields),
                          'sharedPrice': fields.Integer(default=None),
                          'startStateTime': fields.String, 'doneStateTime': fields.String}
                          # 'startStateTime': fields.DateTime(dt_format='iso8601'), 'doneStateTime': fields.DateTime(dt_format='iso8601')}

        result_fields = {
            'details': fields.Nested(details_fields),
            'totalNumberOfSessions': fields.Integer(),
            'totalSharedPrice': fields.Integer(),
        }

        qParser = reqparse.RequestParser()

        qParser.add_argument('fromDate', type=dateInput, default=None)
        qParser.add_argument('toDate', type=dateInput, default=None)
        qParser.add_argument('doctor_id', type=int, default=None)
        qParser.add_argument('service_id', type=int, default=None)
        qParser.add_argument('patient_id', type=int, default=None)
        qParser.add_argument('state', type=str, default=None)
        qParser.add_argument('patient_mobile', type=str, default=None)

        args = qParser.parse_args()

        fromDate = args.get('fromDate')
        toDate = args.get('toDate')
        doctor_id = args.get('doctor_id')
        service_id = args.get('service_id')
        patient_id = args.get('patient_id')
        state = args.get('state')
        patient_mobile = args.get('patient_mobile')

        if patient_mobile is not None:
            patient = Patient.query.filter_by(mobileNumber=patient_mobile).first()
            if patient:
                patient_id = patient.id
            else:
                patient_id = None

        report = SessionsDetails()
        report.filterDateRange(fromDate, toDate)
        report.filterByDoctor(doctor_id)
        report.filterByService(service_id)
        report.filterByState(state)
        report.filterByPatient(patient_id)

        result = report.result()
        return marshal(result, result_fields)
Ejemplo n.º 2
0
    def get(self):

        details_fields = {
            "order_id": fields.Integer(),
            "patient_id": fields.Integer(),
            "service_id": fields.Integer(),
            "doctor_id": fields.Integer(),
            "state": fields.String,
            "serviceName": fields.String,
            "patientName": fields.String,
            "doctorName": fields.String,
            "serviceName": fields.String,
            "startTime": fields.String,
            "sessionDate": fields.DateTime(dt_format="iso8601"),
            "endTime": fields.String,
            "notes": fields.String,
        }

        result_fields = {"details": fields.Nested(details_fields), "totalNumberOfSessions": fields.Integer()}

        qParser = reqparse.RequestParser()

        qParser.add_argument("fromDate", type=dateInput, default=None)
        qParser.add_argument("toDate", type=dateInput, default=None)
        qParser.add_argument("doctor_id", type=int, default=None)
        qParser.add_argument("service_id", type=int, default=None)
        qParser.add_argument("patient_id", type=int, default=None)
        qParser.add_argument("state", type=str, default=None)
        qParser.add_argument("patient_mobile", type=str, default=None)

        args = qParser.parse_args()

        fromDate = args.get("fromDate")
        toDate = args.get("toDate")
        doctor_id = args.get("doctor_id")
        service_id = args.get("service_id")
        patient_id = args.get("patient_id")
        state = args.get("state")
        patient_mobile = args.get("patient_mobile")

        if patient_mobile is not None:
            patient = Patient.query.filter_by(mobileNumber=patient_mobile).first()
            patient_id = patient.id if patient else None

        report = SessionsDetails()
        report.filterDateRange(fromDate, toDate)
        report.filterByDoctor(doctor_id)
        report.filterByService(service_id)
        report.filterByState(state)
        report.filterByPatient(patient_id)

        result = report.result()
        return marshal(result, result_fields)
Ejemplo n.º 3
0
    def test_sessions_details_report(self):

        report = SessionsDetails()
        # report.filterDateRange(datetime.date.today(), datetime.datetime.now() + datetime.timedelta(days=1) )

        report.filterDateRange()
        result = report.result()
        # print(result)
        totalSessions = 5
        for item in result['details']:
            self.assertTrue(item["service_id"] is not None)
            # self.assertEquals(item["stateCount"])]
            self.assertTrue(item["doctor_id"] is not None)
            self.assertTrue(item["serviceName"] is not None)
            self.assertTrue(item["doctorName"] is not None)
            self.assertTrue(item["startTime"] is not None)
            self.assertTrue(item["endTime"] is not None)
            # this is gonna throw error if start time minutes grater than 45
            self.assertTrue((item["endTime"].minute - item["startTime"].minute) == 15 )
            self.assertEquals(item["state"], 'done')
        self.assertEquals(totalSessions, result['totalNumberOfSessions'])