Skip to content

Work with knowledge packs

Suppose you are mapping a lab test. The source gives the analyte and specimen, and the vocabulary offers several candidates. One candidate also names a test method. How do you decide whether that extra detail is supported? The bundled measurement guidance says to keep the details the source gives and leave an unstated method out of the mapping.

A knowledge pack gives you a convention you can consult while making a decision. Groundworkers ships general OMOP and vocabulary guidance. Your team can add packs for particular instruments or deployments. You or your agent choose the applicable guidance and use it to review the candidate evidence.

Use a pack to review a mapping

  1. Find the relevant guidance. Pass the domain you are working in to knowledge_catalogue. The catalogue gives you each pack’s name, scope, and origin. For a lab test, look for the bundled measurement-concept-granularity pack.
  2. Read the selected pack. Pass its name and layer to knowledge_pack. Check the guidance against the details you have from the source and the candidate concepts.
  3. Explain the decision. In this example, you can record that you kept the analyte and specimen and avoided assuming a method. If the candidates still leave a question open, carry it forward for review.

You can ask an agent to do this in ordinary language.

Help me review this lab-test mapping. Find the relevant measurement guidance, show which details each candidate adds or drops, and explain which choice the source supports.

If you call the tools directly, start with knowledge_catalogue.

{"domains": ["Measurement"]}

Then read the selected pack with knowledge_pack.

{"name": "measurement-concept-granularity", "layer": "core"}

Find the conventions for your source

A source system identifies a platform or format. Many different instruments can use the same platform, and each instrument version can assign its own meaning to the answers. If you know the instrument, pass its exact versioned ID with the rest of the context.

{
  "source_system": "redcap",
  "instrument": "publisher/form@2"
}

A pack with applicability.instrument needs the matching ID in a job query, alongside any other filters you supply. If you have only a source system, domain, or section, the result still includes general guidance that matches that context. Omit the job filters to browse every pack, or read the knowledge://catalogue resource for the full index. Use include_local: false to omit the localisation layer.

Check origin when you want to know whose copy you are reading. It identifies the bundled or configured root and gives the pack’s directory relative to that root. Configured roots are numbered from zero in load order after duplicate directories have been removed. A bundled pack has a null root index. Configure knowledge pack roots

Choose how to record a convention

Use guidance.md for advice a reviewer can read, and keep any existing rules or examples with it. A structured slot gives a consumer data it can look up by name.

The question you need to answer Slot
Does this source code represent a missing answer, and why? null_codes gives mapping agents the source meaning and a terminology reason.
Which concept ID or numeric value does this source code map to? code_maps gives consumers the named lookup table and a digest that identifies its exact entries.
How should the mapped fields be shaped into OMOP rows? shape_presets points a projection runtime to the catalogue files to compile.

Groundworkers loads and serves the files. The mapping agent uses the null-code list when interpreting a field, and the projection runtime checks and applies the shapes and maps selected by its caller.

Author a pack

Declare the files the pack provides in the slots block of manifest.yaml. Each path is relative to the pack directory and must resolve to a file inside it.

slots:
  null_codes: null-codes.yaml
  code_maps:
    score: maps/score.json
  shape_presets:
    - shapes/base.yaml
    - shapes/overrides.yaml
Slot File format knowledge_pack response
null_codes A YAML mapping from list names to arrays of entries. Each entry has a string code, a nonblank meaning, and a reason with a terminology system URI and code. Quote codes to preserve leading zeros or an empty string. Codes are unique within each list. Named lists and their entries.
code_maps One JSON object per map, with unique source-code strings as keys and finite numbers as values. Each map’s entries and sha256. The digest comes from compact JSON with sorted keys and ASCII escaping.
shape_presets An ordered list of YAML catalogue files. Each file contains a top-level shapes list of mappings. The projection runtime validates the shape definitions when it compiles those files. Pack-relative filenames in the order declared.

Once the root is configured, use knowledge_catalogue to check the pack’s origin and declared slots. Read it with knowledge_pack to check the null-code lists, map entries, and preset filenames it serves.

When a pack is unavailable

What you see What to check
NOT_FOUND Check the name and layer against the catalogue. If you expected a configured override, check the server log for a malformed or duplicate definition.
INVALID_INPUT for a name that appears in multiple layers Pass the layer listed for the pack you want.
BACKEND_UNAVAIL with a slot name Check the server log for the declared file that is missing or malformed.

A successful read includes the manifest, guidance, rules, examples, and slots.

Direct Python use

from groundworkers.services.knowledge import KnowledgeCatalogue

catalogue = KnowledgeCatalogue.with_bundled()
selected = catalogue.get_pack("measurement-concept-granularity", layer="core")

Hosted plugins can read the same catalogue as the MCP tools. See how to read a pack from a plugin.