Skip to content

Commit

Permalink
ABDM M3 (#1829)
Browse files Browse the repository at this point in the history
Co-authored-by: Aakash Singh <mail@singhaakash.dev>
Co-authored-by: Gigin George <mail.gigin@gmail.com>
3 people authored May 13, 2024

Partially verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
1 parent 5be2e00 commit 4a5bacb
Showing 27 changed files with 1,727 additions and 43 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -356,3 +356,7 @@ secrets.sh
/.idea/modules.xml
/.idea/vcs.xml
/.idea/ruff.xml


# Redis
*.rdb
4 changes: 4 additions & 0 deletions aws/backend.json
Original file line number Diff line number Diff line change
@@ -41,6 +41,10 @@
"name": "CURRENT_DOMAIN",
"value": "https://care.ohc.network"
},
{
"name": "BACKEND_DOMAIN",
"value": "https://careapi.ohc.network"
},
{
"name": "DJANGO_ADMIN_URL",
"value": "w8BYTTYRkxqAsbS2iU9Yd2ZgQy6D3uws"
8 changes: 8 additions & 0 deletions aws/celery.json
Original file line number Diff line number Diff line change
@@ -32,6 +32,10 @@
"name": "CURRENT_DOMAIN",
"value": "https://care.ohc.network"
},
{
"name": "BACKEND_DOMAIN",
"value": "https://careapi.ohc.network"
},
{
"name": "DJANGO_ADMIN_URL",
"value": "w8BYTTYRkxqAsbS2iU9Yd2ZgQy6D3uws"
@@ -307,6 +311,10 @@
"name": "CURRENT_DOMAIN",
"value": "https://care.ohc.network"
},
{
"name": "BACKEND_DOMAIN",
"value": "https://careapi.ohc.network"
},
{
"name": "DJANGO_ADMIN_URL",
"value": "w8BYTTYRkxqAsbS2iU9Yd2ZgQy6D3uws"
33 changes: 33 additions & 0 deletions care/abdm/api/serializers/consent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from rest_framework import serializers

from care.abdm.api.serializers.abhanumber import AbhaNumberSerializer
from care.abdm.models.consent import ConsentArtefact, ConsentRequest
from care.users.api.serializers.user import UserBaseMinimumSerializer


class ConsentArtefactSerializer(serializers.ModelSerializer):
id = serializers.CharField(source="external_id", read_only=True)

class Meta:
model = ConsentArtefact
exclude = (
"deleted",
"external_id",
"key_material_private_key",
"key_material_public_key",
"key_material_nonce",
"key_material_algorithm",
"key_material_curve",
"signature",
)


class ConsentRequestSerializer(serializers.ModelSerializer):
id = serializers.CharField(source="external_id", read_only=True)
patient_abha_object = AbhaNumberSerializer(source="patient_abha", read_only=True)
requester = UserBaseMinimumSerializer(read_only=True)
consent_artefacts = ConsentArtefactSerializer(many=True, read_only=True)

class Meta:
model = ConsentRequest
exclude = ("deleted", "external_id")
12 changes: 8 additions & 4 deletions care/abdm/api/viewsets/auth.py
Original file line number Diff line number Diff line change
@@ -290,7 +290,7 @@ def post(self, request, *args, **kwargs):
data["hiRequest"]["keyMaterial"]["nonce"],
)

AbdmGateway().data_transfer(
data_transfer_response = AbdmGateway().data_transfer(
{
"transaction_id": data["transactionId"],
"data_push_url": data["hiRequest"]["dataPushUrl"],
@@ -306,11 +306,11 @@ def post(self, request, *args, **kwargs):
],
"data": cipher.encrypt(
Fhir(
PatientConsultation.objects.get(
PatientConsultation.objects.filter(
external_id=context[
"careContextReference"
]
)
).first()
).create_record(record)
)["data"],
},
@@ -332,7 +332,7 @@ def post(self, request, *args, **kwargs):
"parameters": "Curve25519/32byte random key",
"keyValue": cipher.key_to_share,
},
"nonce": cipher.sender_nonce,
"nonce": cipher.internal_nonce,
},
}
)
@@ -345,6 +345,10 @@ def post(self, request, *args, **kwargs):
],
"consent_id": data["hiRequest"]["consent"]["id"],
"transaction_id": data["transactionId"],
"session_status": "TRANSFERRED"
if data_transfer_response
and data_transfer_response.status_code == 202
else "FAILED",
"care_contexts": list(
map(
lambda context: {"id": context["careContextReference"]},
Loading

0 comments on commit 4a5bacb

Please sign in to comment.