<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="sfm-MedicationComposition" />
  <url value="http://ehelse.no/fhir/StructureDefinition/sfm-MedicationComposition" />
  <version value="1.1" />
  <name value="SfmMedicationComposition" />
  <title value="sfm-MedicationComposition" />
  <status value="active" />
  <date value="2023-11-23" />
  <publisher value="Norsk Helsenett SFM" />
  <description value="Bundle for use in SFM API for aggregated medication and prescription info" />
  <purpose value="The purpose of this profile is to define the structure of the SfmMedicationBundle." />
  <fhirVersion value="4.0.0" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Composition" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Composition" />
  <derivation value="constraint" />
  <differential>
    <element id="Composition">
      <path value="Composition" />
      <short value="Norwegian Composition for PLL and Prescriptions" />
      <definition value="Norwegian Composition for PLL and Prescriptions. A composition for aggregated information provided by SFM to systems consuming the API Basis. The Composition is a result of lookup to national systems for prescription (Reseptformidleren) and medication history from Kjernejounal. The composition is also used for submitting updates to the nationals systems. The PLL (short for Pasientens LegemiddelListe : Patient medication list) is supported by separate identifier in sfmMedicationStatement." />
      <comment value="The Composition refers to some sfm specific profiles, and other norwegian basis profiles (no-basis). This may change over time untill final specification is published in advance of initial production release of SFM API Basis&#xD;&#xA;All resources refered in this Composition must reside in the outer sfmMedicationBundle where this Composition serves as an index." />
    </element>
    <element id="Composition.subject">
      <path value="Composition.subject" />
      <short value="Identification of the patient" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://ehelse.no/fhir/StructureDefinition/sfm-Patient" />
        <aggregation value="bundled" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Composition.author">
      <path value="Composition.author" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Device" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Organization" />
        <targetProfile value="http://ehelse.no/fhir/StructureDefinition/sfm-Practitioner" />
      </type>
    </element>
    <element id="Composition.attester">
      <path value="Composition.attester" />
      <slicing>
        <discriminator>
          <type value="profile" />
          <path value="party.reference" />
        </discriminator>
        <ordered value="true" />
        <rules value="open" />
      </slicing>
      <definition value="When submitting this composition to SFM: One for the Practitioner and one for the organisation" />
      <max value="2" />
      <mustSupport value="true" />
    </element>
    <element id="Composition.attester:attesterPractitioner">
      <path value="Composition.attester" />
      <sliceName value="attesterPractitioner" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Composition.attester:attesterPractitioner.party">
      <path value="Composition.attester.party" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://ehelse.no/fhir/StructureDefinition/sfm-Practitioner" />
      </type>
    </element>
    <element id="Composition.attester:attesterOrganisation">
      <path value="Composition.attester" />
      <sliceName value="attesterOrganisation" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Composition.attester:attesterOrganisation.party">
      <path value="Composition.attester.party" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://example.org/fhir/StructureDefinition/sfm-Organization" />
      </type>
    </element>
    <element id="Composition.section">
      <path value="Composition.section" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="code.coding.code" />
        </discriminator>
        <description value="Slicing of this section is done on code.coding.code with use of valueset" />
        <ordered value="false" />
        <rules value="open" />
      </slicing>
      <short value="Medication list" />
      <definition value="This defined sections of this Composition are defined as slices using codesystem sfm-section-types:&#xD;&#xA;sectionMedication, sectionPLL, sectionPLLinfo, sectionAllergies, sectionOtherPrescriptions, sectionDispense" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Composition.section:sectionPLLinfo">
      <path value="Composition.section" />
      <sliceName value="sectionPLLinfo" />
      <code>
        <system value="http://ehelse.no/fhir/CodeSystem/sfm-section-types" />
        <code value="sectionPLL" />
      </code>
      <short value="toplevel info from PLL" />
      <definition value="Contains information on special practitioner roles and delivery information for multidose patients" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Composition.section:sectionPLLinfo.code.coding.system">
      <path value="Composition.section.code.coding.system" />
      <short value="SFM section types" />
      <fixedUri value="http://ehelse.no/fhir/CodeSystem/sfm-section-types" />
    </element>
    <element id="Composition.section:sectionPLLinfo.code.coding.code">
      <path value="Composition.section.code.coding.code" />
      <fixedCode value="sectionPLLinfo" />
    </element>
    <element id="Composition.section:sectionPLLinfo.entry">
      <path value="Composition.section.entry" />
      <max value="3" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://ehelse.no/fhir/StructureDefinition/sfm-PLL-info" />
        <aggregation value="referenced" />
        <aggregation value="bundled" />
      </type>
    </element>
    <element id="Composition.section:sectionMedication">
      <path value="Composition.section" />
      <sliceName value="sectionMedication" />
      <code>
        <system value="http://ehelse.no/fhir/CodeSystem/sfm-section-types" />
        <code value="sectionMedication" />
      </code>
      <short value="Medication section" />
      <definition value="This section contains the medication info representation in national systems" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Composition.section:sectionMedication.code.coding.system">
      <path value="Composition.section.code.coding.system" />
      <fixedUri value="http://ehelse.no/fhir/CodeSystem/sfm-section-types" />
    </element>
    <element id="Composition.section:sectionMedication.code.coding.code">
      <path value="Composition.section.code.coding.code" />
      <fixedCode value="sectionMedication" />
    </element>
    <element id="Composition.section:sectionMedication.entry">
      <path value="Composition.section.entry" />
      <short value="A reference to sfm-MedicationStatemen" />
      <definition value="Medication entries in the MedicationComposition" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://ehelse.no/fhir/StructureDefinition/sfm-MedicationStatement" />
        <aggregation value="referenced" />
        <aggregation value="bundled" />
      </type>
    </element>
    <element id="Composition.section:sectionOtherPrescriptions">
      <path value="Composition.section" />
      <sliceName value="sectionOtherPrescriptions" />
      <code>
        <system value="http://ehelse.no/fhir/CodeSystem/sfm-section-types" />
        <code value="sectionOtherPrescriptions" />
      </code>
      <definition value="This section contains the non-medicinal prescriptions for the patient" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Composition.section:sectionOtherPrescriptions.code.coding.system">
      <path value="Composition.section.code.coding.system" />
      <fixedUri value="http://ehelse.no/fhir/CodeSystem/sfm-section-types" />
    </element>
    <element id="Composition.section:sectionOtherPrescriptions.code.coding.code">
      <path value="Composition.section.code.coding.code" />
      <fixedCode value="sectionOtherPrescriptions" />
    </element>
    <element id="Composition.section:sectionOtherPrescriptions.entry">
      <path value="Composition.section.entry" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://ehelse.no/fhir/StructureDefinition/sfm-BandaPrescription" />
        <aggregation value="referenced" />
        <aggregation value="bundled" />
      </type>
    </element>
    <element id="Composition.section:sectionAllergies">
      <path value="Composition.section" />
      <sliceName value="sectionAllergies" />
      <code>
        <system value="http://ehelse.no/fhir/CodeSystem/sfm-section-types" />
        <code value="sectionAllergies" />
      </code>
      <definition value="A list of known allergies for the particular patient." />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Composition.section:sectionAllergies.code.coding.system">
      <path value="Composition.section.code.coding.system" />
      <fixedUri value="http://ehelse.no/fhir/CodeSystem/sfm-section-types" />
    </element>
    <element id="Composition.section:sectionAllergies.code.coding.code">
      <path value="Composition.section.code.coding.code" />
      <fixedCode value="sectionAllergies" />
    </element>
    <element id="Composition.section:sectionAllergies.entry">
      <path value="Composition.section.entry" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://nhn.no/kj/fhir/StructureDefinition/KjAllergyIntolerance" />
      </type>
    </element>
    <element id="Composition.section:sectionDispense">
      <path value="Composition.section" />
      <sliceName value="sectionDispense" />
      <code>
        <system value="http://ehelse.no/fhir/CodeSystem/sfm-section-types" />
        <code value="sectionDispense" />
      </code>
      <short value="Dispense information from Pharamcy and Bandasjist" />
      <definition value="Dispense information for the patient. Only present when reading the resouce from SFM." />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Composition.section:sectionDispense.code.coding.system">
      <path value="Composition.section.code.coding.system" />
      <fixedUri value="http://ehelse.no/fhir/CodeSystem/sfm-section-types" />
    </element>
    <element id="Composition.section:sectionDispense.code.coding.code">
      <path value="Composition.section.code.coding.code" />
      <fixedCode value="sectionDispense" />
    </element>
    <element id="Composition.section:sectionDispense.entry">
      <path value="Composition.section.entry" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://ehelse.no/fhir/StructureDefinition/sfm-MedicationDispense" />
        <targetProfile value="http://ehelse.no/fhir/StructureDefinition/sfm-GeneralDispense" />
      </type>
    </element>
  </differential>
</StructureDefinition>