<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="mp-ReplyProposalMedicationAgreement" />
  <url value="http://nictiz.nl/fhir/StructureDefinition/mp-ReplyProposalMedicationAgreement" />
  <version value="2.0.0-rc.7" />
  <name value="MpReplyProposalMedicationAgreement" />
  <title value="mp ReplyProposalMedicationAgreement" />
  <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 response proposal medication agreement is a response from the prescriber to the proposal medication agreement. In this response, the prescriber indicates whether they agree (after which an (adjusted) medication agreement will follow) or disagree (and the reason for this)." />
  <purpose value="To define the reply proposal medication agreement 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 medication agreement." />
      <alias value="Antwoord" />
      <constraint>
        <key value="mp-2033-ma-1" />
        <severity value="error" />
        <human value="If the decision is 'accepted' (11) or 'accepted with changes' (12), the relation to the new MedicationAgreement 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.RelationToNewMedicationAgreement').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-MedicationAgreement 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://nictiz.nl/fhir/StructureDefinition/mp-ProposalMedicationAgreement-Bundle" />
        <targetProfile value="http://nictiz.nl/fhir/StructureDefinition/mp-MedicationAgreement" />
      </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) MedicationAgreement -->
    <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:relationToNewMedicationAgreement">
      <path value="Communication.extension" />
      <sliceName value="relationToNewMedicationAgreement" />
      <short value="RelationToNewMedicationAgreement" />
      <definition value="Relation from this reply to the new medication agreement building block that is accepted (possibly with changes)." />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Extension" />
      </type>
    </element>
    <element id="Communication.extension:relationToNewMedicationAgreement.url">
      <path value="Communication.extension.url" />
      <fixedUri value="http://nictiz.nl/fhir/StructureDefinition/ext-Communication.RelationToNewMedicationAgreement" />
    </element>
    <element id="Communication.extension:relationToNewMedicationAgreement.value[x]">
      <path value="Communication.extension.value[x]" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://nictiz.nl/fhir/StructureDefinition/mp-MedicationAgreement" />
      </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="ResponseMedicationAgreementExplanation" />
      <definition value="Explanation (free text) for the response to the proposed medication agreement." />
      <alias value="AntwoordMedicatieafspraakToelichting" />
      <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="ResponseMedicationAgreementDecision" />
      <definition value="Decision for the response to the proposed medication agreement." />
      <alias value="AntwoordMedicatieafspraakBesluit" />
      <min value="1" />
      <binding>
        <strength value="required" />
        <description value="Decision for the response to the proposed medication agreement." />
        <valueSet value="http://decor.nictiz.nl/fhir/ValueSet/2.16.840.1.113883.2.4.3.11.60.20.77.11.44--20251217150448" />
      </binding>
      <mapping>
        <identity value="mp-dataset-mp9-300-rc1-20250522" />
        <map value="mp-dataelement9x-1364" />
        <comment value="ResponseMedicationAgreement" />
      </mapping>
      <mapping>
        <identity value="mp-dataset-mp9-300-rc2-20260213" />
        <map value="mp-dataelement9x-1364" />
        <comment value="ResponseMedicationAgreement" />
      </mapping>
    </element>
  </differential>
</StructureDefinition>