android-fhir icon indicating copy to clipboard operation
android-fhir copied to clipboard

Fhir engine search does not return correct data.

Open mansikalraa opened this issue 1 year ago • 4 comments

Describe the Issue Fhir engine search does not return correct data when using include.

when try to replicate the query

%HOST_URL%/Encounter?type=%SYSTEM_URL%|%CODE%&status=%STATUS%&_include=Encounter:patient:Patient&_elements=_id,type,status&_total=accurate

with fhir engine search method :

      fhirEngine.search(ResourceType.Encounter) {
                filter(
                    Encounter.TYPE, {
                        value = of(Coding("%SYSTEM_URL%", "%CODE%", ""))
                    }
                )
                filter(
                    Encounter.STATUS, {
                        value = of("%STATUS%")
                    }
                )
                include(ResourceType.Patient, Encounter.SUBJECT)
            }

The fhir engine does not return any Patient resouce (patient resource should be returned, checked on our server)

Tried using Encounter.Patient in resource reference as well.

I could not find any documentation on how to use include with the search in fhir engine. Is the code incorrect, or is it not returning the correct value?

@jingtang10 @fredhersch help would be appreciated.

Would you like to work on the issue?

mansikalraa avatar Oct 11 '23 12:10 mansikalraa

@mansikalraa Could you please provide some test data ( encounters + associated patients) for us to test on our end?

aditya-07 avatar Oct 19 '23 09:10 aditya-07

@williamito can you please help improving documentation for include / revinclude.

jingtang10 avatar Feb 07 '24 08:02 jingtang10

@mansikalraa thanks for raising this issue. can you please provide some test data as @aditya-07 requested?

jingtang10 avatar Feb 07 '24 08:02 jingtang10

@jingtang10 @aditya-07 Thank you for the response. While exploring the search feature, I was able to find how to retrieve the included resouce successfully.

fhirEngine.search(ResourceType.Encounter) {
                filter(
                    Encounter.TYPE, {
                        value = of(Coding("%SYSTEM_URL%", "%CODE%", ""))
                    }
                )
                filter(
                    Encounter.STATUS, {
                        value = of("%STATUS%")
                    }
                )
                include(ResourceType.Patient, Encounter.SUBJECT)
            }.forEach { searchResult ->
                  val includedResource = searchResult.included?.get(Encounter.SUBJECT.paramName)[0] as Patient
            }
        }

mansikalraa avatar Mar 08 '24 06:03 mansikalraa