Пример #1
0
 def list(self, request):
     queryset = self.get_queryset().order_by("-created_at")
     paginated_queryset = paginate_queryset(queryset, request)
     serializer = serializers.AppNotificationSerializer(paginated_queryset,
                                                        many=True)
     return AppNotificationViewSet.append_unviewed_unread_count(
         serializer.data, queryset)
Пример #2
0
    def list(self, request):
        category_url = request.GET.get('categoryUrl', None)
        if not category_url:
            return Response({"error": "Missing Parameter: categoryUrl"},
                            status=status.HTTP_400_BAD_REQUEST)

        article_start = request.GET.get('startsWith', None)
        article_contains = request.GET.get('contains', None)

        category_qs = article_models.ArticleCategory.objects.filter(
            url=category_url)
        if category_qs.exists():
            category = category_qs.first()
        else:
            return Response(status=status.HTTP_404_NOT_FOUND,
                            data={'error': 'Category url not found'})

        article_data = self.get_queryset().filter(category__url=category_url)
        if article_start:
            article_data = article_data.filter(
                title__istartswith=article_start)
        if article_contains and len(article_contains) > 2:
            article_data = article_data.filter(
                title__icontains=article_contains)
        articles_count = article_data.count()
        article_data = paginate_queryset(article_data, request, 50)
        resp = serializers.ArticleListSerializer(article_data,
                                                 many=True,
                                                 context={
                                                     'request': request
                                                 }).data
        title = ''
        description = ''
        title_description = ArticleCategory.objects.filter(
            url=category_url).values('title', 'description')
        if title_description.exists():
            title = title_description.first().get('title', '')
            description = title_description.first().get('description', '')

        category_seo = {"title": title, "description": description}

        dynamic_content = NewDynamic.objects.filter(url__url=category_url,
                                                    is_enabled=True).first()
        top_content = None
        bottom_content = None
        if dynamic_content:
            top_content = dynamic_content.top_content
            bottom_content = dynamic_content.bottom_content
        return Response({
            'result': resp,
            'seo': category_seo,
            'category': category.name,
            'total_articles': articles_count,
            'search_content': top_content,
            'bottom_content': bottom_content
        })
Пример #3
0
 def list(self, request):
     queryset = paginate_queryset(self.get_queryset(), request, 10)
     article_category_list = [
         serializers.ArticleCategoryListSerializer(category,
                                                   context={
                                                       'request': request
                                                   }).data
         for category in queryset
     ]
     return Response(article_category_list)
Пример #4
0
 def billing_appointments(self, request):
     query_param = request.query_params
     serializer = BillingSummarySerializer(data=query_param)
     serializer.is_valid(raise_exception=True)
     valid_data = serializer.validated_data
     if valid_data.get('level') in [
             Outstanding.DOCTOR_LEVEL, Outstanding.HOSPITAL_LEVEL,
             Outstanding.HOSPITAL_NETWORK_LEVEL
     ]:
         resp_queryset = OpdAppointment.get_billing_appointment(
             request.user, valid_data)
         resp_queryset = paginate_queryset(resp_queryset, request)
         serializer = OpdAppointmentBillingSerializer(
             resp_queryset, many=True, context={"request": request})
     elif valid_data.get('level') in [
             Outstanding.LAB_NETWORK_LEVEL, Outstanding.LAB_LEVEL
     ]:
         resp_queryset = LabAppointment.get_billing_appointment(
             request.user, valid_data)
         resp_queryset = paginate_queryset(request, resp_queryset)
         serializer = LabAppointmentBillingSerializer(resp_queryset,
                                                      many=True)
     # return Response([])
     return Response(serializer.data)
Пример #5
0
 def mark_notifications_as_viewed(self, request):
     viewed_time = timezone.now()
     required_notifications_ids = request.data.get("notificationids", None)
     if required_notifications_ids:
         required_notifications_ids = AppNotificationViewSet.get_notification_ids_list(
             required_notifications_ids)
         self.get_queryset().filter(
             pk__in=required_notifications_ids,
             viewed_at__isnull=True).update(viewed_at=viewed_time)
     else:
         self.get_queryset().filter(viewed_at__isnull=True).update(
             viewed_at=viewed_time)
     queryset = self.get_queryset().order_by("-created_at")
     paginated_queryset = paginate_queryset(queryset, request)
     serializer = serializers.AppNotificationSerializer(paginated_queryset,
                                                        many=True)
     return AppNotificationViewSet.append_unviewed_unread_count(
         serializer.data, queryset)
Пример #6
0
    def list(self, request):
        serializer = serializers.RatingListBodySerializerdata(data=request.query_params)
        serializer.is_valid(raise_exception=True)
        valid_data = serializer.validated_data
        if valid_data.get('content_type') == RatingsReview.OPD:
            queryset, graph_queryset, appointment = self.get_opd_ratings(valid_data)
        elif valid_data.get('content_type') == RatingsReview.LAB:
            queryset, graph_queryset, appointment = self.get_lab_ratings(valid_data)
        else:
            queryset, graph_queryset, appointment = self.get_hospital_ratings(valid_data)

        queryset = paginate_queryset(queryset, request)
        body_serializer = serializers.RatingsModelSerializer(queryset, many=True, context={'request': request,
                                                                                           'app': appointment})
        graph_serializer = serializers.RatingsGraphSerializer(graph_queryset,
                                                              context={'request': request})

        return Response({'rating': body_serializer.data,
                         'rating_graph': graph_serializer.data})
Пример #7
0
    def list(self, request):
        name = request.query_params.get('name', None)

        procedure_data = dict()
        if name:
            search_key = re.findall(r'[a-z0-9A-Z.]+', name)
            search_key = " ".join(search_key).lower()
            search_key = "".join(search_key.split("."))
            procedure_queryset = Procedure.objects.filter(
                Q(search_key__icontains=search_key)
                | Q(search_key__icontains=' ' + search_key)
                | Q(search_key__istartswith=search_key)).annotate(
                    search_index=StrIndex('search_key', Value(
                        search_key))).order_by('search_index')
            procedure_queryset = paginate_queryset(procedure_queryset, request)
        else:
            procedure_queryset = self.get_queryset()[:20]

        procedure_list_serializer = procedure_serializer.ProcedureInSerializer(
            procedure_queryset, many=True)
        procedure_data['procedures'] = procedure_list_serializer.data
        return Response(procedure_data)