1

I'm using FHIR R4 with Hapi FHIR API.

I want to know how marked the ServiceRequest resources with information about created user.

I've read the FHIR documentation and I've found the relevantHistory tag where I can put there a Provenance reference.

All good but the HAPI Fhir can't query that field/tag so I can't get all ServiceRequests created by me or another user.

I've also tried to use a customize extension named tracking, where I've put the tracking user info.

I don't want to use a requester tag because, it is filled with other guide line meaning supplied by customer

EDIT AFTER Mirjam Baltus

Hi, interesting your point of view but, I've found another solution as follow, I want to discuss it with you (if you want).

I've added a SearchParameter resource attached on ServiceRequest to allow the search on relevantHistory field.

This is the JSON resource:

{
    "resourceType": "SearchParameter",
    "id": "6589",
    "meta": {
        "versionId": "7",
        "lastUpdated": "2021-02-25T11:25:25.549+00:00",
        "source": "#1btUOFbG0D3dMdwI"
    },
    "title": "Storia",
    "status": "active",
    "code": "relevantHistory",
    "base": [
        "ServiceRequest"
    ],
    "type": "reference",
    "expression": "ServiceRequest.relevantHistory",
    "xpathUsage": "normal",
    "target": [
        "Provenance"
    ],
    "modifier": [
        "missing"
    ],
    "chain": [
        "reference"
    ]
}

So I've written a query on ServiceRequest filtered by relevantHistory field (linked to Provenance).

I've adopted this strategy because I need to know only the creator of ServiceRerquest, so in this way, I've factorized the information in Provenance resource where in the target field I've put the Practitioner / Organization who created the ServiceRequest and in the agent component I've replicated this information with ENTERER value in the enum AgentRole and AgentType.

In this way, I've collected one Provenance for more ServiceRequests, instead If I follow your way, I'll have for each ServiceRequest a dedicated Provenance.

You think I've followed a wrong way or it is a possible solution?

Joe Taras
  • 15,166
  • 7
  • 42
  • 55
  • After your edit, something to consider for Provenance is this: "The Provenance resource corresponds to a single activity that identifies a set of resources (target) generated by the activity." So you could only use the Provenance if the ServiceRequests are all created in one activity. Also, the relevantHistory field "SHALL NOT include the Provenance associated with this current version of the resource." so that would not match with what you intend. I've edited my answer to add another option. – Mirjam Baltus Feb 27 '21 at 11:51

1 Answers1

1

The relevantHistory is not the right field to use, since that will only list older Provenance resources that hold relevant information. The description specifically says it does not hold the Provenance resource associated with the current version of the ServiceRequest (see http://hl7.org/fhir/servicerequest-definitions.html#ServiceRequest.relevantHistory).

I think Provenance can still help you. You would not search on a field in ServiceRequest, but find ServiceRequests that have a Provenance where you/user are the actor:

GET [base]/ServiceRequest?_has:Provenance:target:actor=[user_reference]

Or approach it the other way around, by looking for Provenance resources from the user, and including ServiceRequests that are the target of the Provenance.

Added after edit of original post:

As I mention in my comment, I think the way you are trying to use the relevantHistory field and one Provenance for multiple ServiceRequests is not according to how that field and resource type are supposed to be used.

If you are able to create a custom search parameter, why not use an extension on the ServiceRequest to indicate who created it, and then make that extension searchable? If you want more discussion about this, please ask on https://chat.fhir.org, where more people from the FHIR community will be able to chime in.

Mirjam Baltus
  • 2,035
  • 9
  • 13
  • Dear thank you very much for your reply, I've updated my question after your considerations. If you want, we can discuss – Joe Taras Feb 26 '21 at 07:53