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

ElementDefinition.id typing is incorrect #101

Closed
Healthedata1 opened this issue May 9, 2022 · 0 comments
Closed

ElementDefinition.id typing is incorrect #101

Healthedata1 opened this issue May 9, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@Healthedata1
Copy link

  • fhir.resources version: current
  • Python version: 3.7
  • Operating System: Mac OS Monterey ver 12.12.1

Description

The StructureDefinition model generates validation errors for the element.id elements due to the regex defined in the model. The regex is based on the FHIR id datatype. However, the element.id element is a string datatype and should not use the id datatype regex.

See the element definition here http://hl7.org/fhir/element.html#Element, and Element.id definition here : http://hl7.org/fhir/elementdefinition.html#id

What I Did

from fhir.resources.structuredefinition import StructureDefinition
for i in us_core_files:
    #print(i.name)
    constraints = {}
    #sd_dict = loads(i.read_text())
    sd = StructureDefinition.parse_file(i)
    


---------------------------------------------------------------------------
ValidationError                           Traceback (most recent call last)
Input In [30], in <cell line: 2>()
      4 constraints = {}
      5 #sd_dict = loads(i.read_text())
----> 6 sd = StructureDefinition.parse_file(i)
      7 #print(sd_dict['type'])
      9 if sd.type =="Observation":

File ~/.pyenv/versions/3.10.2/envs/jupyter/lib/python3.10/site-packages/fhir/resources/fhirabstractmodel.py:243, in FHIRAbstractModel.parse_file(cls, path, content_type, encoding, proto, allow_pickle, **extra)
    233 extra.update({"cls": cls})
    234 obj = load_file(
    235     path,
    236     proto=proto,
   (...)
    241     **extra,
    242 )
--> 243 return cls.parse_obj(obj)

File ~/.pyenv/versions/3.10.2/envs/jupyter/lib/python3.10/site-packages/pydantic/main.py:511, in pydantic.main.BaseModel.parse_obj()

File ~/.pyenv/versions/3.10.2/envs/jupyter/lib/python3.10/site-packages/fhir/resources/fhirabstractmodel.py:105, in FHIRAbstractModel.__init__(__pydantic_self__, **data)
    102 if errors:
    103     raise ValidationError(errors, __pydantic_self__.__class__)
--> 105 BaseModel.__init__(__pydantic_self__, **data)

File ~/.pyenv/versions/3.10.2/envs/jupyter/lib/python3.10/site-packages/pydantic/main.py:331, in pydantic.main.BaseModel.__init__()

ValidationError: 23 validation errors for StructureDefinition
snapshot -> element -> 14 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
snapshot -> element -> 15 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
snapshot -> element -> 16 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
snapshot -> element -> 17 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
snapshot -> element -> 18 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
snapshot -> element -> 19 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
snapshot -> element -> 20 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
snapshot -> element -> 21 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
snapshot -> element -> 22 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
snapshot -> element -> 23 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
snapshot -> element -> 24 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
snapshot -> element -> 25 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
snapshot -> element -> 30 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
snapshot -> element -> 33 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
snapshot -> element -> 34 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
snapshot -> element -> 35 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
snapshot -> element -> 36 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
snapshot -> element -> 37 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
snapshot -> element -> 38 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
snapshot -> element -> 39 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
snapshot -> element -> 40 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
snapshot -> element -> 41 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
snapshot -> element -> 66 -> id
  string does not match regex "^[A-Za-z0-9\-.]+$" (type=value_error.str.regex; pattern=^[A-Za-z0-9\-.]+$)
@Healthedata1 Healthedata1 changed the title ElementDefintion.id typing is incorrect ElementDefinition.id typing is incorrect May 9, 2022
@nazrulworld nazrulworld added the bug Something isn't working label May 10, 2022
nazrulworld added a commit that referenced this issue May 11, 2022
* Remove extension for Element.id & Resource.id.
* changes log updated.
nazrulworld added a commit that referenced this issue May 11, 2022
kupsum added a commit to kupsum/fhir.resources that referenced this issue Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants