Working on valueset operations in JPA
This commit is contained in:
parent
d5b99c2c10
commit
89965fb6bd
|
@ -0,0 +1,113 @@
|
|||
package ca.uhn.fhir.jpa.provider;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR JPA Server
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2015 University Health Network
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import ca.uhn.fhir.model.dstu2.resource.ValueSet;
|
||||
import ca.uhn.fhir.model.dstu2.resource.ValueSet.ComposeInclude;
|
||||
import ca.uhn.fhir.model.dstu2.resource.ValueSet.ComposeIncludeConcept;
|
||||
import ca.uhn.fhir.model.dstu2.resource.ValueSet.DefineConcept;
|
||||
import ca.uhn.fhir.model.primitive.DateTimeDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Operation;
|
||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
|
||||
public class BaseJpaResourceProviderValueSetDstu2 extends JpaResourceProviderDstu2<ValueSet> {
|
||||
|
||||
@Operation(name = "$expand", idempotent = true)
|
||||
public ValueSet everything(HttpServletRequest theServletRequest, @IdParam IdDt theId, @OperationParam(name = "filter") StringDt theFilter) {
|
||||
startRequest(theServletRequest);
|
||||
try {
|
||||
ValueSet retVal = new ValueSet();
|
||||
retVal.setDate(DateTimeDt.withCurrentTime());
|
||||
|
||||
ValueSet source = read(theServletRequest, theId);
|
||||
|
||||
Map<String, ComposeInclude> systemToCompose = new HashMap<String, ComposeInclude>();
|
||||
|
||||
/*
|
||||
* Add composed concepts
|
||||
*/
|
||||
|
||||
for (ComposeInclude nextInclude : source.getCompose().getInclude()) {
|
||||
for (ComposeIncludeConcept next : nextInclude.getConcept()) {
|
||||
ComposeInclude include = null;
|
||||
if (theFilter == null || theFilter.isEmpty()) {
|
||||
if (include == null) {
|
||||
include = getOrAddComposeInclude(retVal, systemToCompose, nextInclude.getSystem());
|
||||
}
|
||||
include.addConcept(next);
|
||||
} else {
|
||||
String filter = theFilter.getValue().toLowerCase();
|
||||
if (next.getDisplay().toLowerCase().contains(filter) || next.getCode().toLowerCase().contains(filter)) {
|
||||
if (include == null) {
|
||||
include = getOrAddComposeInclude(retVal, systemToCompose, nextInclude.getSystem());
|
||||
}
|
||||
include.addConcept(next);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Add defined concepts
|
||||
*/
|
||||
|
||||
ComposeInclude include = null;
|
||||
for (DefineConcept next : source.getDefine().getConcept()) {
|
||||
if (theFilter == null || theFilter.isEmpty()) {
|
||||
if (include == null) {
|
||||
include = getOrAddComposeInclude(retVal, systemToCompose, source.getDefine().getSystem());
|
||||
}
|
||||
include.addConcept(new ComposeIncludeConcept().setCode(next.getCode()).setDisplay(next.getDisplay()));
|
||||
} else {
|
||||
String filter = theFilter.getValue().toLowerCase();
|
||||
if (next.getDisplay().toLowerCase().contains(filter) || next.getCode().toLowerCase().contains(filter)) {
|
||||
include.addConcept(new ComposeIncludeConcept().setCode(next.getCode()).setDisplay(next.getDisplay()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
|
||||
} finally {
|
||||
endRequest(theServletRequest);
|
||||
}
|
||||
}
|
||||
|
||||
private ComposeInclude getOrAddComposeInclude(ValueSet retVal, Map<String, ComposeInclude> systemToCompose, String system) {
|
||||
ComposeInclude include;
|
||||
include = systemToCompose.get(system);
|
||||
if (include == null) {
|
||||
include = retVal.getCompose().addInclude();
|
||||
include.setSystem(system);
|
||||
systemToCompose.put(system, include);
|
||||
}
|
||||
return include;
|
||||
}
|
||||
|
||||
}
|
|
@ -64,6 +64,7 @@ import ca.uhn.fhir.model.dstu2.resource.Observation;
|
|||
import ca.uhn.fhir.model.dstu2.resource.Organization;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Parameters;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.resource.ValueSet;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.EncounterClassEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.EncounterStateEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.HTTPVerbEnum;
|
||||
|
@ -91,12 +92,12 @@ import ca.uhn.fhir.rest.server.RestfulServer;
|
|||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
|
||||
public class ResourceProviderDstu2Test extends BaseJpaTest {
|
||||
public class ResourceProviderDstu2Test extends BaseJpaTest {
|
||||
|
||||
private static ClassPathXmlApplicationContext ourAppCtx;
|
||||
private static IGenericClient ourClient;
|
||||
private static DaoConfig ourDaoConfig;
|
||||
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||
private static DaoConfig ourDaoConfig;
|
||||
private static CloseableHttpClient ourHttpClient;
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderDstu2Test.class);
|
||||
private static IFhirResourceDao<Organization> ourOrganizationDao;
|
||||
|
@ -339,7 +340,8 @@ public class ResourceProviderDstu2Test extends BaseJpaTest {
|
|||
}
|
||||
|
||||
/*
|
||||
* Try it with a raw socket call. The Apache client won't let us use the unescaped "|" in the URL but we want to make sure that works too..
|
||||
* Try it with a raw socket call. The Apache client won't let us use the unescaped "|" in the URL but we want to
|
||||
* make sure that works too..
|
||||
*/
|
||||
Socket sock = new Socket();
|
||||
sock.setSoTimeout(3000);
|
||||
|
@ -634,7 +636,7 @@ public class ResourceProviderDstu2Test extends BaseJpaTest {
|
|||
|
||||
IIdType newId = ourClient.create().resource(p1).execute().getId();
|
||||
|
||||
Patient actual = ourClient.read(Patient.class, (UriDt)newId);
|
||||
Patient actual = ourClient.read(Patient.class, (UriDt) newId);
|
||||
assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">HELLO WORLD</div>", actual.getText().getDiv().getValueAsString());
|
||||
}
|
||||
|
||||
|
@ -650,7 +652,7 @@ public class ResourceProviderDstu2Test extends BaseJpaTest {
|
|||
|
||||
IIdType newId = ourClient.create().resource(p1).execute().getId();
|
||||
|
||||
Patient actual = ourClient.read(Patient.class, (UriDt)newId);
|
||||
Patient actual = ourClient.read(Patient.class, (UriDt) newId);
|
||||
assertEquals(1, actual.getContained().getContainedResources().size());
|
||||
assertThat(actual.getText().getDiv().getValueAsString(), containsString("<td>Identifier</td><td>testSaveAndRetrieveWithContained01</td>"));
|
||||
|
||||
|
@ -713,8 +715,7 @@ public class ResourceProviderDstu2Test extends BaseJpaTest {
|
|||
p1.addIdentifier().setValue("testSearchByIdentifierWithoutSystem01");
|
||||
IdDt p1Id = (IdDt) ourClient.create().resource(p1).execute().getId();
|
||||
|
||||
Bundle actual = ourClient.search().forResource(Patient.class).where(Patient.IDENTIFIER.exactly().systemAndCode(null, "testSearchByIdentifierWithoutSystem01")).encodedJson().prettyPrint()
|
||||
.execute();
|
||||
Bundle actual = ourClient.search().forResource(Patient.class).where(Patient.IDENTIFIER.exactly().systemAndCode(null, "testSearchByIdentifierWithoutSystem01")).encodedJson().prettyPrint().execute();
|
||||
assertEquals(1, actual.size());
|
||||
assertEquals(p1Id.getIdPart(), actual.getEntries().get(0).getResource().getId().getIdPart());
|
||||
|
||||
|
@ -755,6 +756,127 @@ public class ResourceProviderDstu2Test extends BaseJpaTest {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchLastUpdatedParamRp() throws InterruptedException {
|
||||
String methodName = "testSearchLastUpdatedParamRp";
|
||||
|
||||
int sleep = 100;
|
||||
Thread.sleep(sleep);
|
||||
|
||||
DateTimeDt beforeAny = new DateTimeDt(new Date(), TemporalPrecisionEnum.MILLI);
|
||||
IdDt id1a;
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
patient.addName().addFamily(methodName).addGiven("Joe");
|
||||
id1a = (IdDt) ourClient.create().resource(patient).execute().getId().toUnqualifiedVersionless();
|
||||
}
|
||||
IdDt id1b;
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("002");
|
||||
patient.addName().addFamily(methodName + "XXXX").addGiven("Joe");
|
||||
id1b = (IdDt) ourClient.create().resource(patient).execute().getId().toUnqualifiedVersionless();
|
||||
}
|
||||
|
||||
Thread.sleep(1100);
|
||||
DateTimeDt beforeR2 = new DateTimeDt(new Date(), TemporalPrecisionEnum.MILLI);
|
||||
Thread.sleep(1100);
|
||||
|
||||
IdDt id2;
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("002");
|
||||
patient.addName().addFamily(methodName).addGiven("John");
|
||||
id2 = (IdDt) ourClient.create().resource(patient).execute().getId().toUnqualifiedVersionless();
|
||||
}
|
||||
|
||||
{
|
||||
//@formatter:off
|
||||
Bundle found = ourClient.search()
|
||||
.forResource(Patient.class)
|
||||
.where(Patient.NAME.matches().value("testSearchLastUpdatedParamRp"))
|
||||
.execute();
|
||||
//@formatter:on
|
||||
List<IdDt> patients = toIdListUnqualifiedVersionless(found);
|
||||
assertThat(patients, hasItems(id1a, id1b, id2));
|
||||
}
|
||||
{
|
||||
//@formatter:off
|
||||
Bundle found = ourClient.search()
|
||||
.forResource(Patient.class)
|
||||
.where(Patient.NAME.matches().value("testSearchLastUpdatedParamRp"))
|
||||
.lastUpdated(new DateRangeParam(beforeAny, null))
|
||||
.execute();
|
||||
//@formatter:on
|
||||
List<IdDt> patients = toIdListUnqualifiedVersionless(found);
|
||||
assertThat(patients, hasItems(id1a, id1b, id2));
|
||||
}
|
||||
{
|
||||
//@formatter:off
|
||||
Bundle found = ourClient.search()
|
||||
.forResource(Patient.class)
|
||||
.where(Patient.NAME.matches().value("testSearchLastUpdatedParamRp"))
|
||||
.lastUpdated(new DateRangeParam(beforeR2, null))
|
||||
.execute();
|
||||
//@formatter:on
|
||||
List<IdDt> patients = toIdListUnqualifiedVersionless(found);
|
||||
assertThat(patients, hasItems(id2));
|
||||
assertThat(patients, not(hasItems(id1a, id1b)));
|
||||
}
|
||||
{
|
||||
//@formatter:off
|
||||
Bundle found = ourClient.search()
|
||||
.forResource(Patient.class)
|
||||
.where(Patient.NAME.matches().value("testSearchLastUpdatedParamRp"))
|
||||
.lastUpdated(new DateRangeParam(beforeAny, beforeR2))
|
||||
.execute();
|
||||
//@formatter:on
|
||||
List<IdDt> patients = toIdListUnqualifiedVersionless(found);
|
||||
assertThat(patients.toString(), patients, not(hasItems(id2)));
|
||||
assertThat(patients.toString(), patients, (hasItems(id1a, id1b)));
|
||||
}
|
||||
{
|
||||
//@formatter:off
|
||||
Bundle found = ourClient.search()
|
||||
.forResource(Patient.class)
|
||||
.where(Patient.NAME.matches().value("testSearchLastUpdatedParamRp"))
|
||||
.lastUpdated(new DateRangeParam(null, beforeR2))
|
||||
.execute();
|
||||
//@formatter:on
|
||||
List<IdDt> patients = toIdListUnqualifiedVersionless(found);
|
||||
assertThat(patients, (hasItems(id1a, id1b)));
|
||||
assertThat(patients, not(hasItems(id2)));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchReturnsSearchDate() throws Exception {
|
||||
Date before = new Date();
|
||||
Thread.sleep(1);
|
||||
|
||||
//@formatter:off
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle found = ourClient
|
||||
.search()
|
||||
.forResource(Patient.class)
|
||||
.prettyPrint()
|
||||
.returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
Thread.sleep(1);
|
||||
Date after = new Date();
|
||||
|
||||
InstantDt updated = ResourceMetadataKeyEnum.UPDATED.get(found);
|
||||
assertNotNull(updated);
|
||||
Date value = updated.getValue();
|
||||
assertNotNull(value);
|
||||
ourLog.info(value.getTime() + "");
|
||||
ourLog.info(before.getTime() + "");
|
||||
assertTrue(value.after(before));
|
||||
assertTrue(value.before(after));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithInclude() throws Exception {
|
||||
Organization org = new Organization();
|
||||
|
@ -786,34 +908,6 @@ public class ResourceProviderDstu2Test extends BaseJpaTest {
|
|||
assertEquals(BundleEntrySearchModeEnum.INCLUDE, found.getEntries().get(1).getResource().getResourceMetadata().get(ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchReturnsSearchDate() throws Exception {
|
||||
Date before = new Date();
|
||||
Thread.sleep(1);
|
||||
|
||||
//@formatter:off
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle found = ourClient
|
||||
.search()
|
||||
.forResource(Patient.class)
|
||||
.prettyPrint()
|
||||
.returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
Thread.sleep(1);
|
||||
Date after = new Date();
|
||||
|
||||
InstantDt updated = ResourceMetadataKeyEnum.UPDATED.get(found);
|
||||
assertNotNull(updated);
|
||||
Date value = updated.getValue();
|
||||
assertNotNull(value);
|
||||
ourLog.info(value.getTime()+"");
|
||||
ourLog.info(before.getTime()+"");
|
||||
assertTrue(value.after(before));
|
||||
assertTrue(value.before(after));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSearchWithMissing() throws Exception {
|
||||
ourLog.info("Starting testSearchWithMissing");
|
||||
|
@ -990,7 +1084,6 @@ public class ResourceProviderDstu2Test extends BaseJpaTest {
|
|||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testUpdateResourceWithPrefer() throws IOException, Exception {
|
||||
String methodName = "testUpdateResourceWithPrefer";
|
||||
|
@ -1036,7 +1129,6 @@ public class ResourceProviderDstu2Test extends BaseJpaTest {
|
|||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testUpdateWithClientSuppliedIdWhichDoesntExist() {
|
||||
deleteToken("Patient", Patient.SP_IDENTIFIER, "urn:system", "testUpdateWithClientSuppliedIdWhichDoesntExistRpDstu2");
|
||||
|
@ -1049,8 +1141,7 @@ public class ResourceProviderDstu2Test extends BaseJpaTest {
|
|||
|
||||
assertThat(p1Id.getValue(), containsString("Patient/testUpdateWithClientSuppliedIdWhichDoesntExistRpDstu2/_history"));
|
||||
|
||||
Bundle actual = ourClient.search().forResource(Patient.class).where(Patient.IDENTIFIER.exactly().systemAndCode("urn:system", "testUpdateWithClientSuppliedIdWhichDoesntExistRpDstu2"))
|
||||
.encodedJson().prettyPrint().execute();
|
||||
Bundle actual = ourClient.search().forResource(Patient.class).where(Patient.IDENTIFIER.exactly().systemAndCode("urn:system", "testUpdateWithClientSuppliedIdWhichDoesntExistRpDstu2")).encodedJson().prettyPrint().execute();
|
||||
assertEquals(1, actual.size());
|
||||
assertEquals(p1Id.getIdPart(), actual.getEntries().get(0).getResource().getId().getIdPart());
|
||||
|
||||
|
@ -1083,32 +1174,52 @@ public class ResourceProviderDstu2Test extends BaseJpaTest {
|
|||
}
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void testValueSetExpandOperartion() throws IOException {
|
||||
|
||||
@Test
|
||||
public void testValidateResourceWithId() throws IOException {
|
||||
ValueSet upload = ourCtx.newXmlParser().parseResource(ValueSet.class, new InputStreamReader(ResourceProviderDstu2Test.class.getResourceAsStream("/extensional-case-2.xml")));
|
||||
IIdType vsid = ourClient.create().resource(upload).execute().getId().toUnqualifiedVersionless();
|
||||
|
||||
Patient patient = new Patient();
|
||||
patient.addName().addGiven("James");
|
||||
patient.setBirthDate(new DateDt("2011-02-02"));
|
||||
|
||||
Parameters input = new Parameters();
|
||||
input.addParameter().setName("resource").setResource(patient);
|
||||
|
||||
String inputStr = ourCtx.newXmlParser().encodeResourceToString(input);
|
||||
ourLog.info(inputStr);
|
||||
|
||||
HttpPost post = new HttpPost(ourServerBase + "/Patient/123/$validate");
|
||||
post.setEntity(new StringEntity(inputStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
|
||||
CloseableHttpResponse response = ourHttpClient.execute(post);
|
||||
HttpGet get = new HttpGet(ourServerBase + "/ValueSet/" + vsid.getIdPart() + "/$expand");
|
||||
CloseableHttpResponse response = ourHttpClient.execute(get);
|
||||
try {
|
||||
String resp = IOUtils.toString(response.getEntity().getContent());
|
||||
ourLog.info(resp);
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
//@formatter:on
|
||||
assertThat(resp, stringContainsInOrder(
|
||||
"<ValueSet xmlns=\"http://hl7.org/fhir\">",
|
||||
"<compose>" ,
|
||||
"<include>" ,
|
||||
"<system value=\"http://loinc.org\"/>" ,
|
||||
"<concept>" ,
|
||||
"<code value=\"11378-7\"/>" ,
|
||||
"<display value=\"Systolic blood pressure at First encounter\"/>" ,
|
||||
"</concept>"));
|
||||
//@formatter:off
|
||||
} finally {
|
||||
IOUtils.closeQuietly(response.getEntity().getContent());
|
||||
response.close();
|
||||
}
|
||||
|
||||
/*
|
||||
* Filter
|
||||
*/
|
||||
|
||||
get = new HttpGet(ourServerBase + "/ValueSet/" + vsid.getIdPart() + "/$expand?filter=systolic");
|
||||
response = ourHttpClient.execute(get);
|
||||
try {
|
||||
String resp = IOUtils.toString(response.getEntity().getContent());
|
||||
ourLog.info(resp);
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
assertThat(resp, stringContainsInOrder(
|
||||
"<code value=\"11378-7\"/>" ,
|
||||
"<display value=\"Systolic blood pressure at First encounter\"/>"));
|
||||
} finally {
|
||||
IOUtils.closeQuietly(response.getEntity().getContent());
|
||||
response.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1139,6 +1250,33 @@ public class ResourceProviderDstu2Test extends BaseJpaTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateResourceWithId() throws IOException {
|
||||
|
||||
Patient patient = new Patient();
|
||||
patient.addName().addGiven("James");
|
||||
patient.setBirthDate(new DateDt("2011-02-02"));
|
||||
|
||||
Parameters input = new Parameters();
|
||||
input.addParameter().setName("resource").setResource(patient);
|
||||
|
||||
String inputStr = ourCtx.newXmlParser().encodeResourceToString(input);
|
||||
ourLog.info(inputStr);
|
||||
|
||||
HttpPost post = new HttpPost(ourServerBase + "/Patient/123/$validate");
|
||||
post.setEntity(new StringEntity(inputStr, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
|
||||
CloseableHttpResponse response = ourHttpClient.execute(post);
|
||||
try {
|
||||
String resp = IOUtils.toString(response.getEntity().getContent());
|
||||
ourLog.info(resp);
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
} finally {
|
||||
IOUtils.closeQuietly(response.getEntity().getContent());
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
|
||||
private List<IdDt> toIdListUnqualifiedVersionless(Bundle found) {
|
||||
List<IdDt> list = new ArrayList<IdDt>();
|
||||
for (BundleEntry next : found.getEntries()) {
|
||||
|
@ -1204,101 +1342,4 @@ public class ResourceProviderDstu2Test extends BaseJpaTest {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testSearchLastUpdatedParamRp() throws InterruptedException {
|
||||
String methodName = "testSearchLastUpdatedParamRp";
|
||||
|
||||
int sleep = 100;
|
||||
Thread.sleep(sleep);
|
||||
|
||||
DateTimeDt beforeAny = new DateTimeDt(new Date(), TemporalPrecisionEnum.MILLI);
|
||||
IdDt id1a;
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
patient.addName().addFamily(methodName).addGiven("Joe");
|
||||
id1a = (IdDt) ourClient.create().resource(patient).execute().getId().toUnqualifiedVersionless();
|
||||
}
|
||||
IdDt id1b;
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("002");
|
||||
patient.addName().addFamily(methodName + "XXXX").addGiven("Joe");
|
||||
id1b = (IdDt) ourClient.create().resource(patient).execute().getId().toUnqualifiedVersionless();
|
||||
}
|
||||
|
||||
Thread.sleep(1100);
|
||||
DateTimeDt beforeR2 = new DateTimeDt(new Date(), TemporalPrecisionEnum.MILLI);
|
||||
Thread.sleep(1100);
|
||||
|
||||
IdDt id2;
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("002");
|
||||
patient.addName().addFamily(methodName).addGiven("John");
|
||||
id2 = (IdDt) ourClient.create().resource(patient).execute().getId().toUnqualifiedVersionless();
|
||||
}
|
||||
|
||||
{
|
||||
//@formatter:off
|
||||
Bundle found = ourClient.search()
|
||||
.forResource(Patient.class)
|
||||
.where(Patient.NAME.matches().value("testSearchLastUpdatedParamRp"))
|
||||
.execute();
|
||||
//@formatter:on
|
||||
List<IdDt> patients = toIdListUnqualifiedVersionless(found);
|
||||
assertThat(patients, hasItems(id1a, id1b, id2));
|
||||
}
|
||||
{
|
||||
//@formatter:off
|
||||
Bundle found = ourClient.search()
|
||||
.forResource(Patient.class)
|
||||
.where(Patient.NAME.matches().value("testSearchLastUpdatedParamRp"))
|
||||
.lastUpdated(new DateRangeParam(beforeAny, null))
|
||||
.execute();
|
||||
//@formatter:on
|
||||
List<IdDt> patients = toIdListUnqualifiedVersionless(found);
|
||||
assertThat(patients, hasItems(id1a, id1b, id2));
|
||||
}
|
||||
{
|
||||
//@formatter:off
|
||||
Bundle found = ourClient.search()
|
||||
.forResource(Patient.class)
|
||||
.where(Patient.NAME.matches().value("testSearchLastUpdatedParamRp"))
|
||||
.lastUpdated(new DateRangeParam(beforeR2, null))
|
||||
.execute();
|
||||
//@formatter:on
|
||||
List<IdDt> patients = toIdListUnqualifiedVersionless(found);
|
||||
assertThat(patients, hasItems(id2));
|
||||
assertThat(patients, not(hasItems(id1a, id1b)));
|
||||
}
|
||||
{
|
||||
//@formatter:off
|
||||
Bundle found = ourClient.search()
|
||||
.forResource(Patient.class)
|
||||
.where(Patient.NAME.matches().value("testSearchLastUpdatedParamRp"))
|
||||
.lastUpdated(new DateRangeParam(beforeAny, beforeR2))
|
||||
.execute();
|
||||
//@formatter:on
|
||||
List<IdDt> patients = toIdListUnqualifiedVersionless(found);
|
||||
assertThat(patients.toString(), patients, not(hasItems(id2)));
|
||||
assertThat(patients.toString(), patients, (hasItems(id1a, id1b)));
|
||||
}
|
||||
{
|
||||
//@formatter:off
|
||||
Bundle found = ourClient.search()
|
||||
.forResource(Patient.class)
|
||||
.where(Patient.NAME.matches().value("testSearchLastUpdatedParamRp"))
|
||||
.lastUpdated(new DateRangeParam(null, beforeR2))
|
||||
.execute();
|
||||
//@formatter:on
|
||||
List<IdDt> patients = toIdListUnqualifiedVersionless(found);
|
||||
assertThat(patients, (hasItems(id1a, id1b)));
|
||||
assertThat(patients, not(hasItems(id2)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,123 @@
|
|||
<ValueSet xmlns="http://hl7.org/fhir">
|
||||
<id value="extensional-case-2" />
|
||||
<text>
|
||||
<status value="generated" />
|
||||
<div xmlns="http://www.w3.org/1999/xhtml">A selection of codes from http://loinc.org</div>
|
||||
</text>
|
||||
<identifier>
|
||||
<value
|
||||
value="http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2" />
|
||||
</identifier>
|
||||
<name value="Terminology Services Connectation #1 Extensional case #2" />
|
||||
<publisher value="Grahame Grieve" />
|
||||
<contact>
|
||||
<telecom>
|
||||
<system value="email" />
|
||||
<value value="grahame@healthintersections.com.au" />
|
||||
</telecom>
|
||||
</contact>
|
||||
<description value="an enumeration of codes defined by LOINC" />
|
||||
<status value="draft" />
|
||||
<experimental value="true" />
|
||||
<compose>
|
||||
<include>
|
||||
<system value="http://loinc.org" />
|
||||
<concept>
|
||||
<code value="11378-7" />
|
||||
<display value="Systolic blood pressure at First encounter" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8493-9" />
|
||||
<display value="Systolic blood pressure 10 hour minimum" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8494-7" />
|
||||
<display value="Systolic blood pressure 12 hour minimum" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8495-4" />
|
||||
<display value="Systolic blood pressure 24 hour minimum" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8450-9" />
|
||||
<display value="Systolic blood pressure--expiration" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8451-7" />
|
||||
<display value="Systolic blood pressure--inspiration" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8452-5" />
|
||||
<display value="Systolic blood pressure.inspiration - expiration" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8459-0" />
|
||||
<display value="Systolic blood pressure--sitting" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8460-8" />
|
||||
<display value="Systolic blood pressure--standing" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8461-6" />
|
||||
<display value="Systolic blood pressure--supine" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8479-8" />
|
||||
<display value="Systolic blood pressure by palpation" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8480-6" />
|
||||
<display value="Systolic blood pressure" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8481-4" />
|
||||
<display value="Systolic blood pressure 1 hour maximum" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8482-2" />
|
||||
<display value="Systolic blood pressure 8 hour maximum" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8483-0" />
|
||||
<display value="Systolic blood pressure 10 hour maximum" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8484-8" />
|
||||
<display value="Systolic blood pressure 12 hour maximum" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8485-5" />
|
||||
<display value="Systolic blood pressure 24 hour maximum" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8486-3" />
|
||||
<display value="Systolic blood pressure 1 hour mean" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8487-1" />
|
||||
<display value="Systolic blood pressure 8 hour mean" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8488-9" />
|
||||
<display value="Systolic blood pressure 10 hour mean" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8489-7" />
|
||||
<display value="Systolic blood pressure 12 hour mean" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8490-5" />
|
||||
<display value="Systolic blood pressure 24 hour mean" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8491-3" />
|
||||
<display value="Systolic blood pressure 1 hour minimum" />
|
||||
</concept>
|
||||
<concept>
|
||||
<code value="8492-1" />
|
||||
<display value="Systolic blood pressure 8 hour minimum" />
|
||||
</concept>
|
||||
</include>
|
||||
</compose>
|
||||
</ValueSet>
|
Loading…
Reference in New Issue