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

Fix for Incorrect Discharge Reasons in Patient Transfers and Readmissions #1712

Merged
merged 8 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion care/facility/api/serializers/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ def save(self, **kwargs):
self.instance.facility = self.validated_data["facility"]
PatientConsultation.objects.filter(
patient=self.instance, discharge_date__isnull=True
).update(discharge_date=localtime(now()))
).update(discharge_date=localtime(now()), discharge_reason="REF")
self.instance.save()


Expand Down
13 changes: 12 additions & 1 deletion care/facility/api/viewsets/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,21 @@
@action(detail=True, methods=["POST"])
def transfer(self, request, *args, **kwargs):
patient = PatientRegistration.objects.get(external_id=kwargs["external_id"])
vigneshhari marked this conversation as resolved.
Show resolved Hide resolved
facility = Facility.objects.get(external_id=request.data["facility"])

Check warning on line 429 in care/facility/api/viewsets/patient.py

View check run for this annotation

Codecov / codecov/patch

care/facility/api/viewsets/patient.py#L429

Added line #L429 was not covered by tests

if patient.is_active and facility == patient.facility:
return Response(

Check warning on line 432 in care/facility/api/viewsets/patient.py

View check run for this annotation

Codecov / codecov/patch

care/facility/api/viewsets/patient.py#L432

Added line #L432 was not covered by tests
{
"Patient": "Patient transfer cannot be completed because the patient has an active consultation in the same facility"
},
status=status.HTTP_406_NOT_ACCEPTABLE,
)

if patient.allow_transfer is False:
return Response(
{"Patient": "Cannot Transfer Patient , Source Facility Does Not Allow"},
{
"Patient": "Patient transfer cannot be completed because the source facility does not permit it"
},
status=status.HTTP_406_NOT_ACCEPTABLE,
)
patient.allow_transfer = False
Expand Down
Loading