Task

The FHIR Task resource is used to manage the workflow for hub & spoke dispensing.

Tree View

idΣ0..1string
metaΣ0..1Meta
implicitRulesΣ ?!0..1uri
language0..1codeBinding
text0..1Narrative
contained0..*Resource
extensionC0..*Extension
modifierExtension?! C0..*Extension
identifier0..*Identifier
instantiatesCanonicalΣ0..1canonical(ActivityDefinition)
instantiatesUriΣ0..1uri
basedOnΣ C0..*Reference(Resource)
groupIdentifierΣ0..1Identifier
partOfΣ C0..*Reference(Task)
statusΣ ?!1..1codeBinding
statusReasonΣ0..1CodeableConcept
businessStatusΣ0..1CodeableConcept
intentΣ1..1codeBinding
priority0..1codeBinding
codeΣ0..1CodeableConcept
descriptionΣ0..1string
focusΣ C0..1Reference(Resource)
forΣ C0..1Reference(Resource)
encounterΣ C0..1Reference(Encounter)
executionPeriodΣ C0..1Period
authoredOnC0..1dateTime
lastModifiedΣ C0..1dateTime
requesterΣ C0..1Reference(Device | Organization | Patient | Practitioner | PractitionerRole | RelatedPerson)
performerType0..*CodeableConceptBinding
ownerΣ C0..1Reference(CareTeam | Device | HealthcareService | Organization | Patient | Practitioner | PractitionerRole | RelatedPerson)
locationΣ C0..1Reference(Location)
reasonCode0..1CodeableConcept
reasonReferenceC0..1Reference(Resource)
insuranceC0..*Reference(ClaimResponse | Coverage)
note0..*Annotation
relevantHistoryC0..*Reference(Provenance)
id0..1string
extensionC0..*Extension
modifierExtensionΣ ?! C0..*Extension
repetitions0..1positiveInt
periodC0..1Period
recipientC0..*Reference(Group | Organization | Patient | Practitioner | PractitionerRole | RelatedPerson)
id0..1string
extensionC0..*Extension
modifierExtensionΣ ?! C0..*Extension
type1..1CodeableConcept
valueAddressAddress
valueAgeAge
valueAnnotationAnnotation
valueAttachmentAttachment
valueBase64Binarybase64Binary
valueBooleanboolean
valueCanonicalcanonical
valueCodecode
valueCodeableConceptCodeableConcept
valueCodingCoding
valueContactDetailContactDetail
valueContactPointContactPoint
valueContributorContributor
valueCountCount
valueDataRequirementDataRequirement
valueDatedate
valueDateTimedateTime
valueDecimaldecimal
valueDistanceDistance
valueDosageDosage
valueDurationDuration
valueExpressionExpression
valueHumanNameHumanName
valueIdid
valueIdentifierIdentifier
valueInstantinstant
valueIntegerinteger
valueMarkdownmarkdown
valueMetaMeta
valueMoneyMoney
valueOidoid
valueParameterDefinitionParameterDefinition
valuePeriodPeriod
valuePositiveIntpositiveInt
valueQuantityQuantity
valueRangeRange
valueRatioRatio
valueReferenceReference
valueRelatedArtifactRelatedArtifact
valueSampledDataSampledData
valueSignatureSignature
valueStringstring
valueTimetime
valueTimingTiming
valueTriggerDefinitionTriggerDefinition
valueUnsignedIntunsignedInt
valueUriuri
valueUrlurl
valueUsageContextUsageContext
valueUuiduuid
id0..1string
extensionC0..*Extension
modifierExtensionΣ ?! C0..*Extension
type1..1CodeableConcept
valueAddressAddress
valueAgeAge
valueAnnotationAnnotation
valueAttachmentAttachment
valueBase64Binarybase64Binary
valueBooleanboolean
valueCanonicalcanonical
valueCodecode
valueCodeableConceptCodeableConcept
valueCodingCoding
valueContactDetailContactDetail
valueContactPointContactPoint
valueContributorContributor
valueCountCount
valueDataRequirementDataRequirement
valueDatedate
valueDateTimedateTime
valueDecimaldecimal
valueDistanceDistance
valueDosageDosage
valueDurationDuration
valueExpressionExpression
valueHumanNameHumanName
valueIdid
valueIdentifierIdentifier
valueInstantinstant
valueIntegerinteger
valueMarkdownmarkdown
valueMetaMeta
valueMoneyMoney
valueOidoid
valueParameterDefinitionParameterDefinition
valuePeriodPeriod
valuePositiveIntpositiveInt
valueQuantityQuantity
valueRangeRange
valueRatioRatio
valueReferenceReference
valueRelatedArtifactRelatedArtifact
valueSampledDataSampledData
valueSignatureSignature
valueStringstring
valueTimetime
valueTimingTiming
valueTriggerDefinitionTriggerDefinition
valueUnsignedIntunsignedInt
valueUriuri
valueUrlurl
valueUsageContextUsageContext
valueUuiduuid

Examples

Task POST Creation

In this example there are 2 x MedicationRequest resources referenced by the Task.input. The Task will be included within the Bundle for the PharmacySpokeToHub FHIR Transaction.

{
  "resourceType": "Task",
  "meta": {
    "profile": [
      "https://hl7.org/fhir/r4/StructureDefinition/Task"
    ]
  },
  "id": "ae92a488-92a1-42e0-a1c7-e61f6beb8c78",
  "status": "requested",
  "intent": "order",
  "requester": {
    "reference": "urn:uuid:a5acefc1-f8ca-4989-a5ac-34ae36741466"
  },
  "input": [
    {
      "type": {
        "coding": [
          {
            "system": "http://hl7.org/fhir/resource-types",
            "code": "MedicationRequest",
            "display": "MedicationRequest"
          }
        ]
      },
      "valueReference": { 
        "reference": "urn:uuid:29356196-1c07-4057-a7f3-e8d9b7e20926",
        "type": "MedicationRequest"
      }
    },
    {
      "type": {
        "coding": [
          {
            "system": "http://hl7.org/fhir/resource-types",
            "code": "MedicationRequest",
            "display": "MedicationRequest"
          }
        ]
      },
      "valueReference": { 
        "reference": "urn:uuid:0b7497d3-5489-45fc-bd82-4d58a393f010",
        "type": "MedicationRequest"
      }
    },
  ]
}

Task PATCH (Accepted)

PATCH https://{base}/Task/{TaskID}
Content-type: application/fhir+json
{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "operation",
      "part": [
        { 
          "name": "type", 
          "valueCode": "replace"
        },
        { 
          "name": "path", 
          "valueString": "Task.status"
        },
        { 
          "name": "value", 
          "valueString": "accepted"
        }
      ]
    }
  ]
}

Task PATCH (Completed)

In this example there is a single MedicationDispense resource referenced by the Task.output. The update to complete the Task will be included within the Bundle for the PharmacyHubToSpoke FHIR Transaction.

{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "operation",
      "part": [
        { 
          "name": "type", 
          "valueCode": "replace"
        },
        { 
          "name": "path", 
          "valueString": "Task.status"
        },
        { 
          "name": "value", 
          "valueString": "completed"
        }
      ]
    },
    {
      "name": "operation",
      "part": [
        { 
          "name": "type", 
          "valueCode": "add"
        },
        { 
          "name": "path", 
          "valueString": "Task.output[0].type"
        },
        { 
          "name": "value", 
          "valueCodeableConcept": {
            "coding": [
              {
                "system": "http://hl7.org/fhir/resource-types",
                "code": "MedicationDispense",
                "display": "MedicationDispense"
              }
            ]
          }
        }
      ]
    },
    {
      "name": "operation",
      "part": [
        { 
          "name": "type", 
          "valueCode": "add"
        },
        { 
          "name": "path", 
          "valueString": "Task.output[0].valueReference"
        },
        { 
          "name": "value", 
          "valueReference": {
            "reference": "urn:uuid:312d757e-21f1-4f10-9f02-1746768bc31d"
          }
        }
      ]
    }
  ]
}

Required / Minimum Dataset

The required fields that represent the minimum dataset to be shared with the spoke pharmacy (the requester) for medication assembled, labelled and shipped to the spoke pharmacy are as follows.

Element Implementation Requirements
id A locally generated UUID.
status See note below.
intent Fixed value of order.
requester A reference to a UKCore-Organization resource for the spoke pharmacy.
input Reference to any number of UKCore-MedicationRequest resources. It is an implementation decision for the relationship between a Task and a MedicationRequest. There may be a 1-to-1 relationship where each Task relates to a single MedicationRequest. There may be a 1-to-many relationship where a Task relates to multiple MedicationRequests, which can either be for the same patient or different patients.
output Omitted by the spoke (requestor) pharmacy. The hub (provider) pharmacy updates with references to any number of UKCore-MedicationDispense resources. The number of referenced MedicationDispenses will depend on how many MedicationRequests were an input for the Task.

Note: Use of Task.status

The Task.status element is key to managing the workflow for hub & spoke dispensing.

hub-spoke-interactions

The Task is created and persisted by the requestor with the status set to requested when the PharmacySpokeToHub FHIR Transaction is posted to the performer.

The performer uses an HTTP PATCH to amend the Task setting the status to either accepted or rejected. If rejected, the spoke pharmacy needs to find an alternative assembly solution.

Optionally the performer may use an HTTP PATCH to amend the Task status to in-progress once the assembly process has started.

Optionally the performer may use an HTTP PATCH to amend the Task status to on-hold if the assembly process pauses, for example, if stock is temporarily unavailable, or there are clinical queries that need to be discussed with the spoke pharmacy.

The performer uses an HTTP POST containing a PharmacyHubToSpoke FHIR Transaction to the requestor. Within this will be an HTTP PATCH for amend the Task resource to a status of completed.

The performer would use an HTTP PATCH to amend the Task status to failed if the assembly process cannot be completed, meaning no medication will be shipped and the spoke needs to find an alternative assembly solution.

Implementation of HTTP PATCH

The FHIR standard support various way to PATCH a resource. Using a FHIRPath with a Parameters resource is preferred over using a JSONPatch, as the latter requires the content to be base64 encoded when used within a Bundle. The examples above include those for a PATCH operation.