{
  "resourceType": "StructureDefinition",
  "url": "http://example.org/fhir/StructureDefinition/ConstrainedQuantity",
  "name": "ConstrainedQuantity",
  "status": "draft",
  "fhirVersion": "4.0.0",
  "kind": "complex-type",
  "abstract": false,
  "type": "Quantity",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Quantity",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Quantity",
        "path": "Quantity",
        "short": "A measured or measurable amount",
        "definition": "A measured amount (or an amount that can potentially be measured). Note that measured amounts include amounts that are not precisely quantified, including amounts involving arbitrary units and floating currencies.",
        "comment": "The context of use may frequently define what kind of quantity this is and therefore what kind of units can be used. The context of use may also restrict the values for the comparator.",
        "constraint": [
          {
            "key": "qty-3",
            "severity": "error",
            "human": "If a code for the unit is present, the system SHALL also be present",
            "expression": "code.empty() or system.exists()",
            "xpath": "not(exists(f:code)) or exists(f:system)"
          }
        ],
        "mapping": [
          {
            "identity": "v2",
            "map": "SN (see also Range) or CQ"
          },
          {
            "identity": "rim",
            "map": "PQ, IVL<PQ>, MO, CO, depending on the values"
          }
        ]
      },
      {
        "id": "Quantity.comparator",
        "path": "Quantity.comparator",
        "max": "0"
      },
      {
        "id": "Quantity.code",
        "path": "Quantity.code",
        "min": 1
      }
    ]
  }
}