ACED-IDP / gen3_util

Collection of command line tools to interact with a Gen3 instance
MIT License
3 stars 1 forks source link

feature/improve-validation-missing-references #66

Closed bwalsh closed 4 months ago

bwalsh commented 8 months ago

Improvement would flag these types of structures as invalid

{
  "resourceType": "Specimen",
  "id": "XXXXXXXXX-8058-57d1-aaf2-c3fcc564125f",
  "identifier": [
    {
      "system": "http://XXXX.YYY/ZZZ/specimen",
      "value": "ABC"
    }
  ]
}

See https://github.com/ACED-IDP/gen3_util/blob/9317dd9001b0a9db1b64b7f9a404370f5e15c721/gen3_util/meta/validator.py#L93

Pseudo-code:


REFERENCE_REQUIRED_EXCEMPTIONS = ['Patient', 'ResearchStudy', 'Substance']  # this is not an exhaustive list
if parse_result.resource.resource_type not in REFERENCE_REQUIRED_EXCEMPTIONS and len(nested_references) == 0:
      parse_result.exception = Exception(
          f"Resource has no references {parse_result.resource.resource_type}/{parse_result.resource.id}"
     )
     exceptions.append(parse_result)  
bwalsh commented 8 months ago

add appropriate unit test(s)

bwalsh commented 4 months ago

addressed here https://github.com/ACED-IDP/gen3_util/blob/44154eb2697c7b8c9ce732996e1abe82971450df/gen3_tracker/meta/validator.py#L96-L111