{
  "resourceType": "StructureDefinition",
  "url": "http://interopsante.org/fhir/StructureDefinition/FrMedication2unique",
  "version": "0.1.0",
  "name": "FrMedication2unique",
  "status": "draft",
  "experimental": true,
  "date": "2021-12-09",
  "description": "ressource Medication unique regroupant les 4 profils en 1 (ucd, ucd-part, non-proprietary-name et compound)",
  "fhirVersion": "4.0.1",
  "mapping": [
    {
      "identity": "script10.6",
      "uri": "http://ncpdp.org/SCRIPT10_6",
      "name": "Mapping to NCPDP SCRIPT 10.6"
    },
    {
      "identity": "rim",
      "uri": "http://hl7.org/v3",
      "name": "RIM Mapping"
    },
    {
      "identity": "w5",
      "uri": "http://hl7.org/fhir/fivews",
      "name": "FiveWs Pattern Mapping"
    },
    {
      "identity": "v2",
      "uri": "http://hl7.org/v2",
      "name": "HL7 v2 Mapping"
    }
  ],
  "kind": "resource",
  "abstract": false,
  "type": "Medication",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Medication",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Medication",
        "path": "Medication",
        "constraint": [
          {
            "key": "frmed-med-1",
            "severity": "error",
            "human": "If fr-medication is a simple medication, ingredient SHALL NOT be a Reference",
            "expression": "code.coding.system.exists() implies (ingredient.item as Reference).empty()",
            "source": "http://interopsante.org/fhir/StructureDefinition/FrMedication2unique"
          }
        ]
      },
      {
        "id": "Medication.code",
        "path": "Medication.code",
        "slicing": {
          "discriminator": [
            {
              "type": "pattern",
              "path": "coding.system"
            }
          ],
          "description": "3 slices: 1. for branded medication ; 2. for non-proprietary named medication ; 3.  for compound medication. Induces 2 constrains on ingredient element: 1. for non-compound medication, ingredient element SHALL be a substance ; for compound medication, ingredient element SHALL be a branded or non-proprietary named medication.",
          "rules": "open"
        },
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Medication.code:ucdCode",
        "path": "Medication.code",
        "sliceName": "ucdCode",
        "sliceIsConstraining": false,
        "short": "Codes that identify branded medication",
        "requirements": "Identify a trade named medication",
        "meaningWhenMissing": "this is not a trade named medication",
        "mustSupport": true
      },
      {
        "id": "Medication.code:ucdCode.coding",
        "path": "Medication.code.coding",
        "short": "Codes that identify this branded medication",
        "definition": "Codes that identify this branded medication",
        "min": 1,
        "max": "1",
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "description": "UCD code",
          "valueSet": "http://phast.fr/fhir/ValueSet/Pharmacy/CIOdc/SIPh-CIO_UCD"
        }
      },
      {
        "id": "Medication.code:ucdCode.coding.system",
        "path": "Medication.code.coding.system",
        "short": "UCD codeSystem",
        "definition": "The UCD code system (under the responsibility of the Club Inter Pharmaceutique (CIP)",
        "comment": "In the absence of a uri defined by the Club Interpharceutique or the competent government authorities, the uri defined by PHAST is used.",
        "requirements": "The code system SHALL be the UCD code system",
        "patternUri": "^http:\\/\\/phast\\.fr\\/fhir\\/ValueSet\\/Pharmacy\\/CIOdc\\/SIPh-CIO_UCD$"
      },
      {
        "id": "Medication.code:ucdCode.coding.code",
        "path": "Medication.code.coding.code",
        "binding": {
          "strength": "required",
          "description": "code UCD valide",
          "valueSet": "http://phast.fr/fhir/ValueSet/Pharmacy/CIOdc/SIPh-CIO_UCD"
        }
      },
      {
        "id": "Medication.code:snomedMedicinalProductCode",
        "path": "Medication.code",
        "sliceName": "snomedMedicinalProductCode",
        "sliceIsConstraining": false,
        "short": "Codes that identify this simple medication",
        "definition": "Codes identifying this simple medication, ie. a medication having ingredients only made of substance without reference to any other Medication ressource",
        "meaningWhenMissing": "this is not a simple medication medication",
        "mustSupport": true
      },
      {
        "id": "Medication.code:snomedMedicinalProductCode.coding",
        "path": "Medication.code.coding",
        "min": 1,
        "max": "1",
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "http://interopsante.org/fhir/ValueSet/fr-medicinal-product-only"
        }
      },
      {
        "id": "Medication.code:snomedMedicinalProductCode.coding.system",
        "path": "Medication.code.coding.system",
        "short": "SNOMED CT codeSystem",
        "requirements": "The code system SHALL be the SNOMED CT code system",
        "patternUri": "^http:\\/\\/snomed\\.info\\/sct$"
      },
      {
        "id": "Medication.code:snomedMedicinalProductCode.coding.code",
        "path": "Medication.code.coding.code",
        "binding": {
          "strength": "required",
          "description": "MP sctid valide",
          "valueSet": "http://interopsante.org/fhir/ValueSet/fr-medicinal-product-only"
        }
      },
      {
        "id": "Medication.code:otherMedicationCode",
        "path": "Medication.code",
        "sliceName": "otherMedicationCode",
        "sliceIsConstraining": false,
        "short": "Codes that identify this compound medication",
        "definition": "Codes identifying this compound medication, ie. a medication having ingredients made of only references to other Medication ressources",
        "constraint": [
          {
            "key": "frmed-med-2",
            "severity": "error",
            "human": "If fr-medication is an othter-medication, its code SHALL NOT be UCD",
            "expression": "coding.system != 'http://phast.fr/fhir/ValueSet/Pharmacy/CIOdc/SIPh-CIO_UCD'",
            "source": "http://interopsante.org/fhir/StructureDefinition/FrMedication2unique"
          },
          {
            "key": "frmed-med-3",
            "severity": "error",
            "human": "If fr-medication is a other-medication, its code SHALL NOT be SNOMED CT",
            "expression": "coding.system != 'http://snomed.info/sct'",
            "source": "http://interopsante.org/fhir/StructureDefinition/FrMedication2unique"
          },
          {
            "key": "frmed-med-4",
            "severity": "error",
            "human": "if fr-medication has no code it SHALL have a text",
            "expression": "coding.code.exist() or text.exist()",
            "source": "http://interopsante.org/fhir/StructureDefinition/FrMedication2unique"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Medication.code:otherMedicationCode.coding",
        "path": "Medication.code.coding",
        "short": "Generaly no code for compound medicinal product",
        "definition": "A code identifing the compound medicinal product. Generaly none : no code defined for G5 1L + NaCl 3g + KCl 2g."
      },
      {
        "id": "Medication.code:otherMedicationCode.coding.system",
        "path": "Medication.code.coding.system",
        "patternUri": "^((?!http:\\/\\/phast\\.fr\\/fhir\\/ValueSet\\/Pharmacy\\/CIOdc\\/SIPh-CIO_UCD|http:\\/\\/snomed\\.info\\/sct).)*$"
      },
      {
        "id": "Medication.code:otherMedicationCode.text",
        "path": "Medication.code.text",
        "comment": "If there is no code (usually not available for a compound drug or must be local if available), a name SHALL be provided.",
        "mustSupport": true
      },
      {
        "id": "Medication.ingredient",
        "path": "Medication.ingredient",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Medication.ingredient.item[x]",
        "path": "Medication.ingredient.item[x]",
        "definition": "The actual ingredient - either a substance (simple medication's ingredient) or another medication (compound medciation's ingredient).",
        "type": [
          {
            "code": "CodeableConcept",
            "profile": [
              "http://interopsante.org/fhir/StructureDefinition/FrMPSubstance2Active"
            ]
          },
          {
            "code": "Reference",
            "targetProfile": [
              "http://interopsante.org/fhir/StructureDefinition/FrMedication2unique"
            ]
          }
        ],
        "mustSupport": true
      }
    ]
  }
}