Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo/pam #55

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 35 additions & 35 deletions flatehr/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(
self,
paths: Dict,
ehr_id: Dict,
set_missing_required_to_default: bool = True,
set_missing_required_to_default: bool = False,
):
self._ehr_id = EhrId(set(ehr_id.get("maps_to", [])), ehr_id["value"])
self._set_missing_required_to_default = set_missing_required_to_default
Expand Down Expand Up @@ -182,39 +182,39 @@ def build_composition(

consumed_paths = []
ehr_id_kvs = {}
for source_key, source_value in source_kvs:

if source_key in conf.ehr_id.maps_to:
ehr_id_kvs[source_key] = source_value

_paths = conf.inverse_mappings[source_key]
for path in _paths:
if "*" in path._id:
continue

if not path.suffixes:
composition.add(path._id)
else:
try:
value_dicts = pending_value_dicts.pop((source_key, path._id))
except KeyError:
value_dicts = [
ValueDict(composition.template, path, path.value_map)
]

for k in path.maps_to:
if k != source_key:
pending_value_dicts[(k, path._id)] += value_dicts

if path._id.startswith("ctx/"):
ctx[path._id] = value_dicts[0]
else:
composition[path._id] = value_dicts[0]

for vd in value_dicts:
if source_value:
vd.add_source_key_value(source_key, source_value)
consumed_paths.append(path)
for source_key, source_values in source_kvs:
for source_value in source_values:
if source_key in conf.ehr_id.maps_to:
ehr_id_kvs[source_key] = source_value

_paths = conf.inverse_mappings[source_key]
for path in _paths:
if "*" in path._id:
continue

if not path.suffixes:
composition.add(path._id)
else:
try:
value_dicts = pending_value_dicts.pop((source_key, path._id))
except KeyError:
value_dicts = [
ValueDict(composition.template, path, path.value_map)
]

for k in path.maps_to:
if k != source_key:
pending_value_dicts[(k, path._id)] += value_dicts

if path._id.startswith("ctx/"):
ctx[path._id] = value_dicts[0]
else:
composition[path._id] = value_dicts[0]

for vd in value_dicts:
if source_value:
vd.add_source_key_value(source_key, source_value)
consumed_paths.append(path)

for path in set([p for p in conf.paths if not p._id.startswith("ctx")]) - set(
consumed_paths
Expand Down Expand Up @@ -245,7 +245,7 @@ def _get_conf(conf_file: str) -> Config:
paths=conf_kwargs["paths"],
ehr_id=conf_kwargs["ehr_id"],
set_missing_required_to_default=conf_kwargs.get(
"set_missing_required_to_default", True
"set_missing_required_to_default", False
),
)

Expand Down
2 changes: 1 addition & 1 deletion flatehr/cli/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def conf_from_file(conf_file: str) -> Config:
paths=conf_kwargs["paths"],
ehr_id=conf_kwargs["ehr_id"],
set_missing_required_to_default=conf_kwargs.get(
"set_missing_required_to_default", True
"set_missing_required_to_default", False
),
)

Expand Down
3 changes: 2 additions & 1 deletion flatehr/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,5 +286,6 @@ def flat(
value_dicts.update(ctx or {})
for _id, suffixes in value_dicts.items():
for suffix, value in suffixes.items():
dct[_id + suffix] = value
if value:
dct[_id + suffix] = value
return dct
Loading