-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert ABDM into Plug - Part 1/3 (#2161)
* added consent flows in abdm * made patient_abha as a foriegn key field in consent * renamed patient_health_id to patient_abha * renamed patient_health_id to patient_abha * added filterset class to consent * send external_id as id in consent serializer * resolved migration conflicts * seperated out consent request and consent artefact * get health information from hip * decrypt data from abdm * store health information in s3 * moved status from consent request to consent artefact * display health information * added patients find apis * added consents__hiu__notify * send push notification in patients/on-find * fixed gateway api calls * remove date range from health-information/cm/request * added ratelimits to abdm m3 apis * added status in consent request * fix consent denied logic * added facility filter to consent requests * fixed a typo * added patient_abha_object in consent request serializer * fixed consent status update logic * support retrieve hi docs by consent id * added all the suggestions from review * update migrations * added date range to health_information__cm__request * fixed reverse mapping of an enum REVERSE_CONDITION_VERIFICATION_STATUSES * fix a type in health_id * fix migration * fix linting error * added backend domain env * removed https prefix while using BACKEND_DOMAIN Co-authored-by: Aakash Singh <mail@singhaakash.dev> * removed duplicate conditional logic Co-authored-by: Aakash Singh <mail@singhaakash.dev> * fix linting issues * added patient field to abdm.abhanumber model * remove abha_number field from facility.patientregistration model * remove abdm references in the patient serializer * remove abdm references (auto add care context on consultation create) in the consultation serializer * removed an unused abdm import * added related_name to patient field in abdm.abhanumber model * add hasattr check while patient.abha_number and revert patient.abha_number to abha_number.patient while saving * added consultation receiver to auto add care context on create * added abha_number viewset and serializer * remove abha number from patient model in dummy data * resolve migration conflicts * fix linting errors * fixed migration reference * Apply suggestions from code review * resolve migration conflict * use bulk update in reverse_patient_abhanumber_relation * resolve migration conflict * fix the migration logic abha_number not found on patient * added validation errors * replaced general exceptions with validation error * fixed consent filters * fix migration conflict * fix dummy data * revert dummy data changes * remove abha_number field * handle json decode errors for abdm responses * use correct json exception * fixed migration conflict * check permission after filtering the query set in AbhaNumberViewSet retrieve * resolve migration conflict --------- Co-authored-by: Aakash Singh <mail@singhaakash.dev> Co-authored-by: Khavin Shankar <khavinshankar@Khavins-MacBook-Air.local>
- Loading branch information
1 parent
4278d87
commit e011af5
Showing
23 changed files
with
8,662 additions
and
8,694 deletions.
There are no files selected for viewing
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 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 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.