{
  "resourceType": "StructureDefinition",
  "id": "ContractPtPatient",
  "meta": {
    "versionId": "1",
    "lastUpdated": "2019-05-28T15:46:51.547+00:00"
  },
  "url": "http://spms.min-saude.pt/fhir/StructureDefinition/ContractPtPatient",
  "name": "ContractPtPatient",
  "status": "draft",
  "fhirVersion": "3.0.1",
  "kind": "resource",
  "abstract": false,
  "type": "Contract",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Contract",
  "derivation": "constraint",
  "snapshot": {},
  "differential": {
    "element": [
      {
        "id": "Contract",
        "path": "Contract",
        "constraint": [
          {
            "key": "subtype-1",
            "requirements": "SubType must be mandatory",
            "severity": "error",
            "human": "SubType must be mandatory",
            "expression": "type.coding.code='BU' implies subtype.exists()",
            "xpath": "(f:type/f:coding/f:code='BU') or exists(subtype)"
          },
          {
            "key": "subtype-2",
            "requirements": "Code must be 'RECM' or 'IsencaoTaxa' or 'Outros'",
            "severity": "error",
            "human": "Code must be 'RECM' or 'IsencaoTaxa' or 'Outros'",
            "expression": "(subtype.coding.code='RECM') or (subtype.coding.code='IsencaoTaxa')  or (subtype.coding.code='Outros')"
          },
          {
            "key": "subtype-3",
            "requirements": "Display must be 'Regime especial de comparticipação de medicamentos' or 'Isenção de pagamento de taxa moderadora' or 'Outro tipo de medicação especial'",
            "severity": "error",
            "human": "Display must be 'Regime especial de comparticipação de medicamentos' or 'Isenção de pagamento de taxa moderadora' or 'Outro tipo de medicação especial'",
            "expression": "(subtype.coding.code='Regime especial de comparticipação de medicamentos') or (subtype.coding.code='Isenção de pagamento de taxa moderadora') or (subtype.coding.code='Outro tipo de medicação especial')",
            "xpath": "(f:subtype/f:coding/f:code='Regime especial de comparticipação de medicamentos') or (f:subtype/f:coding/f:code='Isenção de pagamento de taxa moderadora') or (f:subtype/f:coding/f:code='Outro tipo de medicação especial')"
          }
        ]
      },
      {
        "id": "Contract.extension",
        "path": "Contract.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Contract.extension:country-entity",
        "path": "Contract.extension",
        "sliceName": "country-entity",
        "type": [
          {
            "code": "Extension",
            "profile": "http://spms.min-saude.pt/rnu/systemcodes/country-entity/v0100"
          }
        ]
      },
      {
        "id": "Contract.identifier",
        "path": "Contract.identifier",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "type.coding.code"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Contract.identifier:sliceIdentifierNBU",
        "path": "Contract.identifier",
        "sliceName": "sliceIdentifierNBU"
      },
      {
        "id": "Contract.identifier:sliceIdentifierNBU.type.coding.system",
        "path": "Contract.identifier.type.coding.system",
        "fixedUri": "http://spms.min-saude.pt/rnu/systemcodes/identifier-types/v0100"
      },
      {
        "id": "Contract.identifier:sliceIdentifierNBU.type.coding.code",
        "path": "Contract.identifier.type.coding.code",
        "fixedCode": "NBU"
      },
      {
        "id": "Contract.identifier:sliceIdentifierNBU.type.coding.display",
        "extension": [
          {
            "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-translatable",
            "valueBoolean": true
          }
        ],
        "path": "Contract.identifier.type.coding.display",
        "fixedString": "Número de Beneficiário"
      },
      {
        "id": "Contract.identifier:sliceIdentifierNBU.type.text",
        "extension": [
          {
            "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-translatable",
            "valueBoolean": true
          }
        ],
        "path": "Contract.identifier.type.text",
        "fixedString": "Número de Beneficiário do Utente na Entidade"
      },
      {
        "id": "Contract.identifier:sliceIdentifierUUID",
        "path": "Contract.identifier",
        "sliceName": "sliceIdentifierUUID"
      },
      {
        "id": "Contract.identifier:sliceIdentifierUUID.type.coding.system",
        "path": "Contract.identifier.type.coding.system",
        "fixedUri": "http://spms.min-saude.pt/rnu/systemcodes/identifier-types/v0100"
      },
      {
        "id": "Contract.identifier:sliceIdentifierUUID.type.coding.code",
        "path": "Contract.identifier.type.coding.code",
        "fixedCode": "UUID"
      },
      {
        "id": "Contract.identifier:sliceIdentifierUUID.type.coding.display",
        "extension": [
          {
            "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-translatable",
            "valueBoolean": true
          }
        ],
        "path": "Contract.identifier.type.coding.display",
        "fixedString": "Número Sequencial / UUID do Utente na Entidade"
      },
      {
        "id": "Contract.identifier:sliceIdentifierUUID.system",
        "path": "Contract.identifier.system",
        "fixedUri": "http://spms.min-saude.pt/rnu/identifiers/uuid"
      },
      {
        "id": "Contract.identifier:sliceIdentifierNPROCESSO",
        "path": "Contract.identifier",
        "sliceName": "sliceIdentifierNPROCESSO"
      },
      {
        "id": "Contract.identifier:sliceIdentifierNPROCESSO.type.coding.system",
        "path": "Contract.identifier.type.coding.system",
        "fixedUri": "http://spms.min-saude.pt/rnu/systemcodes/identifier-types/v0100"
      },
      {
        "id": "Contract.identifier:sliceIdentifierNPROCESSO.type.coding.code",
        "path": "Contract.identifier.type.coding.code",
        "fixedCode": "NPROCESSO"
      },
      {
        "id": "Contract.identifier:sliceIdentifierNPROCESSO.type.coding.display",
        "extension": [
          {
            "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-translatable",
            "valueBoolean": true
          }
        ],
        "path": "Contract.identifier.type.coding.display",
        "fixedString": "Número do Processo"
      },
      {
        "id": "Contract.identifier:sliceIdentifierNPROCESSO.type.text",
        "extension": [
          {
            "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-translatable",
            "valueBoolean": true
          }
        ],
        "path": "Contract.identifier.type.text",
        "fixedString": "Número do Porcesso do Utente na Entidade"
      },
      {
        "id": "Contract.identifier:sliceIdentifierNPROCESSO.system",
        "path": "Contract.identifier.system",
        "fixedUri": "http://spms.min-saude.pt/rnu/identifiers/nprocesso"
      },
      {
        "id": "Contract.subject",
        "path": "Contract.subject",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": "http://spms.min-saude.pt/fhir/StructureDefinition/PatientPORTUGAL",
            "aggregation": [
              "referenced",
              "bundled"
            ]
          }
        ]
      },
      {
        "id": "Contract.authority",
        "path": "Contract.authority",
        "type": [
          {
            "code": "Reference",
            "targetProfile": "http://spms.min-saude.pt/fhir/StructureDefinition/OrganizationPatient",
            "aggregation": [
              "referenced",
              "bundled"
            ]
          }
        ]
      },
      {
        "id": "Contract.type.coding",
        "path": "Contract.type.coding",
        "constraint": [
          {
            "key": "code-1",
            "requirements": "Code must be 'ERU' or 'BU'",
            "severity": "error",
            "human": "(f:code='ERU') or (f:code='BU')",
            "expression": "(code='ERU') or (code='BU')"
          },
          {
            "key": "display-1",
            "requirements": "Display must be 'Entidade Responsável' or 'Benefício do Utente'",
            "severity": "error",
            "human": "(f:display='Benefício do Utente') or (f:display='Entidade Responsável')",
            "expression": "(display='Benefício do Utente') or (display='Entidade Responsável')"
          }
        ]
      },
      {
        "id": "Contract.type.coding.code",
        "path": "Contract.type.coding.code",
        "condition": [
          "code-1"
        ]
      },
      {
        "id": "Contract.type.coding.display",
        "extension": [
          {
            "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-translatable",
            "valueBoolean": true
          }
        ],
        "path": "Contract.type.coding.display",
        "condition": [
          "display-1"
        ]
      },
      {
        "id": "Contract.subType",
        "path": "Contract.subType",
        "condition": [
          "subtype-1"
        ]
      },
      {
        "id": "Contract.subType.coding.code",
        "path": "Contract.subType.coding.code",
        "condition": [
          "subtype-2"
        ]
      },
      {
        "id": "Contract.subType.coding.display",
        "extension": [
          {
            "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-translatable",
            "valueBoolean": true
          }
        ],
        "path": "Contract.subType.coding.display",
        "condition": [
          "subtype-3"
        ]
      },
      {
        "id": "Contract.actionReason.coding.system",
        "path": "Contract.actionReason.coding.system",
        "fixedUri": "http://spms.min-saude.pt/rnu/systemcodes/contract-action-reason"
      },
      {
        "id": "Contract.term.identifier.type.coding.system",
        "path": "Contract.term.identifier.type.coding.system",
        "fixedUri": "http://spms.min-saude.pt/rnu/systemcodes/identifier-types/v0100"
      },
      {
        "id": "Contract.term.identifier.type.coding.code",
        "path": "Contract.term.identifier.type.coding.code",
        "fixedCode": "NCBE"
      },
      {
        "id": "Contract.term.identifier.type.coding.display",
        "extension": [
          {
            "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-translatable",
            "valueBoolean": true
          }
        ],
        "path": "Contract.term.identifier.type.coding.display",
        "fixedString": "Número do cartão do benificiário na entidade"
      },
      {
        "id": "Contract.term.identifier.type.text",
        "extension": [
          {
            "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-translatable",
            "valueBoolean": true
          }
        ],
        "path": "Contract.term.identifier.type.text",
        "fixedString": "Número do cartão do benificiário na entidade"
      }
    ]
  }
}