<OperationDefinition xmlns="http://hl7.org/fhir">
  <url value="http://electronichealth.se/fhir/OperationDefinition/NLLEnd" />
  <version value="1.0.0" />
  <name value="NLLEnd" />
  <title value="end" />
  <status value="active" />
  <kind value="operation" />
  <date value="2024-04-16" />
  <publisher value="The Swedish eHealth Agency" />
  <description value="This operation is used for stopping (sv Avsluta) or cancelling (sv Makulera) one or several prescriptions using their logical ids or their legacy NEF-ids." />
  <affectsState value="true" />
  <code value="end" />
  <comment value="Can be invoked with a HTTP POST.&#xD;&#xA;This operation is used for stopping (sv Avsluta) or cancelling (sv Makulera) one or several prescriptions using their logical ids.&#xD;&#xA;In the case of an unsuccessfull transaction, an OperationOutcom is returned." />
  <resource value="MedicationRequest" />
  <system value="false" />
  <type value="true" />
  <instance value="false" />
  <parameter>
    <name value="entry" />
    <use value="in" />
    <min value="1" />
    <max value="*" />
    <documentation value="Data about the MedicationRequest(s) that shall be stopped (sv Avsluta) or cancelled (sv Makulera)." />
    <part>
      <name value="resource" />
      <use value="in" />
      <min value="0" />
      <max value="1" />
      <documentation value="NB! Either a reference OR a NEF-id (PrescriptionSetId, RowId and ProductRowId) must be provided.&#xD;&#xA;Reference to a MedicationRequest that shall be stopped (sv Avsluta) or cancelled (sv Makulera) on either of the following formats MedicationRequest/[id] OR MedicationRequest/[id]/_history/[vid]. In the case that the reference contains a specific version (/_history/[vid]) the version-information will be ignored." />
      <type value="Reference" />
      <targetProfile value="http://electronichealth.se/fhir/StructureDefinition/NLLReference" />
    </part>
    <part>
      <name value="PrescriptionSetId" />
      <use value="in" />
      <min value="0" />
      <max value="1" />
      <documentation value="NB! Either a reference OR a NEF-id (PrescriptionSetId, RowId and ProductRowId) must be provided. &#xD;&#xA;The PrescriptionSetId used in the NEF-id. Can be in combination with RowId and ProductRowId. The provided combination of NEF-id-parts must resolve to a uniqe prescription. (sv Originalordinations-id)" />
      <type value="string" />
    </part>
    <part>
      <name value="RowId" />
      <use value="in" />
      <min value="0" />
      <max value="1" />
      <documentation value="The RowId used in the NEF-id. Used in combination with PrescriptionSetId and ProductRowId. (sv Radnummer)" />
      <type value="positiveInt" />
    </part>
    <part>
      <name value="ProductRowId" />
      <use value="in" />
      <min value="0" />
      <max value="1" />
      <documentation value="The ProductRowId used in the NEF-id. Used in combination with PrescriptionSetId and RowId. (sv Produktradnummer)" />
      <type value="positiveInt" />
    </part>
    <part>
      <name value="reason" />
      <use value="in" />
      <min value="1" />
      <max value="1" />
      <documentation value="Reason the activity is occurring. Will be used in the linked Provenance. (sv Händelseorsak)" />
      <type value="CodeableConcept" />
      <binding>
        <strength value="preferred" />
        <valueSet value="http://electronichealth.se/fhir/ValueSet/nll-reason-for-provenanc" />
      </binding>
    </part>
    <part>
      <name value="activity" />
      <use value="in" />
      <min value="1" />
      <max value="1" />
      <documentation value="Activity that occurred. Will be used in the linked Provenance. (sv Händelsetyp)" />
      <type value="CodeableConcept" />
      <binding>
        <strength value="preferred" />
        <valueSet value="http://ehalsomyndigheten.se/fhir/ValueSet/medication-request-activity-types" />
      </binding>
    </part>
    <part>
      <name value="nllUsageEndDate" />
      <use value="in" />
      <min value="0" />
      <max value="1" />
      <documentation value="End date for dosage usage (sv: Sista doseringsdag)" />
      <part>
        <name value="operationType" />
        <use value="in" />
        <min value="1" />
        <max value="1" />
        <documentation value="replace | delete&#xD;&#xA;The operation that should be applied on the UsageEndDate. It can be replaced with a new date, or it can be deleted." />
        <type value="code" />
        <binding>
          <strength value="required" />
          <valueSet value="http://electronichealth.se/fhir/ValueSet/end-operation-types" />
        </binding>
      </part>
      <part>
        <name value="date" />
        <use value="in" />
        <min value="0" />
        <max value="1" />
        <documentation value="The date value that UsageEndDate shall get. Used in combination with the OperationType &quot;replace&quot;." />
        <type value="date" />
      </part>
    </part>
    <part>
      <name value="nllTreatmentEndDate" />
      <use value="in" />
      <min value="0" />
      <max value="1" />
      <documentation value="Last date for ending this treatment (sv: Senaste datum för avslut)" />
      <part>
        <name value="operationType" />
        <use value="in" />
        <min value="1" />
        <max value="1" />
        <documentation value="replace | delete&#xD;&#xA;The operation that should be applied on the TreatmentEndDate. It can be replaced with a new date, or it can be deleted." />
        <type value="code" />
        <binding>
          <strength value="required" />
          <valueSet value="http://electronichealth.se/fhir/ValueSet/end-operation-types" />
        </binding>
      </part>
      <part>
        <name value="date" />
        <use value="in" />
        <min value="0" />
        <max value="1" />
        <documentation value="The date value that TreatmentEndDate shall get. Used in combination with the OperationType &quot;replace&quot;." />
        <type value="date" />
      </part>
    </part>
  </parameter>
  <parameter>
    <name value="result" />
    <use value="out" />
    <min value="0" />
    <max value="1" />
    <documentation value="In the case of a successfull call, the result is set to &quot;true&quot;" />
    <type value="boolean" />
  </parameter>
</OperationDefinition>