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

Merge Develop To Staging #2794

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
07f3f70
added swaggar support
DraKen0009 Jan 22, 2025
837f0ae
added more swaggar support
DraKen0009 Jan 22, 2025
853427f
fixed create mixin change
DraKen0009 Jan 22, 2025
58a9987
reverted status code change
DraKen0009 Jan 22, 2025
00550df
Merge branch 'develop' into prafful/feat/adding-swagger-support
DraKen0009 Jan 22, 2025
1932fd6
Merge branch 'develop' into prafful/feat/adding-swagger-support
DraKen0009 Jan 23, 2025
aff7fdb
created a decorator for schema generation
DraKen0009 Jan 24, 2025
83cf327
merged develop
DraKen0009 Jan 24, 2025
de73f58
updated the decorator
DraKen0009 Jan 24, 2025
d7b4084
updated decorator to include tags
DraKen0009 Jan 26, 2025
a46ca16
Merge branch 'develop' into prafful/feat/adding-swagger-support
DraKen0009 Jan 26, 2025
45cdda8
update for tags
DraKen0009 Jan 26, 2025
fff6497
Add Location Spec
vigneshhari Jan 26, 2025
f71f10b
Add filters in resource request
vigneshhari Jan 26, 2025
680b141
Merge branch 'vigneshhari/locations' into prafful/feat/adding-swagger…
vigneshhari Jan 26, 2025
b9d5b0f
Merge pull request #2772 from ohcnetwork/prafful/feat/adding-swagger-…
vigneshhari Jan 26, 2025
b84c835
cleanup migrations
vigneshhari Jan 26, 2025
7539d2e
Added TODO items
vigneshhari Jan 26, 2025
70c9bfc
Clean up HTML files and references
vigneshhari Jan 27, 2025
5795b88
Clean up HTML files and references
vigneshhari Jan 27, 2025
96603ca
Fixes TokenSlots of schedule not getting deleted
rithviknishad Jan 27, 2025
0b64be7
Merge pull request #2783 from ohcnetwork/rithviknishad/fix/schedule-d…
vigneshhari Jan 27, 2025
2e6d015
Location API fixes
vigneshhari Jan 27, 2025
a2bcd02
Location API fixes
vigneshhari Jan 27, 2025
8d62a30
Fixed permission issues ?
vigneshhari Jan 27, 2025
be2f03c
Linting fixes
vigneshhari Jan 27, 2025
357dfb8
Delete TokenSlots when availability is deleted
rithviknishad Jan 28, 2025
b0a5d9c
Merge pull request #2786 from ohcnetwork/rithviknishad/fix/delete-tok…
vigneshhari Jan 28, 2025
6176fd6
updated swagger schema (#2789)
DraKen0009 Jan 29, 2025
37c3df3
Fixing bugs
vigneshhari Jan 29, 2025
3d495a8
Merge pull request #2782 from ohcnetwork/vigneshhari/locations
vigneshhari Jan 29, 2025
f9c1b7f
Update lock
vigneshhari Jan 29, 2025
91b0735
Show current location in encounter retrieve
vigneshhari Jan 29, 2025
f9e1852
Show current location in encounter retrieve
vigneshhari Jan 29, 2025
5e56d79
Adding cache for swagger (#2790)
DraKen0009 Jan 29, 2025
e383bc0
Fix Naming in schema
vigneshhari Jan 29, 2025
8a0977a
Merge branch 'develop' of github.com:ohcnetwork/care into develop
vigneshhari Jan 29, 2025
fff04b4
Multi status support in medication request
vigneshhari Jan 29, 2025
c4348a2
Fix type in medicine administration
vigneshhari Jan 29, 2025
644210d
Fix bug in location update
vigneshhari Jan 29, 2025
73ff1bc
Fix issues with location spec
vigneshhari Jan 29, 2025
550a8c0
Make code nullable in quantity
vigneshhari Jan 30, 2025
a5fcb1f
Make code nullable in quantity
vigneshhari Jan 30, 2025
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
8 changes: 4 additions & 4 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name = "pypi"
[packages]
argon2-cffi = "==23.1.0"
authlib = "==1.4.0"
boto3 = "==1.35.98"
boto3 = "==1.36.7"
celery = "==5.4.0"
django = "==5.1.4"
django-environ = "==0.12.0"
Expand All @@ -32,7 +32,7 @@ newrelic = "==10.4.0"
pillow = "==11.1.0"
psycopg = { extras = ["c"], version = "==3.2.3" }
pydantic = "==2.9.2"
pyjwt = "==2.9.0"
pyjwt = "==2.10.1"
python-slugify = "==8.0.4"
pywebpush = "==2.0.1"
redis = { extras = ["hiredis"], version = "==5.2.1" }
Expand All @@ -42,7 +42,7 @@ simplejson = "==3.19.3"
sentry-sdk = "==2.18.0"
whitenoise = "==6.8.2"
django-anymail = {extras = ["amazon-ses"], version = "*"}
pydantic-extra-types = "2.10.1"
pydantic-extra-types = "2.10.2"
phonenumberslite = "==8.13.52"

[dev-packages]
Expand All @@ -56,7 +56,7 @@ djangorestframework-stubs = "==3.15.2"
factory-boy = "==3.3.1"
freezegun = "==1.5.1"
ipython = "==8.31.0"
mypy = "==1.13.0"
mypy = "==1.14.1"
pre-commit = "==4.0.1"
requests-mock = "==1.12.1"
tblib = "==3.0.0"
Expand Down
250 changes: 128 additions & 122 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Care backend makes the following features possible:

### Docs and Guides

You can find the docs at https://care-be-docs.coronasafe.network
You can find the docs at https://care-be-docs.ohc.network

### Staging Deployments

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def update_site_forward(apps, schema_editor):
Site.objects.update_or_create(
id=settings.SITE_ID,
defaults={
"domain": "coronasafe.in",
"domain": "ohc.network",
"name": "Care",
},
)
Expand Down
7 changes: 7 additions & 0 deletions care/emr/api/otp_viewsets/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from django.conf import settings
from django.utils import timezone
from drf_spectacular.utils import extend_schema
from pydantic import BaseModel, Field, field_validator
from rest_framework.decorators import action
from rest_framework.exceptions import ValidationError
Expand Down Expand Up @@ -45,6 +46,9 @@ class OTPLoginView(EMRBaseViewSet):
authentication_classes = []
permission_classes = []

@extend_schema(
request=OTPLoginRequestSpec,
)
@action(detail=False, methods=["POST"])
def send(self, request):
data = OTPLoginRequestSpec(**request.data)
Expand Down Expand Up @@ -76,6 +80,9 @@ def send(self, request):
otp_obj.save()
return Response({"otp": "generated"})

@extend_schema(
request=OTPLoginSpec,
)
@action(detail=False, methods=["POST"])
def login(self, request):
data = OTPLoginSpec(**request.data)
Expand Down
10 changes: 10 additions & 0 deletions care/emr/api/otp_viewsets/slot.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from drf_spectacular.utils import extend_schema
from pydantic import UUID4, BaseModel
from rest_framework.decorators import action
from rest_framework.exceptions import ValidationError
Expand Down Expand Up @@ -39,13 +40,19 @@ class OTPSlotViewSet(EMRRetrieveMixin, EMRBaseViewSet):
database_model = TokenSlot
pydantic_read_model = TokenSlotBaseSpec

@extend_schema(
request=SlotsForDayRequestSpec,
)
@action(detail=False, methods=["POST"])
def get_slots_for_day(self, request, *args, **kwargs):
request_data = SlotsForDayRequestSpec(**request.data)
return SlotViewSet.get_slots_for_day_handler(
request_data.facility, request.data
)

@extend_schema(
request=AppointmentBookingSpec,
)
@action(detail=True, methods=["POST"])
def create_appointment(self, request, *args, **kwargs):
request_data = AppointmentBookingSpec(**request.data)
Expand All @@ -57,6 +64,9 @@ def create_appointment(self, request, *args, **kwargs):
self.get_object(), request.data, None
)

@extend_schema(
request=CancelAppointmentSpec,
)
@action(detail=False, methods=["POST"])
def cancel_appointment(self, request, *args, **kwargs):
request_data = CancelAppointmentSpec(**request.data)
Expand Down
7 changes: 6 additions & 1 deletion care/emr/api/viewsets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.db import transaction
from django.http.response import Http404
from pydantic import ValidationError
from rest_framework import status
from rest_framework.decorators import action
from rest_framework.exceptions import ValidationError as RestFrameworkValidationError
from rest_framework.generics import get_object_or_404
Expand Down Expand Up @@ -183,11 +184,15 @@ def perform_destroy(self, instance):
instance.deleted = True
instance.save(update_fields=["deleted"])

def validate_destroy(self, instance):
pass

def destroy(self, request, *args, **kwargs):
instance = self.get_object()
self.validate_destroy(instance)
self.authorize_destroy(instance)
self.perform_destroy(instance)
return Response(status=204)
return Response(status=status.HTTP_204_NO_CONTENT)


class EMRUpsertMixin:
Expand Down
4 changes: 4 additions & 0 deletions care/emr/api/viewsets/batch_request.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.db import transaction
from drf_spectacular.utils import extend_schema
from pydantic import BaseModel, Field
from rest_framework.response import Response
from rest_framework.viewsets import GenericViewSet
Expand Down Expand Up @@ -26,6 +27,9 @@ class BatchRequestView(GenericViewSet):
def get_exception_handler(self):
return emr_exception_handler

@extend_schema(
request=BatchRequest,
)
def create(self, request, *args, **kwargs):
requests = BatchRequest(**request.data)
errored = False
Expand Down
22 changes: 20 additions & 2 deletions care/emr/api/viewsets/encounter.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class EncounterFilters(filters.FilterSet):
field_name="patient__phone_number", lookup_expr="icontains"
)
name = filters.CharFilter(field_name="patient__name", lookup_expr="icontains")
location = filters.UUIDFilter(field_name="current_location__external_id")
live = LiveFilter()


Expand Down Expand Up @@ -123,7 +124,14 @@ def get_queryset(self):
qs = (
super()
.get_queryset()
.select_related("patient", "facility", "appointment")
.select_related(
"patient",
"facility",
"appointment",
"current_location",
"created_by",
"updated_by",
)
.order_by("-created_date")
)
if (
Expand Down Expand Up @@ -175,6 +183,10 @@ def organizations(self, request, *args, **kwargs):
class EncounterOrganizationManageSpec(BaseModel):
organization: UUID4

@extend_schema(
request=EncounterOrganizationManageSpec,
responses={200: FacilityOrganizationReadSpec},
)
@action(detail=True, methods=["POST"])
def organizations_add(self, request, *args, **kwargs):
instance = self.get_object()
Expand All @@ -195,6 +207,9 @@ def organizations_add(self, request, *args, **kwargs):
)
return Response(FacilityOrganizationReadSpec.serialize(organization).to_json())

@extend_schema(
request=EncounterOrganizationManageSpec,
)
@action(detail=True, methods=["DELETE"])
def organizations_remove(self, request, *args, **kwargs):
instance = self.get_object()
Expand All @@ -213,7 +228,7 @@ def organizations_remove(self, request, *args, **kwargs):
EncounterOrganization.objects.filter(
encounter=instance, organization=organization
).delete()
return Response({}, status=204)
return Response({}, status=status.HTTP_204_NO_CONTENT)

def _check_discharge_summary_access(self, encounter):
if not AuthorizationController.call(
Expand Down Expand Up @@ -284,6 +299,9 @@ def validate_email(cls, value):
django_validate_email(value)
return value

@extend_schema(
request=EmailDischargeSummarySpec,
)
@action(detail=True, methods=["POST"])
def email_discharge_summary(self, request, *args, **kwargs):
encounter = self.get_object()
Expand Down
27 changes: 14 additions & 13 deletions care/emr/api/viewsets/facility.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,24 @@ def authorize_destroy(self, instance):
raise PermissionDenied("Only Super Admins can delete Facilities")

@method_decorator(parser_classes([MultiPartParser]))
@action(methods=["POST"], detail=True)
@action(methods=["POST", "DELETE"], detail=True)
def cover_image(self, request, external_id):
facility = self.get_object()
self.authorize_update({}, facility)
serializer = FacilityImageUploadSerializer(facility, data=request.data)
serializer.is_valid(raise_exception=True)
serializer.save()
return Response(serializer.data)

@cover_image.mapping.delete
def cover_image_delete(self, *args, **kwargs):
facility = self.get_object()
self.authorize_update({}, facility)
delete_cover_image(facility.cover_image_url, "cover_images")
facility.cover_image_url = None
facility.save()
return Response(status=204)
if request.method == "POST":
serializer = FacilityImageUploadSerializer(facility, data=request.data)
serializer.is_valid(raise_exception=True)
serializer.save()
return Response(serializer.data)
if request.method == "DELETE":
if not facility.cover_image_url:
return Response({"detail": "No cover image to delete"}, status=404)
delete_cover_image(facility.cover_image_url, "cover_images")
facility.cover_image_url = None
facility.save()
return Response(status=204)
return Response({"detail": "Method not allowed"}, status=405)


class FacilitySchedulableUsersViewSet(EMRModelReadOnlyViewSet):
Expand Down
6 changes: 6 additions & 0 deletions care/emr/api/viewsets/file_upload.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.utils import timezone
from django_filters import rest_framework as filters
from drf_spectacular.utils import extend_schema
from pydantic import BaseModel
from rest_framework.decorators import action
from rest_framework.exceptions import PermissionDenied
Expand Down Expand Up @@ -110,6 +111,7 @@ def get_queryset(self):
file_authorizer(self.request.user, obj.file_type, obj.associating_id, "read")
return super().get_queryset()

@extend_schema(responses={200: FileUploadListSpec})
@action(detail=True, methods=["POST"])
def mark_upload_completed(self, request, *args, **kwargs):
obj = self.get_object()
Expand All @@ -121,6 +123,10 @@ def mark_upload_completed(self, request, *args, **kwargs):
class ArchiveRequestSpec(BaseModel):
archive_reason: str

@extend_schema(
request=ArchiveRequestSpec,
responses={200: FileUploadListSpec},
)
@action(detail=True, methods=["POST"])
def archive(self, request, *args, **kwargs):
obj = self.get_object()
Expand Down
Loading
Loading