Skip to content

Commit fbbb460

Browse files
committed
feat(local_units): add fields in health data model
1 parent 514e327 commit fbbb460

File tree

6 files changed

+90
-7
lines changed

6 files changed

+90
-7
lines changed

local_units/admin.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
LocalUnitChangeRequest,
2222
LocalUnitLevel,
2323
LocalUnitType,
24+
OtherProfile,
2425
PrimaryHCC,
2526
ProfessionalTrainingFacility,
2627
SpecializedMedicalService,
@@ -206,6 +207,11 @@ class ProfessionalTrainingFacilityAdmin(admin.ModelAdmin):
206207
search_fields = ("name",)
207208

208209

210+
@admin.register(OtherProfile)
211+
class OtherProfileAdmin(admin.ModelAdmin):
212+
search_fields = ("position",)
213+
214+
209215
@admin.register(HealthData)
210216
class HealthDataAdmin(CompareVersionAdmin, admin.ModelAdmin):
211217
autocomplete_fields = [
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Generated by Django 4.2.19 on 2025-10-16 09:46
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('local_units', '0023_remove_localunit_is_locked_and_more'),
10+
]
11+
12+
operations = [
13+
migrations.CreateModel(
14+
name='OtherProfile',
15+
fields=[
16+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
17+
('position', models.CharField(verbose_name='Position')),
18+
('number', models.PositiveIntegerField(verbose_name='Number')),
19+
],
20+
options={
21+
'verbose_name': 'Other Profile',
22+
'verbose_name_plural': 'Other Profiles',
23+
},
24+
),
25+
migrations.AddField(
26+
model_name='healthdata',
27+
name='other_training_facilities',
28+
field=models.TextField(blank=True, null=True, verbose_name='Other Training Facilities'),
29+
),
30+
migrations.AddField(
31+
model_name='healthdata',
32+
name='pharmacists',
33+
field=models.IntegerField(blank=True, null=True, verbose_name='Pharmacists'),
34+
),
35+
migrations.RemoveField(
36+
model_name='healthdata',
37+
name='other_profiles',
38+
),
39+
migrations.AddField(
40+
model_name='healthdata',
41+
name='other_profiles',
42+
field=models.ManyToManyField(blank=True, related_name='health_data_other_profile', to='local_units.otherprofile', verbose_name='Other Profiles'),
43+
),
44+
]

local_units/models.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,18 @@ class Meta:
113113
verbose_name_plural = "Professional Training Facilities"
114114

115115

116+
class OtherProfile(models.Model):
117+
position = models.CharField(verbose_name=_("Position"))
118+
number = models.PositiveIntegerField(verbose_name=_("Number"))
119+
120+
def __str__(self):
121+
return f"{self.position}"
122+
123+
class Meta:
124+
verbose_name = "Other Profile"
125+
verbose_name_plural = "Other Profiles"
126+
127+
116128
@reversion.register()
117129
class HealthData(models.Model):
118130
created_at = models.DateTimeField(verbose_name=_("Created at"), auto_now=True)
@@ -178,6 +190,7 @@ class HealthData(models.Model):
178190
null=True,
179191
blank=True,
180192
)
193+
other_training_facilities = models.TextField(verbose_name="Other Training Facilities", blank=True, null=True)
181194
maximum_capacity = models.IntegerField(verbose_name=_("Maximum Capacity"), blank=True, null=True)
182195
number_of_isolation_rooms = models.IntegerField(verbose_name=_("Number of isolation rooms"), blank=True, null=True)
183196
is_warehousing = models.BooleanField(
@@ -226,12 +239,18 @@ class HealthData(models.Model):
226239
dentist = models.IntegerField(verbose_name=_("Dentist"), blank=True, null=True)
227240
nursing_aid = models.IntegerField(verbose_name=_("Nursing Aid"), blank=True, null=True)
228241
midwife = models.IntegerField(verbose_name=_("Midwife"), blank=True, null=True)
242+
pharmacists = models.IntegerField(verbose_name=_("Pharmacists"), blank=True, null=True)
229243
other_medical_heal = models.BooleanField(
230244
verbose_name=_("Other medical heal"),
231245
null=True,
232246
blank=True,
233247
)
234-
other_profiles = models.CharField(max_length=200, verbose_name=_("Other Profiles"), blank=True, null=True)
248+
other_profiles = models.ManyToManyField(
249+
OtherProfile,
250+
related_name="health_data_other_profile",
251+
verbose_name=_("Other Profiles"),
252+
blank=True,
253+
)
235254
feedback = models.TextField(verbose_name=_("Feedback"), blank=True, null=True)
236255

237256
def __str__(self):

local_units/serializers.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
LocalUnitChangeRequest,
3333
LocalUnitLevel,
3434
LocalUnitType,
35+
OtherProfile,
3536
PrimaryHCC,
3637
ProfessionalTrainingFacility,
3738
SpecializedMedicalService,
@@ -106,6 +107,12 @@ class Meta:
106107
fields = "__all__"
107108

108109

110+
class OtherProfileSerializer(serializers.ModelSerializer):
111+
class Meta:
112+
model = OtherProfile
113+
fields = "__all__"
114+
115+
109116
class MiniHealthDataSerializer(serializers.ModelSerializer):
110117
health_facility_type_details = FacilityTypeSerializer(source="health_facility_type", read_only=True)
111118

@@ -147,6 +154,11 @@ class HealthDataSerializer(
147154
professional_training_facilities_details = ProfessionalTrainingFacilitySerializer(
148155
source="professional_training_facilities", many=True, read_only=True
149156
)
157+
other_profiles_details = OtherProfileSerializer(
158+
source="other_profiles",
159+
many=True,
160+
read_only=True,
161+
)
150162
modified_by_details = LocalUnitMiniUserSerializer(source="modified_by", read_only=True)
151163
created_by_details = LocalUnitMiniUserSerializer(source="created_by", read_only=True)
152164

@@ -541,6 +553,7 @@ class LocalUnitOptionsSerializer(serializers.Serializer):
541553
professional_training_facilities = ProfessionalTrainingFacilitySerializer(many=True)
542554
general_medical_services = GeneralMedicalServiceSerializer(many=True)
543555
specialized_medical_beyond_primary_level = SpecializedMedicalServiceSerializer(many=True)
556+
other_profiles = OtherProfileSerializer(many=True)
544557

545558

546559
class MiniDelegationOfficeSerializer(serializers.ModelSerializer):
@@ -840,7 +853,6 @@ def parse_m2m(field_name, mapping):
840853
parse_m2m("specialized_medical_beyond_primary_level", self.specializedmedicalservice_map)
841854
parse_m2m("blood_services", self.bloodservice_map)
842855
parse_m2m("professional_training_facilities", self.professionaltrainingfacility_map)
843-
844856
return super().to_internal_value(data)
845857

846858
def create(self, validated_data):

local_units/test_views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
LocalUnitChangeRequest,
3535
LocalUnitLevel,
3636
LocalUnitType,
37+
OtherProfile,
3738
PrimaryHCC,
3839
ProfessionalTrainingFacility,
3940
SpecializedMedicalService,
@@ -524,6 +525,7 @@ def test_create_update_local_unit_health(self):
524525
functionality = Functionality.objects.create(code=1, name="Code 1")
525526
health_facility_type = FacilityType.objects.create(code=1, name="Code 1")
526527
primary_health_care_center = PrimaryHCC.objects.create(code=1, name="Code 1")
528+
other_profiles = OtherProfile.objects.create(number=1, position="test")
527529
data = {
528530
"local_branch_name": "Silele Red Cross Clinic, Sigombeni Red Cross Clinic & Mahwalala Red Cross Clinic",
529531
"english_branch_name": None,
@@ -576,7 +578,7 @@ def test_create_update_local_unit_health(self):
576578
"nursing_aid": 0,
577579
"midwife": 9,
578580
"other_medical_heal": True,
579-
"other_profiles": None,
581+
"other_profiles": [other_profiles.id],
580582
"feedback": "first question of initial question did not provide for the option to write the name of the NS. It is written LRC yet it should allow Baphalali Eswatini Red Cross Society (BERCS) to be inscribed in the box.", # noqa: E501
581583
"affiliation": affiliation.id,
582584
"functionality": functionality.id,
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
focal_point_email,focal_point_phone_number,focal_point_position,health_facility_type,other_facility_type,affiliation,functionality,primary_health_care_centre,speciality,hospital_type,is_teaching_hospital,is_in_patient_capacity,maximum_capacity,is_isolation_rooms_wards,number_of_isolation_rooms,is_warehousing,is_cold_chain,general_medical_services,specialized_medical_beyond_primary_level,other_services,blood_services,total_number_of_human_resource,general_practitioner,specialist,residents_doctor,nurse,dentist,nursing_aid,midwife,other_medical_heal,other_profiles,feedback,professional_training_facilities,ambulance_type_a,ambulance_type_b,ambulance_type_c,residential_long_term_care_facilities,primary_health_care_center,other_affiliation,local_branch_name,english_branch_name,subtype,level,postcode,address_loc,address_en,city_loc,city_en,focal_person_loc,focal_person_en,phone,email,link,source_en,source_loc,date_of_data,visibility,longitude,latitude
2-
[email protected],26876088546,Programmes Manager,Ambulance Station,tet,Public Government Facility,Fully Functional,Medical Practices,"Initiate TB treatment, Cervical Cancer Screening and testing and diagnostic and treatment for people living with HIV and follow up care through the ART programme which the government supports very well",Mental Health Hospital,yes,No,2,yes,2,Yes,Yes,Minor Trauma,Anaesthesiology,test,Blood Collection,32,0,0,0,3,0,0,9,Yes,test,first question of initial question did not provide for the option to write the name of the NS. It is written LRC yet it should allow Baphalali Eswatini Red Cross Society (BERCS) to be inscribed in the box.,Nurses,2,1,1,1,Dental Practices,test,Cruz Vermelha - Órgão Central HQ - Brasília,,Office,National,70300-910,"Setor Comercial Sul (SCS), quadra 6, bloco A, nº 157, salas 502 e 503 - Edifício Bandeirantes, Asa Sul, Brasília-DF ",,Brasília - DF,,Lourenço Braga,,55 (61) 99909-0761,[email protected],http://www.cruzvermelha.org.br/,Brazilian Red Cross,Brazilian Red Cross Local,2024-02-07,Public,-47.88972222,-15.79638889
3-
[email protected],26876088546,Programmes Manager,Ambulance Station,tet,Public Government Facility,Fully Functional,"Medical Practices,Dental Practices","Initiate TB treatment, Cervical Cancer Screening and testing and diagnostic and treatment for people living with HIV and follow up care through the ART programme which the government supports very well",Mental Health Hospital,No ,No,2,yes,2,Yes,Yes,Minor Trauma,Anaesthesiology,test,Blood Collection,32,0,0,0,3,0,0,9,Yes,test,first question of initial question did not provide for the option to write the name of the NS. It is written LRC yet it should allow Baphalali Eswatini Red Cross Society (BERCS) to be inscribed in the box.,Nurses,1,2,3,1,Dental Practices,test,Filial Alagoas,,Office,National,57035-530,"Av. Com. Gustavo de Paiva, 2889 - Mangabeiras, Maceió - AL",,Alagoas - AL,,Agarina Mendonça,,55 (82) 3325-2430,[email protected],https://www.cruzvermelha.org.br/pb/filiais/alagoas/,Brazilian Red Cross,Brazilian Red Cross Local,2024-02-07,Public,-35.71611111,-9.64777778
4-
[email protected],26876088546,Programmes Manager,Ambulance Station,tet,Public Government Facility,Fully Functional,Medical Practices,"Initiate TB treatment, Cervical Cancer Screening and testing and diagnostic and treatment for people living with HIV and follow up care through the ART programme which the government supports very well",Mental Health Hospital,No ,No,2,no,2,Yes,Yes,Minor Trauma,Anaesthesiology,test,Blood Collection,32,0,0,0,3,0,0,9,Yes,test,first question of initial question did not provide for the option to write the name of the NS. It is written LRC yet it should allow Baphalali Eswatini Red Cross Society (BERCS) to be inscribed in the box.,Nurses,1,2,2,1,Dental Practices,test,Cruz Vermelha - Órgão Central HQ,,Office,National,20230-130,"Praça Cruz Vermelha N° 10-12, Centro, Rio de Janeiro - RJ",,Rio de Janeiro - RJ,,Thiago Quintaneiro,,55 (21) 2507-3577 / 2507-3392,[email protected],http://www.cruzvermelha.org.br/,Brazilian Red Cross,Brazilian Red Cross Local,2024-02-07,Public,-43.1875,-22.91111111
1+
focal_point_email,focal_point_phone_number,focal_point_position,health_facility_type,other_facility_type,affiliation,functionality,primary_health_care_centre,speciality,hospital_type,is_teaching_hospital,is_in_patient_capacity,maximum_capacity,is_isolation_rooms_wards,number_of_isolation_rooms,is_warehousing,is_cold_chain,general_medical_services,specialized_medical_beyond_primary_level,other_services,blood_services,total_number_of_human_resource,general_practitioner,specialist,residents_doctor,nurse,dentist,nursing_aid,midwife,other_medical_heal,feedback,professional_training_facilities,ambulance_type_a,ambulance_type_b,ambulance_type_c,residential_long_term_care_facilities,primary_health_care_center,other_affiliation,local_branch_name,english_branch_name,subtype,level,postcode,address_loc,address_en,city_loc,city_en,focal_person_loc,focal_person_en,phone,email,link,source_en,source_loc,date_of_data,visibility,longitude,latitude
2+
[email protected],26876088546,Programmes Manager,Ambulance Station,tet,Public Government Facility,Fully Functional,Medical Practices,"Initiate TB treatment, Cervical Cancer Screening and testing and diagnostic and treatment for people living with HIV and follow up care through the ART programme which the government supports very well",Mental Health Hospital,yes,No,2,yes,2,Yes,Yes,Minor Trauma,Anaesthesiology,test,Blood Collection,32,0,0,0,3,0,0,9,Yes,first question of initial question did not provide for the option to write the name of the NS. It is written LRC yet it should allow Baphalali Eswatini Red Cross Society (BERCS) to be inscribed in the box.,Nurses,2,1,1,1,Dental Practices,test,Cruz Vermelha - Órgão Central HQ - Brasília,,Office,National,70300-910,"Setor Comercial Sul (SCS), quadra 6, bloco A, nº 157, salas 502 e 503 - Edifício Bandeirantes, Asa Sul, Brasília-DF ",,Brasília - DF,,Lourenço Braga,,55 (61) 99909-0761,[email protected],http://www.cruzvermelha.org.br/,Brazilian Red Cross,Brazilian Red Cross Local,2024-02-07,Public,-47.88972222,-15.79638889
3+
[email protected],26876088546,Programmes Manager,Ambulance Station,tet,Public Government Facility,Fully Functional,"Medical Practices,Dental Practices","Initiate TB treatment, Cervical Cancer Screening and testing and diagnostic and treatment for people living with HIV and follow up care through the ART programme which the government supports very well",Mental Health Hospital,No ,No,2,yes,2,Yes,Yes,Minor Trauma,Anaesthesiology,test,Blood Collection,32,0,0,0,3,0,0,9,Yes,first question of initial question did not provide for the option to write the name of the NS. It is written LRC yet it should allow Baphalali Eswatini Red Cross Society (BERCS) to be inscribed in the box.,Nurses,1,2,3,1,Dental Practices,test,Filial Alagoas,,Office,National,57035-530,"Av. Com. Gustavo de Paiva, 2889 - Mangabeiras, Maceió - AL",,Alagoas - AL,,Agarina Mendonça,,55 (82) 3325-2430,[email protected],https://www.cruzvermelha.org.br/pb/filiais/alagoas/,Brazilian Red Cross,Brazilian Red Cross Local,2024-02-07,Public,-35.71611111,-9.64777778
4+
[email protected],26876088546,Programmes Manager,Ambulance Station,tet,Public Government Facility,Fully Functional,Medical Practices,"Initiate TB treatment, Cervical Cancer Screening and testing and diagnostic and treatment for people living with HIV and follow up care through the ART programme which the government supports very well",Mental Health Hospital,No ,No,2,no,2,Yes,Yes,Minor Trauma,Anaesthesiology,test,Blood Collection,32,0,0,0,3,0,0,9,Yes,first question of initial question did not provide for the option to write the name of the NS. It is written LRC yet it should allow Baphalali Eswatini Red Cross Society (BERCS) to be inscribed in the box.,Nurses,1,2,2,1,Dental Practices,test,Cruz Vermelha - Órgão Central HQ,,Office,National,20230-130,"Praça Cruz Vermelha N° 10-12, Centro, Rio de Janeiro - RJ",,Rio de Janeiro - RJ,,Thiago Quintaneiro,,55 (21) 2507-3577 / 2507-3392,[email protected],http://www.cruzvermelha.org.br/,Brazilian Red Cross,Brazilian Red Cross Local,2024-02-07,Public,-43.1875,-22.91111111

0 commit comments

Comments
 (0)