-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into list-detail-serializer-bed
- Loading branch information
Showing
76 changed files
with
4,527 additions
and
138 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 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
Empty file.
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 @@ | ||
# Register your models here. |
Empty file.
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,9 @@ | ||
from rest_framework.serializers import ModelSerializer | ||
|
||
from care.abdm.models import AbhaNumber | ||
|
||
|
||
class AbhaSerializer(ModelSerializer): | ||
class Meta: | ||
exclude = ("deleted",) | ||
model = AbhaNumber |
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,10 @@ | ||
# ModelSerializer | ||
from rest_framework import serializers | ||
|
||
from care.abdm.models import AbhaNumber | ||
|
||
|
||
class AbhaNumberSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = AbhaNumber | ||
exclude = ("access_token", "refresh_token", "txn_id") |
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,24 @@ | ||
from rest_framework.serializers import CharField, IntegerField, Serializer | ||
|
||
|
||
class AbdmAuthResponseSerializer(Serializer): | ||
""" | ||
Serializer for the response of the authentication API | ||
""" | ||
|
||
accessToken = CharField() | ||
refreshToken = CharField() | ||
expiresIn = IntegerField() | ||
refreshExpiresIn = IntegerField() | ||
tokenType = CharField() | ||
|
||
|
||
class AbdmAuthInitResponseSerializer(Serializer): | ||
""" | ||
Serializer for the response of the authentication API | ||
""" | ||
|
||
token = CharField() | ||
refreshToken = CharField() | ||
expiresIn = IntegerField() | ||
refreshExpiresIn = IntegerField() |
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,61 @@ | ||
from rest_framework.serializers import CharField, Serializer, UUIDField | ||
|
||
|
||
class AadharOtpGenerateRequestPayloadSerializer(Serializer): | ||
aadhaar = CharField(max_length=16, min_length=12, required=True) | ||
|
||
|
||
class AadharOtpResendRequestPayloadSerializer(Serializer): | ||
txnId = CharField(max_length=64, min_length=1, required=True) | ||
|
||
|
||
class HealthIdSerializer(Serializer): | ||
healthId = CharField(max_length=64, min_length=1, required=True) | ||
|
||
|
||
class QRContentSerializer(Serializer): | ||
hidn = CharField(max_length=17, min_length=17, required=True) | ||
phr = CharField(max_length=64, min_length=1, required=True) | ||
name = CharField(max_length=64, min_length=1, required=True) | ||
gender = CharField(max_length=1, min_length=1, required=True) | ||
dob = CharField(max_length=10, min_length=8, required=True) | ||
|
||
|
||
class HealthIdAuthSerializer(Serializer): | ||
authMethod = CharField(max_length=64, min_length=1, required=True) | ||
healthid = CharField(max_length=64, min_length=1, required=True) | ||
|
||
|
||
class ABHASearchRequestSerializer: | ||
name = CharField(max_length=64, min_length=1, required=False) | ||
mobile = CharField( | ||
max_length=10, | ||
min_length=10, | ||
required=False, | ||
) | ||
gender = CharField(max_length=1, min_length=1, required=False) | ||
yearOfBirth = CharField(max_length=4, min_length=4, required=False) | ||
|
||
|
||
class GenerateMobileOtpRequestPayloadSerializer(Serializer): | ||
mobile = CharField(max_length=10, min_length=10, required=True) | ||
txnId = CharField(max_length=64, min_length=1, required=True) | ||
|
||
|
||
class VerifyOtpRequestPayloadSerializer(Serializer): | ||
otp = CharField(max_length=6, min_length=6, required=True, help_text="OTP") | ||
txnId = CharField(max_length=64, min_length=1, required=True) | ||
patientId = UUIDField(required=False) | ||
|
||
|
||
class VerifyDemographicsRequestPayloadSerializer(Serializer): | ||
gender = CharField(max_length=10, min_length=1, required=True) | ||
name = CharField(max_length=64, min_length=1, required=True) | ||
yearOfBirth = CharField(max_length=4, min_length=4, required=True) | ||
txnId = CharField(max_length=64, min_length=1, required=True) | ||
|
||
|
||
class CreateHealthIdSerializer(Serializer): | ||
healthId = CharField(max_length=64, min_length=1, required=False) | ||
txnId = CharField(max_length=64, min_length=1, required=True) | ||
patientId = UUIDField(required=False) |
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,33 @@ | ||
from rest_framework.serializers import CharField, IntegerField, Serializer | ||
|
||
|
||
class AddressSerializer(Serializer): | ||
line = CharField() | ||
district = CharField() | ||
state = CharField() | ||
pincode = CharField() | ||
|
||
|
||
class PatientSerializer(Serializer): | ||
healthId = CharField(allow_null=True) | ||
healthIdNumber = CharField() | ||
name = CharField() | ||
gender = CharField() | ||
yearOfBirth = IntegerField() | ||
dayOfBirth = IntegerField() | ||
monthOfBirth = IntegerField() | ||
address = AddressSerializer() | ||
|
||
|
||
class ProfileSerializer(Serializer): | ||
hipCode = CharField() | ||
patient = PatientSerializer() | ||
|
||
|
||
class HipShareProfileSerializer(Serializer): | ||
""" | ||
Serializer for the request of the share_profile | ||
""" | ||
|
||
requestId = CharField() | ||
profile = ProfileSerializer() |
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,38 @@ | ||
from rest_framework.decorators import action | ||
from rest_framework.generics import get_object_or_404 | ||
from rest_framework.permissions import IsAuthenticated | ||
from rest_framework.response import Response | ||
from rest_framework.viewsets import GenericViewSet | ||
|
||
from care.abdm.api.serializers.abha import AbhaSerializer | ||
from care.abdm.models import AbhaNumber | ||
from care.abdm.utils.api_call import HealthIdGateway | ||
from care.utils.queryset.patient import get_patient_queryset | ||
|
||
|
||
class AbhaViewSet(GenericViewSet): | ||
serializer_class = AbhaSerializer | ||
model = AbhaNumber | ||
queryset = AbhaNumber.objects.all() | ||
permission_classes = (IsAuthenticated,) | ||
|
||
def get_abha_object(self): | ||
queryset = get_patient_queryset(self.request.user) | ||
patient_obj = get_object_or_404( | ||
queryset.filter(external_id=self.kwargs.get("patient_external_id")) | ||
) | ||
return patient_obj.abha_number | ||
|
||
@action(detail=False, methods=["GET"]) | ||
def get_qr_code(self, request, *args, **kwargs): | ||
obj = self.get_abha_object() | ||
gateway = HealthIdGateway() | ||
response = gateway.get_qr_code(obj) | ||
return Response(response) | ||
|
||
@action(detail=False, methods=["GET"]) | ||
def get_profile(self, request, *args, **kwargs): | ||
obj = self.get_abha_object() | ||
gateway = HealthIdGateway() | ||
response = gateway.get_profile(obj) | ||
return Response(response) |
Oops, something went wrong.