-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for Incorrect Discharge Reasons in Patient Transfers and Readmiss…
…ions (#1712) * Add discharge reason to PatientTransferSerializer and handle patient transfer validation * remove bed on transfer * Migration for beds attached to discharged patients * Apply suggestions from code review Co-authored-by: Aakash Singh <mail@singhaakash.dev> * Update patient.py * lint * atomic transaction * add tests --------- Co-authored-by: Aakash Singh <mail@singhaakash.dev>
- Loading branch information
Showing
5 changed files
with
153 additions
and
8 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
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,28 @@ | ||
# Generated by Django 4.2.6 on 2023-11-14 16:49 | ||
|
||
from django.db import migrations | ||
|
||
|
||
def free_discharged_beds(apps, schema_editor): | ||
PatientConsultation = apps.get_model("facility", "PatientConsultation") | ||
ConsultationBed = apps.get_model("facility", "ConsultationBed") | ||
|
||
for consultation in PatientConsultation.objects.filter( | ||
discharge_date__isnull=False | ||
): | ||
ConsultationBed.objects.filter( | ||
consultation=consultation, end_date__isnull=True | ||
).update(end_date=consultation.discharge_date) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
( | ||
"facility", | ||
"0393_rename_diagnosis_patientconsultation_deprecated_diagnosis_and_more", | ||
), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(free_discharged_beds, migrations.RunPython.noop), | ||
] |
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