Skip to content

Commit

Permalink
fix(daily_round): added recommend_discharge as action
Browse files Browse the repository at this point in the history
  • Loading branch information
aeswibon committed Sep 9, 2023
1 parent 40484cf commit 6c567d9
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from django.db import migrations, models


def update_recommend_discharge(apps, schema_editor):
patient_model = apps.get_model("facility", "PatientRegistration")
patient_model.objects.filter(
last_consultation__last_daily_round__recommend_discharge=True
).update(action=90)


class Migration(migrations.Migration):
dependencies = [
("facility", "0385_alter_patientconsultation_verified_by"),
]

operations = [
migrations.AlterField(
model_name="historicalpatientregistration",
name="action",
field=models.IntegerField(
blank=True,
choices=[
(10, "NO_ACTION"),
(20, "PENDING"),
(30, "SPECIALIST_REQUIRED"),
(40, "PLAN_FOR_HOME_CARE"),
(50, "FOLLOW_UP_NOT_REQUIRED"),
(60, "COMPLETE"),
(70, "REVIEW"),
(80, "NOT_REACHABLE"),
(90, "DISCHARGE_RECOMMENDED"),
],
default=10,
null=True,
),
),
migrations.AlterField(
model_name="patientregistration",
name="action",
field=models.IntegerField(
blank=True,
choices=[
(10, "NO_ACTION"),
(20, "PENDING"),
(30, "SPECIALIST_REQUIRED"),
(40, "PLAN_FOR_HOME_CARE"),
(50, "FOLLOW_UP_NOT_REQUIRED"),
(60, "COMPLETE"),
(70, "REVIEW"),
(80, "NOT_REACHABLE"),
(90, "DISCHARGE_RECOMMENDED"),
],
default=10,
null=True,
),
),
migrations.RunPython(update_recommend_discharge),
migrations.RemoveField(
model_name="dailyround",
name="recommend_discharge",
),
]
39 changes: 30 additions & 9 deletions care/facility/models/daily_round.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ class InsulinIntakeFrequencyType(enum.Enum):
]

consultation = models.ForeignKey(
PatientConsultation, on_delete=models.PROTECT, related_name="daily_rounds"
PatientConsultation,
on_delete=models.PROTECT,
related_name="daily_rounds",
)
temperature = models.DecimalField(
decimal_places=2,
Expand Down Expand Up @@ -158,17 +160,17 @@ class InsulinIntakeFrequencyType(enum.Enum):
current_health = models.IntegerField(
default=0, choices=CURRENT_HEALTH_CHOICES, blank=True
)
recommend_discharge = models.BooleanField(
default=False, verbose_name="Recommend Discharging Patient"
)
other_details = models.TextField(null=True, blank=True)
medication_given = JSONField(default=dict) # To be Used Later on

last_updated_by_telemedicine = models.BooleanField(default=False)
created_by_telemedicine = models.BooleanField(default=False)

created_by = models.ForeignKey(
User, on_delete=models.SET_NULL, null=True, related_name="update_created_user"
User,
on_delete=models.SET_NULL,
null=True,
related_name="update_created_user",
)

last_edited_by = models.ForeignKey(
Expand Down Expand Up @@ -265,7 +267,8 @@ class InsulinIntakeFrequencyType(enum.Enum):
rhythm = models.IntegerField(choices=RythmnChoice, default=RythmnType.UNKNOWN.value)
rhythm_detail = models.TextField(default=None, null=True, blank=True)
ventilator_interface = models.IntegerField(
choices=VentilatorInterfaceChoice, default=VentilatorInterfaceType.UNKNOWN.value
choices=VentilatorInterfaceChoice,
default=VentilatorInterfaceType.UNKNOWN.value,
)
ventilator_mode = models.IntegerField(
choices=VentilatorModeChoice, default=VentilatorModeType.UNKNOWN.value
Expand Down Expand Up @@ -339,7 +342,8 @@ class InsulinIntakeFrequencyType(enum.Enum):
validators=[MinValueValidator(0), MaxValueValidator(10)],
)
pain_scale_enhanced = JSONField(
default=list, validators=[JSONFieldSchemaValidator(PAIN_SCALE_ENHANCED)]
default=list,
validators=[JSONFieldSchemaValidator(PAIN_SCALE_ENHANCED)],
)
ph = models.DecimalField(
decimal_places=2,
Expand Down Expand Up @@ -457,9 +461,26 @@ def cztn(self, value):
return value

def update_pressure_sore(self):
area_interval_points = [0.1, 0.3, 0.7, 1.1, 2.1, 3.1, 4.1, 8.1, 12.1, 25]
area_interval_points = [
0.1,
0.3,
0.7,
1.1,
2.1,
3.1,
4.1,
8.1,
12.1,
25,
]
exudate_amounts = ["None", "Light", "Moderate", "Heavy"]
tissue_types = ["Closed", "Epithelial", "Granulation", "Slough", "Necrotic"]
tissue_types = [
"Closed",
"Epithelial",
"Granulation",
"Slough",
"Necrotic",
]

def cal_push_score(item):
push_score = item.get("base_score", 0.0)
Expand Down
1 change: 1 addition & 0 deletions care/facility/models/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class ActionEnum(enum.Enum):
COMPLETE = 60
REVIEW = 70
NOT_REACHABLE = 80
DISCHARGE_RECOMMENDED = 90

ActionChoices = [(e.value, e.name) for e in ActionEnum]

Expand Down

0 comments on commit 6c567d9

Please sign in to comment.