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 v24.39.0 #2463

Merged
merged 5 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ django-cors-headers = "==4.3.1"
django-filter = "==24.2"
django-maintenance-mode = "==0.21.1"
django-model-utils = "==4.5.1"
django-multiselectfield = "==0.1.12"
django-queryset-csv = "==1.1.0"
django-ratelimit = "==4.1.0"
django-redis = "==5.4.0"
Expand Down
10 changes: 1 addition & 9 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions care/abdm/api/serializers/healthid.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,8 @@ 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)


class LinkPatientSerializer(Serializer):
abha_number = UUIDField(required=True)
patient = UUIDField(required=True)
2 changes: 1 addition & 1 deletion care/abdm/api/viewsets/abha_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_object(self):
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(
if not instance or not get_patient_queryset(self.request.user).contains(
instance.patient
):
raise Http404
Expand Down
60 changes: 60 additions & 0 deletions care/abdm/api/viewsets/healthid.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
GenerateMobileOtpRequestPayloadSerializer,
HealthIdAuthSerializer,
HealthIdSerializer,
LinkPatientSerializer,
QRContentSerializer,
VerifyDemographicsRequestPayloadSerializer,
VerifyOtpRequestPayloadSerializer,
Expand Down Expand Up @@ -415,6 +416,65 @@ def link_via_qr(self, request):
status=status.HTTP_200_OK,
)

@extend_schema(
operation_id="search_by_health_id",
request=LinkPatientSerializer,
tags=["ABDM HealthID"],
)
@action(detail=False, methods=["post"])
def link_patient(self, request):
data = request.data

serializer = LinkPatientSerializer(data=data)
serializer.is_valid(raise_exception=True)

patient_queryset = get_patient_queryset(request.user)
patient = patient_queryset.filter(external_id=data.get("patient")).first()

if not patient:
return Response(
{
"detail": "Patient not found or you do not have permission to access the patient",
},
status=status.HTTP_400_BAD_REQUEST,
)

if hasattr(patient, "abha_number"):
return Response(
{
"detail": "Patient already linked to an ABHA Number",
},
status=status.HTTP_400_BAD_REQUEST,
)

abha_number = AbhaNumber.objects.filter(
external_id=data.get("abha_number")
).first()

if not abha_number:
return Response(
{
"detail": "ABHA Number not found",
},
status=status.HTTP_400_BAD_REQUEST,
)

if abha_number.patient is not None:
return Response(
{
"detail": "ABHA Number already linked to a patient",
},
status=status.HTTP_400_BAD_REQUEST,
)

abha_number.patient = patient
abha_number.save()

return Response(
AbhaNumberSerializer(abha_number).data,
status=status.HTTP_200_OK,
)

@extend_schema(
operation_id="get_new_linking_token",
responses={"200": "{'status': 'boolean'}"},
Expand Down
3 changes: 1 addition & 2 deletions care/audit_log/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from typing import List, NamedTuple

from django.conf import settings
from multiselectfield.db.fields import MSFList
from rest_framework.utils.encoders import JSONEncoder


Expand All @@ -15,7 +14,7 @@ def remove_non_member_fields(d: dict):
def instance_finder(v):
return isinstance(
v,
(list, dict, set, MSFList),
(list, dict, set),
)


Expand Down
27 changes: 27 additions & 0 deletions care/facility/api/serializers/daily_round.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import timedelta

from django.db import transaction
from django.utils import timezone
from django.utils.timezone import localtime, now
from rest_framework import serializers
from rest_framework.exceptions import ValidationError
Expand Down Expand Up @@ -40,6 +41,27 @@ class DailyRoundSerializer(serializers.ModelSerializer):

rounds_type = ChoiceField(choices=DailyRound.RoundsTypeChoice, required=True)

# Community Nurse's Log

bowel_issue = ChoiceField(
choices=DailyRound.BowelDifficultyType.choices, required=False
)
bladder_drainage = ChoiceField(
choices=DailyRound.BladderDrainageType.choices, required=False
)
bladder_issue = ChoiceField(
choices=DailyRound.BladderIssueType.choices, required=False
)
urination_frequency = ChoiceField(
choices=DailyRound.UrinationFrequencyType.choices, required=False
)
sleep = ChoiceField(choices=DailyRound.SleepType.choices, required=False)
nutrition_route = ChoiceField(
choices=DailyRound.NutritionRouteType.choices, required=False
)
oral_issue = ChoiceField(choices=DailyRound.OralIssueType.choices, required=False)
appetite = ChoiceField(choices=DailyRound.AppetiteType.choices, required=False)

# Critical Care Components

consciousness_level = ChoiceField(
Expand Down Expand Up @@ -295,3 +317,8 @@ def validate(self, attrs):
validated["bed_id"] = bed_object.id

return validated

def validate_taken_at(self, value):
if value and value > timezone.now():
raise serializers.ValidationError("Cannot create an update in the future")
return value
20 changes: 20 additions & 0 deletions care/facility/management/commands/load_event_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,26 @@ class Command(BaseCommand):
),
},
{"name": "NURSING", "fields": ("nursing",)},
{
"name": "ROUTINE",
"children": (
{"name": "SLEEP_ROUTINE", "fields": ("sleep",)},
{"name": "BOWEL_ROUTINE", "fields": ("bowel_issue",)},
{
"name": "BLADDER_ROUTINE",
"fields": (
"bladder_drainage",
"bladder_issue",
"experiences_dysuria",
"urination_frequency",
),
},
{
"name": "NUTRITION_ROUTINE",
"fields": ("nutrition_route", "oral_issue", "appetite"),
},
),
},
),
},
{
Expand Down
9 changes: 4 additions & 5 deletions care/facility/migrations/0001_initial_squashed.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import django.core.validators
import django.db.models.deletion
import django.utils.timezone
import multiselectfield.db.fields
import simple_history.models
from django.conf import settings
from django.db import migrations, models
Expand Down Expand Up @@ -1039,7 +1038,7 @@ class Migration(migrations.Migration):
("physical_examination_info", models.TextField(blank=True, null=True)),
(
"additional_symptoms",
multiselectfield.db.fields.MultiSelectField(
models.CharField(
blank=True,
choices=[
(1, "ASYMPTOMATIC"),
Expand Down Expand Up @@ -2052,7 +2051,7 @@ class Migration(migrations.Migration):
("kasp_empanelled", models.BooleanField(default=False)),
(
"features",
multiselectfield.db.fields.MultiSelectField(
models.CharField(
blank=True,
choices=[
(1, "CT Scan Facility"),
Expand Down Expand Up @@ -2402,7 +2401,7 @@ class Migration(migrations.Migration):
),
(
"symptoms",
multiselectfield.db.fields.MultiSelectField(
models.CharField(
blank=True,
choices=[
(1, "ASYMPTOMATIC"),
Expand Down Expand Up @@ -4330,7 +4329,7 @@ class Migration(migrations.Migration):
),
(
"symptoms",
multiselectfield.db.fields.MultiSelectField(
models.CharField(
choices=[
(1, "ASYMPTOMATIC"),
(2, "FEVER"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Generated by Django 4.2.5 on 2024-01-08 17:26

import multiselectfield.db.fields
from django.db import migrations
from django.db import migrations, models


class Migration(migrations.Migration):
Expand All @@ -13,7 +12,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name="dailyround",
name="additional_symptoms",
field=multiselectfield.db.fields.MultiSelectField(
field=models.CharField(
blank=True,
choices=[
(1, "ASYMPTOMATIC"),
Expand Down Expand Up @@ -58,7 +57,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name="patientconsultation",
name="symptoms",
field=multiselectfield.db.fields.MultiSelectField(
field=models.CharField(
blank=True,
choices=[
(1, "ASYMPTOMATIC"),
Expand Down Expand Up @@ -103,7 +102,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name="patientteleconsultation",
name="symptoms",
field=multiselectfield.db.fields.MultiSelectField(
field=models.CharField(
choices=[
(1, "ASYMPTOMATIC"),
(2, "FEVER"),
Expand Down
17 changes: 17 additions & 0 deletions care/facility/migrations/0455_remove_facility_old_features.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.15 on 2024-09-11 13:32

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("facility", "0454_remove_historicalpatientregistration_abha_number_and_more"),
]

operations = [
migrations.RemoveField(
model_name="facility",
name="old_features",
),
]
Loading
Loading