<?xml version="1.0" encoding="UTF-8"?><StructureMap xmlns="http://hl7.org/fhir">
  <id value="supplyrequest-transform"/>
  <text>
    <status value="generated"/>
    <div xmlns="http://www.w3.org/1999/xhtml">
map &quot;http://hl7.org/fhir/StructureMap/supplyrequest-transform&quot; = supplyRequestTransform

uses &quot;http://hl7.org/fhir/StructureDefinition/ActivityDefinition&quot; as source
uses &quot;http://hl7.org/fhir/StructureDefinition/SupplyRequest&quot; as target

group main
  input &quot;source&quot;: ActivityDefinition as source
  input &quot;target&quot;: SupplyRequest as target

  &quot;status&quot;: for source.id make target.status = &#39;draft&#39;
  &quot;category&quot;: for source.id make target.category = &#39;non-stock&#39;
  &quot;priority&quot;: for source.id make target.priority = &#39;routine&#39;
  &quot;quantity&quot;: for source.quantity make target.orderedItem.quantity
  &quot;item&quot;: for source.code make target.orderedItem.itemCodeableConcept
  &quot;when&quot;: for source.id make target.occurrenceDateTime = Now()
  &quot;authoredOn&quot;: for source.id make target.authoredOn = Now()
    </div>
  </text>
  <url value="http://hl7.org/fhir/StructureMap/supplyrequest-transform"/>
  <name value="Transform from an ActivityDefinition to a SupplyRequest"/>
  <status value="draft"/>
  <structure>
	<url value="http://hl7.org/fhir/StructureDefinition/activitydefinition"/>
	<mode value="source"/>
  </structure>
  <structure>
	<url value="http://hl7.org/fhir/StructureDefinition/supplyrequest"/>
	<mode value="target"/>
  </structure>
  <group>
    <name value="main"/>
    <typeMode value="none"/>
    <input>
      <name value="source"/>
      <mode value="source"/>
    </input>  
    <input>
	  <name value="target"/>
      <mode value="target"/>
	</input>
    <rule>
      <name value="status"/>
      <source>
        <context value="source"/>
        <element value="id"/>
        <variable value="a"/>
      </source>
      <target>
        <context value="target"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="&#39;draft&#39;"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="category"/>
      <source>
        <context value="source"/>
        <element value="id"/>
        <variable value="a"/>
      </source>
      <target>
        <context value="target"/>
        <contextType value="variable"/>
        <element value="category"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="&#39;non-stock&#39;"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="priority"/>
      <source>
        <context value="source"/>
        <element value="id"/>
        <variable value="a"/>
      </source>
      <target>
        <context value="target"/>
        <contextType value="variable"/>
        <element value="priority"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="&#39;routine&#39;"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="quantity"/>
      <source>
        <context value="source"/>
        <element value="quantity"/>
        <variable value="a"/>
      </source>
      <target>
        <context value="target"/>
        <contextType value="variable"/>
        <element value="category"/>
        <transform value="copy"/>
      </target>
    </rule>
    <rule>
      <name value="item"/>
      <source>
        <context value="source"/>
        <element value="code"/>
        <variable value="a"/>
      </source>
      <target>
        <context value="target"/>
        <contextType value="variable"/>
        <element value="orderedItem.itemCodeableConcept"/>
        <transform value="copy"/>
      </target>
    </rule>
    <rule>
      <name value="when"/>
      <source>
        <context value="source"/>
        <element value="id"/>
        <variable value="a"/>
      </source>
      <target>
        <context value="target"/>
        <contextType value="variable"/>
        <element value="occurrenceDateTime"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="now()"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="authoredOn"/>
      <source>
        <context value="source"/>
        <element value="id"/>
        <variable value="a"/>
      </source>
      <target>
        <context value="target"/>
        <contextType value="variable"/>
        <element value="authoredOn"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="now()"/>
        </parameter>
      </target>
    </rule>
  </group>
  
</StructureMap>