<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="mp-ReplyProposalDispenseRequest" />
  <url value="http://nictiz.nl/fhir/StructureDefinition/mp-ReplyProposalDispenseRequest" />
  <version value="2.0.0-rc.7" />
  <name value="MpReplyProposalDispenseRequest" />
  <title value="mp ReplyProposalDispenseRequest" />
  <status value="active" />
  <publisher value="Nictiz" />
  <contact>
    <name value="Nictiz" />
    <telecom>
      <system value="url" />
      <value value="https://www.nictiz.nl" />
      <use value="work" />
    </telecom>
  </contact>
  <description value="The reply proposal dispense request is a response from the prescriber to the proposal dispense request. In this response, the prescriber indicates whether they agree (after which a dispensing request will follow) or disagree (and the reason for this)." />
  <purpose value="To define the reply proposal dispense request as stated in the information standard Medication Process." />
  <copyright value="Copyright and related rights waived via CC0, https://creativecommons.org/publicdomain/zero/1.0/. This does not apply to information from third parties, for example a medical terminology system. The implementer alone is responsible for identifying and obtaining any necessary licenses or authorizations to utilize third party IP in connection with the specification or otherwise." />
  <fhirVersion value="4.0.1" />
  <mapping>
    <identity value="mp-dataset-mp9-300-rc1-20250522" />
    <uri value="https://decor.nictiz.nl/pub/medicatieproces/mp-html-20250522T132618/ds-2.16.840.1.113883.2.4.3.11.60.20.77.1.4-2022-06-30T000000.html" />
    <name value="ART-DECOR Dataset MP9 3.0.0-rc.1 20250522" />
  </mapping>
  <mapping>
    <identity value="mp-dataset-mp9-300-rc2-20260213" />
    <uri value="https://decor.nictiz.nl/pub/medicatieproces/mp-html-20260213T112547/ds-2.16.840.1.113883.2.4.3.11.60.20.77.1.4-2022-06-30T000000.html" />
    <name value="ART-DECOR Dataset MP9 3.0.0-rc.2 20260213" />
  </mapping>
  <kind value="resource" />
  <abstract value="false" />
  <type value="Communication" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Communication" />
  <derivation value="constraint" />
  <differential>
    <element id="Communication">
      <path value="Communication" />
      <short value="Response" />
      <definition value="Response to the proposal dispense request." />
      <alias value="Antwoord" />
      <constraint>
        <key value="mp-2033-vv-1" />
        <severity value="error" />
        <human value="If the decision is 'accepted' (11) or 'accepted with changes' (12), the relation to the new DispenseRequest SHALL be present; otherwise it SHALL be absent." />
        <expression value="(payload.content.extension.value.ofType(CodeableConcept).coding.code.intersect({'11','12'}).exists()) = extension.where(url='http://nictiz.nl/fhir/StructureDefinition/ext-Communication.RelationToNewDispenseRequest').exists()" />
      </constraint>
      <mapping>
        <identity value="mp-dataset-mp9-300-rc1-20250522" />
        <map value="mp-dataelement9x-539" />
        <comment value="Response" />
      </mapping>
      <mapping>
        <identity value="mp-dataset-mp9-300-rc2-20260213" />
        <map value="mp-dataelement9x-539" />
        <comment value="Response" />
      </mapping>
    </element>
    <element id="Communication.meta">
      <path value="Communication.meta" />
    </element>
    <element id="Communication.meta.tag">
      <path value="Communication.meta.tag" />
      <slicing>
        <discriminator>
          <type value="pattern" />
          <path value="$this" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <min value="1" />
    </element>
    <element id="Communication.meta.tag:actionable">
      <path value="Communication.meta.tag" />
      <sliceName value="actionable" />
      <min value="1" />
      <max value="1" />
      <patternCoding>
        <system value="http://terminology.hl7.org/CodeSystem/common-tags" />
        <code value="actionable" />
      </patternCoding>
    </element>
    <element id="Communication.identifier">
      <path value="Communication.identifier" />
      <short value="Identification" />
      <definition value="The identification of the response to the proposal. This identification is generated by the system of the person who registers the response and is globally unique and eternally persistent." />
      <comment value="Leading business identifier for the response." />
      <alias value="Identificatie" />
      <min value="1" />
      <max value="1" />
      <mapping>
        <identity value="mp-dataset-mp9-300-rc1-20250522" />
        <map value="mp-dataelement9x-540" />
        <comment value="Identification" />
      </mapping>
      <mapping>
        <identity value="mp-dataset-mp9-300-rc2-20260213" />
        <map value="mp-dataelement9x-540" />
        <comment value="Identification" />
      </mapping>
    </element>
    <element id="Communication.basedOn">
      <path value="Communication.basedOn" />
      <short value="RelationToProposalData" />
      <definition value="Relation to proposal data." />
      <comment value="Preferred: reference the proposal transaction (Bundle) using an identifier-based reference that matches Proposal Bundle.identifier. Backwards compatibility: a direct reference to the proposed mp-DispenseRequest MAY be used during transition." />
      <alias value="RelatieVoorstelGegevens" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Resource" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Bundle" />
        <targetProfile value="http://nictiz.nl/fhir/StructureDefinition/mp-ProposalDispenseRequest-Bundle" />
        <targetProfile value="http://nictiz.nl/fhir/StructureDefinition/mp-DispenseRequest" />
      </type>
      <mapping>
        <identity value="mp-dataset-mp9-300-rc1-20250522" />
        <map value="mp-dataelement9x-544" />
        <comment value="RelationToProposalData" />
      </mapping>
      <mapping>
        <identity value="mp-dataset-mp9-300-rc2-20260213" />
        <map value="mp-dataelement9x-544" />
        <comment value="RelationToProposalData" />
      </mapping>
    </element>
    <element id="Communication.subject">
      <path value="Communication.subject" />
      <short value="Patient" />
      <alias value="Patient" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Patient" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Group" />
        <targetProfile value="http://nictiz.nl/fhir/StructureDefinition/nl-core-Patient" />
      </type>
      <mapping>
        <identity value="mp-dataset-mp9-300-rc1-20250522" />
        <map value="mp-dataelement9x-1" />
        <comment value="Patient" />
      </mapping>
      <mapping>
        <identity value="mp-dataset-mp9-300-rc2-20260213" />
        <map value="mp-dataelement9x-1" />
        <comment value="Patient" />
      </mapping>
    </element>
    <element id="Communication.sent">
      <path value="Communication.sent" />
      <short value="ResponseDate" />
      <definition value="Date of the response to the proposal." />
      <alias value="AntwoordDatum" />
      <min value="1" />
      <mapping>
        <identity value="mp-dataset-mp9-300-rc1-20250522" />
        <map value="mp-dataelement9x-541" />
        <comment value="ResponseDate" />
      </mapping>
      <mapping>
        <identity value="mp-dataset-mp9-300-rc2-20260213" />
        <map value="mp-dataelement9x-541" />
        <comment value="ResponseDate" />
      </mapping>
    </element>
    <element id="Communication.sender">
      <path value="Communication.sender" />
      <short value="Author" />
      <definition value="Author of the response to the proposal." />
      <alias value="Auteur" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <profile value="http://nictiz.nl/fhir/StructureDefinition/pattern-NlCoreHealthProfessionalReference" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Device" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Organization" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Patient" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Practitioner" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/PractitionerRole" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/RelatedPerson" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/HealthcareService" />
        <targetProfile value="http://nictiz.nl/fhir/StructureDefinition/nl-core-HealthProfessional-PractitionerRole" />
      </type>
      <mapping>
        <identity value="mp-dataset-mp9-300-rc1-20250522" />
        <map value="mp-dataelement9x-542" />
        <comment value="Author" />
      </mapping>
      <mapping>
        <identity value="mp-dataset-mp9-300-rc2-20260213" />
        <map value="mp-dataelement9x-542" />
        <comment value="Author" />
      </mapping>
    </element>
    <!-- MP-2033: relation to the accepted (new) DispenseRequest -->
    <element id="Communication.extension">
      <path value="Communication.extension" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="url" />
        </discriminator>
        <rules value="open" />
      </slicing>
    </element>
    <element id="Communication.extension:relationToNewDispenseRequest">
      <path value="Communication.extension" />
      <sliceName value="relationToNewDispenseRequest" />
      <short value="RelationToNewDispenseRequest" />
      <definition value="Relation from this reply to the new dispense request building block that is accepted (possibly with changes)." />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Extension" />
      </type>
    </element>
    <element id="Communication.extension:relationToNewDispenseRequest.url">
      <path value="Communication.extension.url" />
      <fixedUri value="http://nictiz.nl/fhir/StructureDefinition/ext-Communication.RelationToNewDispenseRequest" />
    </element>
    <element id="Communication.extension:relationToNewDispenseRequest.value[x]">
      <path value="Communication.extension.value[x]" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://nictiz.nl/fhir/StructureDefinition/mp-DispenseRequest" />
      </type>
    </element>
    <element id="Communication.payload">
      <path value="Communication.payload" />
      <min value="1" />
    </element>
    <element id="Communication.payload.content[x]">
      <path value="Communication.payload.content[x]" />
      <short value="ResponseDispenseRequestExplanation" />
      <definition value="Explanation (free text) for the response to the proposed dispense request." />
      <alias value="AntwoordVerstrekkingsverzoekToelichting" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="string" />
      </type>
    </element>
    <element id="Communication.payload.content[x].extension">
      <path value="Communication.payload.content[x].extension" />
      <min value="1" />
    </element>
    <element id="Communication.payload.content[x].extension:contentCodeableConcept">
      <path value="Communication.payload.content[x].extension" />
      <sliceName value="contentCodeableConcept" />
      <comment value="This is a pre-adopt of R5 in which the string data type of `.payload.content` is changed to a CodeableConcept." />
      <min value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://nictiz.nl/fhir/StructureDefinition/ext-Communication.Payload.ContentCodeableConcept" />
      </type>
    </element>
    <element id="Communication.payload.content[x].extension:contentCodeableConcept.value[x]">
      <path value="Communication.payload.content[x].extension.value[x]" />
      <short value="ResponseDispenseRequestDecision" />
      <definition value="Decision for the response to the proposed dispense request." />
      <alias value="AntwoordVerstrekkingsverzoekBesluit" />
      <min value="1" />
      <binding>
        <strength value="required" />
        <description value="Decision for the response to the proposed dispense request." />
        <valueSet value="http://decor.nictiz.nl/fhir/ValueSet/2.16.840.1.113883.2.4.3.11.60.20.77.11.36--20251217150952" />
      </binding>
      <mapping>
        <identity value="mp-dataset-mp9-300-rc1-20250522" />
        <map value="mp-dataelement9x-546" />
        <comment value="ResponseDispenseRequest" />
      </mapping>
      <mapping>
        <identity value="mp-dataset-mp9-300-rc2-20260213" />
        <map value="mp-dataelement9x-546" />
        <comment value="ResponseDispenseRequest" />
      </mapping>
    </element>
  </differential>
</StructureDefinition>