Skip to content

Commit

Permalink
Merge branch 'master' into list-detail-serializer-bed
Browse files Browse the repository at this point in the history
  • Loading branch information
GeekGawd authored Jul 27, 2023
2 parents e89ccc2 + 9f62e7a commit bd00ebd
Show file tree
Hide file tree
Showing 76 changed files with 4,527 additions and 138 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/deployment-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ on:

push:
branches:
- abdm
- abdm-m2
- hcx-communications
paths-ignore:
- "docs/**"

jobs:

build-image:
name: Build & Push Staging to container registries
runs-on: ubuntu-latest
Expand All @@ -28,7 +28,6 @@ jobs:
type=raw,value=${{ github.ref_name}}-${{ github.run_number }}
type=raw,value=${{ github.ref_name}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

Expand Down
28 changes: 28 additions & 0 deletions aws/backend.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,26 @@
{
"name": "USE_S3",
"value": "True"
},
{
"name": "ENABLE_ABDM",
"value": "True"
},
{
"name": "ABDM_URL",
"value": "https://dev.abdm.gov.in"
},
{
"name": "HEALTH_SERVICE_API_URL",
"value": "https://healthidsbx.abdm.gov.in/api"
},
{
"name": "X_CM_ID",
"value": "sbx"
},
{
"name": "FIDELIUS_URL",
"value": "https://fidelius.ohc.network"
}
],
"repositoryCredentials": {
Expand Down Expand Up @@ -222,6 +242,14 @@
{
"valueFrom": "/care/backend/HCX_IG_URL",
"name": "HCX_IG_URL"
},
{
"valueFrom": "/care/backend/ABDM_CLIENT_ID",
"name": "ABDM_CLIENT_ID"
},
{
"valueFrom": "/care/backend/ABDM_CLIENT_SECRET",
"name": "ABDM_CLIENT_SECRET"
}
],
"name": "care-backend"
Expand Down
10 changes: 5 additions & 5 deletions aws/celery.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
"repositoryCredentials": {
"credentialsParameter": "arn:aws:secretsmanager:ap-south-1:299650323339:secret:/github/pat-UHmr0B"
},
"memory": 256,
"memoryReservation": 256,
"memory": 512,
"memoryReservation": 512,
"workingDirectory": "/app",
"secrets": [
{
Expand Down Expand Up @@ -232,8 +232,8 @@
"/app/celery_worker-ecs.sh"
],
"cpu": 384,
"memory": 768,
"memoryReservation": 768,
"memory": 1536,
"memoryReservation": 1536,
"environment": [
{
"name": "AUDIT_LOG_ENABLED",
Expand Down Expand Up @@ -437,7 +437,7 @@
"name": "care-celery-worker"
}
],
"memory": "1024",
"memory": "2048",
"taskRoleArn": "arn:aws:iam::299650323339:role/ecsTaskExecutionRole",
"family": "care-celery",
"requiresCompatibilities": [
Expand Down
Empty file added care/abdm/__init__.py
Empty file.
1 change: 1 addition & 0 deletions care/abdm/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Register your models here.
Empty file added care/abdm/api/__init__.py
Empty file.
9 changes: 9 additions & 0 deletions care/abdm/api/serializers/abha.py
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
10 changes: 10 additions & 0 deletions care/abdm/api/serializers/abhanumber.py
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")
24 changes: 24 additions & 0 deletions care/abdm/api/serializers/auth.py
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()
61 changes: 61 additions & 0 deletions care/abdm/api/serializers/healthid.py
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)
33 changes: 33 additions & 0 deletions care/abdm/api/serializers/hip.py
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()
38 changes: 38 additions & 0 deletions care/abdm/api/viewsets/abha.py
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)
Loading

0 comments on commit bd00ebd

Please sign in to comment.