Skip to content

incorrect when compose uses excludes (off-by-one, dev only) #91

@jmandel

Description

@jmandel

Bug

When a ValueSet compose includes codes via is-a filter and excludes specific codes, expansion.total reflects the pre-exclude count rather than the post-exclude count. The contains array is correctly filtered.

Repro

curl -s -X POST 'https://tx-dev.fhir.org/r4/ValueSet/$expand' \
  -H 'Content-Type: application/fhir+json' -H 'Accept: application/fhir+json' \
  -d '{
    "resourceType": "Parameters",
    "parameter": [
      {"name": "count", "valueInteger": 200},
      {"name": "valueSet", "resource": {
        "resourceType": "ValueSet", "status": "active",
        "compose": {
          "include": [{"system": "http://snomed.info/sct",
            "filter": [{"property": "concept", "op": "is-a", "value": "73211009"}]}],
          "exclude": [{"system": "http://snomed.info/sct",
            "concept": [{"code": "73211009"}]}]
        }
      }}
    ]
  }' | jq '{total: .expansion.total, actual: (.expansion.contains | length)}'
# Returns: {"total": 124, "actual": 123}
# Expected: {"total": 123, "actual": 123}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions