Skip to content

Commit

Permalink
Adds fields for social profile: socioeconomic status and domestic hea…
Browse files Browse the repository at this point in the history
…lthcare support (#2464)

* Adds fields for social profile: socioeconomic status and domestic healthcare support

* Add tests
  • Loading branch information
rithviknishad authored Sep 19, 2024
1 parent 57d966b commit a06913e
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 34 deletions.
14 changes: 13 additions & 1 deletion care/facility/api/serializers/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,19 @@


class PatientMetaInfoSerializer(serializers.ModelSerializer):
occupation = ChoiceField(choices=PatientMetaInfo.OccupationChoices, allow_null=True)
occupation = ChoiceField(
choices=PatientMetaInfo.OccupationChoices, allow_null=True, required=False
)
socioeconomic_status = ChoiceField(
choices=PatientMetaInfo.SocioeconomicStatus.choices,
allow_null=True,
required=False,
)
domestic_healthcare_support = ChoiceField(
choices=PatientMetaInfo.DomesticHealthcareSupport.choices,
allow_null=True,
required=False,
)

class Meta:
model = PatientMetaInfo
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated by Django 4.2.10 on 2024-09-19 07:07

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("facility", "0456_dailyround_appetite_dailyround_bladder_drainage_and_more"),
]

operations = [
migrations.AddField(
model_name="patientmetainfo",
name="domestic_healthcare_support",
field=models.SmallIntegerField(
blank=True,
choices=[
(0, "NO_SUPPORT"),
(10, "FAMILY_MEMBER"),
(20, "PAID_CAREGIVER"),
],
null=True,
),
),
migrations.AddField(
model_name="patientmetainfo",
name="socioeconomic_status",
field=models.SmallIntegerField(
blank=True,
choices=[
(10, "VERY_POOR"),
(20, "POOR"),
(30, "MIDDLE_CLASS"),
(40, "WELL_OFF"),
],
null=True,
),
),
]
83 changes: 50 additions & 33 deletions care/facility/models/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,43 +589,60 @@ def format_diagnoses(diagnosis_ids):


class PatientMetaInfo(models.Model):
class OccupationEnum(enum.Enum):
STUDENT = 1
BUSINESSMAN = 2
HEALTH_CARE_WORKER = 3
HEALTH_CARE_LAB_WORKER = 4
ANIMAL_HANDLER = 5
OTHERS = 6
HEALTHCARE_PRACTITIONER = 7
PARADEMICS = 8
BUSINESS_RELATED = 9
ENGINEER = 10
TEACHER = 11
OTHER_PROFESSIONAL_OCCUPATIONS = 12
OFFICE_ADMINISTRATIVE = 13
CHEF = 14
PROTECTIVE_SERVICE = 15
HOSPITALITY = 16
CUSTODIAL = 17
CUSTOMER_SERVICE = 18
SALES_SUPERVISOR = 19
RETAIL_SALES_WORKER = 20
INSURANCE_SALES_AGENT = 21
SALES_REPRESENTATIVE = 22
REAL_ESTATE = 23
CONSTRUCTION_EXTRACTION = 24
AGRI_NATURAL = 25
PRODUCTION_OCCUPATION = 26
PILOT_FLIGHT = 27
VEHICLE_DRIVER = 28
MILITARY = 29
HOMEMAKER = 30
UNKNOWN = 31
NOT_APPLICABLE = 32
class OccupationEnum(models.IntegerChoices):
STUDENT = 1, "STUDENT"
BUSINESSMAN = 2, "BUSINESSMAN"
HEALTH_CARE_WORKER = 3, "HEALTH_CARE_WORKER"
HEALTH_CARE_LAB_WORKER = 4, "HEALTH_CARE_LAB_WORKER"
ANIMAL_HANDLER = 5, "ANIMAL_HANDLER"
OTHERS = 6, "OTHERS"
HEALTHCARE_PRACTITIONER = 7, "HEALTHCARE_PRACTITIONER"
PARADEMICS = 8, "PARADEMICS"
BUSINESS_RELATED = 9, "BUSINESS_RELATED"
ENGINEER = 10, "ENGINEER"
TEACHER = 11, "TEACHER"
OTHER_PROFESSIONAL_OCCUPATIONS = 12, "OTHER_PROFESSIONAL_OCCUPATIONS"
OFFICE_ADMINISTRATIVE = 13, "OFFICE_ADMINISTRATIVE"
CHEF = 14, "CHEF"
PROTECTIVE_SERVICE = 15, "PROTECTIVE_SERVICE"
HOSPITALITY = 16, "HOSPITALITY"
CUSTODIAL = 17, "CUSTODIAL"
CUSTOMER_SERVICE = 18, "CUSTOMER_SERVICE"
SALES_SUPERVISOR = 19, "SALES_SUPERVISOR"
RETAIL_SALES_WORKER = 20, "RETAIL_SALES_WORKER"
INSURANCE_SALES_AGENT = 21, "INSURANCE_SALES_AGENT"
SALES_REPRESENTATIVE = 22, "SALES_REPRESENTATIVE"
REAL_ESTATE = 23, "REAL_ESTATE"
CONSTRUCTION_EXTRACTION = 24, "CONSTRUCTION_EXTRACTION"
AGRI_NATURAL = 25, "AGRI_NATURAL"
PRODUCTION_OCCUPATION = 26, "PRODUCTION_OCCUPATION"
PILOT_FLIGHT = 27, "PILOT_FLIGHT"
VEHICLE_DRIVER = 28, "VEHICLE_DRIVER"
MILITARY = 29, "MILITARY"
HOMEMAKER = 30, "HOMEMAKER"
UNKNOWN = 31, "UNKNOWN"
NOT_APPLICABLE = 32, "NOT_APPLICABLE"

OccupationChoices = [(item.value, item.name) for item in OccupationEnum]

class SocioeconomicStatus(models.IntegerChoices):
VERY_POOR = 10, "VERY_POOR"
POOR = 20, "POOR"
MIDDLE_CLASS = 30, "MIDDLE_CLASS"
WELL_OFF = 40, "WELL_OFF"

class DomesticHealthcareSupport(models.IntegerChoices):
NO_SUPPORT = 0, "NO_SUPPORT"
FAMILY_MEMBER = 10, "FAMILY_MEMBER"
PAID_CAREGIVER = 20, "PAID_CAREGIVER"

occupation = models.IntegerField(choices=OccupationChoices, blank=True, null=True)
socioeconomic_status = models.SmallIntegerField(
choices=SocioeconomicStatus.choices, blank=True, null=True
)
domestic_healthcare_support = models.SmallIntegerField(
choices=DomesticHealthcareSupport.choices, blank=True, null=True
)
head_of_household = models.BooleanField(blank=True, null=True)


Expand Down
21 changes: 21 additions & 0 deletions care/facility/tests/test_patient_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,27 @@ def setUpTestData(cls):
def get_base_url(self) -> str:
return "/api/v1/patient/"

def test_update_patient_with_meta_info(self):
self.client.force_authenticate(user=self.user)
res = self.client.patch(
f"{self.get_base_url()}{self.patient.external_id}/",
data={
"meta_info": {
"socioeconomic_status": "VERY_POOR",
"domestic_healthcare_support": "FAMILY_MEMBER",
}
},
format="json",
)
self.assertEqual(res.status_code, status.HTTP_200_OK)
self.assertDictContainsSubset(
{
"socioeconomic_status": "VERY_POOR",
"domestic_healthcare_support": "FAMILY_MEMBER",
},
res.data.get("meta_info"),
)

def test_has_consent(self):
self.client.force_authenticate(user=self.user)
response = self.client.get(self.get_base_url())
Expand Down

0 comments on commit a06913e

Please sign in to comment.