Skip to content

Commit

Permalink
WSG-100 add cardinality
Browse files Browse the repository at this point in the history
  • Loading branch information
xkmato committed Aug 7, 2024
1 parent e41c6d9 commit c75ab27
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion who_l3_smart_tools/core/data_dictionary/l2.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ def __init__(
self.required = raw_row["Required"]
self.coding_data_element = coding_data_element

@property
def map_cardinality(self):
minimum = "0"
maximum = "1"

if self.required == "R":
minimum = "1"

if self.choice_type == "Select all that apply":
maximum = "*"

return f"{minimum}..{maximum}"

def validate_coding_data_element(self) -> bool:
if self.data_type == "Codes" and not self.coding_data_element:
raise ValueError(
Expand Down Expand Up @@ -109,7 +122,7 @@ def to_model_item(self) -> dict[str, str]:
return {
"id": self.data_element_id,
"slug": to_camel_case(self.data_element_label),
"condition": "1..1",
"condition": self.map_cardinality,
"type": DATA_TYPE_MAP[self.data_type],
"label": self.data_element_label,
"description": self.description,
Expand Down

0 comments on commit c75ab27

Please sign in to comment.