{
  "resourceType": "StructureDefinition",
  "id": "nfdi4health-pr-mds-composition",
  "url": "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-pr-mds-composition",
  "version": "0.9",
  "name": "NFDI4Health_PR_MDS_Composition",
  "title": "NFDI4Health PR MDS Composition",
  "status": "draft",
  "publisher": "NFDI4Health",
  "contact": [
    {
      "telecom": [
        {
          "system": "url",
          "value": "https://www.nfdi4health.de"
        }
      ]
    }
  ],
  "description": "Profile intended to capture information on the core information of resources.",
  "fhirVersion": "4.0.1",
  "mapping": [
    {
      "identity": "workflow",
      "uri": "http://hl7.org/fhir/workflow",
      "name": "Workflow Pattern"
    },
    {
      "identity": "rim",
      "uri": "http://hl7.org/v3",
      "name": "RIM Mapping"
    },
    {
      "identity": "cda",
      "uri": "http://hl7.org/v3/cda",
      "name": "CDA (R2)"
    },
    {
      "identity": "fhirdocumentreference",
      "uri": "http://hl7.org/fhir/documentreference",
      "name": "FHIR DocumentReference"
    },
    {
      "identity": "w5",
      "uri": "http://hl7.org/fhir/fivews",
      "name": "FiveWs Pattern Mapping"
    },
    {
      "identity": "NFDI4Health",
      "name": "NFDI4Health to FHIR Mapping"
    }
  ],
  "kind": "resource",
  "abstract": false,
  "type": "Composition",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Composition",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Composition",
        "path": "Composition",
        "constraint": [
          {
            "key": "core-2a",
            "severity": "error",
            "human": "When author.extension[nameType] = '125676002' then author only Reference (NFDI4Health_PR_MDS_Practitioner_Role)",
            "expression": "author.where(extension('https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-ex-mds-name-type').value as Coding).where(code = '125676002').exists() implies $this.reference.contains('PractitionerRole')",
            "source": "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-pr-mds-composition"
          },
          {
            "key": "core-2b",
            "severity": "error",
            "human": "When author.extension[nameType] = '385437003' then author only Reference (NFDI4Health_PR_MDS_Organization)",
            "expression": "author.where(extension('https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-ex-mds-name-type').value as Coding).where(code = '385437003').exists() implies $this.reference.contains('Organization')",
            "source": "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-pr-mds-composition"
          },
          {
            "key": "core-1a",
            "severity": "error",
            "human": "When Composition.type = 'C63536' OR 'C198230' OR 'C47824' OR 'C61393' OR '178' then Composition.category must be empty.",
            "expression": "type.coding.where(code = 'C63536' or code = 'C198230' or code = 'C47824' or code = 'C61393' or code = '178').exists() implies category.exists().not()",
            "source": "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-pr-mds-composition"
          },
          {
            "key": "core-1b",
            "severity": "error",
            "human": "When Composition.type != 'C63536' OR 'C198230' OR 'C47824' OR 'C61393' OR '178' then Composition.category must exist.",
            "expression": "type.coding.where(code = 'C93381' or code = 'C16468' or code = 'C15518' or code = 'C115779' or code = 'C115761' or code = 'C115756' or code = 'C40988' or code = 'C17048' or code = 'C17649' or code = 'C48800' or code = '021' or code = '020' or code = '019' or code = '018' or code = '017' or code = '016' or code = '011' or code = '009').exists() implies category.exists()",
            "source": "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-pr-mds-composition"
          },
          {
            "key": "core-3a",
            "severity": "error",
            "human": "When Composition.type = 'C63536' or 'C198230' or '178' then subject only Reference (NFDI4Health_PR_MDS_Study)",
            "expression": "type.coding.where(code = 'C63536' or code = 'C198230' or code = '178').exists() implies subject.reference.contains('ResearchStudy')",
            "source": "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-pr-mds-composition"
          },
          {
            "key": "core-3b",
            "severity": "error",
            "human": "When Composition.type = 009, C16468 , C15518, C115779, C115761, C115756, 011, 016, '017', '018', '021' then subject only Reference (NFDI4Health_PR_MDS_Document)",
            "expression": "type.coding.where(code = '009' or code = 'C16468' or code = 'C15518' or code = 'C115779' or code = 'C115761' or code = 'C115756' or code = '011' or code = '016' or code = '017' or code = '018' or code = '021').exists() implies subject.reference.contains('Document')",
            "source": "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-pr-mds-composition"
          },
          {
            "key": "core-3c",
            "severity": "error",
            "human": "When Composition.type = 'C17048' or 'C40988' then subject only Reference (Profile: NFDI4Health_PR_MDS_Questionnaire)",
            "expression": "type.coding.where(code = 'C17048' or code = 'C40988').exists() implies subject.reference.contains('Questionnaire')",
            "source": "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-pr-mds-composition"
          },
          {
            "key": "core-4a",
            "severity": "error",
            "human": "1..*, if Resource.chronicDiseases == 'True' AND Resource.classification.type == ('C93381' OR 'C16468' OR 'C15518' OR 'C115779' OR 'C115761' OR 'C115756' OR 'C40988' OR  '016' OR '017' OR '018' OR '019' OR '021' OR 'C17649'); otherwise 0.. 0",
            "expression": "extension.where(url ='https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-ex-mds-chronic-diseases').where(value = true).exists() implies section.code.coding.where(code = 'C165593').exists()",
            "source": "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-pr-mds-composition"
          },
          {
            "key": "core-4b",
            "severity": "error",
            "human": "1..*, if Resource.chronicDiseases == 'True' AND Resource.classification.type == ('C93381' OR 'C16468' OR 'C15518' OR 'C115779' OR 'C115761' OR 'C115756' OR 'C40988' OR  '016' OR '017' OR '018' OR '019' OR '021' OR 'C17649'); otherwise 0.. 0",
            "expression": "type.coding.where(code = 'C93381' or code = 'C16468' or code = 'C15518' or code = 'C115779' or code = 'C115761' or code = 'C115756' or code = 'C40988' or code =  '016' or code = '017' or code = '018' or code = '019' or code = '021' or code = 'C17649').exists()  implies section.code.coding.where(code = 'C165593').exists()",
            "source": "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-pr-mds-composition"
          },
          {
            "key": "core-5",
            "severity": "error",
            "human": "1..*, if Resource.nutritionalData == 'True'; otherwise 0.. 0",
            "expression": "extension.where(url ='https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-ex-mds-nutritional-data').where(value = true).exists() implies section.code.coding.where(code = 'C16927').exists()",
            "source": "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-pr-mds-composition"
          }
        ]
      },
      {
        "id": "Composition.extension",
        "path": "Composition.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "ordered": false,
          "rules": "open"
        },
        "min": 1
      },
      {
        "id": "Composition.extension:provenanceDataSource",
        "path": "Composition.extension",
        "sliceName": "provenanceDataSource",
        "min": 1,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-ex-mds-provenance-data-source"
            ]
          }
        ],
        "mapping": [
          {
            "identity": "NFDI4Health",
            "map": "Resource.provenance.dataSource"
          }
        ]
      },
      {
        "id": "Composition.extension:chronicDiseases",
        "path": "Composition.extension",
        "sliceName": "chronicDiseases",
        "min": 0,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-ex-mds-chronic-diseases"
            ]
          }
        ],
        "mapping": [
          {
            "identity": "NFDI4Health",
            "map": "Resource.chronicDiseases"
          }
        ]
      },
      {
        "id": "Composition.extension:executionLanguage",
        "path": "Composition.extension",
        "sliceName": "executionLanguage",
        "min": 0,
        "max": "*",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-ex-mds-execution-language"
            ]
          }
        ],
        "mapping": [
          {
            "identity": "NFDI4Health",
            "map": "Resource.languages"
          }
        ]
      },
      {
        "id": "Composition.extension:nutritionalData",
        "path": "Composition.extension",
        "sliceName": "nutritionalData",
        "min": 0,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-ex-mds-nutritional-data"
            ]
          }
        ],
        "mapping": [
          {
            "identity": "NFDI4Health",
            "map": "Resource.nutritionalData"
          }
        ]
      },
      {
        "id": "Composition.identifier",
        "path": "Composition.identifier",
        "short": "Identifier",
        "definition": "Unique identifier of the resource used for identification within the NFDI4Health.",
        "comment": "Additional information: The identifier is assigned automatically."
      },
      {
        "id": "Composition.identifier.value",
        "path": "Composition.identifier.value",
        "min": 1,
        "mapping": [
          {
            "identity": "NFDI4Health",
            "map": "Resource.identifier"
          }
        ]
      },
      {
        "id": "Composition.status",
        "path": "Composition.status",
        "fixedCode": "final"
      },
      {
        "id": "Composition.type",
        "path": "Composition.type",
        "short": "type of the resource",
        "definition": "A term describing the resource.",
        "binding": {
          "strength": "required",
          "valueSet": "https://www.nfdi4health.de/fhir/metadataschema/ValueSet/nfdi4health-vs-mds-resource-type-nci-local"
        },
        "mapping": [
          {
            "identity": "NFDI4Health",
            "map": "Resource.classification.type"
          }
        ]
      },
      {
        "id": "Composition.category",
        "path": "Composition.category",
        "short": "In what form is the [RESOURCE] available?",
        "definition": "Specific information about the form in which the [RESOURCE] is available.",
        "comment": "Cardinality: 1..1, if Resource.classification.type != ('Study' OR 'Substudy' OR 'Dataset' OR 'Registry' OR 'Secondary data source'); otherwise 0..0",
        "max": "1",
        "binding": {
          "strength": "required",
          "valueSet": "https://www.nfdi4health.de/fhir/metadataschema/ValueSet/nfdi4health-vs-mds-resource-type-general-nci-msh-local"
        },
        "mapping": [
          {
            "identity": "NFDI4Health",
            "map": "Resource.classification.typeGeneral"
          }
        ]
      },
      {
        "id": "Composition.subject",
        "path": "Composition.subject",
        "comment": "1..1, if Resource.classification.type == ('Study' OR 'Substudy' OR 'Registry' OR 'Secondary data source'); otherwise 0..0",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-pr-mds-document",
              "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-pr-mds-questionnaire",
              "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-pr-mds-study",
              "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-pr-mds-registry"
            ]
          }
        ]
      },
      {
        "id": "Composition.author",
        "path": "Composition.author",
        "short": "Individual or organisation associated with the [RESOURCE]",
        "definition": "Individual or organisation associated with the [RESOURCE] (use practitionerRole to specify their organisation).",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-pr-mds-practitioner-role",
              "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-pr-mds-organization"
            ]
          }
        ],
        "mapping": [
          {
            "identity": "NFDI4Health",
            "map": "Resource.contributors"
          },
          {
            "identity": "NFDI4Health",
            "map": "Resource.contributors"
          }
        ]
      },
      {
        "id": "Composition.author.extension",
        "path": "Composition.author.extension",
        "min": 1
      },
      {
        "id": "Composition.author.extension:nameType",
        "path": "Composition.author.extension",
        "sliceName": "nameType",
        "min": 1,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-ex-mds-name-type"
            ]
          }
        ],
        "mapping": [
          {
            "identity": "NFDI4Health",
            "map": "Resource.contributors.nameType"
          }
        ]
      },
      {
        "id": "Composition.title",
        "path": "Composition.title",
        "short": "Title(s)/name(s) or acronym(s) of the [RESOURCE]",
        "definition": "Group of items providing information about title(s)/name(s) or acronym(s) of the resource.",
        "comment": "Based on ResearchStudy.label (R5), with an extension for language.",
        "mapping": [
          {
            "identity": "NFDI4Health",
            "map": "Resource.titles"
          },
          {
            "identity": "NFDI4Health",
            "map": "Resource.acronyms"
          }
        ]
      },
      {
        "id": "Composition.title.extension",
        "path": "Composition.title.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "ordered": false,
          "rules": "open"
        },
        "min": 1
      },
      {
        "id": "Composition.title.extension:label",
        "path": "Composition.title.extension",
        "sliceName": "label",
        "min": 1,
        "max": "*",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-ex-mds-label"
            ]
          }
        ]
      },
      {
        "id": "Composition.section",
        "path": "Composition.section",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "code"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Composition.section:nutritionalData",
        "path": "Composition.section",
        "sliceName": "nutritionalData",
        "short": "Nutritional data collected?",
        "definition": "Indication whether the [RESOURCE] collects nutritional data.",
        "comment": "1..*, if Resource.nutritionalData == 'Yes'; otherwise 0.. 0",
        "min": 0,
        "max": "*",
        "mapping": [
          {
            "identity": "NFDI4Health",
            "map": "DietAssessment"
          }
        ]
      },
      {
        "id": "Composition.section:nutritionalData.code",
        "path": "Composition.section.code",
        "min": 1,
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "C16927",
              "system": "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl",
              "display": "Nutritional Science"
            }
          ]
        }
      },
      {
        "id": "Composition.section:nutritionalData.entry",
        "path": "Composition.section.entry",
        "min": 1,
        "max": "1",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-pr-mds-observation-nutritional-epidemiology"
            ]
          }
        ]
      },
      {
        "id": "Composition.section:chronicDiseases",
        "path": "Composition.section",
        "sliceName": "chronicDiseases",
        "short": "Chronic diseases included?",
        "definition": "Indication whether the [RESOURCE] addresses chronic diseases.",
        "comment": "Cardinality: 1..*, if Resource.chronicDiseases == 'Yes' AND Resource.classification.type == ('Study protocol' OR 'Informed consent form' OR 'Patient information sheet' OR 'Manual of operations (SOPs)' OR 'Statistical analysis plan' OR 'Data management plan' OR 'Case report form' OR 'Interview scheme and themes' OR 'Observation guide' OR 'Discussion guide' OR 'Participant tasks' OR 'Other study document' OR 'Other'); otherwise 0..0 / Source of the property and/or allowed values: NFDI4Health UC 5.2 requirements",
        "min": 0,
        "max": "*",
        "mapping": [
          {
            "identity": "NFDI4Health",
            "map": "ChronicDiseasesEpidemiology"
          }
        ]
      },
      {
        "id": "Composition.section:chronicDiseases.code",
        "path": "Composition.section.code",
        "min": 1,
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "C165593",
              "system": "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl",
              "display": "Chronic Disease"
            }
          ]
        }
      },
      {
        "id": "Composition.section:chronicDiseases.entry",
        "path": "Composition.section.entry",
        "min": 1,
        "max": "1",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://www.nfdi4health.de/fhir/metadataschema/StructureDefinition/nfdi4health-pr-mds-chronic-diseases"
            ]
          }
        ]
      }
    ]
  }
}