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

mechanism to pre-load (or dynamically load) the terminology code-system data modules. #3

Open
barabo opened this issue Jun 9, 2024 · 0 comments

Comments

@barabo
Copy link
Owner

barabo commented Jun 9, 2024

The module/terminology/code-system directory structure needs a way to be populated.

One idea would be to update the fhir-jq shell function to inspect the jq exit code. It could look for code 32 (code-system unknown) or code 42 (concept_code unknown in a known code-system), and emit a hint for the user suggesting how the missing data should be added.

If a terminology database is available, the missing systems and concept fields could be automatically added. If users were instructed to download terminology from Athena to populate tables in a sqlite database, it would be easy to have the shell function parse the error message for the missing code-system / concept_code, create missing directories, and inject the codes that are failing.

A configuration option could suggest whether the whole set of codes is loaded when a new code-system is added, or whether new codes are added as they are needed.

Example

The current instructions have users define the following in their shell .rc file:

# The fhir-jq installation directory.
export FHIR_JQ="${HOME}/.jq/fhir"
mkdir -p "${FHIR_JQ}"

##
# fhir-jq is used just like jq, but it injects the path to the fhir-jq
# module when invoked.  All other `jq` args are passed along to jq.
#
function fhir-jq() {
  jq -L "${FHIR_JQ}" "${@}"
}

The shell function could be updated to look more like this:

##
# fhir-jq is used just like jq, but it injects the path to the fhir-jq
# module when invoked.  All other `jq` args are passed along to jq.
#
function fhir-jq() {
  jq -L "${FHIR_JQ}" "${@}"
  local jq_exit_code=${?}

  # Hint when a code is missing from a known code-system.
  if (( jq_exit_code == 42 )); then
    local fixer="${FHIR_JQ}/terminology/bin/add-concept-code.sh"
    cat <<EOM
To add the missing concept_code in the error above, run: ${fixer}
EOM

  # Hint when a code-system is missing.
  elif (( jq_exit_code == 32 )); then
    local fixer="${FHIR_JQ}/terminology/bin/add-code-system.sh"
    cat <<EOM
To add the missing code-system in the error above, run: ${fixer}
EOM

  # Hint when a generic error is detected.
  elif (( jq_exit_code != 0 )); then
    # etc...

  else
    # Default.
  fi

  # Return the original exit code.
  return ${jq_exit_code}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant