예제 #1
0
파일: api.py 프로젝트: Fabfm4/Sita-BackEnd
 def retrieve(self, request, pk=None, *args, **kwards):
     """
     View a specific patient
     ---
     omit_parameters:
         - form
     parameters:
         - name: Authorization
           description: Bearer {token}.
           required: true
           type: string
           paramType: header
     responseMessages:
         - code: 200
           message: OK
         - code: 500
           message: INTERNAL SERVER ERROR
     consumes:
         - application/json
     produces:
         - application/json
     """
     if Note.objects.exists(pk=pk):
         note = Note.objects.get(id=pk)
         if Patient.objects.exists(pk=note.patient_id):
             patient = Patient.objects.get(id=pk)
             if User.objects.exists_user(pk=patient.user_id):
                 user = User.objects.get(id=patient.user_id)
                 if has_permission(request.META, user):
                     return super(NoteViewSet, self).retrieve(request,
                                                              pk=pk,
                                                              instance=note)
             return Response(status=status.HTTP_401_UNAUTHORIZED)
     return Response(status=status.HTTP_404_NOT_FOUND)
예제 #2
0
파일: api.py 프로젝트: Fabfm4/Sita-BackEnd
 def destroy(self, request, pk=None):
     """
     Write the status from patient
     ---
     omit_parameters:
         - form
     parameters:
         - name: Authorization
           description: Bearer {token}.
           required: true
           type: string
           paramType: header
     responseMessages:
         - code: 200
           message: OK
         - code: 500
           message: INTERNAL SERVER ERROR
     consumes:
         - application/json
     produces:
         - application/json
     """
     if Note.objects.exists(pk=pk):
         note = Note.objects.get(id=pk)
         if Patient.objects.exists(pk=note.patient_id):
             patient = Patient.objects.get(id=pk)
             if User.objects.exists_user(pk=patient.user_id):
                 user = User.objects.get(id=patient.user_id)
                 if has_permission(request.META, user):
                     note.delete()
                     return Response(status=status.HTTP_200_OK)
                 return Response(status=status.HTTP_401_UNAUTHORIZED)
     return Response(status=status.HTTP_404_NOT_FOUND)
예제 #3
0
파일: api.py 프로젝트: Fabfm4/Sita-BackEnd
 def list(self, request, *args, **kwargs):
     """
     Return a list of users, that matches with the given word.
     ---
     response_serializer: UserListSerializer
     parameters:
         - name: Authorization
           description: Bearer {token}.
           required: true
           type: string
           paramType: header
         - name: q
           description: Search word.
           paramType: query
           type: string
     responseMessages:
         - code: 200
           message: OK
         - code: 401
           message: UNAUTHORIZED
         - code: 500
           message: INTERNAL SERVER ERROR
     consumes:
         - application/json
     produces:
         - application/json
     """
     # Verify if the user has permission to use
     if has_permission(request.META):
         return super(UserViewSet, self).list(request, *args, **kwargs)
     return Response(status=status.HTTP_401_UNAUTHORIZED)
예제 #4
0
파일: api.py 프로젝트: Fabfm4/Sita-BackEnd
 def list(self, request, *args, **kwards):
     """
     List all patitent from user with filter
     ---
     omit_parameters:
         - form
     parameters:
         - name: Authorization
           description: Bearer {token}.
           required: true
           type: string
           paramType: header
         - name: q
           description: Search word.
           paramType: query
           type: string
     responseMessages:
         - code: 200
           message: OK
         - code: 400
           message: BAD REQUEST
         - code: 500
           message: INTERNAL SERVER ERROR
     consumes:
         - application/json
     produces:
         - application/json
     """
     if has_permission(request.META):
         return super(NoteViewSet, self).list(request,
                                              queryset=self.get_queryset(),
                                              *args,
                                              **kwards)
     return Response(status=status.HTTP_401_UNAUTHORIZED)
예제 #5
0
파일: api.py 프로젝트: Fabfm4/Sita-BackEnd
 def create(self, request, user_pk=None, *args, **kwargs):
     """
     Add card from user
     ---
     omit_parameters:
         - form
     parameters:
         - name: body
           pytype: CardSerializer
           paramType: body
           description:
             'name: <b>required</b> <br>
             email: <b>required</b> <br>
             mobilePhone: <b>required</b> <br>
             lastName:NOT required <br>
             mothersName: NOT required <br>
             age: NOT required <br>
             housePhone: NOT required'
         - name: Authorization
           description: Bearer {token}.
           required: true
           type: string
           paramType: header
     responseMessages:
         - code: 201
           message: CREATED
         - code: 404
           message: NOT FOUND
         - code: 401
           message: UNAUTHORIZED
         - code: 500
           message: INTERNAL SERVER ERROR
     consumes:
         - application/json
     produces:
         - application/json
     """
     if User.objects.exists_user(pk=user_pk):
         user = User.objects.get(id=user_pk)
         if has_permission(request.META, user):
             serializer = CardSerializer(data=request.data)
             if serializer.is_valid():
                 card = conekta_sita.create_card(user=user, data=request.data)
                 if card is not None:
                     card_data = {
                         "last_four":card.last4,
                         "is_default":True,
                         "conekta_card":card.id,
                         "brand_card":card.brand,
                     }
                     fields = Card().get_fields()
                     Card.objects.register(
                         data=card_data, fields=fields, user=user)
                 return Response(status=status.HTTP_201_CREATED)
             return Response(
                 serializer.errors, status=status.HTTP_400_BAD_REQUEST)
         return Response(status=status.HTTP_401_UNAUTHORIZED)
     return Response(status=status.HTTP_404_NOT_FOUND)
예제 #6
0
 def create(self, request, user_pk=None, patient_pk=None, *args, **kwargs):
     """
     Add card from user
     ---
     omit_parameters:
         - form
     parameters:
         - name: body
           pytype: AppointmentSerializer
           paramType: body
           description:
             'name: <b>required</b> <br>
             email: <b>required</b> <br>
             mobilePhone: <b>required</b> <br>
             lastName:NOT required <br>
             mothersName: NOT required <br>
             age: NOT required <br>
             housePhone: NOT required'
         - name: Authorization
           description: Bearer {token}.
           required: true
           type: string
           paramType: header
     responseMessages:
         - code: 201
           message: CREATED
         - code: 404
           message: NOT FOUND
         - code: 401
           message: UNAUTHORIZED
         - code: 500
           message: INTERNAL SERVER ERROR
     consumes:
         - application/json
     produces:
         - application/json
     """
     if User.objects.exists_user(pk=user_pk):
         user = User.objects.get(id=user_pk)
         if Patient.objects.exists(pk=patient_pk):
             patient = Patient.objects.get(pk=patient_pk)
             if patient.is_active and patient.user_id==user.id:
                 if has_permission(request.META, user):
                     serializer = AppointmentSerializer(data=request.data)
                     if serializer.is_valid():
                         fields = Appointment().get_fields()
                         appointment = Appointment.objects.register(
                             data=request.data, fields=fields, user=user, patient=patient)
                         if appointment:
                             return Response(status=status.HTTP_201_CREATED)
                         else:
                             return Response({"message": "Exist a date in the same time"},status=422)
                     return Response(
                         serializer.errors, status=status.HTTP_400_BAD_REQUEST)
                 return Response(status=status.HTTP_401_UNAUTHORIZED)
     return Response(status=status.HTTP_404_NOT_FOUND)
예제 #7
0
파일: api.py 프로젝트: Fabfm4/Sita-BackEnd
    def create(self, request, *args, **kwards):
        """
        Create user by Admin.
        ---
        omit_serializer: true
        omit_parameters:
            - form
        parameters:
            - name: body
              pytype: UserSerializer
              paramType: body
              description:
                'email: <b>required</b> <br>
                password: <b>required</b> <br>
                name:NOT required <br>
                firstName: NOT required <br>
                mothersName: NOT required <br>
                phone: NOT required'
            - name: Authorization
              description: Bearer {token}.
              required: true
              type: string
              paramType: header
        responseMessages:
            - code: 201
              message: CREATED
            - code: 400
              message: BAD REQUEST
            - code: 500
              message: INTERNAL SERVER ERROR
        consumes:
            - application/json
        produces:
            - application/json
        """

        # Verify if the user has permission to use
        if has_permission(request.META):
            serializer = UserSerializer(data=request.data)
            if serializer.is_valid():
                for key in request.data:
                    if key == "name" or key == "phone" or key == "conekta_card":
                        kwards.setdefault(key, request.data.get(key))
                user = User.objects.create_user(
                    email=request.data.get("email"),
                    password=request.data.get("password"),
                    **kwards)
                return Response(headers={
                    "user":
                    request.get_full_path() + "/{0}".format(user.id)
                },
                                status=status.HTTP_201_CREATED)
            return Response(serializer.errors,
                            status=status.HTTP_400_BAD_REQUEST)

        return Response(status=status.HTTP_401_UNAUTHORIZED)
예제 #8
0
파일: api.py 프로젝트: Fabfm4/Sita-BackEnd
    def get_subscription(self, request, pk=None):
        """
        Change password from user
        ---
        omit_serializer: true
        omit_parameters:
            - form
        parameters:
            - name: body
              pytype: UserGetSubscription
              paramType: body
              description:
                'password: <b>required</b> <br>
                confirmPassword: <b>required</b>'
            - name: Authorization
              description: Bearer {token}.
              required: true
              type: string
              paramType: header
        responseMessages:
            - code: 400
              message: BAD REQUEST
            - code: 401
              message: UNAUTHORIZED
            - code: 404
              message: NOT FOUND
            - code: 200
              message: OK
            - code: 500
              message: INTERNAL SERVER ERROR
        consumes:
            - application/json
        produces:
            - application/json
        """
        # Verify if exits the user with pk
        if User.objects.exists_user(pk=pk):
            user = User.objects.get(id=pk)
            print pk
            # Verify if the user has permission to use
            if has_permission(request.META, user):
                serializer = UserGetSubscription(data=request.data)
                if serializer.is_valid():
                    if user.has_subscription == False:
                        generate_payment(user,
                                         request.data.get("subscription_id"))
                        return Response(status=status.HTTP_200_OK)
                    return Response(
                        {"message": "You already have a subscription"},
                        status=422)
                return Response(serializer.errors,
                                status=status.HTTP_400_BAD_REQUEST)
            return Response(status=status.HTTP_401_UNAUTHORIZED)

        return Response(status=status.HTTP_404_NOT_FOUND)
예제 #9
0
파일: api.py 프로젝트: Fabfm4/Sita-BackEnd
 def create(self, request, patient_pk=None):
     """
     Create patient from user
     ---
     omit_parameters:
         - form
     parameters:
         - name: body
           pytype: NoteSerializer
           paramType: body
           description:
             'name: <b>required</b> <br>
             email: <b>required</b> <br>
             mobilePhone: <b>required</b> <br>
             lastName:NOT required <br>
             mothersName: NOT required <br>
             age: NOT required <br>
             housePhone: NOT required'
         - name: Authorization
           description: Bearer {token}.
           required: true
           type: string
           paramType: header
     responseMessages:
         - code: 201
           message: CREATED
         - code: 400
           message: BAD REQUEST
         - code: 500
           message: INTERNAL SERVER ERROR
     consumes:
         - application/json
     produces:
         - application/json
     """
     if Patient.objects.exists(pk=patient_pk):
         patient = Patient.objects.get(id=patient_pk)
         if patient.is_active:
             if User.objects.exists_user(pk=patient.user_id):
                 user = User.objects.get(id=patient.user_id)
                 if has_permission(request.META, user):
                     serializer = NoteSerializer(data=request.data)
                     if serializer.is_valid():
                         fields = Note().get_fields()
                         Note.objects.register(data=request.data,
                                               fields=fields,
                                               patient=patient)
                         return Response(status=status.HTTP_201_CREATED)
                     return Response(serializer.errors,
                                     status=status.HTTP_400_BAD_REQUEST)
             return Response(status=status.HTTP_401_UNAUTHORIZED)
     return Response(status=status.HTTP_404_NOT_FOUND)
예제 #10
0
파일: api.py 프로젝트: Fabfm4/Sita-BackEnd
    def partial_update(self, request, pk=None):
        """
        Update information from an specific patient
        ---
        omit_parameters:
            - form
        parameters:
            - name: body
              pytype: NoteSerializer
              paramType: body
              description:
                'name: NOT required <br>
                lastName: NOT required <br>
                mothersName: NOT required <br>
                email: NOT required <br>
                age: NOT required <br>
                mobilePhone: NOT required <br>
                housePhone: NOT required'
            - name: Authorization
              description: Bearer {token}.
              required: true
              type: string
              paramType: header
        responseMessages:
            - code: 200
              message: OK
            - code: 400
              message: BAD REQUEST
            - code: 500
              message: INTERNAL SERVER ERROR
        consumes:
            - application/json
        produces:
            - application/json
        """

        if Note.objects.exists(pk=pk):
            note = Note.objects.get(id=pk)
            if Patient.objects.exists(pk=note.patient_id):
                patient = Patient.objects.get(id=pk)
                if User.objects.exists_user(pk=patient.user_id):
                    user = User.objects.get(id=patient.user_id)
                    if has_permission(request.META, user):
                        return super(NoteViewSet,
                                     self).partial_update(request, pk, note)
                    return Response(status=status.HTTP_401_UNAUTHORIZED)
        return Response(status=status.HTTP_404_NOT_FOUND)
예제 #11
0
파일: api.py 프로젝트: Fabfm4/Sita-BackEnd
    def calcel_subscrition(self, request, pk=None):
        """
        Change password from user
        ---
        omit_serializer: true
        omit_parameters:
            - form
        parameters:
            - name: body
              pytype: UserUpdatePasswordSerializer
              paramType: body
              description:
                'password: <b>required</b> <br>
                confirmPassword: <b>required</b>'
            - name: Authorization
              description: Bearer {token}.
              required: true
              type: string
              paramType: header
        responseMessages:
            - code: 400
              message: BAD REQUEST
            - code: 401
              message: UNAUTHORIZED
            - code: 404
              message: NOT FOUND
            - code: 200
              message: OK
            - code: 500
              message: INTERNAL SERVER ERROR
        consumes:
            - application/json
        produces:
            - application/json
        """
        # Verify if exits the user with pk
        if User.objects.exists_user(pk=pk):
            user = User.objects.get(id=pk)
            print pk
            # Verify if the user has permission to use
            if has_permission(request.META, user):
                user.automatic_payment = False
                user.save()
                return Response(status=status.HTTP_200_OK)
            return Response(status=status.HTTP_401_UNAUTHORIZED)

        return Response(status=status.HTTP_404_NOT_FOUND)
예제 #12
0
파일: api.py 프로젝트: Fabfm4/Sita-BackEnd
    def partial_update(self, request, pk=None):
        """
        Update user
        ---
        omit_serializer: true
        omit_parameters:
            - form
        parameters:
            - name: body
              pytype: UserPatchSerializer
              paramType: body
              description:
                'name: NOT required <br>
                firstName: NOT required <br>
                mothersName: NOT required <br>
                phone: NOT required'
            - name: Authorization
              description: Bearer {token}.
              required: true
              type: string
              paramType: header
        responseMessages:
            - code: 200
              message: OK
            - code: 401
              message: UNAUTHORIZED
            - code: 404
              message: NOT_FOUND
            - code: 400
              message: BAD REQUEST
            - code: 500
              message: INTERNAL SERVER ERROR
        consumes:
            - application/json
        produces:
            - application/json
        """
        # Verify if exits the user with pk
        if User.objects.exists_user(pk=pk):
            user = User.objects.get(id=pk)
            # Verify if the user has permission to use
            if has_permission(request.META, user):
                return super(UserViewSet, self).partial_update(request, pk)

            return Response(status=status.HTTP_401_UNAUTHORIZED)

        return Response(status=status.HTTP_404_NOT_FOUND)
예제 #13
0
파일: api.py 프로젝트: Fabfm4/Sita-BackEnd
    def retrieve(self, request, pk=None, *args, **kwards):
        """
        View user with pk.
        ---
        response_serializer: UserSerializerModel
        omit_serializer: false
        parameters:
            - name: pk
              description: Photo user.
              required: true
              type: integer
              paramType: path
            - name: Authorization
              description: Bearer {token}.
              required: true
              type: string
              paramType: header
        responseMessages:
            - code: 200
              message: OK
            - code: 401
              message: UNAUTHORIZED
            - code: 404
              message: NOT FOUND
            - code: 500
              message: INTERNAL SERVER ERROR
        consumes:
            - application/json
        produces:
            - application/json
        """

        # Verify if exits the user with pk
        if User.objects.exists_user(pk=pk):
            user = User.objects.get(id=pk)
            # Verify if the user has permission to use
            if has_permission(request.META, user):
                return super(UserViewSet, self).retrieve(request,
                                                         pk=pk,
                                                         *args,
                                                         **kwards)

            return Response(status=status.HTTP_401_UNAUTHORIZED)

        return Response(status=status.HTTP_404_NOT_FOUND)
예제 #14
0
 def list(self, request, user_pk=None, patient_pk=None, *args, **kwards):
     """
     Show all cards from user
     ---
     omit_parameters:
         - form
     parameters:
         - name: Authorization
           description: Bearer {token}.
           required: true
           type: string
           paramType: header
         - name: q
           description: Search word.
           paramType: query
           type: string
     responseMessages:
         - code: 200
           message: OK
         - code: 404
           message: NOT FOUND
         - code: 401
           message: UNAUTHORIZED
         - code: 500
           message: INTERNAL SERVER ERROR
     consumes:
         - application/json
     produces:
         - application/json
     """
     if User.objects.exists_user(pk=user_pk):
         user = User.objects.get(id=user_pk)
         if Patient.objects.exists(pk=patient_pk):
             patient = Patient.objects.get(pk=patient_pk)
             if patient.is_active and patient.user_id==user.id:
                 if has_permission(request.META, user):
                     return super(
                         AppointmentViewSet, self).list(
                             request,
                             queryset=self.get_queryset(user.id, patient.id),
                             *args,
                             **kwards    )
                 return Response(status=status.HTTP_401_UNAUTHORIZED)
     return Response(status=status.HTTP_404_NOT_FOUND)
예제 #15
0
    def create(self, request, *args, **kwards):
        """
        Create patient from user
        ---
        omit_parameters:
            - form
        parameters:
            - name: body
              pytype: SubscriptionSerializer
              paramType: body
              description:
                'title: <b>required</b> <br>
                timeInMinutes: <b>required</b> <br>
                description: <b>required</b>'
            - name: Authorization
              description: Bearer {token}.
              required: true
              type: string
              paramType: header
        responseMessages:
            - code: 201
              message: CREATED
            - code: 400
              message: BAD REQUEST
            - code: 500
              message: INTERNAL SERVER ERROR
        consumes:
            - application/json
        produces:
            - application/json
        """

        if has_permission(request.META):
            serializer = SubscriptionSerializer(data=request.data)
            if serializer.is_valid():
                fields = Subscription().get_fields()
                Subscription.objects.register(data=request.data, fields=fields)
                return Response(status=status.HTTP_201_CREATED)
            return Response(serializer.errors,
                            status=status.HTTP_400_BAD_REQUEST)
        return Response(status=status.HTTP_401_UNAUTHORIZED)
예제 #16
0
파일: api.py 프로젝트: Fabfm4/Sita-BackEnd
 def set_default(self, request, user_pk=None, pk=None, *args, **kwargs):
     """
     Add card from user
     ---
     omit_parameters:
         - form
     parameters:
         - name: Authorization
           description: Bearer {token}.
           required: true
           type: string
           paramType: header
     responseMessages:
         - code: 200
           message: OK
         - code: 404
           message: NOT FOUND
         - code: 401
           message: UNAUTHORIZED
         - code: 500
           message: INTERNAL SERVER ERROR
     consumes:
         - application/json
     produces:
         - application/json
     """
     if User.objects.exists_user(pk=user_pk):
         user = User.objects.get(id=user_pk)
         if Card.objects.exists(pk=pk):
             card = Card.objects.get(id=pk)
             if card.user_id == user.id:
                 if has_permission(request.META, user):
                     card_default = conekta_sita.set_default_card(user=user, card=card)
                     card_default_old = Card.objects.get(is_default=True, user_id=user.id)
                     card_default_old.is_default = False
                     card_default_old.save()
                     card.is_default = True
                     card.save()
                     return Response(status=status.HTTP_200_OK)
                 return Response(status=status.HTTP_401_UNAUTHORIZED)
     return Response(status=status.HTTP_404_NOT_FOUND)
예제 #17
0
 def list(self, request, user_pk=None, *args, **kwards):
     """
     List all patitent from user with filter
     ---
     omit_parameters:
         - form
     parameters:
         - name: Authorization
           description: Bearer {token}.
           required: true
           type: string
           paramType: header
         - name: q
           description: Search word.
           paramType: query
           type: string
     responseMessages:
         - code: 200
           message: OK
         - code: 400
           message: BAD REQUEST
         - code: 500
           message: INTERNAL SERVER ERROR
     consumes:
         - application/json
     produces:
         - application/json
     """
     if User.objects.exists_user(pk=user_pk):
         print user_pk
         user = User.objects.get(id=user_pk)
         if has_permission(request.META, user):
             return super(
                 PatientUserViewSet, self).list(
                     request,
                     queryset=self.get_queryset(user.id),
                     *args,
                     **kwards    )
         return Response(status=status.HTTP_401_UNAUTHORIZED)
     return Response(status=status.HTTP_404_NOT_FOUND)
예제 #18
0
파일: api.py 프로젝트: Fabfm4/Sita-BackEnd
 def destroy(self, request, pk=None):
     """
     Write the status from patient
     ---
     omit_parameters:
         - form
     parameters:
         - name: Authorization
           description: Bearer {token}.
           required: true
           type: string
           paramType: header
     responseMessages:
         - code: 200
           message: OK
         - code: 500
           message: INTERNAL SERVER ERROR
     consumes:
         - application/json
     produces:
         - application/json
     """
     if Card.objects.exists(pk=pk):
         card = Card.objects.get(id=pk)
         if User.objects.exists_user(pk=card.user_id):
             user = User.objects.get(id=card.user_id)
             if has_permission(request.META, user):
                 card_deleted = conekta_sita.delete_card(user=user, card=card)
                 card.delete()
                 card = Card.objects.filter(user_id=user.id)
                 if card:
                     card_default = conekta_sita.set_default_card(user=user, card=card[0])
                     card[0].is_default = True
                     card[0].save()
                 print card
                 return Response(status=status.HTTP_200_OK)
         return Response(status=status.HTTP_401_UNAUTHORIZED)
     return Response(status=status.HTTP_404_NOT_FOUND)
예제 #19
0
 def partial_update(self, request, pk=None):
     """
     Update information from an specific patient
     ---
     omit_parameters:
         - form
     parameters:
         - name: body
           pytype: SubscriptionSerializer
           paramType: body
           description:
             'title: NOT required <br>
             timeInMinutes: NOT required <br>
             description: NOT required'
         - name: Authorization
           description: Bearer {token}.
           required: true
           type: string
           paramType: header
     responseMessages:
         - code: 200
           message: OK
         - code: 400
           message: BAD REQUEST
         - code: 500
           message: INTERNAL SERVER ERROR
     consumes:
         - application/json
     produces:
         - application/json
     """
     if Subscription.objects.exists(pk=pk):
         subscription = Subscription.objects.get(pk=pk)
         if has_permission(request.META):
             return super(SubscriptionViewSet,
                          self).partial_update(request, pk)
         return Response(status=status.HTTP_401_UNAUTHORIZED)
     return Response(status=status.HTTP_404_NOT_FOUND)
예제 #20
0
    def list(self, request, user_pk=None, *args, **kwargs):
        """
        Show all cards from user
        ---
        omit_parameters:
            - form
        parameters:
            - name: Authorization
              description: Bearer {token}.
              required: true
              type: string
              paramType: header
            - name: date_init
              description: Search word.
              paramType: query
              type: datetime
              required: true
            - name: date_end
              description: Search word.
              paramType: query
              type: datetime
              required: true
        responseMessages:
            - code: 200
              message: OK
            - code: 404
              message: NOT FOUND
            - code: 401
              message: UNAUTHORIZED
            - code: 500
              message: INTERNAL SERVER ERROR
        consumes:
            - application/json
        produces:
            - application/json
        """
        if User.objects.exists_user(pk=user_pk):
            user = User.objects.get(id=user_pk)
            if has_permission(request.META, user):
                query_params = get_query_params(request)
                try:
                    date_init = datetime.strptime(query_params.get("date_init"), "%Y-%m-%dT%H:%M:%S")
                except ValueError:
                    return Response({"date_init": "Is not valid date"},status=status.HTTP_400_BAD_REQUEST)
                try:
                    date_end = datetime.strptime(query_params.get("date_end"), "%Y-%m-%dT%H:%M:%S")
                except ValueError:
                    return Response({"date_end": "Is not valid date"},status=status.HTTP_400_BAD_REQUEST)

                serializer = AppointmentListSerializer()
                query = self.get_queryset(user.id, date_init, date_end)
                data = serializer.serialize(
                    query,
                    fields=("subject", "date_appointment", "user", "patient", "duration_hours", "time_zone"))
                # return super(
                #     AppointmentListViewSet, self).list(
                #         request,
                #         queryset=self.get_queryset(user.id, date_init, date_end),
                #         *args,
                #         **kwargs    )
                return Response({"data":data},status=status.HTTP_200_OK)
            return Response(status=status.HTTP_401_UNAUTHORIZED)
        return Response(status=status.HTTP_404_NOT_FOUND)