GSoC 2020: Improve FHIR Search

Hi everyone, this is a thread for the project “Improve FHIR Search”. It basically involves providing a more exhaustive search for FHIR resources. The project goals for the same are as follows:

  • Adding the remaining essential search parameters for FHIR resources
  • Implementation of advanced search parameters like _include and _elements.
  • Use of the Lucene index available for certain resources to provide a LuceneQuery instead of a CriteriaQuery
  • Improvement to the paging work that has already been done for some resources
  • Integration with GraphQL.

Mentors for the project: @ibacher @reagan

6 Likes

Hi everyone,

This post is to highlight the project goals for phase 1 as discussed with @ibacher.

The goals include:

  • Implementation of common search parameters like _id and _lastUpdated. It can be seen that _id is very forced as a search parameter because it looks more like a read operation, but its significance can be seen when used with other advanced parameters like _include.
  • Implementation of paging for the remaining resources including location, encounter, person, diagnostic report etc.

Hi everyone, I am facing a small issue which I have not been able to resolve for a while. I am writing a criteria query to query drugs based on an ingredient code and have written the following:

criteria.createAlias("ingredients", "i"); criteria.createAlias("i.ingredient", "ic");

But from the logger, I see that the query generated is not as expected. The concept table is perhaps getting joined twice. Here is the generated query-

`select

    this_.drug_id as drug_id1_27_3_,
    this_.name as name2_27_3_,
    this_.combination as combinat3_27_3_,
    this_.maximum_daily_dose as maximum_4_27_3_,
    this_.minimum_daily_dose as minimum_5_27_3_,
    this_.strength as strength6_27_3_,
    this_.date_created as date_cre7_27_3_,
    this_.changed_by as changed_8_27_3_,
    this_.date_changed as date_cha9_27_3_,
    this_.retired as retired10_27_3_,
    this_.date_retired as date_re11_27_3_,
    this_.retire_reason as retire_12_27_3_,
    this_.concept_id as concept13_27_3_,
    this_.dosage_form as dosage_14_27_3_,
    this_.uuid as uuid15_27_3_,
    this_.creator as creator16_27_3_,
    this_.retired_by as retired17_27_3_,
    i1_.drug_id as drug_id1_28_0_,
    i1_.ingredient_id as ingredie2_28_0_,
    i1_.uuid as uuid3_28_0_,
    i1_.strength as strength4_28_0_,
    i1_.units as units5_28_0_,
    ic2_.concept_id as concept_1_6_1_,
    ic2_.uuid as uuid2_6_1_,
    ic2_.retired as retired3_6_1_,
    ic2_.date_created as date_cre4_6_1_,
    ic2_.version as version5_6_1_,
    ic2_.date_changed as date_cha6_6_1_,
    ic2_.is_set as is_set7_6_1_,
    ic2_.retire_reason as retire_r8_6_1_,
    ic2_.date_retired as date_ret9_6_1_,
    ic2_.retired_by as retired10_6_1_,
    ic2_.datatype_id as datatyp11_6_1_,
    ic2_.class_id as class_i12_6_1_,
    ic2_.changed_by as changed13_6_1_,
    ic2_.creator as creator14_6_1_,
    ic2_1_.hi_absolute as hi_absol2_18_1_,
    ic2_1_.hi_critical as hi_criti3_18_1_,
    ic2_1_.hi_normal as hi_norma4_18_1_,
    ic2_1_.low_absolute as low_abso5_18_1_,
    ic2_1_.low_critical as low_crit6_18_1_,
    ic2_1_.low_normal as low_norm7_18_1_,
    ic2_1_.units as units8_18_1_,
    ic2_1_.precise as precise9_18_1_,
    ic2_1_.display_precision as display10_18_1_,
    ic2_2_.handler as handler2_11_1_,
    case 
        when ic2_1_.concept_id is not null then 1 
        when ic2_2_.concept_id is not null then 2 
        when ic2_.concept_id is not null then 0 
    end as clazz_1_,
    ic2_.concept_id as concept_1_6_2_,
    ic2_.uuid as uuid2_6_2_,
    ic2_.retired as retired3_6_2_,
    ic2_.date_created as date_cre4_6_2_,
    ic2_.version as version5_6_2_,
    ic2_.date_changed as date_cha6_6_2_,
    ic2_.is_set as is_set7_6_2_,
    ic2_.retire_reason as retire_r8_6_2_,
    ic2_.date_retired as date_ret9_6_2_,
    ic2_.retired_by as retired10_6_2_,
    ic2_.datatype_id as datatyp11_6_2_,
    ic2_.class_id as class_i12_6_2_,
    ic2_.changed_by as changed13_6_2_,
    ic2_.creator as creator14_6_2_,
    ic2_1_.hi_absolute as hi_absol2_18_2_,
    ic2_1_.hi_critical as hi_criti3_18_2_,
    ic2_1_.hi_normal as hi_norma4_18_2_,
    ic2_1_.low_absolute as low_abso5_18_2_,
    ic2_1_.low_critical as low_crit6_18_2_,
    ic2_1_.low_normal as low_norm7_18_2_,
    ic2_1_.units as units8_18_2_,
    ic2_1_.precise as precise9_18_2_,
    ic2_1_.display_precision as display10_18_2_,
    ic2_2_.handler as handler2_11_2_,
    case 
        when ic2_1_.concept_id is not null then 1 
        when ic2_2_.concept_id is not null then 2 
        when ic2_.concept_id is not null then 0 
    end as clazz_2_ 
from
    drug this_ 
inner join
    drug_ingredient i1_ 
        on this_.drug_id=i1_.drug_id 
inner join
    concept ic2_ 
        on i1_.ingredient_id=ic2_.concept_id 
left outer join
    concept_numeric ic2_1_ 
        on ic2_.concept_id=ic2_1_.concept_id 
left outer join
    concept_complex ic2_2_ 
        on ic2_.concept_id=ic2_2_.concept_id 
inner join
    concept ic2_ 
        on i1_.ingredient_id=ic2_.concept_id 
left outer join
    concept_numeric ic2_1_ 
        on ic2_.concept_id=ic2_1_.concept_id 
left outer join
    concept_complex ic2_2_ 
        on ic2_.concept_id=ic2_2_.concept_id 
where
    (
        (
            (
                ic2_.concept_id in (
                    ?
                ) 
                or ic2_.uuid in (
                    ?
                )
            )
        )
    ) limit ?

Due to this, I am gettting an ambiguous column name "CONCEPT_ID" error, as it is not able to distinguish between the multiple columns that are getting generated. I’d be grateful if somebody can help. Thanks. Pull request link for reference - https://github.com/openmrs/openmrs-module-fhir2/pull/199 `