-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added communication apis in hcx * fixed HcxOperations import issue * get recipentCode from policy.insurer_id * fixed linting errors and conflict in migrations * added authorization to hcx/communication * merged conflicting migrations --------- Co-authored-by: Mathew <matthewzalex@gmail.com>
- Loading branch information
1 parent
1219f00
commit d1d29cd
Showing
17 changed files
with
573 additions
and
9 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Generated by Django 2.2.11 on 2023-06-08 05:15 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("facility", "0359_auto_20230529_1907"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="fileupload", | ||
name="file_type", | ||
field=models.IntegerField( | ||
choices=[ | ||
(1, "PATIENT"), | ||
(2, "CONSULTATION"), | ||
(3, "SAMPLE_MANAGEMENT"), | ||
(4, "CLAIM"), | ||
(5, "DISCHARGE_SUMMARY"), | ||
(6, "COMMUNICATION"), | ||
], | ||
default=1, | ||
), | ||
), | ||
] |
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,12 @@ | ||
# Generated by Django 2.2.11 on 2023-06-10 15:56 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("facility", "0360_auto_20230608_1750"), | ||
("facility", "0360_auto_20230608_1045"), | ||
] | ||
|
||
operations = [] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from rest_framework.serializers import CharField, JSONField, ModelSerializer, UUIDField | ||
|
||
from care.hcx.api.serializers.claim import ClaimSerializer | ||
from care.hcx.models.claim import Claim | ||
from care.hcx.models.communication import Communication | ||
from care.users.api.serializers.user import UserBaseMinimumSerializer | ||
from care.utils.serializer.external_id_field import ExternalIdSerializerField | ||
|
||
TIMESTAMP_FIELDS = ( | ||
"created_date", | ||
"modified_date", | ||
) | ||
|
||
|
||
class CommunicationSerializer(ModelSerializer): | ||
id = UUIDField(source="external_id", read_only=True) | ||
|
||
claim = ExternalIdSerializerField( | ||
queryset=Claim.objects.all(), write_only=True, required=True | ||
) | ||
claim_object = ClaimSerializer(source="claim", read_only=True) | ||
|
||
identifier = CharField(required=False) | ||
content = JSONField(required=False) | ||
|
||
created_by = UserBaseMinimumSerializer(read_only=True) | ||
last_modified_by = UserBaseMinimumSerializer(read_only=True) | ||
|
||
class Meta: | ||
model = Communication | ||
exclude = ("deleted", "external_id") | ||
read_only_fields = TIMESTAMP_FIELDS | ||
|
||
def create(self, validated_data): | ||
validated_data["created_by"] = self.context["request"].user | ||
validated_data["last_modified_by"] = self.context["request"].user | ||
return super().create(validated_data) | ||
|
||
def update(self, instance, validated_data): | ||
instance.last_modified_by = self.context["request"].user | ||
return super().update(instance, validated_data) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from django_filters import rest_framework as filters | ||
from rest_framework import filters as drf_filters | ||
from rest_framework.mixins import ( | ||
CreateModelMixin, | ||
ListModelMixin, | ||
RetrieveModelMixin, | ||
UpdateModelMixin, | ||
) | ||
from rest_framework.permissions import IsAuthenticated | ||
from rest_framework.viewsets import GenericViewSet | ||
|
||
from care.hcx.api.serializers.communication import CommunicationSerializer | ||
from care.hcx.models.communication import Communication | ||
from care.utils.queryset.communications import get_communications | ||
|
||
|
||
class CommunicationFilter(filters.FilterSet): | ||
claim = filters.UUIDFilter(field_name="claim__external_id") | ||
|
||
|
||
class CommunicationViewSet( | ||
CreateModelMixin, | ||
ListModelMixin, | ||
RetrieveModelMixin, | ||
UpdateModelMixin, | ||
GenericViewSet, | ||
): | ||
queryset = Communication.objects.all() | ||
permission_classes = (IsAuthenticated,) | ||
serializer_class = CommunicationSerializer | ||
lookup_field = "external_id" | ||
search_fields = ["claim"] | ||
filter_backends = ( | ||
filters.DjangoFilterBackend, | ||
drf_filters.SearchFilter, | ||
drf_filters.OrderingFilter, | ||
) | ||
filterset_class = CommunicationFilter | ||
ordering_fields = [ | ||
"id", | ||
"created_date", | ||
"modified_date", | ||
] | ||
|
||
def get_queryset(self): | ||
return get_communications(self.request.user) |
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.