From 736578fb4e2db009d096ebd7a84ae546ac2ace95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=E2=89=A1ZRS?= <12814349+LZRS@users.noreply.github.com> Date: Wed, 18 Dec 2024 13:13:41 +0300 Subject: [PATCH] Prefer use of `resourceUuid` index over `resourceType` when selecting from `resourceentity` table (#2739) * Remove resourceType when searching with resourceUuid * Remove inOrder assertion for search results not sorted * Fix NumberSearchParameterizedTest with correct query * Add SearchResultCorrespondenceUnorderedIncludeRevInclude Switching from resourceType multi-column index to resourceUuid, the order of results in include/revInclude is no longer predictable since the resourceUuids are randomly generated, also saved in the db as blob and hence ordered by byte representation of the resourceUuid * Refactor filterStatement to include ifBlank * Revert add Unit type in DatabaseImplTest test methods --------- Co-authored-by: Benjamin Mwalimu --- .../android/fhir/db/impl/DatabaseImplTest.kt | 382 ++++++++++-------- .../google/android/fhir/search/MoreSearch.kt | 61 +-- .../android/fhir/search/NestedSearch.kt | 2 +- .../search/NumberSearchParameterizedTest.kt | 12 +- .../google/android/fhir/search/SearchTest.kt | 278 ++++--------- 5 files changed, 323 insertions(+), 412 deletions(-) diff --git a/engine/src/androidTest/java/com/google/android/fhir/db/impl/DatabaseImplTest.kt b/engine/src/androidTest/java/com/google/android/fhir/db/impl/DatabaseImplTest.kt index 1807b4b2d6..e8e7876358 100644 --- a/engine/src/androidTest/java/com/google/android/fhir/db/impl/DatabaseImplTest.kt +++ b/engine/src/androidTest/java/com/google/android/fhir/db/impl/DatabaseImplTest.kt @@ -2633,92 +2633,93 @@ class DatabaseImplTest { } @Test - fun search_filter_param_values_disjunction_covid_immunization_records() = runBlocking { - val resources = - listOf( - Immunization().apply { - id = "immunization-1" - vaccineCode = - CodeableConcept( - Coding( - "http://id.who.int/icd11/mms", - "XM1NL1", - "COVID-19 vaccine, inactivated virus", - ), - ) - status = Immunization.ImmunizationStatus.COMPLETED - }, - Immunization().apply { - id = "immunization-2" - vaccineCode = - CodeableConcept( - Coding( - "http://id.who.int/icd11/mms", - "XM5DF6", - "COVID-19 vaccine, live attenuated virus", - ), - ) - status = Immunization.ImmunizationStatus.COMPLETED - }, - Immunization().apply { - id = "immunization-3" - vaccineCode = - CodeableConcept( - Coding("http://id.who.int/icd11/mms", "XM6AT1", "COVID-19 vaccine, DNA based"), - ) - status = Immunization.ImmunizationStatus.COMPLETED - }, - Immunization().apply { - id = "immunization-4" - vaccineCode = - CodeableConcept( - Coding( - "http://hl7.org/fhir/sid/cvx", - "140", - "Influenza, seasonal, injectable, preservative free", - ), - ) - status = Immunization.ImmunizationStatus.COMPLETED - }, - ) + fun search_filter_param_values_disjunction_covid_immunization_records() { + runBlocking { + val resources = + listOf( + Immunization().apply { + id = "immunization-1" + vaccineCode = + CodeableConcept( + Coding( + "http://id.who.int/icd11/mms", + "XM1NL1", + "COVID-19 vaccine, inactivated virus", + ), + ) + status = Immunization.ImmunizationStatus.COMPLETED + }, + Immunization().apply { + id = "immunization-2" + vaccineCode = + CodeableConcept( + Coding( + "http://id.who.int/icd11/mms", + "XM5DF6", + "COVID-19 vaccine, live attenuated virus", + ), + ) + status = Immunization.ImmunizationStatus.COMPLETED + }, + Immunization().apply { + id = "immunization-3" + vaccineCode = + CodeableConcept( + Coding("http://id.who.int/icd11/mms", "XM6AT1", "COVID-19 vaccine, DNA based"), + ) + status = Immunization.ImmunizationStatus.COMPLETED + }, + Immunization().apply { + id = "immunization-4" + vaccineCode = + CodeableConcept( + Coding( + "http://hl7.org/fhir/sid/cvx", + "140", + "Influenza, seasonal, injectable, preservative free", + ), + ) + status = Immunization.ImmunizationStatus.COMPLETED + }, + ) - database.insert(*resources.toTypedArray()) + database.insert(*resources.toTypedArray()) - val result = - database.search( - Search(ResourceType.Immunization) - .apply { - filter( - Immunization.VACCINE_CODE, - { - value = - of( - Coding( - "http://id.who.int/icd11/mms", - "XM1NL1", - "COVID-19 vaccine, inactivated virus", - ), - ) - }, - { - value = - of( - Coding( - "http://id.who.int/icd11/mms", - "XM5DF6", - "COVID-19 vaccine, inactivated virus", - ), - ) - }, - operation = Operation.OR, - ) - } - .getQuery(), - ) + val result = + database.search( + Search(ResourceType.Immunization) + .apply { + filter( + Immunization.VACCINE_CODE, + { + value = + of( + Coding( + "http://id.who.int/icd11/mms", + "XM1NL1", + "COVID-19 vaccine, inactivated virus", + ), + ) + }, + { + value = + of( + Coding( + "http://id.who.int/icd11/mms", + "XM5DF6", + "COVID-19 vaccine, inactivated virus", + ), + ) + }, + operation = Operation.OR, + ) + } + .getQuery(), + ) - assertThat(result.map { it.resource.vaccineCode.codingFirstRep.code }) - .containsExactly("XM1NL1", "XM5DF6") - .inOrder() + assertThat(result.map { it.resource.vaccineCode.codingFirstRep.code }) + .containsExactly("XM1NL1", "XM5DF6") + } } @Test @@ -2797,95 +2798,96 @@ class DatabaseImplTest { } @Test - fun test_search_multiple_param_conjunction_with_multiple_values_disjunction() = runBlocking { - val resources = - listOf( - Patient().apply { - id = "patient-01" - addName( - HumanName().apply { - addGiven("John") - family = "Doe" - }, - ) - }, - Patient().apply { - id = "patient-02" - addName( - HumanName().apply { - addGiven("Jane") - family = "Doe" - }, - ) - }, - Patient().apply { - id = "patient-03" - addName( - HumanName().apply { - addGiven("John") - family = "Roe" - }, - ) - }, - Patient().apply { - id = "patient-04" - addName( - HumanName().apply { - addGiven("Jane") - family = "Roe" - }, - ) - }, - Patient().apply { - id = "patient-05" - addName( - HumanName().apply { - addGiven("Rocky") - family = "Balboa" - }, - ) - }, - ) - database.insert(*resources.toTypedArray()) - - val result = - database.search( - Search(ResourceType.Patient) - .apply { - filter( - Patient.GIVEN, - { - value = "John" - modifier = StringFilterModifier.MATCHES_EXACTLY + fun test_search_multiple_param_conjunction_with_multiple_values_disjunction() { + runBlocking { + val resources = + listOf( + Patient().apply { + id = "patient-01" + addName( + HumanName().apply { + addGiven("John") + family = "Doe" }, - { - value = "Jane" - modifier = StringFilterModifier.MATCHES_EXACTLY + ) + }, + Patient().apply { + id = "patient-02" + addName( + HumanName().apply { + addGiven("Jane") + family = "Doe" }, - operation = Operation.OR, ) - - filter( - Patient.FAMILY, - { - value = "Doe" - modifier = StringFilterModifier.MATCHES_EXACTLY + }, + Patient().apply { + id = "patient-03" + addName( + HumanName().apply { + addGiven("John") + family = "Roe" }, - { - value = "Roe" - modifier = StringFilterModifier.MATCHES_EXACTLY + ) + }, + Patient().apply { + id = "patient-04" + addName( + HumanName().apply { + addGiven("Jane") + family = "Roe" + }, + ) + }, + Patient().apply { + id = "patient-05" + addName( + HumanName().apply { + addGiven("Rocky") + family = "Balboa" }, - operation = Operation.OR, ) + }, + ) + database.insert(*resources.toTypedArray()) - operation = Operation.AND - } - .getQuery(), - ) + val result = + database.search( + Search(ResourceType.Patient) + .apply { + filter( + Patient.GIVEN, + { + value = "John" + modifier = StringFilterModifier.MATCHES_EXACTLY + }, + { + value = "Jane" + modifier = StringFilterModifier.MATCHES_EXACTLY + }, + operation = Operation.OR, + ) - assertThat(result.map { it.resource.nameFirstRep.nameAsSingleString }) - .containsExactly("John Doe", "Jane Doe", "John Roe", "Jane Roe") - .inOrder() + filter( + Patient.FAMILY, + { + value = "Doe" + modifier = StringFilterModifier.MATCHES_EXACTLY + }, + { + value = "Roe" + modifier = StringFilterModifier.MATCHES_EXACTLY + }, + operation = Operation.OR, + ) + + operation = Operation.AND + } + .getQuery(), + ) + + assertThat(result.map { it.resource.nameFirstRep.nameAsSingleString }) + .containsExactly("John Doe", "Jane Doe", "John Roe", "Jane Roe") + } } @Test @@ -3137,7 +3139,6 @@ class DatabaseImplTest { revIncluded = null, ), ) - .inOrder() } @Test @@ -3230,7 +3231,6 @@ class DatabaseImplTest { mapOf((ResourceType.Condition to Condition.SUBJECT.paramName) to listOf(con3)), ), ) - .inOrder() } @Test @@ -3534,7 +3534,7 @@ class DatabaseImplTest { .execute(database) assertThat(result) - .comparingElementsUsing(SearchResultCorrespondence) + .comparingElementsUsing(SearchResultCorrespondenceUnorderedIncludeRevInclude) .displayingDiffsPairedBy { it.resource.logicalId } .containsExactly( SearchResult( @@ -3576,7 +3576,6 @@ class DatabaseImplTest { ), ), ) - .inOrder() } @Test @@ -3695,11 +3694,10 @@ class DatabaseImplTest { revIncluded = null, ), ) - .inOrder() } @Test - fun search_patient_and_revinclude_person_should_map_common_person_to_all_matching_patients() = + fun search_patient_and_revinclude_person_should_map_common_person_to_all_matching_patients() { runBlocking { val person1 = Person().apply { @@ -3813,8 +3811,8 @@ class DatabaseImplTest { mapOf(Pair(ResourceType.Person, Person.LINK.paramName) to listOf(person2, person3)), ), ) - .inOrder() } + } @Test fun search_patient_and_revInclude_encounters_sorted_by_date_descending(): Unit = runBlocking { @@ -5239,6 +5237,18 @@ class DatabaseImplTest { ) .formattingDiffsUsing(::formatDiff) + /** + * [Correspondence] to provide a custom [equalityCheck] for the [SearchResult]s whereby + * [SearchResult.included] and [SearchResult.revIncluded] may not be in the correct order + */ + val SearchResultCorrespondenceUnorderedIncludeRevInclude: + Correspondence, SearchResult> = + Correspondence.from, SearchResult>( + ::equalityCheckUnordered, + "is shallow equals (by logical id comparison) to the ", + ) + .formattingDiffsUsing(::formatDiff) + private fun equalityCheck( actual: SearchResult, expected: SearchResult, @@ -5248,6 +5258,15 @@ class DatabaseImplTest { equalsShallow(actual.revIncluded, expected.revIncluded) } + private fun equalityCheckUnordered( + actual: SearchResult, + expected: SearchResult, + ): Boolean { + return equalsShallow(actual.resource, expected.resource) && + equalsShallow(actual.included, expected.included, inOrder = false) && + equalsShallow(actual.revIncluded, expected.revIncluded, inOrder = false) + } + private fun equalsShallow(first: Resource, second: Resource) = first.resourceType == second.resourceType && first.logicalId == second.logicalId @@ -5255,13 +5274,24 @@ class DatabaseImplTest { first.size == second.size && first.asSequence().zip(second.asSequence()).all { (x, y) -> equalsShallow(x, y) } + private fun resourceTypeAndIdEqualUnordered(first: List, second: List) = + first.size == second.size && + first.map { it.resourceType to it.logicalId }.toSet() == + second.map { it.resourceType to it.logicalId }.toSet() + private fun equalsShallow( first: Map>?, second: Map>?, + inOrder: Boolean = true, ) = if (first != null && second != null && first.size == second.size) { first.entries.asSequence().zip(second.entries.asSequence()).all { (x, y) -> - x.key == y.key && equalsShallow(x.value, y.value) + x.key == y.key && + if (inOrder) { + equalsShallow(x.value, y.value) + } else { + resourceTypeAndIdEqualUnordered(x.value, y.value) + } } } else { first?.size == second?.size @@ -5271,10 +5301,16 @@ class DatabaseImplTest { private fun equalsShallow( first: Map, List>?, second: Map, List>?, + inOrder: Boolean = true, ) = if (first != null && second != null && first.size == second.size) { first.entries.asSequence().zip(second.entries.asSequence()).all { (x, y) -> - x.key == y.key && equalsShallow(x.value, y.value) + x.key == y.key && + if (inOrder) { + equalsShallow(x.value, y.value) + } else { + resourceTypeAndIdEqualUnordered(x.value, y.value) + } } } else { first?.size == second?.size diff --git a/engine/src/main/java/com/google/android/fhir/search/MoreSearch.kt b/engine/src/main/java/com/google/android/fhir/search/MoreSearch.kt index e12919b8d7..daa577b68f 100644 --- a/engine/src/main/java/com/google/android/fhir/search/MoreSearch.kt +++ b/engine/src/main/java/com/google/android/fhir/search/MoreSearch.kt @@ -116,7 +116,6 @@ internal fun Search.getRevIncludeQuery(includeIds: List): SearchQuery { args.add(resourceToInclude.name) args.add(param.paramName) args.addAll(includeIds) - args.add(resourceToInclude.name) var filterQuery = "" val filters = search.getFilterQueries() @@ -136,6 +135,7 @@ internal fun Search.getRevIncludeQuery(includeIds: List): SearchQuery { } } } + if (filters.isEmpty()) args.add(resourceToInclude.name) return filterQuery } @@ -151,8 +151,8 @@ internal fun Search.getRevIncludeQuery(includeIds: List): SearchQuery { JOIN ReferenceIndexEntity rie ON re.resourceUuid = rie.resourceUuid ${join.query} - WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.index_value IN ($uuidsString) AND re.resourceType = ? - ${if (filterQuery.isNotEmpty()) "AND re.resourceUuid IN ($filterQuery)" else ""} + WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.index_value IN ($uuidsString) + ${if (filterQuery.isNotBlank()) "AND re.resourceUuid IN ($filterQuery)" else "AND re.resourceType = ?"} $order """ .trimIndent() @@ -179,7 +179,6 @@ internal fun Search.getIncludeQuery(includeIds: List): SearchQuery { args.add(baseResourceType.name) args.add(param.paramName) args.addAll(includeIds.map { convertUUIDToByte(it) }) - args.add(resourceToInclude.name) var filterQuery = "" val filters = search.getFilterQueries() @@ -199,6 +198,7 @@ internal fun Search.getIncludeQuery(includeIds: List): SearchQuery { } } } + if (filters.isEmpty()) args.add(resourceToInclude.name) return filterQuery } @@ -214,8 +214,8 @@ internal fun Search.getIncludeQuery(includeIds: List): SearchQuery { JOIN ReferenceIndexEntity rie ON re.resourceType||"/"||re.resourceId = rie.index_value ${join.query} - WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.resourceUuid IN ($uuidsString) AND re.resourceType = ? - ${if (filterQuery.isNotEmpty()) "AND re.resourceUuid IN ($filterQuery)" else ""} + WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.resourceUuid IN ($uuidsString) + ${if (filterQuery.isNotBlank()) "AND re.resourceUuid IN ($filterQuery)" else "AND re.resourceType = ?"} $order """ .trimIndent() @@ -363,21 +363,19 @@ internal fun Search.getQuery( val sortOrderStatement = order val sortArgs = join.args - var filterStatement = "" - val filterArgs = mutableListOf() val filterQuery = getFilterQueries() - filterQuery.forEachIndexed { i, it -> - filterStatement += + val filterQueryStatement = + filterQuery.joinToString(separator = "${operation.logicalOperator} ") { // spotless:off - """ - ${if (i == 0) "AND a.resourceUuid IN (" else "a.resourceUuid IN ("} + """ + a.resourceUuid IN ( ${it.query} ) - ${if (i != filterQuery.lastIndex) "${operation.logicalOperator} " else ""} + """.trimIndent() // spotless:on - filterArgs.addAll(it.args) - } + } + val filterQueryArgs = filterQuery.flatMap { it.args } var limitStatement = "" val limitArgs = mutableListOf() @@ -390,10 +388,20 @@ internal fun Search.getQuery( } } - nestedSearches.nestedQuery(type, operation)?.let { - filterStatement += it.query - filterArgs.addAll(it.args) - } + val nestedFilterQuery = nestedSearches.nestedQuery(type, operation) + val nestedQueryFilterStatement = nestedFilterQuery?.query ?: "" + val nestedQueryFilterArgs = nestedFilterQuery?.args ?: emptyList() + + // Combines filter statements derived from filter queries and nested queries, that use the + // resourceUuid field, + // and defaults to filter statement with the resourceType field when blank + val filterStatement = + listOf(filterQueryStatement, nestedQueryFilterStatement) + .filter { it.isNotBlank() } + .joinToString(separator = " AND ") + .ifBlank { "a.resourceType = ?" } + val filterArgs = (filterQueryArgs + nestedQueryFilterArgs).ifEmpty { listOf(type.name) } + val whereArgs = mutableListOf() val nestedArgs = mutableListOf() val query = @@ -404,8 +412,7 @@ internal fun Search.getQuery( SELECT COUNT(*) FROM ResourceEntity a $sortJoinStatement - WHERE a.resourceType = ? - $filterStatement + WHERE $filterStatement $sortOrderStatement $limitStatement """ @@ -423,8 +430,7 @@ internal fun Search.getQuery( SELECT substr(a.index_value, $start) FROM ReferenceIndexEntity a $sortJoinStatement - WHERE a.resourceType = ? AND a.index_name = ? - $filterStatement + WHERE a.index_name = ? AND $filterStatement $sortOrderStatement $limitStatement) """ @@ -436,8 +442,7 @@ internal fun Search.getQuery( SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a $sortJoinStatement - WHERE a.resourceType = ? - $filterStatement + WHERE $filterStatement $sortOrderStatement $limitStatement """ @@ -446,7 +451,11 @@ internal fun Search.getQuery( .split("\n") .filter { it.isNotBlank() } .joinToString("\n") { it.trim() } - return SearchQuery(query, nestedArgs + sortArgs + type.name + whereArgs + filterArgs + limitArgs) + + return SearchQuery( + query, + nestedArgs + sortArgs + whereArgs + filterArgs + limitArgs, + ) } private val Order?.sqlString: String diff --git a/engine/src/main/java/com/google/android/fhir/search/NestedSearch.kt b/engine/src/main/java/com/google/android/fhir/search/NestedSearch.kt index 4818680ec5..1f39a00c32 100644 --- a/engine/src/main/java/com/google/android/fhir/search/NestedSearch.kt +++ b/engine/src/main/java/com/google/android/fhir/search/NestedSearch.kt @@ -219,7 +219,7 @@ internal fun List.nestedQuery( SearchQuery( query = searchQueries.joinToString( - prefix = "AND a.resourceUuid IN ", + prefix = "a.resourceUuid IN ", separator = " ${operation.logicalOperator} a.resourceUuid IN", ) { searchQuery -> "(\n${searchQuery.query}\n) " diff --git a/engine/src/test/java/com/google/android/fhir/search/NumberSearchParameterizedTest.kt b/engine/src/test/java/com/google/android/fhir/search/NumberSearchParameterizedTest.kt index 7dcb4e177d..a7f597bedb 100644 --- a/engine/src/test/java/com/google/android/fhir/search/NumberSearchParameterizedTest.kt +++ b/engine/src/test/java/com/google/android/fhir/search/NumberSearchParameterizedTest.kt @@ -53,8 +53,7 @@ class NumberSearchParameterizedTest( """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM NumberIndexEntity """ .trimIndent() @@ -86,7 +85,6 @@ class NumberSearchParameterizedTest( assertThat(search.args) .isEqualTo( listOf( - ResourceType.RiskAssessment.name, ResourceType.RiskAssessment.name, RiskAssessment.PROBABILITY.paramName, lowerBound.toDouble(), @@ -122,7 +120,6 @@ class NumberSearchParameterizedTest( assertThat(search.args) .isEqualTo( listOf( - ResourceType.RiskAssessment.name, ResourceType.RiskAssessment.name, RiskAssessment.PROBABILITY.paramName, lowerBound.toDouble(), @@ -158,7 +155,6 @@ class NumberSearchParameterizedTest( assertThat(search.args) .isEqualTo( listOf( - ResourceType.RiskAssessment.name, ResourceType.RiskAssessment.name, RiskAssessment.PROBABILITY.paramName, num.toDouble(), @@ -193,7 +189,6 @@ class NumberSearchParameterizedTest( assertThat(search.args) .isEqualTo( listOf( - ResourceType.RiskAssessment.name, ResourceType.RiskAssessment.name, RiskAssessment.PROBABILITY.paramName, num.toDouble(), @@ -228,7 +223,6 @@ class NumberSearchParameterizedTest( assertThat(search.args) .isEqualTo( listOf( - ResourceType.RiskAssessment.name, ResourceType.RiskAssessment.name, RiskAssessment.PROBABILITY.paramName, num.toDouble(), @@ -262,7 +256,6 @@ class NumberSearchParameterizedTest( assertThat(search.args) .isEqualTo( listOf( - ResourceType.RiskAssessment.name, ResourceType.RiskAssessment.name, RiskAssessment.PROBABILITY.paramName, num.toDouble(), @@ -317,7 +310,6 @@ class NumberSearchParameterizedTest( assertThat(search.args) .isEqualTo( listOf( - ResourceType.RiskAssessment.name, ResourceType.RiskAssessment.name, RiskAssessment.PROBABILITY.paramName, num.toDouble(), @@ -372,7 +364,6 @@ class NumberSearchParameterizedTest( assertThat(search.args) .isEqualTo( listOf( - ResourceType.RiskAssessment.name, ResourceType.RiskAssessment.name, RiskAssessment.PROBABILITY.paramName, num.toDouble(), @@ -407,7 +398,6 @@ class NumberSearchParameterizedTest( assertThat(search.args) .isEqualTo( listOf( - ResourceType.RiskAssessment.name, ResourceType.RiskAssessment.name, RiskAssessment.PROBABILITY.paramName, 0.09, diff --git a/engine/src/test/java/com/google/android/fhir/search/SearchTest.kt b/engine/src/test/java/com/google/android/fhir/search/SearchTest.kt index 6fea58fc2a..2ddb427a55 100644 --- a/engine/src/test/java/com/google/android/fhir/search/SearchTest.kt +++ b/engine/src/test/java/com/google/android/fhir/search/SearchTest.kt @@ -156,8 +156,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM DateIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_from BETWEEN ? AND ? AND index_to BETWEEN ? AND ?) ) @@ -178,7 +177,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.BIRTHDATE.paramName, diffStart, @@ -209,8 +207,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM DateIndexEntity WHERE resourceType = ? AND index_name = ? AND index_from > ? ) @@ -221,7 +218,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.BIRTHDATE.paramName, DateTimeType("2013-03-14").value.epochDay, @@ -249,8 +245,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM DateIndexEntity WHERE resourceType = ? AND index_name = ? AND index_to < ? ) @@ -261,7 +256,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.BIRTHDATE.paramName, DateTimeType("2013-03-14").value.epochDay, @@ -289,8 +283,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM DateIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_from NOT BETWEEN ? AND ? OR index_to NOT BETWEEN ? AND ?) ) @@ -301,7 +294,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.BIRTHDATE.paramName, DateType("2013-03-14").value.epochDay, @@ -324,8 +316,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM DateIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_from BETWEEN ? AND ? AND index_to BETWEEN ? AND ?) ) @@ -336,7 +327,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.BIRTHDATE.paramName, DateType("2013-03-14").value.epochDay, @@ -367,8 +357,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM DateIndexEntity WHERE resourceType = ? AND index_name = ? AND index_to > ? ) @@ -379,7 +368,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.BIRTHDATE.paramName, DateTimeType("2013-03-14").value.epochDay, @@ -407,8 +395,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM DateIndexEntity WHERE resourceType = ? AND index_name = ? AND index_to >= ? ) @@ -419,7 +406,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.BIRTHDATE.paramName, DateTimeType("2013-03-14").value.epochDay, @@ -447,8 +433,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM DateIndexEntity WHERE resourceType = ? AND index_name = ? AND index_from < ? ) @@ -459,7 +444,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.BIRTHDATE.paramName, DateType("2013-03-14").value.epochDay, @@ -487,8 +471,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM DateIndexEntity WHERE resourceType = ? AND index_name = ? AND index_from <= ? ) @@ -499,7 +482,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.BIRTHDATE.paramName, DateType("2013-03-14").value.epochDay, @@ -532,8 +514,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM DateTimeIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_from BETWEEN ? AND ? AND index_to BETWEEN ? AND ?) ) @@ -555,7 +536,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.BIRTHDATE.paramName, diffStart, @@ -586,8 +566,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM DateTimeIndexEntity WHERE resourceType = ? AND index_name = ? AND index_from > ? ) @@ -598,7 +577,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.BIRTHDATE.paramName, DateTimeType("2013-03-15").value.time - 1, @@ -626,8 +604,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM DateTimeIndexEntity WHERE resourceType = ? AND index_name = ? AND index_to < ? ) @@ -638,7 +615,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.BIRTHDATE.paramName, DateTimeType("2013-03-14").value.time, @@ -666,8 +642,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM DateTimeIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_from NOT BETWEEN ? AND ? OR index_to NOT BETWEEN ? AND ?) ) @@ -678,7 +653,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.BIRTHDATE.paramName, DateTimeType("2013-03-14").value.time, @@ -709,8 +683,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM DateTimeIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_from BETWEEN ? AND ? AND index_to BETWEEN ? AND ?) ) @@ -721,7 +694,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.BIRTHDATE.paramName, DateTimeType("2013-03-14").value.time, @@ -752,8 +724,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM DateTimeIndexEntity WHERE resourceType = ? AND index_name = ? AND index_to > ? ) @@ -764,7 +735,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.BIRTHDATE.paramName, DateTimeType("2013-03-15").value.time - 1, @@ -792,8 +762,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM DateTimeIndexEntity WHERE resourceType = ? AND index_name = ? AND index_to >= ? ) @@ -804,7 +773,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.BIRTHDATE.paramName, DateTimeType("2013-03-14").value.time, @@ -832,8 +800,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM DateTimeIndexEntity WHERE resourceType = ? AND index_name = ? AND index_from < ? ) @@ -844,7 +811,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.BIRTHDATE.paramName, DateTimeType("2013-03-14").value.time, @@ -872,8 +838,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM DateTimeIndexEntity WHERE resourceType = ? AND index_name = ? AND index_from <= ? ) @@ -884,7 +849,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.BIRTHDATE.paramName, DateTimeType("2013-03-15").value.time - 1, @@ -904,8 +868,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM StringIndexEntity WHERE resourceType = ? AND index_name = ? AND index_value LIKE ? || '%' COLLATE NOCASE ) @@ -914,7 +877,6 @@ class SearchTest { ) assertThat(query.args) .containsExactly( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.ADDRESS.paramName, "someValue", @@ -941,8 +903,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM StringIndexEntity WHERE resourceType = ? AND index_name = ? AND index_value = ? ) @@ -951,7 +912,6 @@ class SearchTest { ) assertThat(query.args) .containsExactly( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.ADDRESS.paramName, "someValue", @@ -978,8 +938,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM StringIndexEntity WHERE resourceType = ? AND index_name = ? AND index_value LIKE '%' || ? || '%' COLLATE NOCASE ) @@ -988,7 +947,6 @@ class SearchTest { ) assertThat(query.args) .containsExactly( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.ADDRESS.paramName, "someValue", @@ -1015,8 +973,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_value = ? AND IFNULL(index_system,'') = ?) ) @@ -1026,7 +983,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.GENDER.paramName, "male", @@ -1055,8 +1011,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_value = ? AND IFNULL(index_system,'') = ?) ) @@ -1066,7 +1021,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Immunization.name, ResourceType.Immunization.name, Immunization.VACCINE_CODE.paramName, "260385009", @@ -1090,8 +1044,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_value = ? AND IFNULL(index_system,'') = ?) ) @@ -1101,7 +1054,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.IDENTIFIER.paramName, "12345", @@ -1135,8 +1087,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_value = ? AND IFNULL(index_system,'') = ?) ) @@ -1146,7 +1097,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.TELECOM.paramName, "test@gmail.com", @@ -1179,8 +1129,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND index_value = ? ) @@ -1190,7 +1139,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.TELECOM.paramName, "test@gmail.com", @@ -1209,8 +1157,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND index_value = ? ) @@ -1220,7 +1167,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.GENDER.paramName, "male", @@ -1238,8 +1184,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND index_value = ? ) @@ -1249,7 +1194,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.ACTIVE.paramName, "true", @@ -1274,8 +1218,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND index_value = ? ) @@ -1285,7 +1228,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.IDENTIFIER.paramName, "16009886-bd57-11eb-8529-0242ac130003", @@ -1305,8 +1247,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND index_value = ? ) @@ -1316,7 +1257,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.PHONE.paramName, "+14845219791", @@ -1344,8 +1284,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM QuantityIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_code = ? AND index_value >= ? AND index_value < ?) ) @@ -1355,7 +1294,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOfNotNull( - ResourceType.Observation.name, ResourceType.Observation.name, Observation.VALUE_QUANTITY.paramName, "g", @@ -1385,8 +1323,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM QuantityIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_code = ? AND index_value < ?) ) @@ -1396,7 +1333,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOfNotNull( - ResourceType.Observation.name, ResourceType.Observation.name, Observation.VALUE_QUANTITY.paramName, "g", @@ -1425,8 +1361,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM QuantityIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_system = ? AND index_value <= ?) ) @@ -1436,7 +1371,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOfNotNull( - ResourceType.Observation.name, ResourceType.Observation.name, Observation.VALUE_QUANTITY.paramName, "http://unitsofmeasure.org", @@ -1465,8 +1399,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM QuantityIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_system = ? AND index_value > ?) ) @@ -1476,7 +1409,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOfNotNull( - ResourceType.Observation.name, ResourceType.Observation.name, Observation.VALUE_QUANTITY.paramName, "http://unitsofmeasure.org", @@ -1504,8 +1436,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM QuantityIndexEntity WHERE resourceType = ? AND index_name = ? AND index_value >= ? ) @@ -1515,7 +1446,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOfNotNull( - ResourceType.Observation.name, ResourceType.Observation.name, Observation.VALUE_QUANTITY.paramName, BigDecimal("5.403").toDouble(), @@ -1542,8 +1472,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM QuantityIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_value < ? OR index_value >= ?) ) @@ -1553,7 +1482,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOfNotNull( - ResourceType.Observation.name, ResourceType.Observation.name, Observation.VALUE_QUANTITY.paramName, BigDecimal("5.4025").toDouble(), @@ -1581,8 +1509,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM QuantityIndexEntity WHERE resourceType = ? AND index_name = ? AND index_value > ? ) @@ -1592,7 +1519,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOfNotNull( - ResourceType.Observation.name, ResourceType.Observation.name, Observation.VALUE_QUANTITY.paramName, BigDecimal("5.403").toDouble(), @@ -1619,8 +1545,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM QuantityIndexEntity WHERE resourceType = ? AND index_name = ? AND index_value < ? ) @@ -1630,7 +1555,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOfNotNull( - ResourceType.Observation.name, ResourceType.Observation.name, Observation.VALUE_QUANTITY.paramName, BigDecimal("5.403").toDouble(), @@ -1659,8 +1583,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM QuantityIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_system = ? AND index_code = ? AND index_value >= ? AND index_value < ?) ) @@ -1670,7 +1593,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOfNotNull( - ResourceType.Observation.name, ResourceType.Observation.name, Observation.VALUE_QUANTITY.paramName, "http://unitsofmeasure.org", @@ -1691,8 +1613,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM UriIndexEntity WHERE resourceType = ? AND index_name = ? AND index_value = ? ) @@ -1701,7 +1622,6 @@ class SearchTest { ) assertThat(query.args) .containsExactly( - ResourceType.Library.name, ResourceType.Library.name, Library.URL.paramName, "someValue", @@ -1794,8 +1714,7 @@ class SearchTest { FROM ResourceEntity a LEFT JOIN StringIndexEntity b ON a.resourceUuid = b.resourceUuid AND b.index_name = ? - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM StringIndexEntity WHERE resourceType = ? AND index_name = ? AND index_value LIKE ? || '%' COLLATE NOCASE ) @@ -1811,7 +1730,6 @@ class SearchTest { listOf( Patient.GIVEN.paramName, ResourceType.Patient.name, - ResourceType.Patient.name, Patient.FAMILY.paramName, "Jones", 10, @@ -1839,15 +1757,13 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM ResourceEntity a WHERE a.resourceType = ? AND a.resourceId IN ( SELECT substr(a.index_value, 9) FROM ReferenceIndexEntity a - WHERE a.resourceType = ? AND a.index_name = ? - AND a.resourceUuid IN ( + WHERE a.index_name = ? AND a.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_value = ? AND IFNULL(index_system,'') = ?) ) @@ -1861,8 +1777,6 @@ class SearchTest { .isEqualTo( listOf( ResourceType.Patient.name, - ResourceType.Patient.name, - ResourceType.Condition.name, Condition.SUBJECT.paramName, ResourceType.Condition.name, Condition.CODE.paramName, @@ -1915,8 +1829,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM StringIndexEntity WHERE resourceType = ? AND index_name = ? AND index_value = ? ) @@ -1926,8 +1839,7 @@ class SearchTest { WHERE a.resourceType = ? AND a.resourceId IN ( SELECT substr(a.index_value, 9) FROM ReferenceIndexEntity a - WHERE a.resourceType = ? AND a.index_name = ? - AND a.resourceUuid IN ( + WHERE a.index_name = ? AND a.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_value = ? AND IFNULL(index_system,'') = ?) ) @@ -1944,12 +1856,10 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - ResourceType.Patient.name, ResourceType.Patient.name, Patient.ADDRESS_COUNTRY.paramName, "IN", ResourceType.Patient.name, - ResourceType.Immunization.name, Immunization.PATIENT.paramName, ResourceType.Immunization.name, Immunization.VACCINE_CODE.paramName, @@ -1964,7 +1874,7 @@ class SearchTest { } @Test - fun practitioner_has_patient_has_condition_diabetes_and_hypertension() { + fun search_has_patient_has_condition_diabetes_and_hypertension() { val query = Search(ResourceType.Patient) .apply { @@ -1988,15 +1898,13 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM ResourceEntity a WHERE a.resourceType = ? AND a.resourceId IN ( SELECT substr(a.index_value, 9) FROM ReferenceIndexEntity a - WHERE a.resourceType = ? AND a.index_name = ? - AND a.resourceUuid IN ( + WHERE a.index_name = ? AND a.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_value = ? AND IFNULL(index_system,'') = ?) ) @@ -2007,8 +1915,7 @@ class SearchTest { WHERE a.resourceType = ? AND a.resourceId IN ( SELECT substr(a.index_value, 9) FROM ReferenceIndexEntity a - WHERE a.resourceType = ? AND a.index_name = ? - AND a.resourceUuid IN ( + WHERE a.index_name = ? AND a.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_value = ? AND IFNULL(index_system,'') = ?) ) @@ -2022,15 +1929,12 @@ class SearchTest { .isEqualTo( listOf( ResourceType.Patient.name, - ResourceType.Patient.name, - ResourceType.Condition.name, Condition.SUBJECT.paramName, ResourceType.Condition.name, Condition.CODE.paramName, "44054006", "http://snomed.info/sct", ResourceType.Patient.name, - ResourceType.Condition.name, Condition.SUBJECT.paramName, ResourceType.Condition.name, Condition.CODE.paramName, @@ -2111,8 +2015,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM StringIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_value = ? OR index_value = ?) ) @@ -2120,7 +2023,7 @@ class SearchTest { .trimIndent(), ) - assertThat(query.args).isEqualTo(listOf("Patient", "Patient", "given", "John", "Jane")) + assertThat(query.args).isEqualTo(listOf("Patient", "given", "John", "Jane")) } @Test @@ -2152,8 +2055,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM StringIndexEntity WHERE resourceType = ? AND index_name = ? AND index_value = ? ) @@ -2165,8 +2067,7 @@ class SearchTest { .trimIndent(), ) - assertThat(query.args) - .isEqualTo(listOf("Patient", "Patient", "given", "John", "Patient", "given", "Jane")) + assertThat(query.args).isEqualTo(listOf("Patient", "given", "John", "Patient", "given", "Jane")) } // Test for https://github.com/google/android-fhir/issues/903 @@ -2185,8 +2086,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM StringIndexEntity WHERE resourceType = ? AND index_name = ? AND index_value LIKE ? || '%' COLLATE NOCASE ) @@ -2199,7 +2099,7 @@ class SearchTest { ) assertThat(query.args) - .isEqualTo(listOf("Patient", "Patient", "given", "John", "Patient", "family", "Doe", "Roe")) + .isEqualTo(listOf("Patient", "given", "John", "Patient", "family", "Doe", "Roe")) } @Test @@ -2216,8 +2116,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND index_value = ? ) @@ -2225,8 +2124,7 @@ class SearchTest { .trimIndent(), ) - assertThat(query.args) - .isEqualTo(listOf("Condition", "Condition", "clinical-status", "test-code")) + assertThat(query.args).isEqualTo(listOf("Condition", "clinical-status", "test-code")) } @Test @@ -2254,8 +2152,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_value = ? AND IFNULL(index_system,'') = ?) ) @@ -2266,7 +2163,6 @@ class SearchTest { assertThat(query.args) .isEqualTo( listOf( - "Condition", "Condition", "clinical-status", "test-code", @@ -2295,7 +2191,8 @@ class SearchTest { FROM ResourceEntity re JOIN ReferenceIndexEntity rie ON re.resourceType||"/"||re.resourceId = rie.index_value - WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.resourceUuid IN (?, ?) AND re.resourceType = ? + WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.resourceUuid IN (?, ?) + AND re.resourceType = ? ) """ .trimIndent(), @@ -2337,7 +2234,7 @@ class SearchTest { FROM ResourceEntity re JOIN ReferenceIndexEntity rie ON re.resourceType||"/"||re.resourceId = rie.index_value - WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.resourceUuid IN (?, ?) AND re.resourceType = ? + WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.resourceUuid IN (?, ?) AND re.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND index_value = ? @@ -2355,7 +2252,6 @@ class SearchTest { convertUUIDToByte(UUID.fromString("e2c79e28-ed4d-2029-a12c-108d1eb5bedb")), convertUUIDToByte(UUID.fromString("e2c79e28-ed4d-4029-a12c-108d1eb5bedb")), "Practitioner", - "Practitioner", "active", "true", ) @@ -2389,7 +2285,7 @@ class SearchTest { ON re.resourceType||"/"||re.resourceId = rie.index_value LEFT JOIN StringIndexEntity b ON re.resourceUuid = b.resourceUuid AND b.index_name = ? - WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.resourceUuid IN (?, ?) AND re.resourceType = ? + WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.resourceUuid IN (?, ?) AND re.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND index_value = ? @@ -2411,7 +2307,6 @@ class SearchTest { convertUUIDToByte(UUID.fromString("e2c79e28-ed4d-2029-a12c-108d1eb5bedb")), convertUUIDToByte(UUID.fromString("e2c79e28-ed4d-4029-a12c-108d1eb5bedb")), "Practitioner", - "Practitioner", "active", "true", ) @@ -2450,7 +2345,7 @@ class SearchTest { ON re.resourceType||"/"||re.resourceId = rie.index_value LEFT JOIN StringIndexEntity b ON re.resourceUuid = b.resourceUuid AND b.index_name = ? - WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.resourceUuid IN (?, ?) AND re.resourceType = ? + WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.resourceUuid IN (?, ?) AND re.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND index_value = ? @@ -2467,7 +2362,7 @@ class SearchTest { ON re.resourceType||"/"||re.resourceId = rie.index_value LEFT JOIN StringIndexEntity b ON re.resourceUuid = b.resourceUuid AND b.index_name = ? - WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.resourceUuid IN (?, ?) AND re.resourceType = ? + WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.resourceUuid IN (?, ?) AND re.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND index_value = ? @@ -2489,7 +2384,6 @@ class SearchTest { convertUUIDToByte(UUID.fromString("e2c79e28-ed4d-2029-a12c-108d1eb5bedb")), convertUUIDToByte(UUID.fromString("e2c79e28-ed4d-4029-a12c-108d1eb5bedb")), "Practitioner", - "Practitioner", "active", "true", "name", @@ -2498,7 +2392,6 @@ class SearchTest { convertUUIDToByte(UUID.fromString("e2c79e28-ed4d-2029-a12c-108d1eb5bedb")), convertUUIDToByte(UUID.fromString("e2c79e28-ed4d-4029-a12c-108d1eb5bedb")), "Organization", - "Organization", "active", "true", ) @@ -2520,7 +2413,8 @@ class SearchTest { FROM ResourceEntity re JOIN ReferenceIndexEntity rie ON re.resourceUuid = rie.resourceUuid - WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.index_value IN (?, ?) AND re.resourceType = ? + WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.index_value IN (?, ?) + AND re.resourceType = ? ) """ .trimIndent(), @@ -2558,7 +2452,7 @@ class SearchTest { FROM ResourceEntity re JOIN ReferenceIndexEntity rie ON re.resourceUuid = rie.resourceUuid - WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.index_value IN (?, ?) AND re.resourceType = ? + WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.index_value IN (?, ?) AND re.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_value = ? AND IFNULL(index_system,'') = ?) @@ -2575,7 +2469,6 @@ class SearchTest { "Patient/pa01", "Patient/pa02", "Condition", - "Condition", "code", "44054006", "http://snomed.info/sct", @@ -2615,7 +2508,7 @@ class SearchTest { ON re.resourceUuid = b.resourceUuid AND b.index_name = ? LEFT JOIN DateTimeIndexEntity c ON re.resourceUuid = c.resourceUuid AND c.index_name = ? - WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.index_value IN (?, ?) AND re.resourceType = ? + WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.index_value IN (?, ?) AND re.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_value = ? AND IFNULL(index_system,'') = ?) @@ -2637,7 +2530,6 @@ class SearchTest { "Patient/pa01", "Patient/pa02", "Condition", - "Condition", "code", "44054006", "http://snomed.info/sct", @@ -2694,7 +2586,7 @@ class SearchTest { ON re.resourceUuid = b.resourceUuid AND b.index_name = ? LEFT JOIN DateTimeIndexEntity c ON re.resourceUuid = c.resourceUuid AND c.index_name = ? - WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.index_value IN (?, ?) AND re.resourceType = ? + WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.index_value IN (?, ?) AND re.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_value = ? AND IFNULL(index_system,'') = ?) @@ -2713,7 +2605,7 @@ class SearchTest { ON re.resourceUuid = b.resourceUuid AND b.index_name = ? LEFT JOIN DateTimeIndexEntity c ON re.resourceUuid = c.resourceUuid AND c.index_name = ? - WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.index_value IN (?, ?) AND re.resourceType = ? + WHERE rie.resourceType = ? AND rie.index_name = ? AND rie.index_value IN (?, ?) AND re.resourceUuid IN ( SELECT resourceUuid FROM TokenIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_value = ? AND IFNULL(index_system,'') = ?) @@ -2735,7 +2627,6 @@ class SearchTest { "Patient/pa01", "Patient/pa02", "Encounter", - "Encounter", "status", "arrived", "http://hl7.org/fhir/encounter-status", @@ -2746,7 +2637,6 @@ class SearchTest { "Patient/pa01", "Patient/pa02", "Condition", - "Condition", "code", "44054006", "http://snomed.info/sct", @@ -2772,8 +2662,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM ReferenceIndexEntity WHERE resourceType = ? AND index_name = ? AND (((((((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR (((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))))) OR ((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))))) OR (((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))))) OR ((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))))))) OR ((((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))))) OR ((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))))) OR (((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))))) OR ((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))))))) OR (((((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))))) OR ((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))))) OR (((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))))) OR ((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))))))) OR ((((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))))) OR ((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))))) OR (((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))))) OR ((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))))))))) OR ((((((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR (((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))))) OR ((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))))) OR (((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))))) OR ((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))))))) OR ((((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))))) OR ((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))))) OR (((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))))) OR ((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))))))) OR (((((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))))) OR ((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))))) OR (((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))))) OR ((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))))))) OR ((((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))))) OR ((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))))) OR (((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))))) OR ((((index_value = ? OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))) OR ((((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) OR (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)))))))))) ) @@ -2783,7 +2672,6 @@ class SearchTest { assertThat(query.args) .containsExactly( - "CarePlan", "CarePlan", "subject", *patientIdReferenceList.toTypedArray(), @@ -2801,8 +2689,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM ReferenceIndexEntity WHERE resourceType = ? AND index_name = ? ) @@ -2812,7 +2699,6 @@ class SearchTest { assertThat(query.args) .containsExactly( - "CarePlan", "CarePlan", "subject", ) @@ -2832,8 +2718,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM ReferenceIndexEntity WHERE resourceType = ? AND index_name = ? AND index_value = ? ) @@ -2843,7 +2728,6 @@ class SearchTest { assertThat(query.args) .containsExactly( - "CarePlan", "CarePlan", "subject", "Patient/patient-0", @@ -2866,8 +2750,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM ReferenceIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_value = ? OR index_value = ?) ) @@ -2877,7 +2760,6 @@ class SearchTest { assertThat(query.args) .containsExactly( - "CarePlan", "CarePlan", "subject", "Patient/patient-0", @@ -2906,8 +2788,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM ReferenceIndexEntity WHERE resourceType = ? AND index_name = ? AND (index_value = ? OR (index_value = ? OR index_value = ?)) ) @@ -2917,7 +2798,6 @@ class SearchTest { assertThat(query.args) .containsExactly( - "CarePlan", "CarePlan", "subject", "Patient/patient-0", @@ -2948,8 +2828,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM ReferenceIndexEntity WHERE resourceType = ? AND index_name = ? AND ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) ) @@ -2959,7 +2838,6 @@ class SearchTest { assertThat(query.args) .containsExactly( - "CarePlan", "CarePlan", "subject", "Patient/patient-0", @@ -2987,8 +2865,7 @@ class SearchTest { """ SELECT a.resourceUuid, a.serializedResource FROM ResourceEntity a - WHERE a.resourceType = ? - AND a.resourceUuid IN ( + WHERE a.resourceUuid IN ( SELECT resourceUuid FROM ReferenceIndexEntity WHERE resourceType = ? AND index_name = ? AND (((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?)) OR ((index_value = ? OR index_value = ?) OR (index_value = ? OR index_value = ?))) ) @@ -2998,7 +2875,6 @@ class SearchTest { assertThat(query.args) .containsExactly( - "CarePlan", "CarePlan", "subject", *patientIdReferenceList.toTypedArray(),