From b3ad350f9bdd043f3d3e5139ecc85bda0c16dff0 Mon Sep 17 00:00:00 2001 From: Prafful Sharma <115104695+DraKen0009@users.noreply.github.com> Date: Mon, 23 Sep 2024 10:33:49 +0530 Subject: [PATCH] archived spo2 field to archived_spo2 (#2397) archived spo2 field to archived_spo2 (#2397) --------- Co-authored-by: Aakash Singh --- care/abdm/utils/fhir.py | 17 ++++++++--------- .../management/commands/load_event_types.py | 2 +- ...0464_rename_spo2_dailyround_archived_spo2.py | 17 +++++++++++++++++ care/facility/models/daily_round.py | 4 ++-- 4 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 care/facility/migrations/0464_rename_spo2_dailyround_archived_spo2.py diff --git a/care/abdm/utils/fhir.py b/care/abdm/utils/fhir.py index 5c56c54d81..eb9db58f2e 100644 --- a/care/abdm/utils/fhir.py +++ b/care/abdm/utils/fhir.py @@ -316,7 +316,7 @@ def _observations_from_daily_round(self, daily_round): ), self._observation( "SpO2", - {"value": daily_round.spo2, "unit": "%"}, + {"value": daily_round.ventilator_spo2, "unit": "%"}, id, date, ), @@ -1205,17 +1205,16 @@ def create_op_consultation_record(self): def create_record(self, record_type): if record_type == "Prescription": return self.create_prescription_record() - elif record_type == "WellnessRecord": + if record_type == "WellnessRecord": return self.create_wellness_record() - elif record_type == "ImmunizationRecord": + if record_type == "ImmunizationRecord": return self.create_immunization_record() - elif record_type == "HealthDocumentRecord": + if record_type == "HealthDocumentRecord": return self.create_health_document_record() - elif record_type == "DiagnosticReport": + if record_type == "DiagnosticReport": return self.create_diagnostic_report_record() - elif record_type == "DischargeSummary": + if record_type == "DischargeSummary": return self.create_discharge_summary_record() - elif record_type == "OPConsultation": + if record_type == "OPConsultation": return self.create_op_consultation_record() - else: - return self.create_discharge_summary_record() + return self.create_discharge_summary_record() diff --git a/care/facility/management/commands/load_event_types.py b/care/facility/management/commands/load_event_types.py index b41966f195..271f510b79 100644 --- a/care/facility/management/commands/load_event_types.py +++ b/care/facility/management/commands/load_event_types.py @@ -116,7 +116,6 @@ class Command(BaseCommand): "name": "VITALS", "children": ( {"name": "TEMPERATURE", "fields": ("temperature",)}, - {"name": "SPO2", "fields": ("spo2",)}, {"name": "PULSE", "fields": ("pulse",)}, {"name": "BLOOD_PRESSURE", "fields": ("bp",)}, {"name": "RESPIRATORY_RATE", "fields": ("resp",)}, @@ -268,6 +267,7 @@ class Command(BaseCommand): "VENTILATOR_MODES", "SYMPTOMS", "ROUND_SYMPTOMS", + "SPO2", ) def create_objects( diff --git a/care/facility/migrations/0464_rename_spo2_dailyround_archived_spo2.py b/care/facility/migrations/0464_rename_spo2_dailyround_archived_spo2.py new file mode 100644 index 0000000000..f792cb874e --- /dev/null +++ b/care/facility/migrations/0464_rename_spo2_dailyround_archived_spo2.py @@ -0,0 +1,17 @@ +# Generated by Django 5.1.1 on 2024-09-22 19:07 + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("facility", "0463_patientnotes_reply_to"), + ] + + operations = [ + migrations.RenameField( + model_name="dailyround", + old_name="spo2", + new_name="archived_spo2", + ), + ] diff --git a/care/facility/models/daily_round.py b/care/facility/models/daily_round.py index ddfb409cd1..718b75d058 100644 --- a/care/facility/models/daily_round.py +++ b/care/facility/models/daily_round.py @@ -162,9 +162,9 @@ class InsulinIntakeFrequencyType(models.IntegerChoices): null=True, validators=[MinValueValidator(Decimal(95)), MaxValueValidator(Decimal(106))], ) - spo2 = models.DecimalField( + archived_spo2 = models.DecimalField( max_digits=4, decimal_places=2, blank=True, null=True, default=None - ) + ) # Deprecated physical_examination_info = models.TextField(null=True, blank=True) deprecated_covid_category = models.CharField( choices=COVID_CATEGORY_CHOICES,