Class ProfileRequirementsCompiler

java.lang.Object
org.fhirfrog.frog.profilecompiler.ProfileRequirementsCompiler

public class ProfileRequirementsCompiler extends Object
The compiler's top-level entry point: deriveRequirements(org.hl7.fhir.r4.model.StructureDefinition) implements algorithm.md §2-§4 (must-support extraction, partitioned per §3.0, plus mandatory-element extraction per §4) and compileAssertions(org.hl7.fhir.r4.model.StructureDefinition) implements the per-instance literal-FHIRPath translation (§7, this change's tasks.md 5.11). Binding extraction (§5) and the full reference inventory / delayed- reference test-ordering (§6) are deliberate v1 exclusions - see this change's design.md.

Mandatory-by-path is ambiguous for slices, so it isn't used for them. ProfileRequirements.mandatoryElementPaths() is keyed by ElementDefinition.path, which - unlike id - is identical across a sliced element's base and every one of its slices (e.g. Patient.identifier, Patient.identifier:ihi, and Patient.identifier:medicare all share the path "Patient.identifier"). Looking a slice's mandatory-ness up in that set would therefore either wrongly mark every slice mandatory (if the shared path is mandatory) or wrongly mark none of them (if it isn't), regardless of that specific slice's own cardinality. This compiler instead reads each slice's, choice element's, and plain element's own min directly (see SliceRequirement.mandatory() / ChoiceTypeMustSupportElement.mandatory() / PlainMustSupportElement.mandatory()), and keeps mandatoryElementPaths only as algorithm.md §4's own descriptive bucket.

  • Constructor Details

    • ProfileRequirementsCompiler

      public ProfileRequirementsCompiler(IgProfileSource igProfileSource)
  • Method Details

    • deriveRequirements

      public ProfileRequirements deriveRequirements(org.hl7.fhir.r4.model.StructureDefinition profile)
    • compileAssertions

      public List<GeneratedAssertion> compileAssertions(org.hl7.fhir.r4.model.StructureDefinition profile)
    • toTestScriptAsserts

      public List<org.hl7.fhir.r4.model.TestScript.SetupActionAssertComponent> toTestScriptAsserts(List<GeneratedAssertion> assertions)
      Converts compiled assertions to literal TestScript.SetupActionAssertComponents (design.md's chosen artifact shape: the same "compile to literal, inspectable TestScript" pattern fhir-frog-shorthand/fhir-frog-mbt already use). Deliberately does not assemble a full TestScript (setup/test actions, fixtures, the operations that would fetch an instance to run these asserts against) - wiring compiled asserts into actual operations is a separate, TestPlan/MBT-shaped concern this change doesn't attempt to solve; see design.md.