8
8
from base .models import Link , LinkTypeChoices
9
9
from datasources .models import SourceSubdivision
10
10
from signals .models import (
11
+ DemographicScope ,
11
12
Geography ,
12
13
Pathogen ,
13
14
Signal ,
@@ -72,9 +73,13 @@ class SignalResource(resources.ModelResource):
72
73
active = Field (attribute = 'active' , column_name = 'Active' )
73
74
short_description = Field (attribute = 'short_description' , column_name = 'Short Description' )
74
75
description = Field (attribute = 'description' , column_name = 'Description' )
75
- format = Field (attribute = 'format ' , column_name = 'Format' )
76
+ format_type = Field (attribute = 'format_type ' , column_name = 'Format' )
76
77
time_type = Field (attribute = 'time_type' , column_name = 'Time Type' )
77
78
time_label = Field (attribute = 'time_label' , column_name = 'Time Label' )
79
+ reporting_cadence = Field (attribute = 'reporting_cadence' , column_name = 'Reporting Cadence' )
80
+ demographic_scope = Field (attribute = 'demographic_scope' , column_name = 'Demographic Scope' )
81
+ severenity_pyramid_rungs = Field (attribute = 'severenity_pyramid_rungs' , column_name = 'Severity Pyramid Rungs' )
82
+
78
83
category = Field (
79
84
attribute = 'category' ,
80
85
column_name = 'Category' ,
@@ -101,6 +106,11 @@ class SignalResource(resources.ModelResource):
101
106
column_name = 'Links' ,
102
107
widget = widgets .ManyToManyWidget (Link , field = 'url' , separator = '|' ),
103
108
)
109
+ data_censoring = Field (attribute = 'data_censoring' , column_name = 'Data Censoring' )
110
+ missingness = Field (attribute = 'missingness' , column_name = 'Missingness' )
111
+ gender_breakdown = Field (attribute = 'gender_breakdown' , column_name = 'Gender Breakdown' )
112
+ race_breakdown = Field (attribute = 'race_breakdown' , column_name = 'Race Breakdown' )
113
+ age_breakdown = Field (attribute = 'age_breakdown' , column_name = 'Age Breakdown' )
104
114
105
115
class Meta :
106
116
model = Signal
@@ -112,9 +122,12 @@ class Meta:
112
122
'active' ,
113
123
'short_description' ,
114
124
'description' ,
115
- 'format ' ,
125
+ 'format_type ' ,
116
126
'time_type' ,
117
127
'time_label' ,
128
+ 'reporting_cadence' ,
129
+ 'demographic_scope' ,
130
+ 'severenity_pyramid_rungs' ,
118
131
'available_geography' ,
119
132
'is_smoothed' ,
120
133
'is_weighted' ,
@@ -123,7 +136,12 @@ class Meta:
123
136
'has_sample_size' ,
124
137
'high_values_are' ,
125
138
'source' ,
126
- 'links'
139
+ 'links' ,
140
+ 'data_censoring' ,
141
+ 'missingness' ,
142
+ 'gender_breakdown' ,
143
+ 'race_breakdown' ,
144
+ 'age_breakdown' ,
127
145
]
128
146
import_id_fields : list [str ] = ['name' , 'source' , 'display_name' ]
129
147
@@ -132,9 +150,19 @@ def before_import_row(self, row, **kwargs) -> None:
132
150
Pre-processes each row before importing.
133
151
"""
134
152
135
- self .fix_boolean_fields (row , ['Active' , 'Is Smoothed' , 'Is Weighted' , 'Is Cumulative' , 'Has StdErr' , 'Has Sample Size' ])
153
+ self .fix_boolean_fields (row , [
154
+ 'Active' ,
155
+ 'Is Smoothed' ,
156
+ 'Is Weighted' ,
157
+ 'Is Cumulative' ,
158
+ 'Has StdErr' ,
159
+ 'Has Sample Size' ,
160
+ 'gender_breakdown' ,
161
+ 'race_breakdown' ,
162
+ ])
136
163
self .process_links (row )
137
164
self .process_pathogen (row )
165
+ self .process_demographic_scope (row )
138
166
139
167
def is_url_in_domain (self , url , domain ) -> Any :
140
168
"""
@@ -193,3 +221,13 @@ def process_pathogen(self, row) -> None:
193
221
pathogens : str = row ['Pathogen/ Disease Area' ].split (',' )
194
222
for pathogen in pathogens :
195
223
Pathogen .objects .get_or_create (name = pathogen .strip ())
224
+
225
+ def process_demographic_scope (self , row ) -> None :
226
+ """
227
+ Processes demographic scope.
228
+ """
229
+
230
+ if row ['Demographic Scope' ]:
231
+ demographic_scopes : str = row ['Demographic Scope' ].split (',' )
232
+ for demographic_scope in demographic_scopes :
233
+ DemographicScope .objects .get_or_create (name = demographic_scope .strip ())
0 commit comments