onaio / fhir-tooling

A command line utility to support FHIR Core content authoring
Other
2 stars 1 forks source link

Validate StructureMaps based on connection to Questionnaires #199

Closed pld closed 3 weeks ago

pld commented 5 months ago

Extend validation tooling and expand CI to:

  1. Parse the Composition to create a map from Questionnaires to the StructureMaps
  2. For each (Questionnaire, StructureMap) pair
    1. Generate a QuestionnnaireResponse for the Questionnaire
    2. Run the StructureMap against the QuestionnaireResponse and output a list of additional [Resources]
      • Fail any StructureMap fails to run
    3. For each Resource in the output list of [Resources]
      1. Validate it is valid FHIR with valid references
        • Fail if any resource is invalid or has invalid references
  3. Pass
pld commented 5 months ago

Somewhat related issue, https://github.com/onaio/fhir-tooling/issues/6

pld commented 5 months ago

Somewhat related issue, https://github.com/opensrp/fhircore/issues/3113

f-odhiambo commented 5 months ago

NB. We need some form of template validation that will help validate gaps in missing references that cause malformed resources e.g.

  1. Encounter.subject = Patient/$patient_id = valid
  2. Encounter.subject = $patient_id is not valid
  3. Encounter.subject = Patient/ is not valid

This should apply to other Resources that reference each other

Maybe having a reference check such as Reference xx/xx should be sufficient

pld commented 5 months ago

Good call, yep we probably need something like a linter for FHIR, or a very rudimentary version of that

dubdabasoduba commented 4 months ago

@Wambere @f-odhiambo I am looking at this validation in 2 stages

Stage 1

Stage 2

cc: @pld

pld commented 4 months ago

Sounds good, for stage 2 we would not want to access a server, we need to have this test work without assuming anything exists that the test writer cannot control.

There's a potential Stage 3 where we write the extracted resources first, or a subset of them, like should create this resources with these keys filled... hmm actually instead of writing the extracted resource a Profile might be want we want , then we validate that the extracted resources matches the target (or the profile). And later we build tooling to generate the structuremap from the Q and the target/profile

@Wambere let's focus on Stage 1 for now, get that into CI, then we can revisit the approach for Stage 2 and how it fits into our priorities.

pld commented 4 months ago

marking as blocked by #15

Wambere commented 2 months ago

Breaking this down to actionable tasks

cc @pld @ndegwamartin

Wambere commented 1 month ago

@pld @dubdabasoduba @f-odhiambo @ndegwamartin

We are trying to map the Questionnaires and StructureMaps in the composition file and we're trying to figure out if it's possible for us to all agree on the same format to naming these resources. For example can we enforce that the title should always match? Or the title and the identifier.value should always match (replacing spaces with - or something like that)

For example:

_compositionconfig.json

[
  {
    "title": "Questionnaires",
    "mode": "working",
    "section": [
      {
        "title": "Add Family Member",
        "focus": {
          "reference": "Questionnaire/ccaedb32-0e23-4a29-8df1-bde75bf4a183",
          "identifier": {
            "value": "add-family-member"
          }
        },
        "mode": "working"
      }
    ]
  },
  {
    "title": "StructureMaps",
    "mode": "working",
    "section": [
      {
        "title": "Add Family Member",
        "focus": {
          "reference": "StructureMap/eb7e8cbb-4cef-4d62-9e4d-7d4243b68c80",
          "identifier": {
            "value": "add-family-member"
          }
        },
        "mode": "working"
      }
    ]
  }
]

So far it looks like every project has it's own style

dubdabasoduba commented 1 month ago

@Wambere @sharon2719 I am okay with the suggested naming approach. Can we add it to the validation? So validation fails if the naming is not adhered to.

Wambere commented 1 month ago

After a small discussion with @ndegwamartin we found out that this is already happening here for the validate command. This basically checks the structureMap that is referenced inside the questionnaire (so not using the composition) So @sharon2719 is looking into how we can basically use the same functionality to build the Questionnaire/StructureMap map