{
  "resourceType": "StructureDefinition",
  "id": "hrex-task-data-request",
  "url": "http://hl7.org/fhir/us/davinci-hrex/StructureDefinition/hrex-task-data-request",
  "version": "0.2.0",
  "name": "HRexTaskDataRequest",
  "title": "HRex Task Data Request Profile",
  "status": "active",
  "experimental": false,
  "date": "2020-09-11T05:25:14+00:00",
  "publisher": "HL7 International - Clinical Interoperability Council",
  "contact": [
    {
      "telecom": [
        {
          "system": "url",
          "value": "http://www.hl7.org/Special/committees/cic"
        }
      ]
    }
  ],
  "description": "This Task profile is used to solicit information from a system when direct query is not possible and human intervention might be required",
  "jurisdiction": [
    {
      "coding": [
        {
          "system": "urn:iso:std:iso:3166",
          "code": "US"
        }
      ]
    }
  ],
  "fhirVersion": "4.0.1",
  "mapping": [
    {
      "identity": "workflow",
      "uri": "http://hl7.org/fhir/workflow",
      "name": "Workflow Pattern"
    },
    {
      "identity": "rim",
      "uri": "http://hl7.org/v3",
      "name": "RIM Mapping"
    },
    {
      "identity": "w5",
      "uri": "http://hl7.org/fhir/fivews",
      "name": "FiveWs Pattern Mapping"
    },
    {
      "identity": "v2",
      "uri": "http://hl7.org/v2",
      "name": "HL7 v2 Mapping"
    }
  ],
  "kind": "resource",
  "abstract": false,
  "type": "Task",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Task",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Task",
        "path": "Task",
        "definition": "This Task profile is used to solicit information from a system when direct query is not possible and human intervention might be required",
        "constraint": [
          {
            "key": "tdr-1",
            "severity": "error",
            "human": "Must have exactly one input that is data-query or data-code",
            "expression": "input.type.where(coding.where(system='http://hl7.org/fhir/us/davinci-hrex/CodeSystem/hrex-temp' and (code='data-code' or code='data-query')).exists()).count()=1"
          },
          {
            "key": "tdr-2",
            "severity": "error",
            "human": "Task statusReason SHALL be populated if status is 'rejected' or 'failed'",
            "expression": "(status = 'rejected' or status = 'failed') implies statusReason.exists()"
          },
          {
            "key": "tdr-3",
            "severity": "error",
            "human": "Task output SHALL be populated if status is 'completed'",
            "expression": "(status = 'completed') implies output.exists()"
          }
        ]
      },
      {
        "id": "Task.basedOn",
        "path": "Task.basedOn",
        "short": "Also known as Member identifier",
        "requirements": "Indicates the order (ServiceRequest, CommunicationRequest, etc.) that authorizes the data request",
        "mustSupport": true
      },
      {
        "id": "Task.status",
        "path": "Task.status",
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "http://hl7.org/fhir/us/davinci-hrex/ValueSet/hrex-task-status"
        }
      },
      {
        "id": "Task.statusReason",
        "path": "Task.statusReason",
        "requirements": "Indicates why task failed or was rejected.",
        "mustSupport": true
      },
      {
        "id": "Task.statusReason.text",
        "path": "Task.statusReason.text",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Task.businessStatus",
        "path": "Task.businessStatus",
        "short": "E.g. 'waiting on internal review'",
        "comment": "Conveys the internal business progress of the request and provides more nuance than the overall status.  There is no expectation this will be coded, but negotiation of agreed codes can be used between partners",
        "requirements": "Indicates progress in retrieving the data",
        "mustSupport": true
      },
      {
        "id": "Task.businessStatus.text",
        "path": "Task.businessStatus.text",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Task.intent",
        "path": "Task.intent",
        "fixedCode": "order",
        "mustSupport": true
      },
      {
        "id": "Task.code",
        "path": "Task.code",
        "min": 1,
        "patternCodeableConcept": {
          "coding": [
            {
              "system": "http://hl7.org/fhir/us/davinci-hrex/CodeSystem/hrex-temp",
              "code": "data-request"
            }
          ]
        },
        "mustSupport": true
      },
      {
        "id": "Task.for",
        "path": "Task.for",
        "short": "Member being queried",
        "comment": "Queries must always be in the scope of a single member",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Task.authoredOn",
        "path": "Task.authoredOn",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Task.requester",
        "path": "Task.requester",
        "short": "Who is asking for data",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/us/core/StructureDefinition/us-core-organization",
              "http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitioner"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Task.owner",
        "path": "Task.owner",
        "short": "Who is being asked for data",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/us/core/StructureDefinition/us-core-organization",
              "http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitioner"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Task.reasonCode",
        "path": "Task.reasonCode",
        "comment": "Only text is expected, though codes can be used for partners with agreed value sets",
        "requirements": "Indicates why the information request is occurring",
        "mustSupport": true
      },
      {
        "id": "Task.reasonCode.text",
        "path": "Task.reasonCode.text",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Task.reasonReference",
        "path": "Task.reasonReference",
        "comment": "Likely targets would be HRex Coverage, PCDE Claim (for prior authorization) or a bare Claim resource for referencing an actual Claim.",
        "requirements": "Indicates why the information request is occurring",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/Claim",
              "http://hl7.org/fhir/us/davinci-hrex/StructureDefinition/hrex-coverage"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Task.input",
        "path": "Task.input",
        "slicing": {
          "discriminator": [
            {
              "type": "pattern",
              "path": "type"
            }
          ],
          "rules": "open"
        },
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Task.input:query",
        "path": "Task.input",
        "sliceName": "query",
        "short": "Requested query",
        "definition": "Indicates the specific FHIR RESTful query to be executed",
        "comment": "This will contain the text that should go after the '?' when executing the query.",
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Task.input:query.type",
        "path": "Task.input.type",
        "patternCodeableConcept": {
          "coding": [
            {
              "system": "http://hl7.org/fhir/us/davinci-hrex/CodeSystem/hrex-temp",
              "code": "data-query"
            }
          ]
        },
        "mustSupport": true
      },
      {
        "id": "Task.input:query.value[x]",
        "path": "Task.input.value[x]",
        "short": "query value",
        "type": [
          {
            "code": "string"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Task.input:code",
        "path": "Task.input",
        "sliceName": "code",
        "short": "Requested data code",
        "definition": "A code indicating the type of data/document to be returned",
        "comment": "This might be a document code or other code describing the requested information.  If no appropriate standard code exists, local codes may be used between partners, or a human-readable textual description of the desired data can be provided.  Downstream profiles may tighten expectations for this element.",
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Task.input:code.type",
        "path": "Task.input.type",
        "patternCodeableConcept": {
          "coding": [
            {
              "system": "http://hl7.org/fhir/us/davinci-hrex/CodeSystem/hrex-temp",
              "code": "data-code"
            }
          ]
        },
        "mustSupport": true
      },
      {
        "id": "Task.input:code.value[x]",
        "path": "Task.input.value[x]",
        "short": "query value",
        "type": [
          {
            "code": "CodeableConcept"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Task.output",
        "path": "Task.output",
        "slicing": {
          "discriminator": [
            {
              "type": "pattern",
              "path": "type"
            }
          ],
          "rules": "open"
        },
        "mustSupport": true
      },
      {
        "id": "Task.output:data",
        "path": "Task.output",
        "sliceName": "data",
        "short": "Requested data",
        "definition": "The data content requested.  Multiple repetitions are permitted in the event that a single request returns multiple instances and packaging in a Bundle is not necessary/approrpriate.  Also, in most cases Provenance instances should accompany returned data so that the requester can best integrate and allocate trust/confidence to the provided data.",
        "mustSupport": true
      },
      {
        "id": "Task.output:data.type",
        "path": "Task.output.type",
        "patternCodeableConcept": {
          "coding": [
            {
              "system": "http://hl7.org/fhir/us/davinci-hrex/CodeSystem/hrex-temp",
              "code": "data-value"
            }
          ]
        },
        "mustSupport": true
      },
      {
        "id": "Task.output:data.value[x]",
        "path": "Task.output.value[x]",
        "short": "data reference",
        "comment": "The referenced data might be contained within the Task (if it doesn't have/shouldn't have independent persistence), but can also refer to data stored elsewhere - either on the owner's system or some other system.  Note that all returned data SHOULD comply with appropriate US-Core and/or Da Vinci profiles.",
        "type": [
          {
            "code": "Reference"
          }
        ],
        "mustSupport": true
      }
    ]
  }
}