-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2459 from ohcnetwork/staging
Production Release v24.38.0
- Loading branch information
Showing
26 changed files
with
8,732 additions
and
8,694 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# ModelSerializer | ||
from rest_framework import serializers | ||
|
||
from care.abdm.models import AbhaNumber | ||
from care.facility.api.serializers.patient import PatientDetailSerializer | ||
from care.facility.models import PatientRegistration | ||
from care.utils.serializer.external_id_field import ExternalIdSerializerField | ||
|
||
|
||
class AbhaNumberSerializer(serializers.ModelSerializer): | ||
id = serializers.CharField(source="external_id", read_only=True) | ||
patient = ExternalIdSerializerField( | ||
queryset=PatientRegistration.objects.all(), required=False, allow_null=True | ||
) | ||
patient_object = PatientDetailSerializer(source="patient", read_only=True) | ||
new = serializers.BooleanField(read_only=True) | ||
|
||
class Meta: | ||
model = AbhaNumber | ||
exclude = ("deleted", "access_token", "refresh_token", "txn_id") |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from django.db.models import Q | ||
from django.http import Http404 | ||
from rest_framework.decorators import action | ||
from rest_framework.mixins import RetrieveModelMixin | ||
from rest_framework.permissions import IsAuthenticated | ||
from rest_framework.response import Response | ||
from rest_framework.viewsets import GenericViewSet | ||
|
||
from care.abdm.api.serializers.abha_number import AbhaNumberSerializer | ||
from care.abdm.models import AbhaNumber | ||
from care.abdm.utils.api_call import HealthIdGateway | ||
from care.utils.queryset.patient import get_patient_queryset | ||
|
||
|
||
class AbhaNumberViewSet( | ||
GenericViewSet, | ||
RetrieveModelMixin, | ||
): | ||
serializer_class = AbhaNumberSerializer | ||
model = AbhaNumber | ||
queryset = AbhaNumber.objects.all() | ||
permission_classes = (IsAuthenticated,) | ||
|
||
def get_object(self): | ||
id = self.kwargs.get("pk") | ||
|
||
instance = self.queryset.filter( | ||
Q(abha_number=id) | Q(health_id=id) | Q(patient__external_id=id) | ||
).first() | ||
|
||
if not instance or not get_patient_queryset(self.request.user).contains( | ||
instance.patient | ||
): | ||
raise Http404 | ||
|
||
self.check_object_permissions(self.request, instance) | ||
|
||
return instance | ||
|
||
@action(detail=True, methods=["GET"]) | ||
def qr_code(self, request, *args, **kwargs): | ||
obj = self.get_object() | ||
serializer = self.get_serializer(obj) | ||
response = HealthIdGateway().get_qr_code(serializer.data) | ||
return Response(response) | ||
|
||
@action(detail=True, methods=["GET"]) | ||
def profile(self, request, *args, **kwargs): | ||
obj = self.get_object() | ||
serializer = self.get_serializer(obj) | ||
response = HealthIdGateway().get_profile(serializer.data) | ||
return Response(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.