Skip to content

Commit

Permalink
fix mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
bwalsh committed Feb 12, 2025
1 parent cdf2fe5 commit 1066acc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions fhir_query/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def dataframe(db_path: str, output_path: str, launch_dtale: bool, data_type: str
# TODO - add more data types - including condition
assert data_type in ["Specimen", "Patient"], f"Sorry {data_type} dataframe is not supported yet."

df = None
df: pd.DataFrame | None = None
if data_type == "Specimen":
df = pd.DataFrame(db.flattened_specimens())
if data_type == "Patient":
Expand All @@ -222,11 +222,13 @@ def dataframe(db_path: str, output_path: str, launch_dtale: bool, data_type: str
import dtale

dtale.show(df, subprocess=False, open_browser=True, port=40000)
else:
elif df is not None:
# export to csv
file_name = output_path if output_path else f"{data_type}.csv"
df.to_csv(file_name, index=False)
click.secho(f"Saved {file_name}", file=sys.stderr)
else:
click.secho(f"No data found for {data_type}", file=sys.stderr)

except Exception as e:
logging.error(f"Error: {e}", exc_info=True)
Expand Down
4 changes: 3 additions & 1 deletion fhir_query/dataframer.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,13 @@ def values(self) -> dict:
return {}

# update the key if code information is available

if self.resource.get("code", {}).get("text", None):
source = self.resource["code"]["text"]
else:
source = self.resource["code"]["coding"][0].get("display", self.resource["code"]["coding"][0].get("code"))

if not source:
source = "NA"
source = inflection.underscore(inflection.parameterize(source))
return {source: value}

Expand Down

0 comments on commit 1066acc

Please sign in to comment.