From af11763dee300d6189332af4e1fd637e08c9ebde Mon Sep 17 00:00:00 2001 From: ianmarshall Date: Mon, 13 Apr 2020 08:56:56 -0400 Subject: [PATCH] Fixes to command line tool, clean-up and minor re-factoring. --- .../ca/uhn/fhir/jpa/demo/CommonConfig.java | 26 +- .../src/main/java/ca/uhn/fhir/fhir/App.java | 13 - .../test/java/ca/uhn/fhir/fhir/AppTest.java | 20 - .../ca/uhn/fhir/jpa/config/BaseConfig.java | 3 +- ...exedCodeCodeableConceptSearchParamDao.java | 2 +- ...vationIndexedCodeCodingSearchParamDao.java | 2 +- ...ObservationIndexedSearchParamLastNDao.java | 2 +- .../ObservationLastNIndexPersistDstu3Svc.java | 3 +- .../ObservationLastNIndexPersistR4Svc.java | 3 +- .../ObservationLastNIndexPersistR5Svc.java | 3 +- .../ObservationLastNIndexPersistSvc.java | 80 ---- ...nIndexedCategoryCodeableConceptEntity.java | 2 +- ...bservationIndexedCategoryCodingEntity.java | 2 +- ...ationIndexedCodeCodeableConceptEntity.java | 4 +- .../ObservationIndexedCodeCodingEntity.java | 2 +- ...ervationIndexedSearchParamLastNEntity.java | 2 +- .../lastn/ElasticsearchBulkIndexSvcImpl.java | 4 +- .../search/lastn/ElasticsearchSvcImpl.java | 4 +- .../fhir/jpa/search/lastn/IndexConstants.java | 4 +- ...bservationIndexedSearchParamLastNTest.java | 4 +- .../lastn/ElasticsearchPerformanceTests.java | 195 ---------- .../ElasticsearchV5PerformanceTests.java | 153 -------- ...ElasticsearchSvcSingleObservationTest.java | 11 +- ...icsearchV5SvcMultipleObservationsTest.java | 312 ---------------- ...asticsearchV5SvcSingleObservationTest.java | 346 ------------------ 25 files changed, 41 insertions(+), 1161 deletions(-) delete mode 100644 hapi-fhir-elasticsearch-6/src/main/java/ca/uhn/fhir/fhir/App.java delete mode 100644 hapi-fhir-elasticsearch-6/src/test/java/ca/uhn/fhir/fhir/AppTest.java delete mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/ObservationLastNIndexPersistSvc.java rename hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/{dao/lastn => model}/entity/ObservationIndexedCategoryCodeableConceptEntity.java (97%) rename hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/{dao/lastn => model}/entity/ObservationIndexedCategoryCodingEntity.java (95%) rename hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/{dao/lastn => model}/entity/ObservationIndexedCodeCodeableConceptEntity.java (96%) rename hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/{dao/lastn => model}/entity/ObservationIndexedCodeCodingEntity.java (97%) rename hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/{dao/lastn => model}/entity/ObservationIndexedSearchParamLastNEntity.java (98%) delete mode 100644 hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchPerformanceTests.java delete mode 100644 hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchV5PerformanceTests.java delete mode 100644 hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchV5SvcMultipleObservationsTest.java delete mode 100644 hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchV5SvcSingleObservationTest.java diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/CommonConfig.java b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/CommonConfig.java index 82b9a9b98dd..c23c27568bc 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/CommonConfig.java +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo/CommonConfig.java @@ -233,18 +233,20 @@ public class CommonConfig { public EmbeddedElastic embeddedElasticSearch() { String ELASTIC_VERSION = "6.5.4"; - EmbeddedElastic embeddedElastic; - try { - embeddedElastic = EmbeddedElastic.builder() - .withElasticVersion(ELASTIC_VERSION) - .withSetting(PopularProperties.TRANSPORT_TCP_PORT, 0) - .withSetting(PopularProperties.HTTP_PORT, 0) - .withSetting(PopularProperties.CLUSTER_NAME, UUID.randomUUID()) - .withStartTimeout(60, TimeUnit.SECONDS) - .build() - .start(); - } catch (IOException | InterruptedException e) { - throw new ConfigurationException(e); + EmbeddedElastic embeddedElastic = null; + if(!ContextHolder.isExternalElasticsearch()) { + try { + embeddedElastic = EmbeddedElastic.builder() + .withElasticVersion(ELASTIC_VERSION) + .withSetting(PopularProperties.TRANSPORT_TCP_PORT, 0) + .withSetting(PopularProperties.HTTP_PORT, 0) + .withSetting(PopularProperties.CLUSTER_NAME, UUID.randomUUID()) + .withStartTimeout(60, TimeUnit.SECONDS) + .build() + .start(); + } catch (IOException | InterruptedException e) { + throw new ConfigurationException(e); + } } return embeddedElastic; diff --git a/hapi-fhir-elasticsearch-6/src/main/java/ca/uhn/fhir/fhir/App.java b/hapi-fhir-elasticsearch-6/src/main/java/ca/uhn/fhir/fhir/App.java deleted file mode 100644 index 9b658e5bf48..00000000000 --- a/hapi-fhir-elasticsearch-6/src/main/java/ca/uhn/fhir/fhir/App.java +++ /dev/null @@ -1,13 +0,0 @@ -package ca.uhn.fhir.fhir; - -/** - * Hello world! - * - */ -public class App -{ - public static void main( String[] args ) - { - System.out.println( "Hello World!" ); - } -} diff --git a/hapi-fhir-elasticsearch-6/src/test/java/ca/uhn/fhir/fhir/AppTest.java b/hapi-fhir-elasticsearch-6/src/test/java/ca/uhn/fhir/fhir/AppTest.java deleted file mode 100644 index 83fcc8b98cb..00000000000 --- a/hapi-fhir-elasticsearch-6/src/test/java/ca/uhn/fhir/fhir/AppTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package ca.uhn.fhir.fhir; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -/** - * Unit test for simple App. - */ -public class AppTest -{ - /** - * Rigorous Test :-) - */ - @Test - public void shouldAnswerWithTrue() - { - assertTrue( true ); - } -} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java index 5318c8cbaa2..11163796b33 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseConfig.java @@ -285,8 +285,7 @@ public abstract class BaseConfig { public static void configureEntityManagerFactory(LocalContainerEntityManagerFactoryBean theFactory, FhirContext theCtx) { theFactory.setJpaDialect(hibernateJpaDialect(theCtx.getLocalizer())); - //TODO: Consider moving the jpa.dao.lastn.entity.* classes into jpa.entity at some point. - theFactory.setPackagesToScan("ca.uhn.fhir.jpa.model.entity", "ca.uhn.fhir.jpa.entity", "ca.uhn.fhir.jpa.dao.lastn.entity"); + theFactory.setPackagesToScan("ca.uhn.fhir.jpa.model.entity", "ca.uhn.fhir.jpa.entity"); theFactory.setPersistenceProvider(new HibernatePersistenceProvider()); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IObservationIndexedCodeCodeableConceptSearchParamDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IObservationIndexedCodeCodeableConceptSearchParamDao.java index 2bde707c764..84c6c0e680f 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IObservationIndexedCodeCodeableConceptSearchParamDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IObservationIndexedCodeCodeableConceptSearchParamDao.java @@ -1,6 +1,6 @@ package ca.uhn.fhir.jpa.dao.data; -import ca.uhn.fhir.jpa.dao.lastn.entity.ObservationIndexedCodeCodeableConceptEntity; +import ca.uhn.fhir.jpa.model.entity.ObservationIndexedCodeCodeableConceptEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IObservationIndexedCodeCodingSearchParamDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IObservationIndexedCodeCodingSearchParamDao.java index d5d46f47e16..c4ca00b856a 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IObservationIndexedCodeCodingSearchParamDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IObservationIndexedCodeCodingSearchParamDao.java @@ -1,6 +1,6 @@ package ca.uhn.fhir.jpa.dao.data; -import ca.uhn.fhir.jpa.dao.lastn.entity.ObservationIndexedCodeCodingEntity; +import ca.uhn.fhir.jpa.model.entity.ObservationIndexedCodeCodingEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IObservationIndexedSearchParamLastNDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IObservationIndexedSearchParamLastNDao.java index 7a33dec68cd..04d3780058c 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IObservationIndexedSearchParamLastNDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IObservationIndexedSearchParamLastNDao.java @@ -1,6 +1,6 @@ package ca.uhn.fhir.jpa.dao.data; -import ca.uhn.fhir.jpa.dao.lastn.entity.ObservationIndexedSearchParamLastNEntity; +import ca.uhn.fhir.jpa.model.entity.ObservationIndexedSearchParamLastNEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/ObservationLastNIndexPersistDstu3Svc.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/ObservationLastNIndexPersistDstu3Svc.java index f02743db2fd..0dfdea37f18 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/ObservationLastNIndexPersistDstu3Svc.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/ObservationLastNIndexPersistDstu3Svc.java @@ -3,7 +3,7 @@ package ca.uhn.fhir.jpa.dao.lastn; import ca.uhn.fhir.jpa.dao.data.IObservationIndexedCodeCodeableConceptSearchParamDao; import ca.uhn.fhir.jpa.dao.data.IObservationIndexedCodeCodingSearchParamDao; import ca.uhn.fhir.jpa.dao.data.IObservationIndexedSearchParamLastNDao; -import ca.uhn.fhir.jpa.dao.lastn.entity.*; +import ca.uhn.fhir.jpa.model.entity.*; import org.hl7.fhir.dstu3.model.CodeableConcept; import org.hl7.fhir.dstu3.model.Coding; import org.hl7.fhir.dstu3.model.Observation; @@ -25,7 +25,6 @@ public class ObservationLastNIndexPersistDstu3Svc { @Autowired IObservationIndexedCodeCodingSearchParamDao myObservationIndexedCodeCodingSearchParamDao; - // TODO: Change theSubjectId to be a Long public void indexObservation(Observation theObservation, String theSubjectId) { ObservationIndexedSearchParamLastNEntity indexedObservation = new ObservationIndexedSearchParamLastNEntity(); String resourcePID = theObservation.getIdElement().getIdPart(); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/ObservationLastNIndexPersistR4Svc.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/ObservationLastNIndexPersistR4Svc.java index ec7a4afe6f9..e6336fcf135 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/ObservationLastNIndexPersistR4Svc.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/ObservationLastNIndexPersistR4Svc.java @@ -3,7 +3,7 @@ package ca.uhn.fhir.jpa.dao.lastn; import ca.uhn.fhir.jpa.dao.data.IObservationIndexedCodeCodeableConceptSearchParamDao; import ca.uhn.fhir.jpa.dao.data.IObservationIndexedCodeCodingSearchParamDao; import ca.uhn.fhir.jpa.dao.data.IObservationIndexedSearchParamLastNDao; -import ca.uhn.fhir.jpa.dao.lastn.entity.*; +import ca.uhn.fhir.jpa.model.entity.*; import org.hl7.fhir.r4.model.CodeableConcept; import org.hl7.fhir.r4.model.Coding; import org.hl7.fhir.r4.model.Observation; @@ -25,7 +25,6 @@ public class ObservationLastNIndexPersistR4Svc { @Autowired IObservationIndexedCodeCodingSearchParamDao myObservationIndexedCodeCodingSearchParamDao; - // TODO: Change theSubjectId to be a Long public void indexObservation(Observation theObservation, String theSubjectId) { ObservationIndexedSearchParamLastNEntity indexedObservation = new ObservationIndexedSearchParamLastNEntity(); String resourcePID = theObservation.getIdElement().getIdPart(); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/ObservationLastNIndexPersistR5Svc.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/ObservationLastNIndexPersistR5Svc.java index 4365740fc91..8650b2d2925 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/ObservationLastNIndexPersistR5Svc.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/ObservationLastNIndexPersistR5Svc.java @@ -3,7 +3,7 @@ package ca.uhn.fhir.jpa.dao.lastn; import ca.uhn.fhir.jpa.dao.data.IObservationIndexedCodeCodeableConceptSearchParamDao; import ca.uhn.fhir.jpa.dao.data.IObservationIndexedCodeCodingSearchParamDao; import ca.uhn.fhir.jpa.dao.data.IObservationIndexedSearchParamLastNDao; -import ca.uhn.fhir.jpa.dao.lastn.entity.*; +import ca.uhn.fhir.jpa.model.entity.*; import org.hl7.fhir.r5.model.CodeableConcept; import org.hl7.fhir.r5.model.Coding; import org.hl7.fhir.r5.model.Observation; @@ -25,7 +25,6 @@ public class ObservationLastNIndexPersistR5Svc { @Autowired IObservationIndexedCodeCodingSearchParamDao myObservationIndexedCodeCodingSearchParamDao; - // TODO: Change theSubjectId to be a Long public void indexObservation(Observation theObservation, String theSubjectId) { ObservationIndexedSearchParamLastNEntity indexedObservation = new ObservationIndexedSearchParamLastNEntity(); String resourcePID = theObservation.getIdElement().getIdPart(); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/ObservationLastNIndexPersistSvc.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/ObservationLastNIndexPersistSvc.java deleted file mode 100644 index 3a4a2c4ab07..00000000000 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/ObservationLastNIndexPersistSvc.java +++ /dev/null @@ -1,80 +0,0 @@ -package ca.uhn.fhir.jpa.dao.lastn; - -import ca.uhn.fhir.jpa.dao.data.IObservationIndexedCodeCodingSearchParamDao; -import ca.uhn.fhir.jpa.dao.lastn.entity.*; -import ca.uhn.fhir.jpa.dao.data.IObservationIndexedCodeCodeableConceptSearchParamDao; -import ca.uhn.fhir.jpa.dao.data.IObservationIndexedSearchParamLastNDao; -import org.hl7.fhir.r4.model.CodeableConcept; -import org.hl7.fhir.r4.model.Coding; -import org.hl7.fhir.r4.model.Observation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.*; - -//@Component -public class ObservationLastNIndexPersistSvc { - - @Autowired - IObservationIndexedSearchParamLastNDao myResourceIndexedObservationLastNDao; - - @Autowired - IObservationIndexedCodeCodeableConceptSearchParamDao myObservationIndexedCodeableConceptSearchParamDao; - - @Autowired - IObservationIndexedCodeCodingSearchParamDao myObservationIndexedCodeCodingSearchParamDao; - - public void indexObservation(Observation theObservation) { - ObservationIndexedSearchParamLastNEntity indexedObservation = new ObservationIndexedSearchParamLastNEntity(); - String resourcePID = theObservation.getId(); - indexedObservation.setIdentifier(resourcePID); - // TODO: Need to improve this as there are multiple use cases involving subject. - String subjectId = "Patient/" + theObservation.getSubject().getReference(); - indexedObservation.setSubject(subjectId); - Date effectiveDtm = theObservation.getEffectiveDateTimeType().getValue(); - indexedObservation.setEffectiveDtm(effectiveDtm); - - // Build CodeableConcept entities for Observation.Category - Set categoryConcepts = new HashSet<>(); - for(CodeableConcept categoryCodeableConcept : theObservation.getCategory()) { - // Build Coding entities for each category CodeableConcept - Set categoryCodingEntities = new HashSet<>(); - ObservationIndexedCategoryCodeableConceptEntity categoryCodeableConceptEntity = new ObservationIndexedCategoryCodeableConceptEntity(categoryCodeableConcept.getText()); - for(Coding categoryCoding : categoryCodeableConcept.getCoding()){ - categoryCodingEntities.add(new ObservationIndexedCategoryCodingEntity(categoryCoding.getSystem(), categoryCoding.getCode(), categoryCoding.getDisplay())); - } - categoryCodeableConceptEntity.setObservationIndexedCategoryCodingEntitySet(categoryCodingEntities); - categoryConcepts.add(categoryCodeableConceptEntity); - } - indexedObservation.setCategoryCodeableConcepts(categoryConcepts); - - // Build CodeableConcept entity for Observation.Code. - CodeableConcept codeCodeableConcept = theObservation.getCode(); - String observationCodeNormalizedId = null; - - // Determine if a Normalized ID was created previously for Observation Code - for (Coding codeCoding : codeCodeableConcept.getCoding()) { - if (codeCoding.hasCode() && codeCoding.hasSystem()) { - observationCodeNormalizedId = myObservationIndexedCodeCodingSearchParamDao.findForCodeAndSystem(codeCoding.getCode(), codeCoding.getSystem()); - } else { - observationCodeNormalizedId = myObservationIndexedCodeCodingSearchParamDao.findForDisplay(codeCoding.getDisplay()); - } - } - // Generate a new a normalized ID if necessary - if (observationCodeNormalizedId == null) { - observationCodeNormalizedId = UUID.randomUUID().toString(); - } - - // Create/update normalized Observation Code index record - ObservationIndexedCodeCodeableConceptEntity codeableConceptField = new ObservationIndexedCodeCodeableConceptEntity(codeCodeableConcept.getText(), observationCodeNormalizedId); - for (Coding codeCoding : codeCodeableConcept.getCoding()) { - codeableConceptField.addCoding(new ObservationIndexedCodeCodingEntity(codeCoding.getSystem(), codeCoding.getCode(), codeCoding.getDisplay(), observationCodeNormalizedId)); - } - myObservationIndexedCodeableConceptSearchParamDao.save(codeableConceptField); - - indexedObservation.setObservationCode(codeableConceptField); - indexedObservation.setCodeNormalizedId(observationCodeNormalizedId); - myResourceIndexedObservationLastNDao.save(indexedObservation); - - } -} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/entity/ObservationIndexedCategoryCodeableConceptEntity.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/model/entity/ObservationIndexedCategoryCodeableConceptEntity.java similarity index 97% rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/entity/ObservationIndexedCategoryCodeableConceptEntity.java rename to hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/model/entity/ObservationIndexedCategoryCodeableConceptEntity.java index 7d5d98525af..cf5df932ef4 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/entity/ObservationIndexedCategoryCodeableConceptEntity.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/model/entity/ObservationIndexedCategoryCodeableConceptEntity.java @@ -1,4 +1,4 @@ -package ca.uhn.fhir.jpa.dao.lastn.entity; +package ca.uhn.fhir.jpa.model.entity; import org.hibernate.search.annotations.DocumentId; import org.hibernate.search.annotations.Field; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/entity/ObservationIndexedCategoryCodingEntity.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/model/entity/ObservationIndexedCategoryCodingEntity.java similarity index 95% rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/entity/ObservationIndexedCategoryCodingEntity.java rename to hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/model/entity/ObservationIndexedCategoryCodingEntity.java index 9bc95ed657c..a29ac733005 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/entity/ObservationIndexedCategoryCodingEntity.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/model/entity/ObservationIndexedCategoryCodingEntity.java @@ -1,4 +1,4 @@ -package ca.uhn.fhir.jpa.dao.lastn.entity; +package ca.uhn.fhir.jpa.model.entity; import ca.uhn.fhir.jpa.dao.lastn.util.CodeSystemHash; import org.hibernate.search.annotations.Analyze; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/entity/ObservationIndexedCodeCodeableConceptEntity.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/model/entity/ObservationIndexedCodeCodeableConceptEntity.java similarity index 96% rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/entity/ObservationIndexedCodeCodeableConceptEntity.java rename to hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/model/entity/ObservationIndexedCodeCodeableConceptEntity.java index cfe95e2f93d..a2035cc0540 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/entity/ObservationIndexedCodeCodeableConceptEntity.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/model/entity/ObservationIndexedCodeCodeableConceptEntity.java @@ -1,4 +1,4 @@ -package ca.uhn.fhir.jpa.dao.lastn.entity; +package ca.uhn.fhir.jpa.model.entity; import org.hibernate.search.annotations.DocumentId; import org.hibernate.search.annotations.Field; @@ -6,8 +6,6 @@ import org.hibernate.search.annotations.Indexed; import org.hibernate.search.annotations.IndexedEmbedded; import javax.persistence.*; -import java.util.HashSet; -import java.util.Set; @Entity @Indexed(index = "code_index") diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/entity/ObservationIndexedCodeCodingEntity.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/model/entity/ObservationIndexedCodeCodingEntity.java similarity index 97% rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/entity/ObservationIndexedCodeCodingEntity.java rename to hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/model/entity/ObservationIndexedCodeCodingEntity.java index ecdbfd6e7e3..8b28dc1d9af 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/entity/ObservationIndexedCodeCodingEntity.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/model/entity/ObservationIndexedCodeCodingEntity.java @@ -1,4 +1,4 @@ -package ca.uhn.fhir.jpa.dao.lastn.entity; +package ca.uhn.fhir.jpa.model.entity; import ca.uhn.fhir.jpa.dao.lastn.util.CodeSystemHash; import org.hibernate.search.annotations.Analyze; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/entity/ObservationIndexedSearchParamLastNEntity.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/model/entity/ObservationIndexedSearchParamLastNEntity.java similarity index 98% rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/entity/ObservationIndexedSearchParamLastNEntity.java rename to hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/model/entity/ObservationIndexedSearchParamLastNEntity.java index c56753063ee..8948f2e3575 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/lastn/entity/ObservationIndexedSearchParamLastNEntity.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/model/entity/ObservationIndexedSearchParamLastNEntity.java @@ -1,4 +1,4 @@ -package ca.uhn.fhir.jpa.dao.lastn.entity; +package ca.uhn.fhir.jpa.model.entity; import org.hibernate.search.annotations.*; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchBulkIndexSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchBulkIndexSvcImpl.java index 2444195c631..d0ace200a6a 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchBulkIndexSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchBulkIndexSvcImpl.java @@ -38,7 +38,7 @@ public class ElasticsearchBulkIndexSvcImpl { } String observationMapping = "{\n" + " \"mappings\" : {\n" + - " \"ca.uhn.fhir.jpa.dao.lastn.entity.ObservationIndexedSearchParamLastNEntity\" : {\n" + + " \"ca.uhn.fhir.jpa.model.entity.ObservationIndexedSearchParamLastNEntity\" : {\n" + " \"properties\" : {\n" + " \"codeconceptid\" : {\n" + " \"type\" : \"keyword\",\n" + @@ -100,7 +100,7 @@ public class ElasticsearchBulkIndexSvcImpl { } String codeMapping = "{\n" + " \"mappings\" : {\n" + - " \"ca.uhn.fhir.jpa.dao.lastn.entity.ObservationIndexedCodeCodeableConceptEntity\" : {\n" + + " \"ca.uhn.fhir.jpa.model.entity.ObservationIndexedCodeCodeableConceptEntity\" : {\n" + " \"properties\" : {\n" + " \"codeable_concept_id\" : {\n" + " \"type\" : \"keyword\",\n" + diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchSvcImpl.java index ef5f2c4b0cd..a04e070184b 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchSvcImpl.java @@ -73,7 +73,7 @@ public class ElasticsearchSvcImpl implements IElasticsearchSvc { } String observationMapping = "{\n" + " \"mappings\" : {\n" + - " \"ca.uhn.fhir.jpa.dao.lastn.entity.ObservationIndexedSearchParamLastNEntity\" : {\n" + + " \"ca.uhn.fhir.jpa.model.entity.ObservationIndexedSearchParamLastNEntity\" : {\n" + " \"properties\" : {\n" + " \"codeconceptid\" : {\n" + " \"type\" : \"keyword\",\n" + @@ -135,7 +135,7 @@ public class ElasticsearchSvcImpl implements IElasticsearchSvc { } String codeMapping = "{\n" + " \"mappings\" : {\n" + - " \"ca.uhn.fhir.jpa.dao.lastn.entity.ObservationIndexedCodeCodeableConceptEntity\" : {\n" + + " \"ca.uhn.fhir.jpa.model.entity.ObservationIndexedCodeCodeableConceptEntity\" : {\n" + " \"properties\" : {\n" + " \"codeable_concept_id\" : {\n" + " \"type\" : \"keyword\",\n" + diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/IndexConstants.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/IndexConstants.java index 94276924896..e605bd079ca 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/IndexConstants.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/IndexConstants.java @@ -4,6 +4,6 @@ public class IndexConstants { public static final String OBSERVATION_INDEX = "observation_index"; public static final String CODE_INDEX = "code_index"; - public static final String OBSERVATION_DOCUMENT_TYPE = "ca.uhn.fhir.jpa.dao.lastn.entity.ObservationIndexedSearchParamLastNEntity"; - public static final String CODE_DOCUMENT_TYPE = "ca.uhn.fhir.jpa.dao.lastn.entity.ObservationIndexedCodeCodeableConceptEntity"; + public static final String OBSERVATION_DOCUMENT_TYPE = "ca.uhn.fhir.jpa.model.entity.ObservationIndexedSearchParamLastNEntity"; + public static final String CODE_DOCUMENT_TYPE = "ca.uhn.fhir.jpa.model.entity.ObservationIndexedCodeCodeableConceptEntity"; } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/lastn/PersistObservationIndexedSearchParamLastNTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/lastn/PersistObservationIndexedSearchParamLastNTest.java index d117a41de72..62abeeb0eca 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/lastn/PersistObservationIndexedSearchParamLastNTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/lastn/PersistObservationIndexedSearchParamLastNTest.java @@ -2,8 +2,8 @@ package ca.uhn.fhir.jpa.dao.lastn; import ca.uhn.fhir.jpa.dao.lastn.config.TestObservationIndexSearchConfig; import ca.uhn.fhir.jpa.dao.data.IObservationIndexedCodeCodeableConceptSearchParamDao; -import ca.uhn.fhir.jpa.dao.lastn.entity.ObservationIndexedCodeCodeableConceptEntity; -import ca.uhn.fhir.jpa.dao.lastn.entity.ObservationIndexedSearchParamLastNEntity; +import ca.uhn.fhir.jpa.model.entity.ObservationIndexedCodeCodeableConceptEntity; +import ca.uhn.fhir.jpa.model.entity.ObservationIndexedSearchParamLastNEntity; import ca.uhn.fhir.jpa.dao.data.IObservationIndexedSearchParamLastNDao; import org.hl7.fhir.r4.model.*; import org.junit.After; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchPerformanceTests.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchPerformanceTests.java deleted file mode 100644 index 2e4c751093b..00000000000 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchPerformanceTests.java +++ /dev/null @@ -1,195 +0,0 @@ -package ca.uhn.fhir.jpa.search.lastn; - -import ca.uhn.fhir.jpa.search.lastn.json.CodeJson; -import ca.uhn.fhir.jpa.search.lastn.json.ObservationJson; -import ca.uhn.fhir.jpa.search.lastn.util.SimpleStopWatch; -import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; -import ca.uhn.fhir.rest.param.ReferenceParam; -import ca.uhn.fhir.rest.param.TokenParam; -import com.fasterxml.jackson.databind.ObjectMapper; -/* -import org.shadehapi.elasticsearch.action.search.SearchRequest; -import org.shadehapi.elasticsearch.action.search.SearchResponse; -import org.shadehapi.elasticsearch.index.query.QueryBuilders; -import org.shadehapi.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder; -import org.shadehapi.elasticsearch.index.query.functionscore.RandomScoreFunctionBuilder; -import org.shadehapi.elasticsearch.search.SearchHit; -import org.shadehapi.elasticsearch.search.aggregations.AggregationBuilders; -import org.shadehapi.elasticsearch.search.aggregations.Aggregations; -import org.shadehapi.elasticsearch.search.aggregations.bucket.terms.ParsedTerms; -import org.shadehapi.elasticsearch.search.aggregations.bucket.terms.Terms; -import org.shadehapi.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; -import org.shadehapi.elasticsearch.search.aggregations.metrics.tophits.ParsedTopHits; -import org.shadehapi.elasticsearch.search.aggregations.support.ValueType; -import org.shadehapi.elasticsearch.search.builder.SearchSourceBuilder; -import org.shadehapi.elasticsearch.search.sort.SortOrder; - */ -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import static org.junit.Assert.assertEquals; - -@Ignore -public class ElasticsearchPerformanceTests { - - private ElasticsearchSvcImpl elasticsearchSvc = new ElasticsearchSvcImpl("localhost", 9301, "elastic", "changeme"); - private List patientIds = new ArrayList<>(); - - @Before - public void before() throws IOException { -/* SearchRequest searchRequest = new SearchRequest(IndexConstants.OBSERVATION_INDEX); - SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); - RandomScoreFunctionBuilder randomScoreFunctionBuilder = new RandomScoreFunctionBuilder(); - Date now = new Date(); - randomScoreFunctionBuilder.seed(now.getTime()); - FunctionScoreQueryBuilder functionScoreQueryBuilder = QueryBuilders.functionScoreQuery(randomScoreFunctionBuilder); - searchSourceBuilder.query(functionScoreQueryBuilder); - searchSourceBuilder.size(0); - - // Aggregation by order codes - TermsAggregationBuilder observationCodeValuesBuilder = new TermsAggregationBuilder("group_by_patient", ValueType.STRING).field("subject"); - observationCodeValuesBuilder.size(1000); - // Top Hits Aggregation - String[] topHitsInclude = {"subject"}; - observationCodeValuesBuilder.subAggregation(AggregationBuilders.topHits("most_recent_effective") - .sort("effectivedtm", SortOrder.DESC) - .fetchSource(topHitsInclude, null).size(1)); - - searchSourceBuilder.aggregation(observationCodeValuesBuilder); - searchRequest.source(searchSourceBuilder); - - SearchResponse response = elasticsearchSvc.executeSearchRequest(searchRequest); - patientIds = buildResults(response); -*/ - } - -// @Test - public void testObservationCodesQueryPerformance() throws IOException { -// SearchRequest searchRequest = elasticsearchSvc.buildObservationCodesSearchRequest(10000); - long totalElapsedTimes = 0L; - long totalElapsedSearchAndBuildTimes = 0L; - for(int i=0; i<1000; i++) { - SimpleStopWatch stopWatch = new SimpleStopWatch(); -// SearchResponse response = elasticsearchSvc.executeSearchRequest(searchRequest); - totalElapsedTimes += stopWatch.getElapsedTime(); -// List codes = elasticsearchSvc.buildCodeResult(response); - totalElapsedSearchAndBuildTimes += stopWatch.getElapsedTime(); -// assertEquals(1000L, codes.size()); - } - System.out.println("Codes query Average elapsed time = " + totalElapsedTimes/1000 + " ms"); - System.out.println("Codes query Average elapsed search and build time = " + totalElapsedSearchAndBuildTimes/1000 + " ms"); - } - - @Test - public void testObservationsQueryPerformance() throws IOException { - long totalElapsedTimes = 0L; - long totalElapsedSearchAndBuildTimes = 0L; - for(String patientId : patientIds) { - SearchParameterMap searchParameterMap = new SearchParameterMap(); - ReferenceParam subjectParam = new ReferenceParam("Patient", "", patientId); - searchParameterMap.add("subject", subjectParam); - TokenParam categoryParam = new TokenParam("http://mycodes.org/fhir/category-code", "test-category-code"); - searchParameterMap.add("category", categoryParam); - -// SearchRequest searchRequest = elasticsearchSvc.buildObservationTermsSearchRequest(1000, searchParameterMap, 100); - SimpleStopWatch stopWatch = new SimpleStopWatch(); -// SearchResponse response = elasticsearchSvc.executeSearchRequest(searchRequest); - totalElapsedTimes += stopWatch.getElapsedTime(); -// List observations = elasticsearchSvc.buildObservationTermsResults(response); - totalElapsedSearchAndBuildTimes += stopWatch.getElapsedTime(); -// assertEquals(25, observations.size()); - } - System.out.println("Observations query Average elapsed time = " + totalElapsedTimes/(patientIds.size()) + " ms"); - System.out.println("Observations query Average elapsed search and build time = " + totalElapsedSearchAndBuildTimes/(patientIds.size()) + " ms"); - } - -// @Test - public void testSingleObservationsQuery() throws IOException { - long totalElapsedTimes = 0L; - SearchParameterMap searchParameterMap = new SearchParameterMap(); - ReferenceParam subjectParam = new ReferenceParam("Patient", "", "5b2091a5-a50e-447b-aff4-c34b69eb43d5"); - searchParameterMap.add("subject", subjectParam); - TokenParam categoryParam = new TokenParam("http://mycodes.org/fhir/category-code", "test-category-code"); - searchParameterMap.add("category", categoryParam); - -// SearchRequest searchRequest = elasticsearchSvc.buildObservationCompositeSearchRequest(1000, searchParameterMap, 100); - SimpleStopWatch stopWatch = new SimpleStopWatch(); -// SearchResponse response = elasticsearchSvc.executeSearchRequest(searchRequest); - totalElapsedTimes += stopWatch.getElapsedTime(); -// List observations = elasticsearchSvc.buildObservationCompositeResults(response); -// assertEquals(25, observations.size()); - System.out.println("Average elapsed time = " + totalElapsedTimes/1000 + " ms"); - } - -// @Test - public void testLastNObservationsQueryTermsPerformance() throws IOException { - long totalElapsedTimes = 0L; - long totalElapsedSearchAndBuildTimes = 0L; - for(String patientId : patientIds) { - SearchParameterMap searchParameterMap = new SearchParameterMap(); - ReferenceParam subjectParam = new ReferenceParam("Patient", "", patientId); - searchParameterMap.add("subject", subjectParam); - TokenParam categoryParam = new TokenParam("http://mycodes.org/fhir/category-code", "test-category-code"); - searchParameterMap.add("category", categoryParam); - -// SearchRequest searchRequest = elasticsearchSvc.buildObservationTermsSearchRequest(1000, searchParameterMap, 5); - SimpleStopWatch stopWatch = new SimpleStopWatch(); -// SearchResponse response = elasticsearchSvc.executeSearchRequest(searchRequest); - totalElapsedTimes += stopWatch.getElapsedTime(); -// elasticsearchSvc.buildObservationTermsResults(response); - totalElapsedSearchAndBuildTimes += stopWatch.getElapsedTime(); - } - System.out.println("LastN Average elapsed time = " + totalElapsedTimes/(patientIds.size()) + " ms"); - System.out.println("LastN Average elapsed search and Build time = " + totalElapsedSearchAndBuildTimes/(patientIds.size()) + " ms"); - } - -// @Test - public void testLastNObservationsQueryCompPerformance() throws IOException { - long totalElapsedTimes = 0L; - long totalElapsedSearchAndBuildTimes = 0L; - for(String patientId : patientIds) { - SearchParameterMap searchParameterMap = new SearchParameterMap(); - ReferenceParam subjectParam = new ReferenceParam("Patient", "", patientId); - searchParameterMap.add("subject", subjectParam); - TokenParam categoryParam = new TokenParam("http://mycodes.org/fhir/category-code", "test-category-code"); - searchParameterMap.add("category", categoryParam); - -// SearchRequest searchRequest = elasticsearchSvc.buildObservationCompositeSearchRequest(1000, searchParameterMap, 5); - SimpleStopWatch stopWatch = new SimpleStopWatch(); -// SearchResponse response = elasticsearchSvc.executeSearchRequest(searchRequest); - totalElapsedTimes += stopWatch.getElapsedTime(); -// elasticsearchSvc.buildObservationCompositeResults(response); - totalElapsedSearchAndBuildTimes += stopWatch.getElapsedTime(); - } - System.out.println("LastN Average elapsed time = " + totalElapsedTimes/(patientIds.size()) + " ms"); - System.out.println("LastN Average elapsed search and Build time = " + totalElapsedSearchAndBuildTimes/(patientIds.size()) + " ms"); - } - -/* private List buildResults(SearchResponse theSearchResponse) throws IOException { - Aggregations responseAggregations = theSearchResponse.getAggregations(); - ParsedTerms aggregatedObservationCodes = responseAggregations.get("group_by_patient"); - aggregatedObservationCodes.getBuckets(); - List observationCodeBuckets = aggregatedObservationCodes.getBuckets(); - ObjectMapper objectMapper = new ObjectMapper(); - List identifiers = new ArrayList<>(10000); - for (Terms.Bucket observationCodeBucket : observationCodeBuckets) { - Aggregations topHitObservationCodes = observationCodeBucket.getAggregations(); - ParsedTopHits parsedTopHits = topHitObservationCodes.get("most_recent_effective"); - SearchHit[] topHits = parsedTopHits.getHits().getHits(); - for (SearchHit topHit : topHits) { - String sources = topHit.getSourceAsString(); - ObservationJson code = objectMapper.readValue(sources,ObservationJson.class); - identifiers.add(code.getSubject().substring(8)); - } - } - return identifiers; - } -*/ - -} diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchV5PerformanceTests.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchV5PerformanceTests.java deleted file mode 100644 index 96a71aeacc8..00000000000 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchV5PerformanceTests.java +++ /dev/null @@ -1,153 +0,0 @@ -package ca.uhn.fhir.jpa.search.lastn; - -import ca.uhn.fhir.jpa.search.lastn.json.CodeJson; -import ca.uhn.fhir.jpa.search.lastn.json.ObservationJson; -import ca.uhn.fhir.jpa.search.lastn.util.SimpleStopWatch; -import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; -import ca.uhn.fhir.rest.param.ReferenceParam; -import ca.uhn.fhir.rest.param.TokenParam; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.elasticsearch.action.search.SearchRequest; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder; -import org.elasticsearch.index.query.functionscore.RandomScoreFunctionBuilder; -import org.elasticsearch.search.SearchHit; -import org.elasticsearch.search.aggregations.AggregationBuilders; -import org.elasticsearch.search.aggregations.Aggregations; -import org.elasticsearch.search.aggregations.bucket.terms.ParsedTerms; -import org.elasticsearch.search.aggregations.bucket.terms.Terms; -import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; -import org.elasticsearch.search.aggregations.metrics.tophits.ParsedTopHits; -import org.elasticsearch.search.aggregations.support.ValueType; -import org.elasticsearch.search.builder.SearchSourceBuilder; -import org.elasticsearch.search.sort.SortOrder; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import static org.junit.Assert.assertEquals; - -@Ignore -public class ElasticsearchV5PerformanceTests { -/* - private ElasticsearchV5SvcImpl elasticsearchSvc = new ElasticsearchV5SvcImpl("localhost", 9301, "elastic", "changeme"); - private List patientIds = new ArrayList<>(); - - @Before - public void before() throws IOException { - SearchRequest searchRequest = new SearchRequest(IndexConstants.OBSERVATION_INDEX); - SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); - RandomScoreFunctionBuilder randomScoreFunctionBuilder = new RandomScoreFunctionBuilder(); - Date now = new Date(); - randomScoreFunctionBuilder.seed(now.getTime()); - FunctionScoreQueryBuilder functionScoreQueryBuilder = QueryBuilders.functionScoreQuery(randomScoreFunctionBuilder); - searchSourceBuilder.query(functionScoreQueryBuilder); - searchSourceBuilder.size(0); - - // Aggregation by order codes - TermsAggregationBuilder observationCodeValuesBuilder = new TermsAggregationBuilder("group_by_patient", ValueType.STRING).field("subject"); - observationCodeValuesBuilder.size(1000); - // Top Hits Aggregation - String[] topHitsInclude = {"subject"}; - observationCodeValuesBuilder.subAggregation(AggregationBuilders.topHits("most_recent_effective") - .sort("effectivedtm", SortOrder.DESC) - .fetchSource(topHitsInclude, null).size(1)); - - searchSourceBuilder.aggregation(observationCodeValuesBuilder); - searchRequest.source(searchSourceBuilder); - -// SearchResponse response = elasticsearchSvc.executeSearchRequest(searchRequest); -// patientIds = buildResults(response); - - } - - @Test - public void testObservationCodesQueryPerformance() throws IOException { -// SearchRequest searchRequest = elasticsearchSvc.buildObservationCodesSearchRequest(10000); - long totalElapsedTimes = 0L; - long totalElapsedSearchAndBuildTimes = 0L; - for(int i=0; i<1000; i++) { - SimpleStopWatch stopWatch = new SimpleStopWatch(); -// SearchResponse response = elasticsearchSvc.executeSearchRequest(searchRequest); - totalElapsedTimes += stopWatch.getElapsedTime(); -// List codes = elasticsearchSvc.buildCodeResult(response); - totalElapsedSearchAndBuildTimes += stopWatch.getElapsedTime(); -// assertEquals(1000L, codes.size()); - } - System.out.println("Codes query Average elapsed time = " + totalElapsedTimes/1000 + " ms"); - System.out.println("Codes query Average elapsed search and build time = " + totalElapsedSearchAndBuildTimes/1000 + " ms"); - } - - @Test - public void testObservationsQueryPerformance() throws IOException { - long totalElapsedTimes = 0L; - long totalElapsedSearchAndBuildTimes = 0L; - for(String patientId : patientIds) { - SearchParameterMap searchParameterMap = new SearchParameterMap(); - ReferenceParam subjectParam = new ReferenceParam("Patient", "", patientId); - searchParameterMap.add("subject", subjectParam); - TokenParam categoryParam = new TokenParam("http://mycodes.org/fhir/category-code", "test-category-code"); - searchParameterMap.add("category", categoryParam); - -// SearchRequest searchRequest = elasticsearchSvc.buildObservationTermsSearchRequest(1000, searchParameterMap, 100); - SimpleStopWatch stopWatch = new SimpleStopWatch(); -// SearchResponse response = elasticsearchSvc.executeSearchRequest(searchRequest); - totalElapsedTimes += stopWatch.getElapsedTime(); -// List observations = elasticsearchSvc.buildObservationTermsResults(response); - totalElapsedSearchAndBuildTimes += stopWatch.getElapsedTime(); -// assertEquals(25, observations.size()); - } - System.out.println("Observations query Average elapsed time = " + totalElapsedTimes/(patientIds.size()) + " ms"); - System.out.println("Observations query Average elapsed search and build time = " + totalElapsedSearchAndBuildTimes/(patientIds.size()) + " ms"); - } - - @Test - public void testLastNObservationsQueryTermsPerformance() throws IOException { - long totalElapsedTimes = 0L; - long totalElapsedSearchAndBuildTimes = 0L; - for(String patientId : patientIds) { - SearchParameterMap searchParameterMap = new SearchParameterMap(); - ReferenceParam subjectParam = new ReferenceParam("Patient", "", patientId); - searchParameterMap.add("subject", subjectParam); - TokenParam categoryParam = new TokenParam("http://mycodes.org/fhir/category-code", "test-category-code"); - searchParameterMap.add("category", categoryParam); - -// SearchRequest searchRequest = elasticsearchSvc.buildObservationTermsSearchRequest(1000, searchParameterMap, 5); - SimpleStopWatch stopWatch = new SimpleStopWatch(); -// SearchResponse response = elasticsearchSvc.executeSearchRequest(searchRequest); - totalElapsedTimes += stopWatch.getElapsedTime(); -// elasticsearchSvc.buildObservationTermsResults(response); - totalElapsedSearchAndBuildTimes += stopWatch.getElapsedTime(); - } - System.out.println("LastN Average elapsed time = " + totalElapsedTimes/(patientIds.size()) + " ms"); - System.out.println("LastN Average elapsed search and Build time = " + totalElapsedSearchAndBuildTimes/(patientIds.size()) + " ms"); - } - - private List buildResults(SearchResponse theSearchResponse) throws IOException { - Aggregations responseAggregations = theSearchResponse.getAggregations(); - ParsedTerms aggregatedObservationCodes = responseAggregations.get("group_by_patient"); - aggregatedObservationCodes.getBuckets(); - List observationCodeBuckets = aggregatedObservationCodes.getBuckets(); - ObjectMapper objectMapper = new ObjectMapper(); - List identifiers = new ArrayList<>(10000); - for (Terms.Bucket observationCodeBucket : observationCodeBuckets) { - Aggregations topHitObservationCodes = observationCodeBucket.getAggregations(); - ParsedTopHits parsedTopHits = topHitObservationCodes.get("most_recent_effective"); - SearchHit[] topHits = parsedTopHits.getHits().getHits(); - for (SearchHit topHit : topHits) { - String sources = topHit.getSourceAsString(); - ObservationJson code = objectMapper.readValue(sources,ObservationJson.class); - identifiers.add(code.getSubject().substring(8)); - } - } - return identifiers; - } -*/ - -} diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchSvcSingleObservationTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchSvcSingleObservationTest.java index 59011bc48f8..3c210d42453 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchSvcSingleObservationTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchSvcSingleObservationTest.java @@ -37,8 +37,9 @@ public class LastNElasticsearchSvcSingleObservationTest { static ObjectMapper ourMapperNonPrettyPrint; final String RESOURCEPID = "123"; - final String SUBJECTID = "4567"; - final String SUBJECTTYPEANDID = "Patient/4567"; +// final String SUBJECTID = "4567"; +// final String SUBJECTTYPEANDID = "Patient/4567"; + final String SUBJECTID = "Patient/4567"; final Date EFFECTIVEDTM = new Date(); final String FIRSTCATEGORYTEXT = "Test Codeable Concept Field for first category"; final String CATEGORYFIRSTCODINGSYSTEM = "http://mycodes.org/fhir/observation-category"; @@ -150,7 +151,8 @@ public class LastNElasticsearchSvcSingleObservationTest { ObservationJson observation = observations.get(0); assertEquals(RESOURCEPID, observation.getIdentifier()); - assertEquals(SUBJECTTYPEANDID, observation.getSubject()); +// assertEquals(SUBJECTTYPEANDID, observation.getSubject()); + assertEquals(SUBJECTID, observation.getSubject()); assertEquals(RESOURCEPID, observation.getIdentifier()); assertEquals(EFFECTIVEDTM, observation.getEffectiveDtm()); assertEquals(OBSERVATIONSINGLECODEID, observation.getCode_concept_id()); @@ -322,7 +324,8 @@ public class LastNElasticsearchSvcSingleObservationTest { private void createSingleObservation() throws IOException { ObservationJson indexedObservation = new ObservationJson(); indexedObservation.setIdentifier(RESOURCEPID); - indexedObservation.setSubject(SUBJECTTYPEANDID); +// indexedObservation.setSubject(SUBJECTTYPEANDID); + indexedObservation.setSubject(SUBJECTID); indexedObservation.setEffectiveDtm(EFFECTIVEDTM); // Add three CodeableConcepts for category diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchV5SvcMultipleObservationsTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchV5SvcMultipleObservationsTest.java deleted file mode 100644 index a3ded8e1a86..00000000000 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchV5SvcMultipleObservationsTest.java +++ /dev/null @@ -1,312 +0,0 @@ -package ca.uhn.fhir.jpa.search.lastn; - -import ca.uhn.fhir.jpa.search.lastn.config.TestElasticsearchV5Config; -import ca.uhn.fhir.jpa.search.lastn.json.CodeJson; -import ca.uhn.fhir.jpa.search.lastn.json.ObservationJson; -import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; -import ca.uhn.fhir.rest.param.ReferenceParam; -import ca.uhn.fhir.rest.param.TokenParam; -import ca.uhn.fhir.rest.param.TokenParamModifier; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import org.hl7.fhir.r4.model.CodeableConcept; -import org.hl7.fhir.r4.model.Coding; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.elasticsearch.action.search.SearchRequest; -import org.elasticsearch.action.search.SearchResponse; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import java.io.IOException; -import java.util.*; - -import static org.junit.Assert.*; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { TestElasticsearchV5Config.class } ) -public class LastNElasticsearchV5SvcMultipleObservationsTest { - - @Autowired -// private ElasticsearchV5SvcImpl elasticsearchSvc; - - private static ObjectMapper ourMapperNonPrettyPrint; - - private Map>> createdPatientObservationMap = new HashMap<>(); - - - @BeforeClass - public static void beforeClass() { - ourMapperNonPrettyPrint = new ObjectMapper(); - ourMapperNonPrettyPrint.setSerializationInclusion(JsonInclude.Include.NON_NULL); - ourMapperNonPrettyPrint.disable(SerializationFeature.INDENT_OUTPUT); - ourMapperNonPrettyPrint.disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET); - } - - @Before - public void before() throws IOException { -// createMultiplePatientsAndObservations(); - } - - @After - public void after() throws IOException { -// elasticsearchSvc.deleteAllDocuments(IndexConstants.OBSERVATION_INDEX); -// elasticsearchSvc.deleteAllDocuments(IndexConstants.CODE_INDEX); - } -/* - @Test - public void testLastNNoCriteriaQuery() throws IOException { - - // execute Observation ID search (Terms Aggregation) last 3 observations for each patient - SearchRequest searchRequestIdsOnly = elasticsearchSvc.buildObservationTermsSearchRequest(1000, null, 3); - SearchResponse responseIds = elasticsearchSvc.executeSearchRequest(searchRequestIdsOnly); - List observationIdsOnly = elasticsearchSvc.buildObservationTermsResults(responseIds); - - validateQueryResponse(observationIdsOnly); - - } - - private void validateQueryResponse(List observationIdsOnly) { - assertEquals(60, observationIdsOnly.size()); - - // Observation documents should be grouped by subject, then by observation code, and then sorted by effective date/time - // within each observation code. Verify the grouping by creating a nested Map. - Map>> queriedPatientObservationMap = new HashMap<>(); - ObservationJson previousObservationJson = null; - for (ObservationJson observationJson : observationIdsOnly) { - assertNotNull(observationJson.getIdentifier()); - assertNotNull(observationJson.getSubject()); - assertNotNull(observationJson.getCode_concept_id()); - assertNotNull(observationJson.getEffectiveDtm()); - if (previousObservationJson == null) { - ArrayList observationDates = new ArrayList<>(); - observationDates.add(observationJson.getEffectiveDtm()); - Map> codeObservationMap = new HashMap<>(); - codeObservationMap.put(observationJson.getCode_concept_id(),observationDates); - queriedPatientObservationMap.put(observationJson.getSubject(), codeObservationMap); - } else if (observationJson.getSubject().equals(previousObservationJson.getSubject())) { - if (observationJson.getCode_concept_id().equals(previousObservationJson.getCode_concept_id())) { - queriedPatientObservationMap.get(observationJson.getSubject()).get(observationJson.getCode_concept_id()). - add(observationJson.getEffectiveDtm()); - } else { - Map> codeObservationDateMap = queriedPatientObservationMap.get(observationJson.getSubject()); - // Ensure that code concept was not already retrieved out of order for this subject/patient. - assertFalse(codeObservationDateMap.containsKey(observationJson.getCode_concept_id())); - ArrayList observationDates = new ArrayList<>(); - observationDates.add(observationJson.getEffectiveDtm()); - codeObservationDateMap.put(observationJson.getCode_concept_id(),observationDates); - } - } else { - // Ensure that subject/patient was not already retrieved out of order - assertFalse(queriedPatientObservationMap.containsKey(observationJson.getSubject())); - ArrayList observationDates = new ArrayList<>(); - observationDates.add(observationJson.getEffectiveDtm()); - Map> codeObservationMap = new HashMap<>(); - codeObservationMap.put(observationJson.getCode_concept_id(),observationDates); - queriedPatientObservationMap.put(observationJson.getSubject(), codeObservationMap); - } - previousObservationJson = observationJson; - } - - // Finally check that only the most recent effective date/time values were returned and in the correct order. - for(String subjectId : queriedPatientObservationMap.keySet()) { - Map> queriedObservationCodeMap = queriedPatientObservationMap.get(subjectId); - Map> createdObservationCodeMap = createdPatientObservationMap.get(subjectId); - for(String observationCode : queriedObservationCodeMap.keySet()) { - List queriedObservationDates = queriedObservationCodeMap.get(observationCode); - List createdObservationDates = createdObservationCodeMap.get(observationCode); - for (int dateIdx=0; dateIdx observationIdsOnly = elasticsearchSvc.buildObservationTermsResults(responseIds); - - assertEquals(10, observationIdsOnly.size()); - - } - - @Test - public void testLastNCodeCodeOnlyCategoryCodeOnly() throws IOException { - // Include subject and patient - SearchParameterMap searchParameterMap = new SearchParameterMap(); - ReferenceParam subjectParam = new ReferenceParam("Patient", "", "3"); - searchParameterMap.add("subject", subjectParam); - TokenParam categoryParam = new TokenParam ("test-heart-rate"); - searchParameterMap.add("category", categoryParam); - TokenParam codeParam = new TokenParam("test-code-1"); - searchParameterMap.add("code", codeParam); - - SearchRequest searchRequestIdsOnly = elasticsearchSvc.buildObservationTermsSearchRequest(1000, searchParameterMap, 100); - SearchResponse responseIds = elasticsearchSvc.executeSearchRequest(searchRequestIdsOnly); - List observationIdsOnly = elasticsearchSvc.buildObservationTermsResults(responseIds); - - assertEquals(5, observationIdsOnly.size()); - - } - - @Test - public void testLastNCodeSystemOnlyCategorySystemOnly() throws IOException { - // Include subject and patient - SearchParameterMap searchParameterMap = new SearchParameterMap(); - ReferenceParam subjectParam = new ReferenceParam("Patient", "", "3"); - searchParameterMap.add("subject", subjectParam); - TokenParam categoryParam = new TokenParam("http://mycodes.org/fhir/observation-category", null); - searchParameterMap.add("category", categoryParam); - TokenParam codeParam = new TokenParam("http://mycodes.org/fhir/observation-code", null); - searchParameterMap.add("code", codeParam); - - SearchRequest searchRequestIdsOnly = elasticsearchSvc.buildObservationTermsSearchRequest(1000, searchParameterMap, 100); - SearchResponse responseIds = elasticsearchSvc.executeSearchRequest(searchRequestIdsOnly); - List observationIdsOnly = elasticsearchSvc.buildObservationTermsResults(responseIds); - - assertEquals(10, observationIdsOnly.size()); - } - - @Test - public void testLastNCodeCodeTextCategoryTextOnly() throws IOException { - SearchParameterMap searchParameterMap = new SearchParameterMap(); - ReferenceParam subjectParam = new ReferenceParam("Patient", "", "3"); - searchParameterMap.add("subject", subjectParam); - TokenParam categoryParam = new TokenParam("test-heart-rate display"); - categoryParam.setModifier(TokenParamModifier.TEXT); - searchParameterMap.add("category", categoryParam); - TokenParam codeParam = new TokenParam("test-code-1 display"); - codeParam.setModifier(TokenParamModifier.TEXT); - searchParameterMap.add("code", codeParam); - - SearchRequest searchRequestIdsOnly = elasticsearchSvc.buildObservationTermsSearchRequest(1000, searchParameterMap, 100); - SearchResponse responseIds = elasticsearchSvc.executeSearchRequest(searchRequestIdsOnly); - List observationIdsOnly = elasticsearchSvc.buildObservationTermsResults(responseIds); - - assertEquals(5, observationIdsOnly.size()); - - } - - private void createMultiplePatientsAndObservations() throws IOException { - // Create CodeableConcepts for two Codes, each with three codings. - String codeableConceptId1 = UUID.randomUUID().toString(); - CodeableConcept codeableConceptField1 = new CodeableConcept().setText("Test Codeable Concept Field for First Code"); - codeableConceptField1.addCoding(new Coding("http://mycodes.org/fhir/observation-code", "test-code-1", "test-code-1 display")); - codeableConceptField1.addCoding(new Coding("http://myalternatecodes.org/fhir/observation-code", "test-alt-code-1", "test-alt-code-1 display")); - codeableConceptField1.addCoding(new Coding("http://mysecondaltcodes.org/fhir/observation-code", "test-second-alt-code-1", "test-second-alt-code-1 display")); - CodeJson codeJson1 = new CodeJson(codeableConceptField1, codeableConceptId1); - String codeJson1Document = ourMapperNonPrettyPrint.writeValueAsString(codeJson1); - - String codeableConceptId2 = UUID.randomUUID().toString(); - CodeableConcept codeableConceptField2 = new CodeableConcept().setText("Test Codeable Concept Field for Second Code"); - codeableConceptField2.addCoding(new Coding("http://mycodes.org/fhir/observation-code", "test-code-2", "test-code-2 display")); - codeableConceptField2.addCoding(new Coding("http://myalternatecodes.org/fhir/observation-code", "test-alt-code-2", "test-alt-code-2 display")); - codeableConceptField2.addCoding(new Coding("http://mysecondaltcodes.org/fhir/observation-code", "test-second-alt-code-2", "test-second-alt-code-2 display")); - CodeJson codeJson2 = new CodeJson(codeableConceptField2, codeableConceptId2); - String codeJson2Document = ourMapperNonPrettyPrint.writeValueAsString(codeJson2); - - // Create CodeableConcepts for two categories, each with three codings. - List category1 = new ArrayList<>(); - // Create three codings and first category CodeableConcept - category1.add(new Coding("http://mycodes.org/fhir/observation-category", "test-heart-rate", "test-heart-rate display")); - category1.add(new Coding("http://myalternatecodes.org/fhir/observation-category", "test-alt-heart-rate", "test-alt-heart-rate display")); - category1.add(new Coding("http://mysecondaltcodes.org/fhir/observation-category", "test-2nd-alt-heart-rate", "test-2nd-alt-heart-rate display")); - List categoryConcepts1 = new ArrayList<>(); - CodeableConcept categoryCodeableConcept1 = new CodeableConcept().setText("Test Codeable Concept Field for first category"); - categoryCodeableConcept1.setCoding(category1); - categoryConcepts1.add(categoryCodeableConcept1); - // Create three codings and second category CodeableConcept - List category2 = new ArrayList<>(); - category2.add(new Coding("http://mycodes.org/fhir/observation-category", "test-vital-signs", "test-vital-signs display")); - category2.add(new Coding("http://myalternatecodes.org/fhir/observation-category", "test-alt-vitals", "test-alt-vitals display")); - category2.add(new Coding("http://mysecondaltcodes.org/fhir/observation-category", "test-2nd-alt-vitals", "test-2nd-alt-vitals display")); - List categoryConcepts2 = new ArrayList<>(); - CodeableConcept categoryCodeableConcept2 = new CodeableConcept().setText("Test Codeable Concept Field for second category"); - categoryCodeableConcept2.setCoding(category2); - categoryConcepts2.add(categoryCodeableConcept2); - - for (int patientCount = 0; patientCount < 10 ; patientCount++) { - - String subject = "Patient/"+patientCount; - - for ( int entryCount = 0; entryCount < 10 ; entryCount++ ) { - - ObservationJson observationJson = new ObservationJson(); - String identifier = String.valueOf((entryCount + patientCount*10)); - observationJson.setIdentifier(identifier); - observationJson.setSubject(subject); - - if (entryCount%2 == 1) { - observationJson.setCategories(categoryConcepts1); - observationJson.setCode(codeableConceptField1); - observationJson.setCode_concept_id(codeableConceptId1); - assertTrue(elasticsearchSvc.performIndex(IndexConstants.CODE_INDEX, codeableConceptId1, codeJson1Document, IndexConstants.CODE_DOCUMENT_TYPE)); - } else { - observationJson.setCategories(categoryConcepts2); - observationJson.setCode(codeableConceptField2); - observationJson.setCode_concept_id(codeableConceptId2); - assertTrue(elasticsearchSvc.performIndex(IndexConstants.CODE_INDEX, codeableConceptId2, codeJson2Document, IndexConstants.CODE_DOCUMENT_TYPE)); - } - - Calendar observationDate = new GregorianCalendar(); - observationDate.add(Calendar.HOUR, -10 + entryCount); - Date effectiveDtm = observationDate.getTime(); - observationJson.setEffectiveDtm(effectiveDtm); - - String observationDocument = ourMapperNonPrettyPrint.writeValueAsString(observationJson); - assertTrue(elasticsearchSvc.performIndex(IndexConstants.OBSERVATION_INDEX, identifier,observationDocument, IndexConstants.OBSERVATION_DOCUMENT_TYPE)); - - if (createdPatientObservationMap.containsKey(subject)) { - Map> observationCodeMap = createdPatientObservationMap.get(subject); - if (observationCodeMap.containsKey(observationJson.getCode_concept_id())) { - List observationDates = observationCodeMap.get(observationJson.getCode_concept_id()); - // Want dates to be sorted in descending order - observationDates.add(0, effectiveDtm); - // Only keep the three most recent dates for later check. - if(observationDates.size() > 3) { - observationDates.remove(3); - } - } else { - ArrayList observationDates = new ArrayList<>(); - observationDates.add(effectiveDtm); - observationCodeMap.put(observationJson.getCode_concept_id(), observationDates); - } - } else { - ArrayList observationDates = new ArrayList<>(); - observationDates.add(effectiveDtm); - Map> codeObservationMap = new HashMap<>(); - codeObservationMap.put(observationJson.getCode_concept_id(), observationDates); - createdPatientObservationMap.put(subject, codeObservationMap); - } - } - } - - try { - Thread.sleep(2000L); - } catch (InterruptedException theE) { - theE.printStackTrace(); - } - - } -*/ -} diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchV5SvcSingleObservationTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchV5SvcSingleObservationTest.java deleted file mode 100644 index 5c2479957aa..00000000000 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchV5SvcSingleObservationTest.java +++ /dev/null @@ -1,346 +0,0 @@ -package ca.uhn.fhir.jpa.search.lastn; - -import ca.uhn.fhir.jpa.search.lastn.config.TestElasticsearchV5Config; -import ca.uhn.fhir.jpa.search.lastn.json.CodeJson; -import ca.uhn.fhir.jpa.search.lastn.json.ObservationJson; -import ca.uhn.fhir.jpa.search.lastn.util.CodeSystemHash; -import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; -import ca.uhn.fhir.rest.param.ReferenceParam; -import ca.uhn.fhir.rest.param.TokenParam; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import org.hl7.fhir.r4.model.CodeableConcept; -import org.hl7.fhir.r4.model.Coding; -import org.junit.After; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.elasticsearch.action.search.SearchRequest; -import org.elasticsearch.action.search.SearchResponse; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.UUID; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { TestElasticsearchV5Config.class } ) -public class LastNElasticsearchV5SvcSingleObservationTest { - - @Autowired -// ElasticsearchV5SvcImpl elasticsearchSvc; - - static ObjectMapper ourMapperNonPrettyPrint; - - final String RESOURCEPID = "123"; - final String SUBJECTID = "4567"; - final String SUBJECTTYPEANDID = "Patient/4567"; - final Date EFFECTIVEDTM = new Date(); - final String FIRSTCATEGORYTEXT = "Test Codeable Concept Field for first category"; - final String CATEGORYFIRSTCODINGSYSTEM = "http://mycodes.org/fhir/observation-category"; - final String CATEGORYSECONDCODINGSYSTEM = "http://myalternatecodes.org/fhir/observation-category"; - final String CATEGORYTHIRDCODINGSYSTEM = "http://mysecondaltcodes.org/fhir/observation-category"; - final String FIRSTCATEGORYFIRSTCODINGCODE = "test-heart-rate"; - final String FIRSTCATEGORYFIRSTCODINGDISPLAY = "test-heart-rate display"; - final String FIRSTCATEGORYSECONDCODINGCODE = "test-alt-heart-rate"; - final String FIRSTCATEGORYSECONDCODINGDISPLAY = "test-alt-heart-rate display"; - final String FIRSTCATEGORYTHIRDCODINGCODE = "test-2nd-alt-heart-rate"; - final String FIRSTCATEGORYTHIRDCODINGDISPLAY = "test-2nd-alt-heart-rate display"; - final String SECONDCATEGORYTEXT = "Test Codeable Concept Field for for second category"; - final String SECONDCATEGORYFIRSTCODINGCODE = "test-vital-signs"; - final String SECONDCATEGORYFIRSTCODINGDISPLAY = "test-vital-signs display"; - final String SECONDCATEGORYSECONDCODINGCODE = "test-alt-vitals"; - final String SECONDCATEGORYSECONDCODINGDISPLAY = "test-alt-vitals display"; - final String SECONDCATEGORYTHIRDCODINGCODE = "test-2nd-alt-vitals"; - final String SECONDCATEGORYTHIRDCODINGDISPLAY = "test-2nd-alt-vitals display"; - final String THIRDCATEGORYTEXT = "Test Codeable Concept Field for third category"; - final String THIRDCATEGORYFIRSTCODINGCODE = "test-vital-panel"; - final String THIRDCATEGORYFIRSTCODINGDISPLAY = "test-vitals-panel display"; - final String THIRDCATEGORYSECONDCODINGCODE = "test-alt-vitals-panel"; - final String THIRDCATEGORYSECONDCODINGDISPLAY = "test-alt-vitals display"; - final String THIRDCATEGORYTHIRDCODINGCODE = "test-2nd-alt-vitals-panel"; - final String THIRDCATEGORYTHIRDCODINGDISPLAY = "test-2nd-alt-vitals-panel display"; - - final String OBSERVATIONSINGLECODEID = UUID.randomUUID().toString(); - final String OBSERVATIONCODETEXT = "Test Codeable Concept Field for Code"; - final String CODEFIRSTCODINGSYSTEM = "http://mycodes.org/fhir/observation-code"; - final String CODEFIRSTCODINGCODE = "test-code"; - final String CODEFIRSTCODINGDISPLAY = "test-code display"; - final String CODESECONDCODINGSYSTEM = "http://myalternatecodes.org/fhir/observation-code"; - final String CODESECONDCODINGCODE = "test-alt-code"; - final String CODESECONDCODINGDISPLAY = "test-alt-code display"; - final String CODETHIRDCODINGSYSTEM = "http://mysecondaltcodes.org/fhir/observation-code"; - final String CODETHIRDCODINGCODE = "test-second-alt-code"; - final String CODETHIRDCODINGDISPLAY = "test-second-alt-code display"; - - @BeforeClass - public static void beforeClass() { - ourMapperNonPrettyPrint = new ObjectMapper(); - ourMapperNonPrettyPrint.setSerializationInclusion(JsonInclude.Include.NON_NULL); - ourMapperNonPrettyPrint.disable(SerializationFeature.INDENT_OUTPUT); - ourMapperNonPrettyPrint.disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET); - - } - - // @Before - public void before() throws IOException { -// elasticsearchSvc.deleteAllDocuments(IndexConstants.OBSERVATION_INDEX); -// elasticsearchSvc.deleteAllDocuments(IndexConstants.CODE_INDEX); - } - - @After - public void after() throws IOException { -// elasticsearchSvc.deleteAllDocuments(IndexConstants.OBSERVATION_INDEX); -// elasticsearchSvc.deleteAllDocuments(IndexConstants.CODE_INDEX); - } - @Test - public void testSingleObservationQuery() throws IOException { - - createSingleObservation(); - - SearchParameterMap searchParameterMap = new SearchParameterMap(); - ReferenceParam subjectParam = new ReferenceParam("Patient", "", SUBJECTID); - searchParameterMap.add("subject", subjectParam); - TokenParam categoryParam = new TokenParam(CATEGORYFIRSTCODINGSYSTEM, FIRSTCATEGORYFIRSTCODINGCODE); - searchParameterMap.add("category", categoryParam); - TokenParam codeParam = new TokenParam(CODEFIRSTCODINGSYSTEM, CODEFIRSTCODINGCODE); - searchParameterMap.add("code", codeParam); - - // execute Observation ID search - Terms Aggregation -/* SearchRequest searchRequestIdsOnly = elasticsearchSvc.buildObservationTermsSearchRequest(1000, searchParameterMap, 3); - SearchResponse responseIds = elasticsearchSvc.executeSearchRequest(searchRequestIdsOnly); - List observationIdsOnly = elasticsearchSvc.buildObservationTermsResults(responseIds); - - assertEquals(1, observationIdsOnly.size()); - ObservationJson observationIdOnly = observationIdsOnly.get(0); - assertEquals(RESOURCEPID, observationIdOnly.getIdentifier()); - - // execute full Observation search - Terms Aggregation - SearchRequest searchRequestAllFields = elasticsearchSvc.buildObservationAllFieldsTermsSearchRequest(1000, searchParameterMap, 3); - SearchResponse response = elasticsearchSvc.executeSearchRequest(searchRequestAllFields); - List observations = elasticsearchSvc.buildObservationTermsResults(response); - - validateFullObservationSearch(observations); -*/ - } - - private void validateFullObservationSearch(List observations) throws IOException { - - assertEquals(1, observations.size()); - ObservationJson observation = observations.get(0); - assertEquals(RESOURCEPID, observation.getIdentifier()); - - assertEquals(SUBJECTTYPEANDID, observation.getSubject()); - assertEquals(RESOURCEPID, observation.getIdentifier()); - assertEquals(EFFECTIVEDTM, observation.getEffectiveDtm()); - assertEquals(OBSERVATIONSINGLECODEID, observation.getCode_concept_id()); - - List category_concept_text_values = observation.getCategory_concept_text(); - assertEquals(3,category_concept_text_values.size()); - assertEquals(FIRSTCATEGORYTEXT, category_concept_text_values.get(0)); - assertEquals(SECONDCATEGORYTEXT, category_concept_text_values.get(1)); - assertEquals(THIRDCATEGORYTEXT, category_concept_text_values.get(2)); - - List> category_codings_systems = observation.getCategory_coding_system(); - assertEquals(3,category_codings_systems.size()); - List category_coding_systems = category_codings_systems.get(0); - assertEquals(3, category_coding_systems.size()); - assertEquals(CATEGORYFIRSTCODINGSYSTEM, category_coding_systems.get(0)); - assertEquals(CATEGORYSECONDCODINGSYSTEM, category_coding_systems.get(1)); - assertEquals(CATEGORYTHIRDCODINGSYSTEM, category_coding_systems.get(2)); - category_codings_systems.get(1); - assertEquals(3, category_coding_systems.size()); - assertEquals(CATEGORYFIRSTCODINGSYSTEM, category_coding_systems.get(0)); - assertEquals(CATEGORYSECONDCODINGSYSTEM, category_coding_systems.get(1)); - assertEquals(CATEGORYTHIRDCODINGSYSTEM, category_coding_systems.get(2)); - category_codings_systems.get(2); - assertEquals(3, category_coding_systems.size()); - assertEquals(CATEGORYFIRSTCODINGSYSTEM, category_coding_systems.get(0)); - assertEquals(CATEGORYSECONDCODINGSYSTEM, category_coding_systems.get(1)); - assertEquals(CATEGORYTHIRDCODINGSYSTEM, category_coding_systems.get(2)); - - List> category_codings_codes = observation.getCategory_coding_code(); - assertEquals(3, category_codings_codes.size()); - List category_coding_codes = category_codings_codes.get(0); - assertEquals(3, category_coding_codes.size()); - assertEquals(FIRSTCATEGORYFIRSTCODINGCODE, category_coding_codes.get(0)); - assertEquals(FIRSTCATEGORYSECONDCODINGCODE, category_coding_codes.get(1)); - assertEquals(FIRSTCATEGORYTHIRDCODINGCODE, category_coding_codes.get(2)); - category_coding_codes = category_codings_codes.get(1); - assertEquals(3, category_coding_codes.size()); - assertEquals(SECONDCATEGORYFIRSTCODINGCODE, category_coding_codes.get(0)); - assertEquals(SECONDCATEGORYSECONDCODINGCODE, category_coding_codes.get(1)); - assertEquals(SECONDCATEGORYTHIRDCODINGCODE, category_coding_codes.get(2)); - category_coding_codes = category_codings_codes.get(2); - assertEquals(3, category_coding_codes.size()); - assertEquals(THIRDCATEGORYFIRSTCODINGCODE, category_coding_codes.get(0)); - assertEquals(THIRDCATEGORYSECONDCODINGCODE, category_coding_codes.get(1)); - assertEquals(THIRDCATEGORYTHIRDCODINGCODE, category_coding_codes.get(2)); - - List> category_codings_displays = observation.getCategory_coding_display(); - assertEquals(3, category_codings_displays.size()); - List category_coding_displays = category_codings_displays.get(0); - assertEquals(FIRSTCATEGORYFIRSTCODINGDISPLAY, category_coding_displays.get(0)); - assertEquals(FIRSTCATEGORYSECONDCODINGDISPLAY, category_coding_displays.get(1)); - assertEquals(FIRSTCATEGORYTHIRDCODINGDISPLAY, category_coding_displays.get(2)); - category_coding_displays = category_codings_displays.get(1); - assertEquals(3, category_coding_displays.size()); - assertEquals(SECONDCATEGORYFIRSTCODINGDISPLAY, category_coding_displays.get(0)); - assertEquals(SECONDCATEGORYSECONDCODINGDISPLAY, category_coding_displays.get(1)); - assertEquals(SECONDCATEGORYTHIRDCODINGDISPLAY, category_coding_displays.get(2)); - category_coding_displays = category_codings_displays.get(2); - assertEquals(3, category_coding_displays.size()); - assertEquals(THIRDCATEGORYFIRSTCODINGDISPLAY, category_coding_displays.get(0)); - assertEquals(THIRDCATEGORYSECONDCODINGDISPLAY, category_coding_displays.get(1)); - assertEquals(THIRDCATEGORYTHIRDCODINGDISPLAY, category_coding_displays.get(2)); - - List> category_codings_code_system_hashes = observation.getCategory_coding_code_system_hash(); - assertEquals(3, category_codings_code_system_hashes.size()); - List category_coding_code_system_hashes = category_codings_code_system_hashes.get(0); - assertEquals(String.valueOf(CodeSystemHash.hashCodeSystem(CATEGORYFIRSTCODINGSYSTEM, FIRSTCATEGORYFIRSTCODINGCODE)), category_coding_code_system_hashes.get(0)); - assertEquals(String.valueOf(CodeSystemHash.hashCodeSystem(CATEGORYSECONDCODINGSYSTEM, FIRSTCATEGORYSECONDCODINGCODE)), category_coding_code_system_hashes.get(1)); - assertEquals(String.valueOf(CodeSystemHash.hashCodeSystem(CATEGORYTHIRDCODINGSYSTEM, FIRSTCATEGORYTHIRDCODINGCODE)), category_coding_code_system_hashes.get(2)); - category_coding_code_system_hashes = category_codings_code_system_hashes.get(1); - assertEquals(3, category_coding_code_system_hashes.size()); - assertEquals(String.valueOf(CodeSystemHash.hashCodeSystem(CATEGORYFIRSTCODINGSYSTEM, SECONDCATEGORYFIRSTCODINGCODE)), category_coding_code_system_hashes.get(0)); - assertEquals(String.valueOf(CodeSystemHash.hashCodeSystem(CATEGORYSECONDCODINGSYSTEM, SECONDCATEGORYSECONDCODINGCODE)), category_coding_code_system_hashes.get(1)); - assertEquals(String.valueOf(CodeSystemHash.hashCodeSystem(CATEGORYTHIRDCODINGSYSTEM, SECONDCATEGORYTHIRDCODINGCODE)), category_coding_code_system_hashes.get(2)); - category_coding_code_system_hashes = category_codings_code_system_hashes.get(2); - assertEquals(3, category_coding_code_system_hashes.size()); - assertEquals(String.valueOf(CodeSystemHash.hashCodeSystem(CATEGORYFIRSTCODINGSYSTEM, THIRDCATEGORYFIRSTCODINGCODE)), category_coding_code_system_hashes.get(0)); - assertEquals(String.valueOf(CodeSystemHash.hashCodeSystem(CATEGORYSECONDCODINGSYSTEM, THIRDCATEGORYSECONDCODINGCODE)), category_coding_code_system_hashes.get(1)); - assertEquals(String.valueOf(CodeSystemHash.hashCodeSystem(CATEGORYTHIRDCODINGSYSTEM, THIRDCATEGORYTHIRDCODINGCODE)), category_coding_code_system_hashes.get(2)); - - String code_concept_text_values = observation.getCode_concept_text(); - assertEquals(OBSERVATIONCODETEXT, code_concept_text_values); -/* - List code_coding_systems = observation.getCode_coding_system(); - assertEquals(3,code_coding_systems.size()); - assertEquals(CODEFIRSTCODINGSYSTEM, code_coding_systems.get(0)); - assertEquals(CODESECONDCODINGSYSTEM, code_coding_systems.get(1)); - assertEquals(CODETHIRDCODINGSYSTEM, code_coding_systems.get(2)); - - List code_coding_codes = observation.getCode_coding_code(); - assertEquals(3, code_coding_codes.size()); - assertEquals(CODEFIRSTCODINGCODE, code_coding_codes.get(0)); - assertEquals(CODESECONDCODINGCODE, code_coding_codes.get(1)); - assertEquals(CODETHIRDCODINGCODE, code_coding_codes.get(2)); - - List code_coding_display = observation.getCode_coding_display(); - assertEquals(3, code_coding_display.size()); - assertEquals(CODEFIRSTCODINGDISPLAY, code_coding_display.get(0)); - assertEquals(CODESECONDCODINGDISPLAY, code_coding_display.get(1)); - assertEquals(CODETHIRDCODINGDISPLAY, code_coding_display.get(2)); - - List code_coding_code_system_hash = observation.getCode_coding_code_system_hash(); - assertEquals(3, code_coding_code_system_hash.size()); - assertEquals(String.valueOf(CodeSystemHash.hashCodeSystem(CODEFIRSTCODINGSYSTEM, CODEFIRSTCODINGCODE)), code_coding_code_system_hash.get(0)); - assertEquals(String.valueOf(CodeSystemHash.hashCodeSystem(CODESECONDCODINGSYSTEM, CODESECONDCODINGCODE)), code_coding_code_system_hash.get(1)); - assertEquals(String.valueOf(CodeSystemHash.hashCodeSystem(CODETHIRDCODINGSYSTEM, CODETHIRDCODINGCODE)), code_coding_code_system_hash.get(2)); -*/ - // Retrieve all Observation codes -/* SearchRequest searchRequest = elasticsearchSvc.buildObservationCodesSearchRequest(1000); - SearchResponse response = elasticsearchSvc.executeSearchRequest(searchRequest); - List codes = elasticsearchSvc.buildCodeResult(response); - assertEquals(1, codes.size()); - CodeJson persistedObservationCode = codes.get(0); - - String persistedCodeConceptID = persistedObservationCode.getCodeableConceptId(); - assertEquals(OBSERVATIONSINGLECODEID, persistedCodeConceptID); - String persistedCodeConceptText = persistedObservationCode.getCodeableConceptText(); - assertEquals(OBSERVATIONCODETEXT, persistedCodeConceptText); - - List persistedCodeCodingSystems = persistedObservationCode.getCoding_system(); - assertEquals(3,persistedCodeCodingSystems.size()); - assertEquals(CODEFIRSTCODINGSYSTEM, persistedCodeCodingSystems.get(0)); - assertEquals(CODESECONDCODINGSYSTEM, persistedCodeCodingSystems.get(1)); - assertEquals(CODETHIRDCODINGSYSTEM, persistedCodeCodingSystems.get(2)); - - List persistedCodeCodingCodes = persistedObservationCode.getCoding_code(); - assertEquals(3, persistedCodeCodingCodes.size()); - assertEquals(CODEFIRSTCODINGCODE, persistedCodeCodingCodes.get(0)); - assertEquals(CODESECONDCODINGCODE, persistedCodeCodingCodes.get(1)); - assertEquals(CODETHIRDCODINGCODE, persistedCodeCodingCodes.get(2)); - - List persistedCodeCodingDisplays = persistedObservationCode.getCoding_display(); - assertEquals(3, persistedCodeCodingDisplays.size()); - assertEquals(CODEFIRSTCODINGDISPLAY, persistedCodeCodingDisplays.get(0)); - assertEquals(CODESECONDCODINGDISPLAY, persistedCodeCodingDisplays.get(1)); - assertEquals(CODETHIRDCODINGDISPLAY, persistedCodeCodingDisplays.get(2)); - - List persistedCodeCodingCodeSystemHashes = persistedObservationCode.getCoding_code_system_hash(); - assertEquals(3, persistedCodeCodingCodeSystemHashes.size()); - assertEquals(String.valueOf(CodeSystemHash.hashCodeSystem(CODEFIRSTCODINGSYSTEM, CODEFIRSTCODINGCODE)), persistedCodeCodingCodeSystemHashes.get(0)); - assertEquals(String.valueOf(CodeSystemHash.hashCodeSystem(CODESECONDCODINGSYSTEM, CODESECONDCODINGCODE)), persistedCodeCodingCodeSystemHashes.get(1)); - assertEquals(String.valueOf(CodeSystemHash.hashCodeSystem(CODETHIRDCODINGSYSTEM, CODETHIRDCODINGCODE)), persistedCodeCodingCodeSystemHashes.get(2)); -*/ - - } - - private void createSingleObservation() throws IOException { - ObservationJson indexedObservation = new ObservationJson(); - indexedObservation.setIdentifier(RESOURCEPID); - indexedObservation.setSubject(SUBJECTTYPEANDID); - indexedObservation.setEffectiveDtm(EFFECTIVEDTM); - - // Add three CodeableConcepts for category - List categoryConcepts = new ArrayList<>(); - // Create three codings and first category CodeableConcept - List category1 = new ArrayList<>(); - CodeableConcept categoryCodeableConcept1 = new CodeableConcept().setText(FIRSTCATEGORYTEXT); - category1.add(new Coding(CATEGORYFIRSTCODINGSYSTEM, FIRSTCATEGORYFIRSTCODINGCODE, FIRSTCATEGORYFIRSTCODINGDISPLAY)); - category1.add(new Coding(CATEGORYSECONDCODINGSYSTEM, FIRSTCATEGORYSECONDCODINGCODE, FIRSTCATEGORYSECONDCODINGDISPLAY)); - category1.add(new Coding(CATEGORYTHIRDCODINGSYSTEM, FIRSTCATEGORYTHIRDCODINGCODE, FIRSTCATEGORYTHIRDCODINGDISPLAY)); - categoryCodeableConcept1.setCoding(category1); - categoryConcepts.add(categoryCodeableConcept1); - // Create three codings and second category CodeableConcept - List category2 = new ArrayList<>(); - CodeableConcept categoryCodeableConcept2 = new CodeableConcept().setText(SECONDCATEGORYTEXT); - category2.add(new Coding(CATEGORYFIRSTCODINGSYSTEM, SECONDCATEGORYFIRSTCODINGCODE, SECONDCATEGORYFIRSTCODINGDISPLAY)); - category2.add(new Coding(CATEGORYSECONDCODINGSYSTEM, SECONDCATEGORYSECONDCODINGCODE, SECONDCATEGORYSECONDCODINGDISPLAY)); - category2.add(new Coding(CATEGORYTHIRDCODINGSYSTEM, SECONDCATEGORYTHIRDCODINGCODE, SECONDCATEGORYTHIRDCODINGDISPLAY)); - categoryCodeableConcept2.setCoding(category2); - categoryConcepts.add(categoryCodeableConcept2); - // Create three codings and third category CodeableConcept - List category3 = new ArrayList<>(); - CodeableConcept categoryCodeableConcept3 = new CodeableConcept().setText(THIRDCATEGORYTEXT); - category3.add(new Coding(CATEGORYFIRSTCODINGSYSTEM, THIRDCATEGORYFIRSTCODINGCODE, THIRDCATEGORYFIRSTCODINGDISPLAY)); - category3.add(new Coding(CATEGORYSECONDCODINGSYSTEM, THIRDCATEGORYSECONDCODINGCODE, THIRDCATEGORYSECONDCODINGDISPLAY)); - category3.add(new Coding(CATEGORYTHIRDCODINGSYSTEM, THIRDCATEGORYTHIRDCODINGCODE, THIRDCATEGORYTHIRDCODINGDISPLAY)); - categoryCodeableConcept3.setCoding(category3); - categoryConcepts.add(categoryCodeableConcept3); - indexedObservation.setCategories(categoryConcepts); - - // Create CodeableConcept for Code with three codings. - indexedObservation.setCode_concept_id(OBSERVATIONSINGLECODEID); - CodeableConcept codeableConceptField = new CodeableConcept().setText(OBSERVATIONCODETEXT); - codeableConceptField.addCoding(new Coding(CODEFIRSTCODINGSYSTEM, CODEFIRSTCODINGCODE, CODEFIRSTCODINGDISPLAY)); - codeableConceptField.addCoding(new Coding(CODESECONDCODINGSYSTEM, CODESECONDCODINGCODE, CODESECONDCODINGDISPLAY)); - codeableConceptField.addCoding(new Coding(CODETHIRDCODINGSYSTEM, CODETHIRDCODINGCODE, CODETHIRDCODINGDISPLAY)); - indexedObservation.setCode(codeableConceptField); - - String observationDocument = ourMapperNonPrettyPrint.writeValueAsString(indexedObservation); -// assertTrue(elasticsearchSvc.performIndex(IndexConstants.OBSERVATION_INDEX, RESOURCEPID, observationDocument, IndexConstants.OBSERVATION_DOCUMENT_TYPE)); - - CodeJson observationCode = new CodeJson(codeableConceptField, OBSERVATIONSINGLECODEID); - String codeDocument = ourMapperNonPrettyPrint.writeValueAsString(observationCode); -// assertTrue(elasticsearchSvc.performIndex(IndexConstants.CODE_INDEX, OBSERVATIONSINGLECODEID, codeDocument, IndexConstants.CODE_DOCUMENT_TYPE)); - - try { - Thread.sleep(1000L); - } catch (InterruptedException theE) { - theE.printStackTrace(); - } - - } - -}