<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="pr-medication-request" />
  <meta>
    <security>
      <system value="https://www.icanbwell.com/owner" />
      <code value="bwell" />
    </security>
    <security>
      <system value="https://www.icanbwell.com/access" />
      <code value="bwell" />
    </security>
  </meta>
  <url value="https://fhir.icanbwell.com/4_0_0/StructureDefinition/pr-medication-request" />
  <version value="1.0" />
  <name value="MedicationRequest" />
  <title value="Profile: Medication Request" />
  <status value="active" />
  <experimental value="false" />
  <date value="2024-03-01" />
  <publisher value="b.Well Connected Health" />
  <description value="Prescriptions" />
  <jurisdiction>
    <coding>
      <system value="urn:iso:std:iso:3166" />
      <code value="US" />
      <display value="United States of America" />
    </coding>
    <text value="United States of America" />
  </jurisdiction>
  <fhirVersion value="4.0.0" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="MedicationRequest" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/MedicationRequest" />
  <derivation value="constraint" />
  <differential>
    <element id="MedicationRequest">
      <path value="MedicationRequest" />
    </element>
    <element id="MedicationRequest.id">
      <path value="MedicationRequest.id" />
      <min value="1" />
      <max value="1" />
    </element>
    <element id="MedicationRequest.meta">
      <path value="MedicationRequest.meta" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="Meta" />
      </type>
    </element>
    <element id="MedicationRequest.meta.source">
      <path value="MedicationRequest.meta.source" />
      <short value="uri of the data source" />
      <definition value="Typically the data owner's URL followed by a source/file description" />
      <requirements value="mandatory for all resources in bWell's FHIR Server" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="uri" />
      </type>
      <example>
        <label value="example of meta.source" />
        <valueUri value="https://www.icanbwell.com/provider-directory" />
      </example>
    </element>
    <element id="MedicationRequest.meta.security">
      <path value="MedicationRequest.meta.security" />
      <short value="security tags representing the data's owner, vendor, and accessibility" />
      <definition value="data owner: &#xA; &#xA; data vendor: &#xA; &#xA; data access:" />
      <requirements value="/owner &amp; /access are mandatory for all resources in bWell's FHIR Server" />
      <min value="1" />
      <max value="*" />
      <type>
        <code value="Coding" />
      </type>
      <example>
        <label value="example of data owner security tag" />
        <valueCoding>
          <system value="https://www.icanbwell.com/owner" />
          <code value="bwell" />
        </valueCoding>
      </example>
      <example>
        <label value="example of data access security tag" />
        <valueCoding>
          <system value="https://www.icanbwell.com/access" />
          <code value="bwell" />
        </valueCoding>
      </example>
      <example>
        <label value="example of data vendor security tag" />
        <valueCoding>
          <system value="https://www.icanbwell.com/vendor" />
          <code value="bwell" />
        </valueCoding>
      </example>
    </element>
    <element id="MedicationRequest.identifier">
      <path value="MedicationRequest.identifier" />
      <slicing>
        <description value="slice by types" />
        <rules value="open" />
      </slicing>
      <short value="a value to identify the resource" />
      <min value="0" />
      <max value="*" />
      <type>
        <code value="Identifier" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="MedicationRequest.identifier.id">
      <path value="MedicationRequest.identifier.id" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="string" />
      </type>
    </element>
    <element id="MedicationRequest.identifier.use">
      <path value="MedicationRequest.identifier.use" />
      <short value="usual | official | temp | secondary | old (If known)" />
      <definition value="The purpose of this identifier." />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="code" />
      </type>
    </element>
    <element id="MedicationRequest.identifier.type">
      <path value="MedicationRequest.identifier.type" />
      <short value="Description of identifier" />
      <definition value="A coded type for the identifier that can be used to determine which identifier to use for a specific purpose." />
      <requirements value="Needs binding valueset" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="CodeableConcept" />
      </type>
    </element>
    <element id="MedicationRequest.identifier.system">
      <path value="MedicationRequest.identifier.system" />
      <short value="The system which created the identifier" />
      <definition value="Values may be an oid, uri, url, or canonical" />
      <comment value="for mapped data, this is frequently a canonical url" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="uri" />
      </type>
      <example>
        <label value="a client's unknown system" />
        <valueUri value="https://www.health.org/person-identifier" />
      </example>
    </element>
    <element id="MedicationRequest.identifier.value">
      <path value="MedicationRequest.identifier.value" />
      <short value="The unique value" />
      <definition value="The raw identifier value that represents a resource" />
      <requirements value="This should be the raw value, as it exists in the source data (ie without prefix)" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="string" />
      </type>
    </element>
    <element id="MedicationRequest.identifier-rx-number">
      <path value="MedicationRequest.identifier" />
      <sliceName value="rx-number" />
      <short value="The prescription (Rx) unique identifier" />
      <alias value="rx-number" />
      <min value="1" />
      <max value="1" />
      <example>
        <label value="Rx Identifier" />
        <valueIdentifier id="rx-number">
          <type>
            <coding id="rx">
              <system value="https://fhir.icanbwell.com/4_0_0/CodeSystem/vs-identifier-type" />
              <code value="RX" />
            </coding>
          </type>
        </valueIdentifier>
      </example>
    </element>
    <element id="MedicationRequest.status">
      <path value="MedicationRequest.status" />
      <short value="active | on-hold | cancelled | completed | entered-in-error | stopped | draft | unknown" />
      <comment value="default to 'completed'" />
      <min value="1" />
      <type>
        <code value="code" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="MedicationRequest.intent">
      <path value="MedicationRequest.intent" />
      <short value="proposal | plan | order | original-order | reflex-order | filler-order | instance-order | option" />
      <comment value="default to 'order'" />
      <min value="1" />
      <type>
        <code value="code" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="MedicationRequest.category">
      <path value="MedicationRequest.category" />
      <slicing>
        <description value="slice by type" />
        <rules value="open" />
      </slicing>
      <short value="Type of medication usage" />
      <min value="0" />
      <type>
        <code value="CodeableConcept" />
      </type>
      <example>
        <label value="MedicationRequest.category example" />
        <valueCodeableConcept id="category">
          <coding id="order-category">
            <system value="http://terminology.hl7.org/CodeSystem/medicationrequest-category" />
            <code value="community" />
          </coding>
        </valueCodeableConcept>
      </example>
      <mustSupport value="true" />
    </element>
    <element id="MedicationRequest.reported[x]">
      <path value="MedicationRequest.reported[x]" />
      <short value="Reported rather than primary record" />
      <min value="0" />
      <type>
        <code value="boolean" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="MedicationRequest.medication[x]">
      <path value="MedicationRequest.medication[x]" />
      <short value="a value to identify the resource" />
      <min value="1" />
      <type>
        <code value="CodeableConcept" />
      </type>
      <example>
        <label value="medicationCodeableConcept example with ndc and snomed codes" />
        <valueCodeableConcept>
          <coding id="ndc">
            <system value="http://hl7.org/fhir/sid/ndc" />
            <code value="0573-0134" />
          </coding>
          <coding id="snomed">
            <system value="http://snomed.info/sct" />
            <code value="387207008" />
          </coding>
          <text value="Advil" />
        </valueCodeableConcept>
      </example>
      <mustSupport value="true" />
    </element>
    <element id="MedicationRequest.medication[x].coding">
      <path value="MedicationRequest.medication[x].coding" />
      <slicing>
        <description value="slice by code system" />
        <rules value="open" />
      </slicing>
      <short value="The code-system pair describing the medication" />
      <min value="1" />
      <max value="*" />
      <type>
        <code value="Coding" />
      </type>
    </element>
    <element id="MedicationRequest.medication[x].coding-ndc">
      <path value="MedicationRequest.medication[x].coding-ndc" />
      <sliceName value="ndc" />
      <short value="National Drug Code" />
      <definition value="system = http://hl7.org/fhir/sid/ndc" />
      <type>
        <code value="Coding" />
      </type>
    </element>
    <element id="MedicationRequest.medication[x].coding-rxnorm">
      <path value="MedicationRequest.medication[x].coding-rxnorm" />
      <sliceName value="rxnorm" />
      <short value="RxNorm code" />
      <definition value="system = http://www.nlm.nih.gov/research/umls/rxnorm" />
      <type>
        <code value="Coding" />
      </type>
    </element>
    <element id="MedicationRequest.medication[x].coding-snomed">
      <path value="MedicationRequest.medication[x].coding-snomed" />
      <sliceName value="snomed" />
      <short value="SNOMED code" />
      <definition value="system = http://snomed.info/sct" />
      <type>
        <code value="Coding" />
      </type>
    </element>
    <element id="MedicationRequest.medication[x].coding-ndfrt">
      <path value="MedicationRequest.medication[x].coding-ndfrt" />
      <sliceName value="ndfrt" />
      <short value="National Durg File - Reference Terminology code" />
      <definition value="system = http://hl7.org/fhir/ndfrt" />
      <type>
        <code value="Coding" />
      </type>
    </element>
    <element id="MedicationRequest.medication[x].coding-gpi">
      <path value="MedicationRequest.medication[x].coding-gpi" />
      <sliceName value="gpi" />
      <short value="Generic Product Identifier code" />
      <definition value="system = http://terminology.hl7.org/CodeSystem/MGPI" />
      <type>
        <code value="Coding" />
      </type>
    </element>
    <element id="MedicationRequest.subject">
      <path value="MedicationRequest.subject" />
      <short value="The patient" />
      <alias value="patient" />
      <alias value="user" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://fhir.icanbwell.com/4_0_0/StructureDefinition/pr-patient" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="MedicationRequest.encounter">
      <path value="MedicationRequest.encounter" />
      <short value="Reference to a relevent Encounter" />
      <min value="0" />
      <type>
        <code value="Reference" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="MedicationRequest.authoredOn">
      <path value="MedicationRequest.authoredOn" />
      <short value="When the prescription was written by the requesting practitioner" />
      <alias value="prescribed-date" />
      <min value="1" />
      <type>
        <code value="dateTime" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="MedicationRequest.requester">
      <path value="MedicationRequest.requester" />
      <short value="The practitioner who authored the prescription" />
      <alias value="prescribing-practitioner" />
      <min value="1" />
      <type>
        <code value="Reference" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="MedicationRequest.dosageInstruction">
      <path value="MedicationRequest.dosageInstruction" />
      <slicing>
        <description value="slice by type" />
        <rules value="open" />
      </slicing>
      <min value="0" />
      <type>
        <code value="Dosage" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="MedicationRequest.dosageInstruction.id">
      <path value="MedicationRequest.dosageInstruction.id" />
      <min value="1" />
      <type>
        <code value="string" />
      </type>
    </element>
    <element id="MedicationRequest.dosageInstruction.text">
      <path value="MedicationRequest.dosageInstruction.text" />
      <short value="Free text dosage instructions" />
      <alias value="dosage-instruction" />
      <min value="1" />
      <type>
        <code value="string" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="MedicationRequest.dispenseRequest">
      <path value="MedicationRequest.dispenseRequest" />
      <alias value="dosage-instruction" />
      <min value="0" />
      <type>
        <code value="BackboneElement" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="MedicationRequest.dispenseRequest.numberOfRepeatsAllowed">
      <path value="MedicationRequest.dispenseRequest.numberOfRepeatsAllowed" />
      <short value="Number of refills allowed" />
      <comment value="Used to calculate number of refills remaining" />
      <alias value="total-refills" />
      <alias value="refills-allowed" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="unsignedInt" />
      </type>
      <mustSupport value="true" />
    </element>
  </differential>
</StructureDefinition>