CLI fixes and update some dependencies

This commit is contained in:
James 2017-08-16 11:20:21 -04:00
parent 1c2af596d4
commit 9e62d7dba9
7 changed files with 635 additions and 496 deletions

View File

@ -207,7 +207,7 @@ public class ExampleDataUploader extends BaseCommand {
case DSTU3: case DSTU3:
return getBundleFromFileDstu3(theLimit, theSuppliedFile, theCtx); return getBundleFromFileDstu3(theLimit, theSuppliedFile, theCtx);
case R4: case R4:
return getBundleFromFileDstu3(theLimit, theSuppliedFile, theCtx); return getBundleFromFileR4(theLimit, theSuppliedFile, theCtx);
default: default:
throw new ParseException("Invalid spec version for this command: " + theCtx.getVersion().getVersion()); throw new ParseException("Invalid spec version for this command: " + theCtx.getVersion().getVersion());
} }
@ -240,12 +240,12 @@ public class ExampleDataUploader extends BaseCommand {
IBaseResource nextCandidateSource = subResourceList.get(i); IBaseResource nextCandidateSource = subResourceList.get(i);
for (ResourceReferenceInfo nextRef : ctx.newTerser().getAllResourceReferences(nextCandidateSource)) { for (ResourceReferenceInfo nextRef : ctx.newTerser().getAllResourceReferences(nextCandidateSource)) {
String nextRefResourceType = nextRef.getResourceReference().getReferenceElement().getResourceType(); String nextRefResourceType = nextRef.getResourceReference().getReferenceElement().getResourceType();
if (isBlank(nextRefResourceType)) { String nextRefIdPart = nextRef.getResourceReference().getReferenceElement().getIdPart();
if (isBlank(nextRefResourceType) || isBlank(nextRefIdPart)) {
nextRef.getResourceReference().setResource(null); nextRef.getResourceReference().setResource(null);
nextRef.getResourceReference().setReference(null); nextRef.getResourceReference().setReference(null);
continue; continue;
} }
String nextRefIdPart = nextRef.getResourceReference().getReferenceElement().getIdPart();
if (nextRefIdPart.startsWith("EX")) { if (nextRefIdPart.startsWith("EX")) {
nextRefIdPart = nextRefIdPart.substring(2); nextRefIdPart = nextRefIdPart.substring(2);
} }
@ -707,6 +707,90 @@ public class ExampleDataUploader extends BaseCommand {
return bundle; return bundle;
} }
@SuppressWarnings("unchecked")
private org.hl7.fhir.r4.model.Bundle getBundleFromFileR4(Integer limit, File inputFile, FhirContext ctx) throws IOException, UnsupportedEncodingException {
org.hl7.fhir.r4.model.Bundle bundle = new org.hl7.fhir.r4.model.Bundle();
bundle.setType(org.hl7.fhir.r4.model.Bundle.BundleType.TRANSACTION);
FhirValidator val = ctx.newValidator();
val.registerValidatorModule(new org.hl7.fhir.r4.hapi.validation.FhirInstanceValidator(new org.hl7.fhir.r4.hapi.ctx.DefaultProfileValidationSupport()));
ZipInputStream zis = new ZipInputStream(FileUtils.openInputStream(inputFile));
byte[] buffer = new byte[2048];
int count = 0;
while (true) {
count++;
if (limit != null && count > limit) {
break;
}
ZipEntry nextEntry = zis.getNextEntry();
if (nextEntry == null) {
break;
}
int len = 0;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
while ((len = zis.read(buffer)) > 0) {
bos.write(buffer, 0, len);
}
byte[] exampleBytes = bos.toByteArray();
String exampleString = new String(exampleBytes, "UTF-8");
if (ourLog.isTraceEnabled()) {
ourLog.trace("Next example: " + exampleString);
}
IBaseResource parsed;
try {
parsed = ctx.newJsonParser().parseResource(exampleString);
} catch (Exception e) {
ourLog.info("FAILED to parse example {}", nextEntry.getName(), e);
continue;
}
ourLog.info("Found example {} - {} - {} chars", nextEntry.getName(), parsed.getClass().getSimpleName(), exampleString.length());
ValidationResult result = val.validateWithResult(parsed);
if (result.isSuccessful() == false) {
ourLog.info("FAILED to validate example {} - {}", nextEntry.getName(), result.toString());
continue;
}
if (ctx.getResourceDefinition(parsed).getName().equals("Bundle")) {
BaseRuntimeChildDefinition entryChildDef = ctx.getResourceDefinition(parsed).getChildByName("entry");
BaseRuntimeElementCompositeDefinition<?> entryDef = (BaseRuntimeElementCompositeDefinition<?>) entryChildDef.getChildByName("entry");
for (IBase nextEntry1 : entryChildDef.getAccessor().getValues(parsed)) {
List<IBase> resources = entryDef.getChildByName("resource").getAccessor().getValues(nextEntry1);
if (resources == null) {
continue;
}
for (IBase nextResource : resources) {
if (nextResource == null) {
continue;
}
if (!ctx.getResourceDefinition((Class<? extends IBaseResource>) nextResource.getClass()).getName().equals("Bundle")
&& ctx.getResourceDefinition((Class<? extends IBaseResource>) nextResource.getClass()).getName().equals("SearchParameter")) {
org.hl7.fhir.r4.model.Bundle.BundleEntryComponent entry = bundle.addEntry();
entry.getRequest().setMethod(org.hl7.fhir.r4.model.Bundle.HTTPVerb.POST);
entry.setResource((org.hl7.fhir.r4.model.Resource) nextResource);
}
}
}
} else {
if (ctx.getResourceDefinition(parsed).getName().equals("SearchParameter")) {
continue;
}
org.hl7.fhir.r4.model.Bundle.BundleEntryComponent entry = bundle.addEntry();
entry.getRequest().setMethod(org.hl7.fhir.r4.model.Bundle.HTTPVerb.POST);
entry.setResource((org.hl7.fhir.r4.model.Resource) parsed);
}
}
return bundle;
}
private void downloadFileFromInternet(CloseableHttpResponse result, File localFile) throws IOException { private void downloadFileFromInternet(CloseableHttpResponse result, File localFile) throws IOException {
FileOutputStream buffer = FileUtils.openOutputStream(localFile); FileOutputStream buffer = FileUtils.openOutputStream(localFile);
try { try {

View File

@ -336,9 +336,9 @@ public class ValidationDataUploader extends BaseCommand {
ourLog.info("Finished uploading ValueSets"); ourLog.info("Finished uploading ValueSets");
uploadDstu3Profiles(theCtx, client, "profiles-resources"); uploadR4Profiles(theCtx, client, "profiles-resources");
uploadDstu3Profiles(theCtx, client, "profiles-types"); uploadR4Profiles(theCtx, client, "profiles-types");
uploadDstu3Profiles(theCtx, client, "profiles-others"); uploadR4Profiles(theCtx, client, "profiles-others");
ourLog.info("Finished uploading ValueSets"); ourLog.info("Finished uploading ValueSets");
@ -393,4 +393,50 @@ public class ValidationDataUploader extends BaseCommand {
} }
} }
private void uploadR4Profiles(FhirContext ctx, IGenericClient client, String name) throws CommandFailureException {
int total;
int count;
org.hl7.fhir.r4.model.Bundle bundle;
ourLog.info("Uploading " + name);
String vsContents;
try {
vsContents = IOUtils.toString(ValidationDataUploader.class.getResourceAsStream("/org/hl7/fhir/r4/model/profile/" + name + ".xml"), "UTF-8");
} catch (IOException e) {
throw new CommandFailureException(e.toString());
}
bundle = ctx.newXmlParser().parseResource(org.hl7.fhir.r4.model.Bundle.class, vsContents);
total = bundle.getEntry().size();
count = 1;
Collections.sort(bundle.getEntry(), new Comparator<org.hl7.fhir.r4.model.Bundle.BundleEntryComponent>() {
@Override
public int compare(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent theO1, org.hl7.fhir.r4.model.Bundle.BundleEntryComponent theO2) {
if (theO1.getResource() == null && theO2.getResource() == null) {
return 0;
}
if (theO1.getResource() == null) {
return 1;
}
if (theO2.getResource() == null) {
return -1;
}
// StructureDefinition, then OperationDefinition, then CompartmentDefinition
return theO2.getResource().getClass().getName().compareTo(theO1.getResource().getClass().getName());
}});
for (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent i : bundle.getEntry()) {
org.hl7.fhir.r4.model.Resource next = i.getResource();
next.setId(next.getIdElement().toUnqualifiedVersionless());
if (next instanceof org.hl7.fhir.r4.model.CapabilityStatement) {
continue;
}
ourLog.info("Uploading {} StructureDefinition {}/{} : {}", new Object[] { name, count, total, next.getIdElement().getValue() });
client.update().resource(next).execute();
count++;
}
}
} }

View File

@ -1,478 +1,479 @@
package org.hl7.fhir.r4.terminologies; package org.hl7.fhir.r4.terminologies;
import static org.apache.commons.lang3.StringUtils.isNotBlank; import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
/* /*
* Copyright (c) 2011+, HL7, Inc * Copyright (c) 2011+, HL7, Inc
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
* *
* Redistributions of source code must retain the above copyright notice, this * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. * list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to * Neither the name of HL7 nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific * endorse or promote products derived from this software without specific
* prior written permission. * prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
*/ */
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import org.apache.commons.lang3.NotImplementedException; import org.apache.commons.lang3.NotImplementedException;
import org.hl7.fhir.r4.context.IWorkerContext; import org.hl7.fhir.r4.context.IWorkerContext;
import org.hl7.fhir.r4.model.BackboneElement; import org.hl7.fhir.r4.model.BackboneElement;
import org.hl7.fhir.r4.model.Base; import org.hl7.fhir.r4.model.Base;
import org.hl7.fhir.r4.model.CodeSystem; import org.hl7.fhir.r4.model.CodeSystem;
import org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentMode; import org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentMode;
import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent; import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent;
import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent; import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent;
import org.hl7.fhir.r4.model.DateTimeType; import org.hl7.fhir.r4.model.DateTimeType;
import org.hl7.fhir.r4.model.ExpansionProfile; import org.hl7.fhir.r4.model.ExpansionProfile;
import org.hl7.fhir.r4.model.Factory; import org.hl7.fhir.r4.model.Factory;
import org.hl7.fhir.r4.model.PrimitiveType; import org.hl7.fhir.r4.model.PrimitiveType;
import org.hl7.fhir.r4.model.Type; import org.hl7.fhir.r4.model.Type;
import org.hl7.fhir.r4.model.UriType; import org.hl7.fhir.r4.model.UriType;
import org.hl7.fhir.r4.model.ValueSet; import org.hl7.fhir.r4.model.ValueSet;
import org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent; import org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent;
import org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent; import org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent;
import org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent; import org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent;
import org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent; import org.hl7.fhir.r4.model.ValueSet.ConceptSetFilterComponent;
import org.hl7.fhir.r4.model.ValueSet.FilterOperator; import org.hl7.fhir.r4.model.ValueSet.FilterOperator;
import org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent; import org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent;
import org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent; import org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent;
import org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent; import org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent;
import org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent; import org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionParameterComponent;
import org.hl7.fhir.r4.utils.ToolingExtensions; import org.hl7.fhir.r4.utils.ToolingExtensions;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.NoTerminologyServiceException; import org.hl7.fhir.exceptions.NoTerminologyServiceException;
import org.hl7.fhir.exceptions.TerminologyServiceException; import org.hl7.fhir.exceptions.TerminologyServiceException;
import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.Utilities;
public class ValueSetExpanderSimple implements ValueSetExpander { public class ValueSetExpanderSimple implements ValueSetExpander {
private List<ValueSetExpansionContainsComponent> codes = new ArrayList<ValueSet.ValueSetExpansionContainsComponent>(); private List<ValueSetExpansionContainsComponent> codes = new ArrayList<ValueSet.ValueSetExpansionContainsComponent>();
private List<ValueSetExpansionContainsComponent> roots = new ArrayList<ValueSet.ValueSetExpansionContainsComponent>(); private List<ValueSetExpansionContainsComponent> roots = new ArrayList<ValueSet.ValueSetExpansionContainsComponent>();
private Map<String, ValueSetExpansionContainsComponent> map = new HashMap<String, ValueSet.ValueSetExpansionContainsComponent>(); private Map<String, ValueSetExpansionContainsComponent> map = new HashMap<String, ValueSet.ValueSetExpansionContainsComponent>();
private IWorkerContext context; private IWorkerContext context;
private boolean canBeHeirarchy = true; private boolean canBeHeirarchy = true;
private Set<String> excludeKeys = new HashSet<String>(); private Set<String> excludeKeys = new HashSet<String>();
private Set<String> excludeSystems = new HashSet<String>(); private Set<String> excludeSystems = new HashSet<String>();
private ValueSetExpanderFactory factory; private ValueSetExpanderFactory factory;
private ValueSet focus; private ValueSet focus;
private int maxExpansionSize = 500; private int maxExpansionSize = 500;
private int total; private int total;
public ValueSetExpanderSimple(IWorkerContext context, ValueSetExpanderFactory factory) { public ValueSetExpanderSimple(IWorkerContext context, ValueSetExpanderFactory factory) {
super(); super();
this.context = context; this.context = context;
this.factory = factory; this.factory = factory;
} }
public void setMaxExpansionSize(int theMaxExpansionSize) { public void setMaxExpansionSize(int theMaxExpansionSize) {
maxExpansionSize = theMaxExpansionSize; maxExpansionSize = theMaxExpansionSize;
} }
private ValueSetExpansionContainsComponent addCode(String system, String code, String display, ValueSetExpansionContainsComponent parent, List<ConceptDefinitionDesignationComponent> designations, private ValueSetExpansionContainsComponent addCode(String system, String code, String display, ValueSetExpansionContainsComponent parent, List<ConceptDefinitionDesignationComponent> designations,
ExpansionProfile profile, boolean isAbstract, boolean inactive, List<ValueSet> filters) { ExpansionProfile profile, boolean isAbstract, boolean inactive, List<ValueSet> filters) {
if (filters != null && !filters.isEmpty() && !filterContainsCode(filters, system, code)) if (filters != null && !filters.isEmpty() && !filterContainsCode(filters, system, code))
return null; return null;
ValueSetExpansionContainsComponent n = new ValueSet.ValueSetExpansionContainsComponent(); ValueSetExpansionContainsComponent n = new ValueSet.ValueSetExpansionContainsComponent();
n.setSystem(system); n.setSystem(system);
n.setCode(code); n.setCode(code);
if (isAbstract) if (isAbstract)
n.setAbstract(true); n.setAbstract(true);
if (inactive) if (inactive)
n.setInactive(true); n.setInactive(true);
if (profile.getIncludeDesignations() && designations != null) { if (profile.getIncludeDesignations() && designations != null) {
for (ConceptDefinitionDesignationComponent t : designations) { for (ConceptDefinitionDesignationComponent t : designations) {
ToolingExtensions.addLanguageTranslation(n, t.getLanguage(), t.getValue()); ToolingExtensions.addLanguageTranslation(n, t.getLanguage(), t.getValue());
} }
} }
ConceptDefinitionDesignationComponent t = profile.hasLanguage() ? getMatchingLang(designations, profile.getLanguage()) : null; ConceptDefinitionDesignationComponent t = profile.hasLanguage() ? getMatchingLang(designations, profile.getLanguage()) : null;
if (t == null) if (t == null)
n.setDisplay(display); n.setDisplay(display);
else else
n.setDisplay(t.getValue()); n.setDisplay(t.getValue());
String s = key(n); String s = key(n);
if (map.containsKey(s) || excludeKeys.contains(s)) { if (map.containsKey(s) || excludeKeys.contains(s)) {
canBeHeirarchy = false; canBeHeirarchy = false;
} else { } else {
codes.add(n); codes.add(n);
map.put(s, n); map.put(s, n);
total++; total++;
} }
if (canBeHeirarchy && parent != null) { if (canBeHeirarchy && parent != null) {
parent.getContains().add(n); parent.getContains().add(n);
} else { } else {
roots.add(n); roots.add(n);
} }
return n; return n;
} }
private boolean filterContainsCode(List<ValueSet> filters, String system, String code) { private boolean filterContainsCode(List<ValueSet> filters, String system, String code) {
for (ValueSet vse : filters) for (ValueSet vse : filters)
if (expansionContainsCode(vse.getExpansion().getContains(), system, code)) if (expansionContainsCode(vse.getExpansion().getContains(), system, code))
return true; return true;
return false; return false;
} }
private boolean expansionContainsCode(List<ValueSetExpansionContainsComponent> contains, String system, String code) { private boolean expansionContainsCode(List<ValueSetExpansionContainsComponent> contains, String system, String code) {
for (ValueSetExpansionContainsComponent cc : contains) { for (ValueSetExpansionContainsComponent cc : contains) {
if (system.equals(cc.getSystem()) && code.equals(cc.getCode())) if (system.equals(cc.getSystem()) && code.equals(cc.getCode()))
return true; return true;
if (expansionContainsCode(cc.getContains(), system, code)) if (expansionContainsCode(cc.getContains(), system, code))
return true; return true;
} }
return false; return false;
} }
private ConceptDefinitionDesignationComponent getMatchingLang(List<ConceptDefinitionDesignationComponent> list, String lang) { private ConceptDefinitionDesignationComponent getMatchingLang(List<ConceptDefinitionDesignationComponent> list, String lang) {
for (ConceptDefinitionDesignationComponent t : list) for (ConceptDefinitionDesignationComponent t : list)
if (t.getLanguage().equals(lang)) if (t.getLanguage().equals(lang))
return t; return t;
for (ConceptDefinitionDesignationComponent t : list) for (ConceptDefinitionDesignationComponent t : list)
if (t.getLanguage().startsWith(lang)) if (t.getLanguage().startsWith(lang))
return t; return t;
return null; return null;
} }
private void addCodeAndDescendents(CodeSystem cs, String system, ConceptDefinitionComponent def, ValueSetExpansionContainsComponent parent, ExpansionProfile profile, List<ValueSet> filters) private void addCodeAndDescendents(CodeSystem cs, String system, ConceptDefinitionComponent def, ValueSetExpansionContainsComponent parent, ExpansionProfile profile, List<ValueSet> filters)
throws FHIRException { throws FHIRException {
// def.checkNoModifiers("Code in Code System", "expanding"); // def.checkNoModifiers("Code in Code System", "expanding");
if (!CodeSystemUtilities.isDeprecated(cs, def)) { if (!CodeSystemUtilities.isDeprecated(cs, def)) {
ValueSetExpansionContainsComponent np = null; ValueSetExpansionContainsComponent np = null;
boolean abs = CodeSystemUtilities.isNotSelectable(cs, def); boolean abs = CodeSystemUtilities.isNotSelectable(cs, def);
boolean inc = CodeSystemUtilities.isInactive(cs, def); boolean inc = CodeSystemUtilities.isInactive(cs, def);
if (canBeHeirarchy || !abs) if (canBeHeirarchy || !abs)
np = addCode(system, def.getCode(), def.getDisplay(), parent, def.getDesignation(), profile, abs, inc, filters); np = addCode(system, def.getCode(), def.getDisplay(), parent, def.getDesignation(), profile, abs, inc, filters);
for (ConceptDefinitionComponent c : def.getConcept()) for (ConceptDefinitionComponent c : def.getConcept())
addCodeAndDescendents(cs, system, c, np, profile, filters); addCodeAndDescendents(cs, system, c, np, profile, filters);
} else { } else {
for (ConceptDefinitionComponent c : def.getConcept()) for (ConceptDefinitionComponent c : def.getConcept())
addCodeAndDescendents(cs, system, c, null, profile, filters); addCodeAndDescendents(cs, system, c, null, profile, filters);
} }
} }
private void addCodes(ValueSetExpansionComponent expand, List<ValueSetExpansionParameterComponent> params, ExpansionProfile profile, List<ValueSet> filters) throws ETooCostly, FHIRException { private void addCodes(ValueSetExpansionComponent expand, List<ValueSetExpansionParameterComponent> params, ExpansionProfile profile, List<ValueSet> filters) throws ETooCostly, FHIRException {
if (expand.getContains().size() > maxExpansionSize) if (expand.getContains().size() > maxExpansionSize)
throw new ETooCostly("Too many codes to display (>" + Integer.toString(expand.getContains().size()) + ")"); throw new ETooCostly("Too many codes to display (>" + Integer.toString(expand.getContains().size()) + ")");
for (ValueSetExpansionParameterComponent p : expand.getParameter()) { for (ValueSetExpansionParameterComponent p : expand.getParameter()) {
if (!existsInParams(params, p.getName(), p.getValue())) if (!existsInParams(params, p.getName(), p.getValue()))
params.add(p); params.add(p);
} }
copyImportContains(expand.getContains(), null, profile, filters); copyImportContains(expand.getContains(), null, profile, filters);
} }
private void excludeCode(String theSystem, String theCode) { private void excludeCode(String theSystem, String theCode) {
ValueSetExpansionContainsComponent n = new ValueSet.ValueSetExpansionContainsComponent(); ValueSetExpansionContainsComponent n = new ValueSet.ValueSetExpansionContainsComponent();
n.setSystem(theSystem); n.setSystem(theSystem);
n.setCode(theCode); n.setCode(theCode);
String s = key(n); String s = key(n);
excludeKeys.add(s); excludeKeys.add(s);
} }
private void excludeCodes(ConceptSetComponent exc, List<ValueSetExpansionParameterComponent> params) throws FHIRException { private void excludeCodes(ConceptSetComponent exc, List<ValueSetExpansionParameterComponent> params) throws FHIRException {
exc.checkNoModifiers("Compose.exclude", "expanding"); exc.checkNoModifiers("Compose.exclude", "expanding");
if (exc.hasSystem() && exc.getConcept().size() == 0 && exc.getFilter().size() == 0) { if (exc.hasSystem() && exc.getConcept().size() == 0 && exc.getFilter().size() == 0) {
excludeSystems.add(exc.getSystem()); excludeSystems.add(exc.getSystem());
} }
if (exc.hasValueSet()) if (exc.hasValueSet())
throw new Error("Processing Value set references in exclude is not yet done"); throw new Error("Processing Value set references in exclude is not yet done");
// importValueSet(imp.getValue(), params, profile); // importValueSet(imp.getValue(), params, profile);
CodeSystem cs = context.fetchCodeSystem(exc.getSystem()); CodeSystem cs = context.fetchCodeSystem(exc.getSystem());
if ((cs == null || cs.getContent() != CodeSystemContentMode.COMPLETE) && context.supportsSystem(exc.getSystem())) { if ((cs == null || cs.getContent() != CodeSystemContentMode.COMPLETE) && context.supportsSystem(exc.getSystem())) {
excludeCodes(context.expandVS(exc, false), params); excludeCodes(context.expandVS(exc, false), params);
return; return;
} }
for (ConceptReferenceComponent c : exc.getConcept()) { for (ConceptReferenceComponent c : exc.getConcept()) {
excludeCode(exc.getSystem(), c.getCode()); excludeCode(exc.getSystem(), c.getCode());
} }
if (exc.getFilter().size() > 0) if (exc.getFilter().size() > 0)
throw new NotImplementedException("not done yet"); throw new NotImplementedException("not done yet");
} }
private void excludeCodes(ValueSetExpansionComponent expand, List<ValueSetExpansionParameterComponent> params) { private void excludeCodes(ValueSetExpansionComponent expand, List<ValueSetExpansionParameterComponent> params) {
for (ValueSetExpansionContainsComponent c : expand.getContains()) { for (ValueSetExpansionContainsComponent c : expand.getContains()) {
excludeCode(c.getSystem(), c.getCode()); excludeCode(c.getSystem(), c.getCode());
} }
} }
private boolean existsInParams(List<ValueSetExpansionParameterComponent> params, String name, Type value) { private boolean existsInParams(List<ValueSetExpansionParameterComponent> params, String name, Type value) {
for (ValueSetExpansionParameterComponent p : params) { for (ValueSetExpansionParameterComponent p : params) {
if (p.getName().equals(name) && PrimitiveType.compareDeep(p.getValue(), value, false)) if (p.getName().equals(name) && PrimitiveType.compareDeep(p.getValue(), value, false))
return true; return true;
} }
return false; return false;
} }
@Override @Override
public ValueSetExpansionOutcome expand(ValueSet source, ExpansionProfile profile) { public ValueSetExpansionOutcome expand(ValueSet source, ExpansionProfile profile) {
if (profile == null) if (profile == null)
profile = makeDefaultExpansion(); profile = makeDefaultExpansion();
try { try {
source.checkNoModifiers("ValueSet", "expanding"); source.checkNoModifiers("ValueSet", "expanding");
focus = source.copy(); focus = source.copy();
focus.setExpansion(new ValueSet.ValueSetExpansionComponent()); focus.setExpansion(new ValueSet.ValueSetExpansionComponent());
focus.getExpansion().setTimestampElement(DateTimeType.now()); focus.getExpansion().setTimestampElement(DateTimeType.now());
focus.getExpansion().setIdentifier(Factory.createUUID()); focus.getExpansion().setIdentifier(Factory.createUUID());
if (!profile.getUrl().startsWith("urn:uuid:")) if (!profile.getUrl().startsWith("urn:uuid:"))
focus.getExpansion().addParameter().setName("profile").setValue(new UriType(profile.getUrl())); focus.getExpansion().addParameter().setName("profile").setValue(new UriType(profile.getUrl()));
if (source.hasCompose()) if (source.hasCompose())
handleCompose(source.getCompose(), focus.getExpansion().getParameter(), profile); handleCompose(source.getCompose(), focus.getExpansion().getParameter(), profile);
if (canBeHeirarchy) { if (canBeHeirarchy) {
for (ValueSetExpansionContainsComponent c : roots) { for (ValueSetExpansionContainsComponent c : roots) {
focus.getExpansion().getContains().add(c); focus.getExpansion().getContains().add(c);
} }
} else { } else {
for (ValueSetExpansionContainsComponent c : codes) { for (ValueSetExpansionContainsComponent c : codes) {
if (map.containsKey(key(c)) && !c.getAbstract()) { // we may have added abstract codes earlier while we still thought it might be heirarchical, but later we gave up, so now ignore them if (map.containsKey(key(c)) && !c.getAbstract()) { // we may have added abstract codes earlier while we still thought it might be heirarchical, but later we gave up, so now ignore them
focus.getExpansion().getContains().add(c); focus.getExpansion().getContains().add(c);
c.getContains().clear(); // make sure any heirarchy is wiped c.getContains().clear(); // make sure any heirarchy is wiped
} }
} }
} }
if (total > 0) { if (total > 0) {
focus.getExpansion().setTotal(total); focus.getExpansion().setTotal(total);
} }
return new ValueSetExpansionOutcome(focus); return new ValueSetExpansionOutcome(focus);
} catch (RuntimeException e) { } catch (RuntimeException e) {
// TODO: we should put something more specific instead of just Exception below, since // TODO: we should put something more specific instead of just Exception below, since
// it swallows bugs.. what would be expected to be caught there? // it swallows bugs.. what would be expected to be caught there?
throw e; throw e;
} catch (NoTerminologyServiceException e) { } catch (NoTerminologyServiceException e) {
// well, we couldn't expand, so we'll return an interface to a checker that can check membership of the set // well, we couldn't expand, so we'll return an interface to a checker that can check membership of the set
// that might fail too, but it might not, later. // that might fail too, but it might not, later.
return new ValueSetExpansionOutcome(new ValueSetCheckerSimple(source, factory, context), e.getMessage(), TerminologyServiceErrorClass.NOSERVICE); return new ValueSetExpansionOutcome(new ValueSetCheckerSimple(source, factory, context), e.getMessage(), TerminologyServiceErrorClass.NOSERVICE);
} catch (Exception e) { } catch (Exception e) {
// well, we couldn't expand, so we'll return an interface to a checker that can check membership of the set // well, we couldn't expand, so we'll return an interface to a checker that can check membership of the set
// that might fail too, but it might not, later. // that might fail too, but it might not, later.
return new ValueSetExpansionOutcome(new ValueSetCheckerSimple(source, factory, context), e.getMessage(), TerminologyServiceErrorClass.UNKNOWN); return new ValueSetExpansionOutcome(new ValueSetCheckerSimple(source, factory, context), e.getMessage(), TerminologyServiceErrorClass.UNKNOWN);
} }
} }
private ExpansionProfile makeDefaultExpansion() { private ExpansionProfile makeDefaultExpansion() {
ExpansionProfile res = new ExpansionProfile(); ExpansionProfile res = new ExpansionProfile();
res.setUrl("urn:uuid:" + UUID.randomUUID().toString().toLowerCase()); res.setUrl("urn:uuid:" + UUID.randomUUID().toString().toLowerCase());
res.setExcludeNested(true); res.setExcludeNested(true);
res.setIncludeDesignations(false); res.setIncludeDesignations(false);
return res; return res;
} }
private void addToHeirarchy(List<ValueSetExpansionContainsComponent> target, List<ValueSetExpansionContainsComponent> source) { private void addToHeirarchy(List<ValueSetExpansionContainsComponent> target, List<ValueSetExpansionContainsComponent> source) {
for (ValueSetExpansionContainsComponent s : source) { for (ValueSetExpansionContainsComponent s : source) {
target.add(s); target.add(s);
} }
} }
private String getCodeDisplay(CodeSystem cs, String code) throws TerminologyServiceException { private String getCodeDisplay(CodeSystem cs, String code) throws TerminologyServiceException {
ConceptDefinitionComponent def = getConceptForCode(cs.getConcept(), code); ConceptDefinitionComponent def = getConceptForCode(cs.getConcept(), code);
if (def == null) if (def == null)
throw new TerminologyServiceException("Unable to find code '" + code + "' in code system " + cs.getUrl()); throw new TerminologyServiceException("Unable to find code '" + code + "' in code system " + cs.getUrl());
return def.getDisplay(); return def.getDisplay();
} }
private ConceptDefinitionComponent getConceptForCode(List<ConceptDefinitionComponent> clist, String code) { private ConceptDefinitionComponent getConceptForCode(List<ConceptDefinitionComponent> clist, String code) {
for (ConceptDefinitionComponent c : clist) { for (ConceptDefinitionComponent c : clist) {
if (code.equals(c.getCode())) if (code.equals(c.getCode()))
return c; return c;
ConceptDefinitionComponent v = getConceptForCode(c.getConcept(), code); ConceptDefinitionComponent v = getConceptForCode(c.getConcept(), code);
if (v != null) if (v != null)
return v; return v;
} }
return null; return null;
} }
private void handleCompose(ValueSetComposeComponent compose, List<ValueSetExpansionParameterComponent> params, ExpansionProfile profile) private void handleCompose(ValueSetComposeComponent compose, List<ValueSetExpansionParameterComponent> params, ExpansionProfile profile)
throws ETooCostly, FileNotFoundException, IOException, FHIRException { throws ETooCostly, FileNotFoundException, IOException, FHIRException {
compose.checkNoModifiers("ValueSet.compose", "expanding"); compose.checkNoModifiers("ValueSet.compose", "expanding");
// Exclude comes first because we build up a map of things to exclude // Exclude comes first because we build up a map of things to exclude
for (ConceptSetComponent inc : compose.getExclude()) for (ConceptSetComponent inc : compose.getExclude())
excludeCodes(inc, params); excludeCodes(inc, params);
canBeHeirarchy = !profile.getExcludeNested() && excludeKeys.isEmpty() && excludeSystems.isEmpty(); canBeHeirarchy = !profile.getExcludeNested() && excludeKeys.isEmpty() && excludeSystems.isEmpty();
boolean first = true; boolean first = true;
for (ConceptSetComponent inc : compose.getInclude()) { for (ConceptSetComponent inc : compose.getInclude()) {
if (first == true) if (first == true)
first = false; first = false;
else else
canBeHeirarchy = false; canBeHeirarchy = false;
includeCodes(inc, params, profile); includeCodes(inc, params, profile);
} }
} }
private ValueSet importValueSet(String value, List<ValueSetExpansionParameterComponent> params, ExpansionProfile profile) private ValueSet importValueSet(String value, List<ValueSetExpansionParameterComponent> params, ExpansionProfile profile)
throws ETooCostly, TerminologyServiceException, FileNotFoundException, IOException { throws ETooCostly, TerminologyServiceException, FileNotFoundException, IOException {
if (value == null) if (value == null)
throw new TerminologyServiceException("unable to find value set with no identity"); throw new TerminologyServiceException("unable to find value set with no identity");
ValueSet vs = context.fetchResource(ValueSet.class, value); ValueSet vs = context.fetchResource(ValueSet.class, value);
if (vs == null) if (vs == null)
throw new TerminologyServiceException("Unable to find imported value set " + value); throw new TerminologyServiceException("Unable to find imported value set " + value);
ValueSetExpansionOutcome vso = factory.getExpander().expand(vs, profile); ValueSetExpansionOutcome vso = factory.getExpander().expand(vs, profile);
if (vso.getError() != null) if (vso.getError() != null)
throw new TerminologyServiceException("Unable to expand imported value set: " + vso.getError()); throw new TerminologyServiceException("Unable to expand imported value set: " + vso.getError());
if (vso.getService() != null) if (vso.getService() != null)
throw new TerminologyServiceException("Unable to expand imported value set " + value); throw new TerminologyServiceException("Unable to expand imported value set " + value);
if (vs.hasVersion()) if (vs.hasVersion())
if (!existsInParams(params, "version", new UriType(vs.getUrl() + "|" + vs.getVersion()))) if (!existsInParams(params, "version", new UriType(vs.getUrl() + "|" + vs.getVersion())))
params.add(new ValueSetExpansionParameterComponent().setName("version").setValue(new UriType(vs.getUrl() + "|" + vs.getVersion()))); params.add(new ValueSetExpansionParameterComponent().setName("version").setValue(new UriType(vs.getUrl() + "|" + vs.getVersion())));
for (ValueSetExpansionParameterComponent p : vso.getValueset().getExpansion().getParameter()) { for (ValueSetExpansionParameterComponent p : vso.getValueset().getExpansion().getParameter()) {
if (!existsInParams(params, p.getName(), p.getValue())) if (!existsInParams(params, p.getName(), p.getValue()))
params.add(p); params.add(p);
} }
canBeHeirarchy = false; // if we're importing a value set, we have to be combining, so we won't try for a heirarchy canBeHeirarchy = false; // if we're importing a value set, we have to be combining, so we won't try for a heirarchy
return vso.getValueset(); return vso.getValueset();
} }
private void copyImportContains(List<ValueSetExpansionContainsComponent> list, ValueSetExpansionContainsComponent parent, ExpansionProfile profile, List<ValueSet> filter) throws FHIRException { private void copyImportContains(List<ValueSetExpansionContainsComponent> list, ValueSetExpansionContainsComponent parent, ExpansionProfile profile, List<ValueSet> filter) throws FHIRException {
for (ValueSetExpansionContainsComponent c : list) { for (ValueSetExpansionContainsComponent c : list) {
c.checkNoModifiers("Imported Expansion in Code System", "expanding"); c.checkNoModifiers("Imported Expansion in Code System", "expanding");
ValueSetExpansionContainsComponent np = addCode(c.getSystem(), c.getCode(), c.getDisplay(), parent, null, profile, c.getAbstract(), c.getInactive(), filter); ValueSetExpansionContainsComponent np = addCode(c.getSystem(), c.getCode(), c.getDisplay(), parent, null, profile, c.getAbstract(), c.getInactive(), filter);
copyImportContains(c.getContains(), np, profile, filter); copyImportContains(c.getContains(), np, profile, filter);
} }
} }
private void includeCodes(ConceptSetComponent inc, List<ValueSetExpansionParameterComponent> params, ExpansionProfile profile) throws ETooCostly, FileNotFoundException, IOException, FHIRException { private void includeCodes(ConceptSetComponent inc, List<ValueSetExpansionParameterComponent> params, ExpansionProfile profile) throws ETooCostly, FileNotFoundException, IOException, FHIRException {
inc.checkNoModifiers("Compose.include", "expanding"); inc.checkNoModifiers("Compose.include", "expanding");
List<ValueSet> imports = new ArrayList<ValueSet>(); List<ValueSet> imports = new ArrayList<ValueSet>();
for (UriType imp : inc.getValueSet()) { for (UriType imp : inc.getValueSet()) {
imports.add(importValueSet(imp.getValue(), params, profile)); imports.add(importValueSet(imp.getValue(), params, profile));
} }
if (!inc.hasSystem()) { if (!inc.hasSystem()) {
if (imports.isEmpty()) // though this is not supposed to be the case if (imports.isEmpty()) // though this is not supposed to be the case
return; return;
ValueSet base = imports.get(0); ValueSet base = imports.get(0);
imports.remove(0); imports.remove(0);
base.checkNoModifiers("Imported ValueSet", "expanding"); base.checkNoModifiers("Imported ValueSet", "expanding");
copyImportContains(base.getExpansion().getContains(), null, profile, imports); copyImportContains(base.getExpansion().getContains(), null, profile, imports);
} else { } else {
CodeSystem cs = context.fetchCodeSystem(inc.getSystem()); CodeSystem cs = context.fetchCodeSystem(inc.getSystem());
if ((cs == null || cs.getContent() != CodeSystemContentMode.COMPLETE) && context.supportsSystem(inc.getSystem())) { if ((cs == null || cs.getContent() != CodeSystemContentMode.COMPLETE) && context.supportsSystem(inc.getSystem())) {
addCodes(context.expandVS(inc, canBeHeirarchy), params, profile, imports); addCodes(context.expandVS(inc, canBeHeirarchy), params, profile, imports);
return; return;
} }
if (cs == null) { if (cs == null) {
if (context.isNoTerminologyServer()) if (context.isNoTerminologyServer())
throw new NoTerminologyServiceException("unable to find code system " + inc.getSystem().toString()); throw new NoTerminologyServiceException("unable to find code system " + inc.getSystem().toString());
else else
throw new TerminologyServiceException("unable to find code system " + inc.getSystem().toString()); throw new TerminologyServiceException("unable to find code system " + inc.getSystem().toString());
} }
cs.checkNoModifiers("Code System", "expanding"); cs.checkNoModifiers("Code System", "expanding");
if (cs.getContent() != CodeSystemContentMode.COMPLETE) // if (cs.getContent() != CodeSystemContentMode.COMPLETE)
throw new TerminologyServiceException("Code system " + inc.getSystem().toString() + " is incomplete"); // throw new TerminologyServiceException("Code system " + inc.getSystem().toString() + " is incomplete");
if (cs.hasVersion())
if (!existsInParams(params, "version", new UriType(cs.getUrl() + "|" + cs.getVersion()))) if (cs.hasVersion())
params.add(new ValueSetExpansionParameterComponent().setName("version").setValue(new UriType(cs.getUrl() + "|" + cs.getVersion()))); if (!existsInParams(params, "version", new UriType(cs.getUrl() + "|" + cs.getVersion())))
params.add(new ValueSetExpansionParameterComponent().setName("version").setValue(new UriType(cs.getUrl() + "|" + cs.getVersion())));
if (inc.getConcept().size() == 0 && inc.getFilter().size() == 0) {
// special case - add all the code system if (inc.getConcept().size() == 0 && inc.getFilter().size() == 0) {
for (ConceptDefinitionComponent def : cs.getConcept()) { // special case - add all the code system
addCodeAndDescendents(cs, inc.getSystem(), def, null, profile, imports); for (ConceptDefinitionComponent def : cs.getConcept()) {
} addCodeAndDescendents(cs, inc.getSystem(), def, null, profile, imports);
} }
}
if (!inc.getConcept().isEmpty()) {
canBeHeirarchy = false; if (!inc.getConcept().isEmpty()) {
for (ConceptReferenceComponent c : inc.getConcept()) { canBeHeirarchy = false;
c.checkNoModifiers("Code in Code System", "expanding"); for (ConceptReferenceComponent c : inc.getConcept()) {
addCode(inc.getSystem(), c.getCode(), Utilities.noString(c.getDisplay()) ? getCodeDisplay(cs, c.getCode()) : c.getDisplay(), null, convertDesignations(c.getDesignation()), profile, false, c.checkNoModifiers("Code in Code System", "expanding");
CodeSystemUtilities.isInactive(cs, c.getCode()), imports); addCode(inc.getSystem(), c.getCode(), Utilities.noString(c.getDisplay()) ? getCodeDisplay(cs, c.getCode()) : c.getDisplay(), null, convertDesignations(c.getDesignation()), profile, false,
} CodeSystemUtilities.isInactive(cs, c.getCode()), imports);
} }
if (inc.getFilter().size() > 1) { }
canBeHeirarchy = false; // which will bt the case if we get around to supporting this if (inc.getFilter().size() > 1) {
throw new TerminologyServiceException("Multiple filters not handled yet"); // need to and them, and this isn't done yet. But this shouldn't arise in non loinc and snomed value sets canBeHeirarchy = false; // which will bt the case if we get around to supporting this
} throw new TerminologyServiceException("Multiple filters not handled yet"); // need to and them, and this isn't done yet. But this shouldn't arise in non loinc and snomed value sets
if (inc.getFilter().size() == 1) { }
ConceptSetFilterComponent fc = inc.getFilter().get(0); if (inc.getFilter().size() == 1) {
if ("concept".equals(fc.getProperty()) && fc.getOp() == FilterOperator.ISA) { ConceptSetFilterComponent fc = inc.getFilter().get(0);
// special: all codes in the target code system under the value if ("concept".equals(fc.getProperty()) && fc.getOp() == FilterOperator.ISA) {
ConceptDefinitionComponent def = getConceptForCode(cs.getConcept(), fc.getValue()); // special: all codes in the target code system under the value
if (def == null) ConceptDefinitionComponent def = getConceptForCode(cs.getConcept(), fc.getValue());
throw new TerminologyServiceException("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'"); if (def == null)
addCodeAndDescendents(cs, inc.getSystem(), def, null, profile, imports); throw new TerminologyServiceException("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'");
} else if ("concept".equals(fc.getProperty()) && fc.getOp() == FilterOperator.DESCENDENTOF) { addCodeAndDescendents(cs, inc.getSystem(), def, null, profile, imports);
// special: all codes in the target code system under the value } else if ("concept".equals(fc.getProperty()) && fc.getOp() == FilterOperator.DESCENDENTOF) {
ConceptDefinitionComponent def = getConceptForCode(cs.getConcept(), fc.getValue()); // special: all codes in the target code system under the value
if (def == null) ConceptDefinitionComponent def = getConceptForCode(cs.getConcept(), fc.getValue());
throw new TerminologyServiceException("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'"); if (def == null)
for (ConceptDefinitionComponent c : def.getConcept()) throw new TerminologyServiceException("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'");
addCodeAndDescendents(cs, inc.getSystem(), c, null, profile, imports); for (ConceptDefinitionComponent c : def.getConcept())
} else if ("display".equals(fc.getProperty()) && fc.getOp() == FilterOperator.EQUAL) { addCodeAndDescendents(cs, inc.getSystem(), c, null, profile, imports);
// gg; note: wtf is this: if the filter is display=v, look up the code 'v', and see if it's diplsay is 'v'? } else if ("display".equals(fc.getProperty()) && fc.getOp() == FilterOperator.EQUAL) {
canBeHeirarchy = false; // gg; note: wtf is this: if the filter is display=v, look up the code 'v', and see if it's diplsay is 'v'?
ConceptDefinitionComponent def = getConceptForCode(cs.getConcept(), fc.getValue()); canBeHeirarchy = false;
if (def != null) { ConceptDefinitionComponent def = getConceptForCode(cs.getConcept(), fc.getValue());
if (isNotBlank(def.getDisplay()) && isNotBlank(fc.getValue())) { if (def != null) {
if (def.getDisplay().contains(fc.getValue())) { if (isNotBlank(def.getDisplay()) && isNotBlank(fc.getValue())) {
addCode(inc.getSystem(), def.getCode(), def.getDisplay(), null, def.getDesignation(), profile, CodeSystemUtilities.isNotSelectable(cs, def), CodeSystemUtilities.isInactive(cs, def), if (def.getDisplay().contains(fc.getValue())) {
imports); addCode(inc.getSystem(), def.getCode(), def.getDisplay(), null, def.getDesignation(), profile, CodeSystemUtilities.isNotSelectable(cs, def), CodeSystemUtilities.isInactive(cs, def),
} imports);
} }
} }
} else }
throw new NotImplementedException("Search by property[" + fc.getProperty() + "] and op[" + fc.getOp() + "] is not supported yet"); } else
} throw new NotImplementedException("Search by property[" + fc.getProperty() + "] and op[" + fc.getOp() + "] is not supported yet");
} }
} }
}
private List<ConceptDefinitionDesignationComponent> convertDesignations(List<ConceptReferenceDesignationComponent> list) {
List<ConceptDefinitionDesignationComponent> res = new ArrayList<CodeSystem.ConceptDefinitionDesignationComponent>(); private List<ConceptDefinitionDesignationComponent> convertDesignations(List<ConceptReferenceDesignationComponent> list) {
for (ConceptReferenceDesignationComponent t : list) { List<ConceptDefinitionDesignationComponent> res = new ArrayList<CodeSystem.ConceptDefinitionDesignationComponent>();
ConceptDefinitionDesignationComponent c = new ConceptDefinitionDesignationComponent(); for (ConceptReferenceDesignationComponent t : list) {
c.setLanguage(t.getLanguage()); ConceptDefinitionDesignationComponent c = new ConceptDefinitionDesignationComponent();
c.setUse(t.getUse()); c.setLanguage(t.getLanguage());
c.setValue(t.getValue()); c.setUse(t.getUse());
} c.setValue(t.getValue());
return res; }
} return res;
}
private String key(String uri, String code) {
return "{" + uri + "}" + code; private String key(String uri, String code) {
} return "{" + uri + "}" + code;
}
private String key(ValueSetExpansionContainsComponent c) {
return key(c.getSystem(), c.getCode()); private String key(ValueSetExpansionContainsComponent c) {
} return key(c.getSystem(), c.getCode());
}
}
}

View File

@ -19,6 +19,7 @@ import org.apache.http.message.BasicHeader;
import org.hl7.fhir.dstu3.model.*; import org.hl7.fhir.dstu3.model.*;
import org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestComponent; import org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestComponent;
import org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceComponent; import org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestResourceComponent;
import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IDomainResource; import org.hl7.fhir.instance.model.api.IDomainResource;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -572,6 +573,7 @@ public class BaseController {
theModelMap.put("outcomeDescription", outcomeDescription); theModelMap.put("outcomeDescription", outcomeDescription);
theModelMap.put("resultDescription", resultDescription.toString()); theModelMap.put("resultDescription", resultDescription.toString());
theModelMap.put("action", action); theModelMap.put("action", action);
theModelMap.put("ri", riBundle instanceof IAnyResource);
theModelMap.put("riBundle", riBundle); theModelMap.put("riBundle", riBundle);
theModelMap.put("resultStatus", resultStatus); theModelMap.put("resultStatus", resultStatus);

View File

@ -314,9 +314,14 @@
<td> <td>
<a th:if="${entry.resource} != null" th:href="${entry.resource.id}" th:text="${entry.resource.idElement.toUnqualified()}" style="font-size: 0.8em"/> <a th:if="${entry.resource} != null" th:href="${entry.resource.id}" th:text="${entry.resource.idElement.toUnqualified()}" style="font-size: 0.8em"/>
</td> </td>
<td th:if="${entry.resource} == null or ${entry.resource.meta.lastUpdatedElement.value} == null"></td> <th:block th:if="${ri}">
<td th:if="${entry.resource} != null and ${entry.resource.meta.lastUpdatedElement.value} != null and ${entry.resource.meta.lastUpdatedElement.today} == true" th:text="${#dates.format(entry.resource.meta.lastUpdated, 'HH:mm:ss')}"></td> <td th:if="${entry.resource} == null or ${entry.resource.meta.lastUpdatedElement.value} == null"></td>
<td th:if="${entry.resource} != null and ${entry.resource.meta.lastUpdatedElement.value} != null and ${entry.resource.meta.lastUpdatedElement.today} == false" th:text="${#dates.format(entry.resource.meta.lastUpdated, 'yyyy-MM-dd HH:mm:ss')}"></td> <td th:if="${entry.resource} != null and ${entry.resource.meta.lastUpdatedElement.value} != null and ${entry.resource.meta.lastUpdatedElement.today} == true" th:text="${#dates.format(entry.resource.meta.lastUpdated, 'HH:mm:ss')}"></td>
<td th:if="${entry.resource} != null and ${entry.resource.meta.lastUpdatedElement.value} != null and ${entry.resource.meta.lastUpdatedElement.today} == false" th:text="${#dates.format(entry.resource.meta.lastUpdated, 'yyyy-MM-dd HH:mm:ss')}"></td>
</th:block>
<th:block th:unless="${ri}">
<td></td>
</th:block>
</tr> </tr>
</tbody> </tbody>
</table> </table>

18
pom.xml
View File

@ -431,12 +431,12 @@
<dependency> <dependency>
<groupId>com.google.errorprone</groupId> <groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId> <artifactId>error_prone_core</artifactId>
<version>2.0.21</version> <version>2.0.19</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<version>22.0</version> <version>23.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.phloc</groupId> <groupId>com.phloc</groupId>
@ -503,7 +503,7 @@
<dependency> <dependency>
<groupId>javax.json</groupId> <groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId> <artifactId>javax.json-api</artifactId>
<version>1.0</version> <version>1.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
@ -513,7 +513,7 @@
<dependency> <dependency>
<groupId>javax.mail</groupId> <groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId> <artifactId>javax.mail-api</artifactId>
<version>1.5.6</version> <version>1.6.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
@ -657,7 +657,7 @@
<dependency> <dependency>
<groupId>org.apache.maven.wagon</groupId> <groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-scm</artifactId> <artifactId>wagon-scm</artifactId>
<version>2.12</version> <version>3.0.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
@ -702,7 +702,7 @@
<dependency> <dependency>
<groupId>org.codehaus.plexus</groupId> <groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId> <artifactId>plexus-utils</artifactId>
<version>3.0.24</version> <version>3.1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.woodstox</groupId> <groupId>org.codehaus.woodstox</groupId>
@ -1009,7 +1009,7 @@
<dependency> <dependency>
<groupId>org.codehaus.plexus</groupId> <groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId> <artifactId>plexus-utils</artifactId>
<version>3.0.24</version> <version>3.1.0</version>
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
@ -1061,7 +1061,7 @@
<dependency> <dependency>
<groupId>org.codehaus.plexus</groupId> <groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId> <artifactId>plexus-utils</artifactId>
<version>3.0.24</version> <version>3.1.0</version>
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
@ -1574,7 +1574,7 @@
<dependency> <dependency>
<groupId>org.apache.maven.wagon</groupId> <groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-scm</artifactId> <artifactId>wagon-scm</artifactId>
<version>2.12</version> <version>3.0.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven.scm</groupId> <groupId>org.apache.maven.scm</groupId>

View File

@ -38,6 +38,7 @@
<li>Hibernate Search (JPA): 5.7.0 -&gt; 5.7.1</li> <li>Hibernate Search (JPA): 5.7.0 -&gt; 5.7.1</li>
<li>Spring (JPA): 4.3.7 -&gt; 4.3.10</li> <li>Spring (JPA): 4.3.7 -&gt; 4.3.10</li>
<li>Spring Data JPA (JPA): 1.10.4 -&gt; 1.11.6</li> <li>Spring Data JPA (JPA): 1.10.4 -&gt; 1.11.6</li>
<li>Guava (JPA): 22.0 -&gt; 23.0</li>
<li>Thymeleaf (Testpage Overlay): 3.0.2 -&gt; 3.0.7</li> <li>Thymeleaf (Testpage Overlay): 3.0.2 -&gt; 3.0.7</li>
<li>OkHttp (Android): 3.4.1 -&gt; 3.8.1</li> <li>OkHttp (Android): 3.4.1 -&gt; 3.8.1</li>
</ul> </ul>