Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abdm M2 #1244

Merged
merged 146 commits into from
Jul 21, 2023
Merged

Abdm M2 #1244

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
db7b2ca
Basic Setup; Aadhaar Registration
gigincg Dec 12, 2022
517adf4
Add models
gigincg Dec 19, 2022
ba20763
Fix models issue
vigneshhari Dec 19, 2022
c2e0a61
Fixed patient to abha integration
vigneshhari Dec 20, 2022
d7cd31b
Fixed patient to abha integration
vigneshhari Dec 20, 2022
5191637
Add V2 API's
vigneshhari Jan 1, 2023
354d58c
Add V2 API's
vigneshhari Jan 1, 2023
1307f00
Skip SSL Verification
gigincg Jan 2, 2023
430ef5c
Fix V2 API's
vigneshhari Jan 2, 2023
6014b8b
Fix V2 API's
vigneshhari Jan 2, 2023
99ac633
Added More Views
vigneshhari Jan 2, 2023
586ba65
Add ABHA_obj;Ignore HealthID
gigincg Jan 2, 2023
e80d843
Merge branch 'abdm-m1' into abdm-m1-vignesh
gigincg Jan 3, 2023
a4c9d2a
Add APIs
gigincg Jan 5, 2023
b636084
Add Init & Verify APIs
gigincg Jan 5, 2023
7f6464d
Fix SearchByHealthId Serializer
gigincg Jan 5, 2023
8ec246f
renamed attributes in HealthIdAuthSerializer
khavinshankar Jan 5, 2023
3abbf8d
fixed get_profile api in abdm
khavinshankar Jan 5, 2023
5a80d18
Add get_profile API
gigincg Jan 9, 2023
9e65e94
fixed aadhaar otp api call
khavinshankar Jan 9, 2023
2a5f1e0
added abha_number to patient serializer
khavinshankar Jan 11, 2023
9478eca
send entire response after health id creation
khavinshankar Jan 29, 2023
076df07
feat: added share_profile endpoint
khavinshankar Jan 30, 2023
2910744
changed endpoint of abdm-hip-share
khavinshankar Feb 1, 2023
5d1e1fb
if patientId then link
khavinshankar Feb 3, 2023
94ec9b3
added patient profile share
khavinshankar Feb 3, 2023
8f32f83
changed response structure of abha_object
khavinshankar Feb 6, 2023
d64f4ee
added extra condition while linking abha with patient
khavinshankar Feb 6, 2023
77ba479
added v0.5 apis for demographic auth
khavinshankar Feb 7, 2023
86fcdf8
update flow for share profile
khavinshankar Feb 8, 2023
ecdef7e
updated the flow of link_via_qr
khavinshankar Feb 8, 2023
b6306f7
verify demographics before patient creation
khavinshankar Feb 8, 2023
526fe21
linking token while confirming with otps
khavinshankar Feb 8, 2023
ded150e
fixed abha creation error in healthid
khavinshankar Feb 8, 2023
226d5c1
fixed address key missing issue
khavinshankar Feb 8, 2023
8e0f849
removed facility id hardcoding in profile share
khavinshankar Feb 8, 2023
5143a86
added pycryptodome
khavinshankar Feb 8, 2023
323cbc4
minor changes
khavinshankar Feb 27, 2023
d736811
Create deployment-branch.yaml
mathew-alex Feb 27, 2023
2a877a0
udpated image tag
mathew-alex Feb 27, 2023
1310632
fixed dob used before declaration error in link_via_qr
khavinshankar Feb 27, 2023
d4d4b19
Merge branch 'abdm-m1-vignesh' of github.com:coronasafe/care into abd…
khavinshankar Feb 27, 2023
87b89f1
added cm_id env
khavinshankar Feb 27, 2023
ce03be0
return patient as response for link_via_qr
khavinshankar Feb 27, 2023
3130220
added authentication to abdm apis
khavinshankar Mar 3, 2023
d0bdf95
Add Basic Auth Ratelimiting on all Endpoints
vigneshhari Mar 3, 2023
1155a8c
Fix Ratelimting bug
vigneshhari Mar 3, 2023
007688b
added rate limit for abdm apis
khavinshankar Mar 3, 2023
31f17d4
Update README.md
mathew-alex Mar 3, 2023
9c76263
Update deployment-branch.yaml
mathew-alex Mar 3, 2023
c8e7a12
fixed ratelimiting for generate_mobile_otp
khavinshankar Mar 6, 2023
5345945
Merge branch 'abdm-m1-vignesh' of github.com:coronasafe/care into abd…
khavinshankar Mar 6, 2023
2649f9c
Add Ratelimiting Docs comment
gigincg Mar 6, 2023
50332f9
allow null for abha_number while registering patient
khavinshankar Mar 7, 2023
4605dc3
fixed confirm_with_aadhaar_otp path
khavinshankar Mar 7, 2023
3ba753a
removed existing abha id validation
khavinshankar Mar 7, 2023
dce2d53
Merge branch 'abdm-m1-vignesh' of github.com:coronasafe/care into abd…
khavinshankar Mar 7, 2023
c63b2be
added care-context linking flow
khavinshankar Mar 30, 2023
70e437b
added consent flow
khavinshankar Mar 30, 2023
859891f
added data transfer flow
khavinshankar Mar 31, 2023
918d7d1
changed encryption according to abdm docs
khavinshankar Apr 3, 2023
b8baf9e
data transfer flow (working version with hardcoded data)
khavinshankar Apr 6, 2023
82514d8
added create_prescription_record in fhir
khavinshankar Apr 6, 2023
9e2574c
removed unwanted variables
khavinshankar Apr 6, 2023
b3b0439
added wellness record
khavinshankar Apr 10, 2023
b953073
added immunization profile
khavinshankar Apr 10, 2023
477e642
added health document profile
khavinshankar Apr 10, 2023
ecb6745
added discharge summary profile
khavinshankar Apr 11, 2023
d1ea874
support sending multiple profiles
khavinshankar Apr 11, 2023
cb21900
Merge branch 'master' into abdm-m2
khavinshankar Apr 13, 2023
b9e94a9
merged conflicting migrations
khavinshankar Apr 13, 2023
c0cbad9
integrated fidelius as a docker service
khavinshankar Apr 13, 2023
7dcac1d
added op consultation profile
khavinshankar Apr 14, 2023
4608e92
added diagnostic report profile
khavinshankar Apr 14, 2023
19c6819
auto link care context while discharge
khavinshankar Apr 21, 2023
b9ea2a0
Update deployment-branch.yaml
mathew-alex Apr 24, 2023
b6b8ac2
Update deployment-branch.yaml
mathew-alex Apr 24, 2023
2d20aa0
disable existing abha number check
khavinshankar Apr 24, 2023
f139ab1
Merge branch 'abdm-m2' of github.com:coronasafe/care into abdm-m2
khavinshankar Apr 24, 2023
9e32644
pick latest patient if more than 1 in discover api
khavinshankar Apr 24, 2023
6bf96a0
removed multiple patient condition check in discover
khavinshankar Apr 24, 2023
c5ff93b
select last patient directly in discover
khavinshankar Apr 24, 2023
307077d
added prints
khavinshankar Apr 24, 2023
3136a9e
improved checks for discover api
khavinshankar Apr 24, 2023
2d52f76
fixed a bug in query in discover api
khavinshankar Apr 24, 2023
cec1ce2
turned on debug and linked a s3 bucket
khavinshankar Apr 25, 2023
85d0ed7
handled None case in immunization record and empty string case in pra…
khavinshankar Apr 26, 2023
11cfa4d
moved add_are_context inti healthid viewset
khavinshankar Apr 26, 2023
67c4be5
added heartbeat api
khavinshankar Apr 27, 2023
949f079
added abha opt out flow
khavinshankar Apr 27, 2023
48cb737
added sms apis
khavinshankar Apr 27, 2023
b37d44e
added ratelimiting to m2 apis
khavinshankar May 24, 2023
a8a4162
added patient_sms_notify
khavinshankar Jun 3, 2023
8ccc1b7
return abdm response in patient_sms_notify
khavinshankar Jun 3, 2023
3cd09d8
added key chech in auth/init and auth/confirm
khavinshankar Jun 4, 2023
66b2316
added key chech in save_linking_token and add_care_context
khavinshankar Jun 4, 2023
72240a2
minor fail safes added
khavinshankar Jun 4, 2023
b562bb5
enabled ratelimiting
khavinshankar Jun 5, 2023
7c57471
debug: ratelimit
khavinshankar Jun 5, 2023
c71012b
removed increament in ratelimiting
khavinshankar Jun 5, 2023
d0c2e2d
added ABDMAuthentication for authentication the callbacks
khavinshankar Jun 7, 2023
e561bc2
set jwt as default auth in production
khavinshankar Jun 7, 2023
3e33b1d
fixed issue in link/confirm callback
khavinshankar Jun 8, 2023
f9303be
temp: send 202 for hip/request and profile/share
khavinshankar Jun 8, 2023
be6968f
set debug to false
khavinshankar Jun 8, 2023
e57e817
add external_id field to users
sainak Jun 9, 2023
69b3996
use uuid for jwt
sainak Jun 9, 2023
3517045
use uuid for user_id in jwt in local conf
khavinshankar Jun 9, 2023
11964b8
Merge branch 'master' into abdm-m2
sainak Jun 9, 2023
08e3850
fix merge issues
sainak Jun 9, 2023
bfbc965
fix lint issues
sainak Jun 9, 2023
057ed5e
Merge branch 'master' into abdm-m2
khavinshankar Jun 13, 2023
c580e4b
set debug to True
khavinshankar Jun 21, 2023
87d5e58
added check_and_generate_mobile_otp
khavinshankar Jun 21, 2023
bffc433
added validation in link_via_qr
khavinshankar Jun 22, 2023
ea1167f
fixed a typo in link_via_qr
khavinshankar Jun 22, 2023
e623cd4
added a patientId is None validation in link_via_qr
khavinshankar Jun 22, 2023
6e9a40b
return error message in create_health_id
khavinshankar Jun 22, 2023
89d3ceb
added direct auth
khavinshankar Jul 4, 2023
24dd683
resolve dependency issue in fhir
khavinshankar Jul 4, 2023
6f91d09
debug
khavinshankar Jul 4, 2023
a0ddbb0
debug
khavinshankar Jul 4, 2023
6095d2c
send health id for direct auth
khavinshankar Jul 4, 2023
d7ded21
fix error in oninit on direct auth
khavinshankar Jul 4, 2023
def4b39
fixed a typo
khavinshankar Jul 4, 2023
fa30758
do confirm to direct auth
khavinshankar Jul 4, 2023
767c419
reverted back to demographics
khavinshankar Jul 4, 2023
a94442c
send healthId
khavinshankar Jul 4, 2023
30ddd72
remove abha address
khavinshankar Jul 4, 2023
92a4548
debug data
khavinshankar Jul 4, 2023
c7c326d
hardcode consultation id for abdm data
khavinshankar Jul 4, 2023
70ad08b
removed hard coding
khavinshankar Jul 4, 2023
0be66c9
Update deployment-branch.yaml
mathew-alex Jul 4, 2023
b96cf47
added support for abha card
khavinshankar Jul 5, 2023
991b89e
Merge branch 'abdm-m2' of github.com:coronasafe/care into abdm-m2
khavinshankar Jul 5, 2023
1ffe7b8
store refresh token while abha creation
khavinshankar Jul 5, 2023
5af1584
get_abha_card_png return original response
khavinshankar Jul 5, 2023
5205e18
added pdf and png downloads for abha card
khavinshankar Jul 5, 2023
53f9586
send 401 when consent is denied in data request
khavinshankar Jul 5, 2023
42ed788
Trigger Build
khavinshankar Jul 5, 2023
59a1674
send health id to createHealthIdWithPreVerified
khavinshankar Jul 19, 2023
7066101
modified link_via_qr to create abha_number
khavinshankar Jul 19, 2023
ff1c300
return an existing abha number if available in link_via_qr
khavinshankar Jul 19, 2023
869966c
changed response data in link_via_qr
khavinshankar Jul 19, 2023
e0a1a59
changed discover filter logic
khavinshankar Jul 19, 2023
3605b8b
fixed searching logic in discover
khavinshankar Jul 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/deployment-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ on:
- "docs/**"

jobs:

build-image:
name: Build & Push Staging to container registries
runs-on: ubuntu-latest
Expand All @@ -29,7 +28,7 @@ jobs:
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
flavor: |
latest=true
latest=false

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
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()
198 changes: 198 additions & 0 deletions care/abdm/api/serializers/healthid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
from rest_framework.serializers import CharField, Serializer


class AadharOtpGenerateRequestPayloadSerializer(Serializer):
aadhaar = CharField(
max_length=16,
min_length=12,
required=True,
help_text="Aadhaar Number",
validators=[],
)


class AadharOtpResendRequestPayloadSerializer(Serializer):
txnId = CharField(
max_length=64,
min_length=1,
required=True,
help_text="Transaction ID",
validators=[],
)


class HealthIdSerializer(Serializer):
healthId = CharField(
max_length=64,
min_length=1,
required=True,
help_text="Health ID",
)


class QRContentSerializer(Serializer):
hidn = CharField(
max_length=17,
min_length=17,
required=True,
help_text="Health ID Number",
)
phr = CharField(
max_length=64,
min_length=1,
required=True,
help_text="Health ID",
)
name = CharField(
max_length=64,
min_length=1,
required=True,
help_text="Name",
)
gender = CharField(
max_length=1,
min_length=1,
required=True,
help_text="Name",
)
dob = CharField(
max_length=10,
min_length=8,
required=True,
help_text="Name",
)
# {"statelgd":"33","distlgd":"573","address":"C/O Gopalsamy NO 33 A WESTSTREET ODANILAI KASTHURIBAI GRAMAM ARACHALUR Erode","state name":"TAMIL NADU","dist name":"Erode","mobile":"7639899448"}


# {
# "authMethod": "AADHAAR_OTP",
# "healthid": "43-4221-5105-6749"
# }
class HealthIdAuthSerializer(Serializer):
authMethod = CharField(
max_length=64,
min_length=1,
required=True,
help_text="Auth Method",
)
healthid = CharField(
max_length=64,
min_length=1,
required=True,
help_text="Health ID",
)


# "gender": "M",
# "mobile": "9545812125",
# "name": "suraj singh karki",
# "yearOfBirth": "1994"


class ABHASearchRequestSerializer:
name = CharField(max_length=64, min_length=1, required=False, help_text="Name")
mobile = CharField(
max_length=10, min_length=10, required=False, help_text="Mobile Number"
)
gender = CharField(max_length=1, min_length=1, required=False, help_text="Gender")
yearOfBirth = CharField(
max_length=4, min_length=4, required=False, help_text="Year of Birth"
)


class GenerateMobileOtpRequestPayloadSerializer(Serializer):
mobile = CharField(
max_length=10,
min_length=10,
required=True,
help_text="Mobile Number",
validators=[],
)
txnId = CharField(
max_length=64,
min_length=1,
required=True,
help_text="Transaction ID",
validators=[],
)


class VerifyOtpRequestPayloadSerializer(Serializer):
otp = CharField(
max_length=6,
min_length=6,
required=True,
help_text="OTP",
validators=[],
)
txnId = CharField(
max_length=64,
min_length=1,
required=True,
help_text="Transaction ID",
validators=[],
)
patientId = CharField(
required=False, help_text="Patient ID to be linked", validators=[]
) # TODO: Add UUID Validation


class VerifyDemographicsRequestPayloadSerializer(Serializer):
gender = CharField(
max_length=10,
min_length=1,
required=True,
help_text="Gender",
validators=[],
)
name = CharField(
max_length=64,
min_length=1,
required=True,
help_text="Name",
validators=[],
)
yearOfBirth = CharField(
max_length=4,
min_length=4,
required=True,
help_text="Year Of Birth",
validators=[],
)
txnId = CharField(
max_length=64,
min_length=1,
required=True,
help_text="Transaction ID",
validators=[],
)


# {
# "email": "[email protected]",
# "firstName": "manoj",
# "healthId": "deepak.pant",
# "lastName": "singh",
# "middleName": "kishan",
# "password": "India@143",
# "profilePhoto": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkJCQkJCQoLCwoODw0PDhQSERESFB4WFxYXFh4uHSEdHSEdLikxKCUoMSlJOTMzOUlUR0NHVGZbW2aBeoGoqOIBCQkJCQkJCgsLCg4PDQ8OFBIRERIUHhYXFhcWHi4dIR0dIR0uKTEoJSgxKUk5MzM5SVRHQ0dUZltbZoF6gaio4v/CABEIBLAHgAMBIgACEQEDEQH/xAAbAAACAwEBAQAAAAAAAAAAAAACAwABBAUGB//aAAgBAQAAAADwawLpMspcK7qrlE5F0Vtul2bVywMUNeBHUkW/bmxvYELGuNjh2VDvixxo5ViljKjDRMoahCULjs2JCShjhjh2OGxo0Y2MoXHOLszsKLhw7tD99mpZQxj8xceofmLEKFwXLTIyHwY1Ls+iEotjHY0M0pjRYxtGj4VFKLPohQlFQyy4Qipc0XG9pS+CP/2Q==",
# "txnId": "a825f76b-0696-40f3-864c-5a3a5b389a83"
# }
class CreateHealthIdSerializer(Serializer):
healthId = CharField(
max_length=64,
min_length=1,
required=False,
help_text="Health ID",
validators=[],
)
txnId = CharField(
max_length=64,
min_length=1,
required=True,
help_text="PreVerified Transaction ID",
validators=[],
)
patientId = CharField(
required=False, help_text="Patient ID to be linked", validators=[]
) # TODO: Add UUID Validation
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()
43 changes: 43 additions & 0 deletions care/abdm/api/viewsets/abha.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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)
print(
"Finding patient with external_id: ", self.kwargs.get("patient_external_id")
)
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()
# Empty Dict as data, obj.access_token as auth
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()
# Empty Dict as data, obj.access_token as auth
response = gateway.get_profile(obj)
return Response(response)
Loading