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

Validate code belongs to the provided system #97

Open
nir-r opened this issue Jul 17, 2024 · 4 comments
Open

Validate code belongs to the provided system #97

nir-r opened this issue Jul 17, 2024 · 4 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@nir-r
Copy link

nir-r commented Jul 17, 2024

As a user, I want to check if a code belongs to the declared system before writing to output.

I should be able to turn on/off this feature so I can use it for select inputs.
Consider doing so programmatically to validate only codes from specific systems (say local ones) or on particular scenarios.

@mechanik-daniel mechanik-daniel added enhancement New feature or request question Further information is requested labels Dec 1, 2024
@mechanik-daniel
Copy link
Contributor

Please describe the requested feature in more detail.
What is it? A function? If so, please provide the intended signature and describe its behavior

@nir-r
Copy link
Author

nir-r commented Dec 4, 2024

Please describe the requested feature in more detail. What is it? A function? If so, please provide the intended signature and describe its behavior

Signature $validateCode(str1, str2)

Checks if the Code provided in str (string) is part of the ValueSet (canonical/identifier/id) provided in str2 (string) and returns one of the following answers:

  1. Valid - The ValuSet IS accessible to fume (can be expanded) & the code IS found within said system
  2. Invalid - The ValuSet IS accessible to fume & the code IS NOT found within it
  3. System N/A - The ValuSet IS NOT accessible to fume hence validation can't be performed. We should think of a more informative output message.

Consider

  1. Validate multiple codes at once?

I doubt this is a common use case, but consider whether such functionality is valuable performance-wise (it saves multiple repeated function calls) or for usability/readability.
Results can be implemented as an array of said results (preferable) or as a single result (the most "negative") for all inputs.

  1. Validate also against a Codesystem?
    Profile elements are bound to ValueSets, not CodeSystems but when processing an FHIR resource instance as input we are provided with a CodeSystem and may want to validate that, i.e - validate against resource rather than against profile

@mechanik-daniel
Copy link
Contributor

To align with the overall philosophy of Jsonata functions, this function should not return coded values as you suggested, but a boolean or undefined. True if the code is valid, false if it's invalid, undefined if it cannot be validated due to expansion issues. In the last case, a warning message should be printed to console/log saying that the VS could not be expanded due to X.

Some more questions:

  • What about the system of the code? Codes in FHIR should be a combination of a system URI and a code and not just a code, although both options should be supported. If the VS is a list of snomed codes, and in the source there's a valid snomed code but the wrong system URI, you should be able to reject that system-code pair as invalid. Claiming it's valid just by looking at the code would be misleading
  • When validating just a code (without the system), if there's a duplicated code in the VS (from different systems) what is the expected result?

@mechanik-daniel
Copy link
Contributor

Regarding multiple codes - if you want to validate a CodeableConcept, that has an array of codings, the appropriate behavior is that if at least one of the is in the VS than the entire CodeableConcept is valid. That's the meaning of required bindings. So I'm not sure validating all of them and giving back a complex structure that the user needs to analyze is the best option.
Performance-wise - running the function multiple times vs running it once on an array is the same thing, since the operation is done in memory against a cached key-vale object representing the VS expansion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants