Skip to content

Commit 3c9f3c2

Browse files
praffqvigneshhari
andauthored
[ENG-925] removed encounter_class_history field (#3743)
* removed encounter_class_history field * fixed migrations * added validation to disallow encounter class change * Remove encounter class from update spec --------- Co-authored-by: vigneshhari <vichuhari100@gmail.com>
1 parent b4a79b2 commit 3c9f3c2

6 files changed

Lines changed: 21 additions & 16 deletions

File tree

care/emr/admin/encounter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class Meta:
4141
"status",
4242
"status_history",
4343
"encounter_class",
44-
"encounter_class_history",
4544
"patient",
4645
"period",
4746
"facility",
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by Django 6.0 on 2026-08-18 17:37
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('emr', '0081_facilitylocation_tags'),
10+
]
11+
12+
operations = [
13+
migrations.RemoveField(
14+
model_name='encounter',
15+
name='encounter_class_history',
16+
),
17+
]

care/emr/models/encounter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class Encounter(EMRBaseModel):
1212
status = models.CharField(max_length=100, null=True, blank=True)
1313
status_history = models.JSONField(default=dict)
1414
encounter_class = models.CharField(max_length=100, null=True, blank=True)
15-
encounter_class_history = models.JSONField(default=dict)
1615
patient = models.ForeignKey("emr.Patient", on_delete=models.CASCADE)
1716
period = models.JSONField(default=dict)
1817
facility = models.ForeignKey("facility.Facility", on_delete=models.PROTECT)

care/emr/resources/encounter/spec.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ class EncounterSpecBase(EMRResource):
6262

6363
id: UUID4 = None
6464
status: StatusChoices
65-
encounter_class: ClassChoices
6665
period: PeriodSpec = {}
6766
hospitalization: HospitalizationSpec | None = {}
6867
priority: EncounterPriorityChoices
@@ -75,6 +74,7 @@ class EncounterCreateSpec(ExtensionValidator, EncounterSpecBase):
7574
facility: UUID4
7675
organizations: list[UUID4] = []
7776
appointment: UUID4 | None = None
77+
encounter_class: ClassChoices
7878

7979
def perform_extra_deserialization(self, is_update, obj):
8080
if not is_update:
@@ -95,11 +95,6 @@ def perform_extra_deserialization(self, is_update, obj):
9595
obj.status_history = {
9696
"history": [{"status": obj.status, "moved_at": str(timezone.now())}]
9797
}
98-
obj.encounter_class_history = {
99-
"history": [
100-
{"status": obj.encounter_class, "moved_at": str(timezone.now())}
101-
]
102-
}
10398

10499

105100
class EncounterUpdateSpec(ExtensionValidator, EncounterSpecBase):
@@ -109,10 +104,6 @@ def perform_extra_deserialization(self, is_update, obj):
109104
obj.status_history["history"].append(
110105
{"status": self.status, "moved_at": str(timezone.now())}
111106
)
112-
if old_instance.encounter_class != self.encounter_class:
113-
obj.encounter_class_history["history"].append(
114-
{"status": self.status, "moved_at": str(timezone.now())}
115-
)
116107
if self.discharge_summary_advice is None and is_update:
117108
obj.discharge_summary_advice = None
118109

@@ -121,12 +112,12 @@ class EncounterListSpec(EncounterSpecBase):
121112
patient: dict
122113
facility: dict
123114
status_history: dict
124-
encounter_class_history: dict
125115
created_date: datetime.datetime
126116
modified_date: datetime.datetime
127117
tags: list[dict] = []
128118
current_location: dict | None = None
129119
care_team: list[dict] = []
120+
encounter_class: ClassChoices
130121

131122
@classmethod
132123
def perform_extra_serialization(cls, mapping, obj):

care/emr/tests/test_encounter_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def setUp(self):
4242
patient=self.patient,
4343
facility=self.facility,
4444
organization=self.facility_organization,
45+
encounter_class=ClassChoices.imp.value,
4546
status_history={"history": []},
46-
encounter_class_history={"history": []},
4747
)
4848
self.client.force_authenticate(user=self.user)
4949
self.url = reverse("encounter-list")
@@ -929,8 +929,8 @@ def setUp(self):
929929
patient=self.patient,
930930
facility=self.facility,
931931
organization=self.facility_organization,
932+
encounter_class=ClassChoices.imp.value,
932933
status_history={"history": []},
933-
encounter_class_history={"history": []},
934934
)
935935
self.client.force_authenticate(user=self.user)
936936
self.url = reverse("encounter-list")

care/emr/tests/test_medication_dispense_api.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def setUp(self):
3636
facility=self.facility,
3737
organization=self.facility_organization,
3838
status_history={"history": []},
39-
encounter_class_history={"history": []},
4039
)
4140
self.supplier = self.create_organization(name="Test Supplier")
4241
self.location = self.create_facility_location(

0 commit comments

Comments
 (0)