FHIR / sushi

SUSHI (aka "SUSHI Unshortens Short Hand Inputs") is a reference implementation command-line interpreter/compiler for FHIR Shorthand (FSH).
Apache License 2.0
147 stars 43 forks source link

Problems applying RuleSets to ValueSets #1431

Closed cmoesel closed 7 months ago

cmoesel commented 8 months ago

As reported by Saul Kravitz:

Rulesets and ValueSets -- don't play together well

Ref: https://fshschool.org/FSHOnline/#/share/3Va87NV

These two valuesets are not equivalent:

Alias: $statesCS = https://www.usps.com/

RuleSet:USTerritories
* $statesCS#AS  "American Samoa"
* $statesCS#GU  "Guam"
* $statesCS#MP  "Northern Mariana Islands"
* $statesCS#PR  "Puerto Rico"
* $statesCS#VI  "Virgin Islands"

ValueSet: ValueSetUSTerritoriesVitalRecords
Id: ValueSet-usterritories-vr
Title: "US Territories Vital Records"
Description: "This valueset contains the set of 2 Letter codes used to represent US Territories"
* ^status = #active
* ^version = "1.0.0"
* ^experimental = false
// * insert USTerritories 

// RuleSet: USTerritories 
* $statesCS#AS  "American Samoa"
* $statesCS#GU  "Guam"
* $statesCS#MP  "Northern Mariana Islands"
* $statesCS#PR  "Puerto Rico"
* $statesCS#VI  "Virgin Islands"

ValueSet: ValueSetUSTerritoriesVitalRecordsV2
Id: ValueSet-usterritories-vr-2
Title: "US Territories Vital Records"
Description: "This valueset contains the set of 2 Letter codes used to represent US Territories"
* ^status = #active
* ^version = "1.0.0"
* ^experimental = false
* insert USTerritories

The first (without the rule set) results in the following correct compose:

  "compose": {
    "include": [
      {
        "system": "https://www.usps.com",
        "concept": [
          {
            "code": "AS",
            "display": "American Samoa"
          },
          {
            "code": "GU",
            "display": "Guam"
          },
          {
            "code": "MP",
            "display": "Northern Mariana Islands"
          },
          {
            "code": "PR",
            "display": "Puerto Rico"
          },
          {
            "code": "VI",
            "display": "Virgin Islands"
          }
        ]
      }
    ]
  }

The second (with the rule set) results in the following incorrect compose:

  "compose": {
    "include": [
      {
        "concept": [
          {
            "code": "AS",
            "display": "American Samoa"
          }
        ]
      },
      {
        "concept": [
          {
            "code": "GU",
            "display": "Guam"
          }
        ]
      },
      {
        "concept": [
          {
            "code": "MP",
            "display": "Northern Mariana Islands"
          }
        ]
      },
      {
        "concept": [
          {
            "code": "PR",
            "display": "Puerto Rico"
          }
        ]
      },
      {
        "concept": [
          {
            "code": "VI",
            "display": "Virgin Islands"
          }
        ]
      }
    ]
  }
jafeltra commented 7 months ago

Fixed by #1432