Skip to content

Commit d611b50

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 9986fb9 commit d611b50

File tree

3 files changed

+13
-23
lines changed

3 files changed

+13
-23
lines changed

reproschema/cli.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,7 @@ def reproschema_to_fhir(reproschema_questionnaire, output):
279279
"Unable to work with reproschema versions other than 0.0.1, 1.0.0-rc1, and 1.0.0-rc4"
280280
)
281281

282-
283-
fhir_questionnaire = convert_to_fhir(
284-
reproschema_content
285-
)
282+
fhir_questionnaire = convert_to_fhir(reproschema_content)
286283

287284
# validate the json using fhir resources
288285
try:

reproschema/reproschema2fhir.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
266260
def 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

reproschema/reproschemaui2redcap.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
from datetime import datetime
3+
34
import pandas as pd
45
import requests
56

0 commit comments

Comments
 (0)