Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#1709 | OpenMRS Validation schema to accept …
Browse files Browse the repository at this point in the history
…all different forms of index term and short name name types
  • Loading branch information
snyaggarwal committed Dec 9, 2023
1 parent 0dc6a1d commit 422e18d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions core/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,3 +917,7 @@ def format_url_for_search(url):
if url:
return url.replace('/', '_').replace(':', '_')
return url


def clean_term(term):
return term.lower().replace(' ', '').replace('-', '').replace('_', '')
4 changes: 3 additions & 1 deletion core/concepts/custom_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pydash import get

from core.common.constants import LOOKUP_CONCEPT_CLASSES
from core.common.utils import clean_term
from core.concepts.constants import (
OPENMRS_MUST_HAVE_EXACTLY_ONE_PREFERRED_NAME,
OPENMRS_AT_LEAST_ONE_FULLY_SPECIFIED_NAME, OPENMRS_PREFERRED_NAME_UNIQUE_PER_SOURCE_LOCALE,
Expand Down Expand Up @@ -178,7 +179,8 @@ def name_type_should_be_valid_attribute(self, concept):
return

for name in names:
if name.type in [FULLY_SPECIFIED, SHORT, INDEX_TERM] or name.is_fully_specified_after_clean:
name_type = clean_term(name.type or '')
if name_type in [clean_term(FULLY_SPECIFIED), clean_term(SHORT), clean_term(INDEX_TERM)]:
continue

if (name.type or 'None') in self.reference_values['NameTypes']:
Expand Down

0 comments on commit 422e18d

Please sign in to comment.