Hapi FHIR search for resource with identifier of specific value, or identifier not defined

108 Views Asked by At

Using the IGenericClient/IQuery, it is possible to perform a search for a resource in fhir, by using the following code:

Bundle bundle = genericFhirClient.search()
        .forResource(Person.class)
        .where(Person.IDENTIFIER.exactly().systemAndValues(STATUS, STATUS_READY))
        ...
        .returnBundle(Bundle.class)
        ...
        .execute();

Is is possible to extend this search by adding an "or"-clause for Persons who does not have the identifier STATUS defined at all? Something like this:

    Bundle bundle = genericFhirClient.search()
        .forResource(Person.class)
        .where(Person.IDENTIFIER.exactly().systemAndValues(STATUS, STATUS_READY))
        .or(Person.IDENTIFIER.doesNotExist(STATUS))
        ...
        .returnBundle(Bundle.class)
        ...
        .execute();

Alternatively a search for all persons excluding statuses of value executing and error would also work. Something like this:

Bundle bundle = genericFhirClient.search()
        .forResource(Person.class)
        .where(Person.IDENTIFIER.exactly().systemAndValues(STATUS, STATUS_READY))
        ...
        .returnBundle(Bundle.class)
        ...
        .execute();

Is is possible to extend this search by adding a clause for Persons who does not have the identifier STATUS defined at all? Something like this:

    Bundle bundle = genericFhirClient.search()
        .forResource(Person.class)
        .where(!Person.IDENTIFIER.exactly().systemAndValues(STATUS, STATUS_EXECUTING))
        .and(!Person.IDENTIFIER.exactly().systemAndValues(STATUS, STATUS_ERROR))
        ...
        .returnBundle(Bundle.class)
        ...
        .execute();

Note the exclamation marks as a rudimentary attempt of making a "not"-syntax.

I've gone through official documentation, and examples, but I have not been able to find anything that works. I also thought of filtering the returned bundles instead, but the amount of possible results, and maybe pagination issues, made med drop that approach for the time being.

Is my question even possible in HAPI-FHIR, through IQuery?

0

There are 0 best solutions below