@@ -85,7 +85,9 @@ def add_options(options_json) -> list:
8585 return options
8686
8787
88- def parse_reproschema_items (reproschema_items : OrderedDict , reproschema_content : OrderedDict ):
88+ def parse_reproschema_items (
89+ reproschema_items : OrderedDict , reproschema_content : OrderedDict
90+ ):
8991 """
9092 Helper function to parse reproschema items into fhir items
9193
@@ -142,9 +144,7 @@ def parse_reproschema_items(reproschema_items: OrderedDict, reproschema_content:
142144
143145 curr_item ["type" ] = item_type
144146 preamble = ""
145- if "preamble" in item_json and isinstance (
146- item_json ["preamble" ], dict
147- ):
147+ if "preamble" in item_json and isinstance (item_json ["preamble" ], dict ):
148148 preamble = item_json ["preamble" ]["en" ]
149149 elif "preamble" in item_json and isinstance (
150150 item_json ["preamble" ], str
@@ -154,9 +154,7 @@ def parse_reproschema_items(reproschema_items: OrderedDict, reproschema_content:
154154 if preamble != "" :
155155 preamble = f"{ preamble } : "
156156
157- if "question" in item_json and isinstance (
158- item_json ["question" ], dict
159- ):
157+ if "question" in item_json and isinstance (item_json ["question" ], dict ):
160158 curr_item ["text" ] = preamble + str (item_json ["question" ]["en" ])
161159
162160 elif "prefLabel" in item_json :
@@ -202,14 +200,12 @@ def parse_reproschema_items(reproschema_items: OrderedDict, reproschema_content:
202200 curr_item ["linkId" ] = var_name
203201 if (
204202 "valueType" in item_json ["responseOptions" ]
205- and "int"
206- in item_json ["responseOptions" ]["valueType" ]
203+ and "int" in item_json ["responseOptions" ]["valueType" ]
207204 ):
208205 curr_item ["type" ] = "integer"
209206 elif (
210207 "valueType" in item_json ["responseOptions" ]
211- and "date"
212- in item_json ["responseOptions" ]["valueType" ]
208+ and "date" in item_json ["responseOptions" ]["valueType" ]
213209 ):
214210 curr_item ["type" ] = "date"
215211 elif (
@@ -226,9 +222,7 @@ def parse_reproschema_items(reproschema_items: OrderedDict, reproschema_content:
226222 item_json ["prefLabel" ]
227223 )
228224 else :
229- curr_item ["text" ] = (
230- preamble + curr_item ["linkId" ]
231- )
225+ curr_item ["text" ] = preamble + curr_item ["linkId" ]
232226 else :
233227 curr_item ["text" ] = preamble + str (
234228 item_json ["question" ]["en" ]
@@ -247,8 +241,7 @@ def parse_reproschema_items(reproschema_items: OrderedDict, reproschema_content:
247241 else :
248242 curr_item ["text" ] = preamble
249243 curr_item ["answerOption" ] = [
250- {"valueString" : option .strip ()}
251- for option in options
244+ {"valueString" : option .strip ()} for option in options
252245 ]
253246
254247 if curr_item ["linkId" ] in question_visibility and isinstance (
@@ -263,6 +256,7 @@ def parse_reproschema_items(reproschema_items: OrderedDict, reproschema_content:
263256 items .append (curr_item )
264257 return items
265258
259+
266260def convert_to_fhir (reproschema_content : dict ):
267261 """
268262 Function used to convert reproschema questionnaire into a fhir json
@@ -312,9 +306,7 @@ def convert_to_fhir(reproschema_content: dict):
312306 (key , reproschema_items [key ]) for key in question_order
313307 )
314308
315- items = parse_reproschema_items (
316- reproschema_items , reproschema_content
317- )
309+ items = parse_reproschema_items (reproschema_items , reproschema_content )
318310
319311 fhir_questionnaire ["item" ] = items
320312 return fhir_questionnaire
0 commit comments