Allow forced id for conceptmap translation (#4304)
* Allow forced id for conceptmap translation * Test fixes * Test fix * Conversion cleanup * Test fixes * Test fixes * Build fixes * Build fix * Test fixes * Test fixes
This commit is contained in:
parent
50ca94eded
commit
312128754b
|
@ -43,6 +43,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
|
@ -341,6 +342,12 @@ public class DefaultProfileValidationSupport implements IValidationSupport {
|
|||
|
||||
private void loadStructureDefinitions(Map<String, IBaseResource> theCodeSystems, String theClasspath) {
|
||||
ourLog.info("Loading structure definitions from classpath: {}", theClasspath);
|
||||
|
||||
String packageUserData = null;
|
||||
if (myCtx.getVersion().getVersion().isEqualOrNewerThan(FhirVersionEnum.DSTU3)) {
|
||||
packageUserData = "hl7.fhir." + myCtx.getVersion().getVersion().name().replace("DSTU", "R").toLowerCase(Locale.US);
|
||||
}
|
||||
|
||||
try (InputStream valueSetText = DefaultProfileValidationSupport.class.getResourceAsStream(theClasspath)) {
|
||||
if (valueSetText != null) {
|
||||
try (InputStreamReader reader = new InputStreamReader(valueSetText, Constants.CHARSET_UTF8)) {
|
||||
|
@ -358,6 +365,12 @@ public class DefaultProfileValidationSupport implements IValidationSupport {
|
|||
|
||||
}
|
||||
|
||||
// This is used by the validator to determine which package a given SD came from.
|
||||
// I don't love this use of magic strings but that's what is expected currently
|
||||
if (packageUserData != null) {
|
||||
next.setUserData("package", packageUserData);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.hl7.fhir.instance.model.api.IBase;
|
|||
import org.hl7.fhir.instance.model.api.IBaseCoding;
|
||||
import org.hl7.fhir.instance.model.api.IBaseParameters;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -257,10 +258,13 @@ public interface IValidationSupport {
|
|||
|
||||
/**
|
||||
* Fetch the given binary data by key.
|
||||
*
|
||||
* @param binaryKey
|
||||
* @return
|
||||
*/
|
||||
default byte[] fetchBinary(String binaryKey) { return null; }
|
||||
default byte[] fetchBinary(String binaryKey) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that the given code exists and if possible returns a display
|
||||
|
@ -814,14 +818,14 @@ public interface IValidationSupport {
|
|||
|
||||
|
||||
class TranslateCodeRequest {
|
||||
private List<IBaseCoding> myCodings;
|
||||
private final String myTargetSystemUrl;
|
||||
private final String myConceptMapUrl;
|
||||
private final String myConceptMapVersion;
|
||||
private final String mySourceValueSetUrl;
|
||||
private final String myTargetValueSetUrl;
|
||||
private final Long myResourcePid;
|
||||
private final IIdType myResourceId;
|
||||
private final boolean myReverse;
|
||||
private List<IBaseCoding> myCodings;
|
||||
|
||||
public TranslateCodeRequest(List<IBaseCoding> theCodings, String theTargetSystemUrl) {
|
||||
myCodings = theCodings;
|
||||
|
@ -830,26 +834,26 @@ public interface IValidationSupport {
|
|||
myConceptMapVersion = null;
|
||||
mySourceValueSetUrl = null;
|
||||
myTargetValueSetUrl = null;
|
||||
myResourcePid = null;
|
||||
myResourceId = null;
|
||||
myReverse = false;
|
||||
}
|
||||
|
||||
public TranslateCodeRequest(
|
||||
List<IBaseCoding> theCodings,
|
||||
String theTargetSystemUrl,
|
||||
String theConceptMapUrl,
|
||||
String theConceptMapVersion,
|
||||
String theSourceValueSetUrl,
|
||||
String theTargetValueSetUrl,
|
||||
Long theResourcePid,
|
||||
boolean theReverse) {
|
||||
List<IBaseCoding> theCodings,
|
||||
String theTargetSystemUrl,
|
||||
String theConceptMapUrl,
|
||||
String theConceptMapVersion,
|
||||
String theSourceValueSetUrl,
|
||||
String theTargetValueSetUrl,
|
||||
IIdType theResourceId,
|
||||
boolean theReverse) {
|
||||
myCodings = theCodings;
|
||||
myTargetSystemUrl = theTargetSystemUrl;
|
||||
myConceptMapUrl = theConceptMapUrl;
|
||||
myConceptMapVersion = theConceptMapVersion;
|
||||
mySourceValueSetUrl = theSourceValueSetUrl;
|
||||
myTargetValueSetUrl = theTargetValueSetUrl;
|
||||
myResourcePid = theResourcePid;
|
||||
myResourceId = theResourceId;
|
||||
myReverse = theReverse;
|
||||
}
|
||||
|
||||
|
@ -872,7 +876,7 @@ public interface IValidationSupport {
|
|||
.append(myConceptMapVersion, that.myConceptMapVersion)
|
||||
.append(mySourceValueSetUrl, that.mySourceValueSetUrl)
|
||||
.append(myTargetValueSetUrl, that.myTargetValueSetUrl)
|
||||
.append(myResourcePid, that.myResourcePid)
|
||||
.append(myResourceId, that.myResourceId)
|
||||
.append(myReverse, that.myReverse)
|
||||
.isEquals();
|
||||
}
|
||||
|
@ -886,7 +890,7 @@ public interface IValidationSupport {
|
|||
.append(myConceptMapVersion)
|
||||
.append(mySourceValueSetUrl)
|
||||
.append(myTargetValueSetUrl)
|
||||
.append(myResourcePid)
|
||||
.append(myResourceId)
|
||||
.append(myReverse)
|
||||
.toHashCode();
|
||||
}
|
||||
|
@ -915,8 +919,8 @@ public interface IValidationSupport {
|
|||
return myTargetValueSetUrl;
|
||||
}
|
||||
|
||||
public Long getResourcePid() {
|
||||
return myResourcePid;
|
||||
public IIdType getResourceId() {
|
||||
return myResourceId;
|
||||
}
|
||||
|
||||
public boolean isReverse() {
|
||||
|
|
|
@ -68,4 +68,11 @@ public class DatatypeUtil {
|
|||
return thePrimitiveType != null ? thePrimitiveType.getValueAsString() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link IPrimitiveType#getValue()} if <code>thePrimitiveType</code> is
|
||||
* not null, else returns null.
|
||||
*/
|
||||
public static Boolean toBooleanValue(IPrimitiveType<Boolean> thePrimitiveType) {
|
||||
return thePrimitiveType != null ? thePrimitiveType.getValue() : null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,13 @@ public class SingleValidationMessage {
|
|||
private String myMessageId;
|
||||
private ResultSeverityEnum mySeverity;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public SingleValidationMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
|
|
|
@ -25,8 +25,6 @@ import ca.uhn.fhir.parser.DataFormatException;
|
|||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
|
@ -35,6 +33,8 @@ import org.apache.commons.io.IOUtils;
|
|||
import org.apache.commons.io.filefilter.FalseFileFilter;
|
||||
import org.apache.commons.io.filefilter.IOFileFilter;
|
||||
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
||||
import org.hl7.fhir.utilities.json.model.JsonArray;
|
||||
import org.hl7.fhir.utilities.json.model.JsonObject;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||
import org.hl7.fhir.utilities.npm.PackageGenerator;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -53,7 +53,6 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
|||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public class CreatePackageCommand extends BaseCommand {
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(CreatePackageCommand.class);
|
||||
public static final String TARGET_DIRECTORY_OPT = "target-directory";
|
||||
public static final String DEPENDENCY_OPT = "dependency";
|
||||
public static final String INCLUDE_EXAMPLE_OPT = "include-example";
|
||||
|
@ -61,6 +60,7 @@ public class CreatePackageCommand extends BaseCommand {
|
|||
public static final String VERSION_OPT = "version";
|
||||
public static final String NAME_OPT = "name";
|
||||
public static final String DESCRIPTION_OPT = "description";
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(CreatePackageCommand.class);
|
||||
private File myWorkDirectory;
|
||||
private String myPackageName;
|
||||
private String myPackageVersion;
|
||||
|
@ -119,7 +119,7 @@ public class CreatePackageCommand extends BaseCommand {
|
|||
|
||||
myPackageVersion = theCommandLine.getOptionValue(VERSION_OPT);
|
||||
if (isBlank(myPackageVersion)) {
|
||||
throw new ParseException(Msg.code(1548) + "No package version supplied (--"+VERSION_OPT+")");
|
||||
throw new ParseException(Msg.code(1548) + "No package version supplied (--" + VERSION_OPT + ")");
|
||||
}
|
||||
if (!NpmPackage.isValidVersion(myPackageVersion)) {
|
||||
throw new ParseException(Msg.code(1549) + "Invalid package version: " + myPackageVersion);
|
||||
|
|
|
@ -99,18 +99,19 @@ public class CreatePackageCommandTest extends BaseTest {
|
|||
String packageJsonContents = IOUtils.toString(new FileInputStream(new File(myExtractDirectory, "package/package.json")), Charsets.UTF_8);
|
||||
ourLog.info("Package.json:\n{}", packageJsonContents);
|
||||
|
||||
String expectedPackageJson = "{\n" +
|
||||
" \"name\": \"com.example.ig\",\n" +
|
||||
" \"version\": \"1.0.1\",\n" +
|
||||
" \"fhirVersions\": [\n" +
|
||||
" \"4.0.1\"\n" +
|
||||
" ],\n" +
|
||||
" \"dependencies\": {\n" +
|
||||
" \"hl7.fhir.core\": \"4.0.1\",\n" +
|
||||
" \"foo.bar\": \"1.2.3\"\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
assertEquals(expectedPackageJson, packageJsonContents);
|
||||
String expectedPackageJson = """
|
||||
{
|
||||
"name" : "com.example.ig",
|
||||
"version" : "1.0.1",
|
||||
"description" : "",
|
||||
"fhirVersions" : ["4.0.1"],
|
||||
"dependencies" : {
|
||||
"hl7.fhir.core" : "4.0.1",
|
||||
"foo.bar" : "1.2.3"
|
||||
}
|
||||
}
|
||||
""";
|
||||
assertEquals(expectedPackageJson.trim(), packageJsonContents.trim());
|
||||
|
||||
// Try parsing the module again to make sure we can
|
||||
NpmPackage loadedPackage = NpmPackage.fromPackage(new FileInputStream(igArchive));
|
||||
|
@ -153,14 +154,15 @@ public class CreatePackageCommandTest extends BaseTest {
|
|||
String packageJsonContents = IOUtils.toString(new FileInputStream(new File(myExtractDirectory, "package/package.json")), Charsets.UTF_8);
|
||||
ourLog.info("Package.json:\n{}", packageJsonContents);
|
||||
|
||||
String expectedPackageJson = "{\n" +
|
||||
" \"name\": \"com.example.ig\",\n" +
|
||||
" \"version\": \"1.0.1\",\n" +
|
||||
" \"fhirVersions\": [\n" +
|
||||
" \"4.0.1\"\n" +
|
||||
" ]\n" +
|
||||
"}";
|
||||
assertEquals(expectedPackageJson, packageJsonContents);
|
||||
String expectedPackageJson = """
|
||||
{
|
||||
"name" : "com.example.ig",
|
||||
"version" : "1.0.1",
|
||||
"description" : "",
|
||||
"fhirVersions" : ["4.0.1"]
|
||||
}
|
||||
""";
|
||||
assertEquals(expectedPackageJson.trim(), packageJsonContents.trim());
|
||||
|
||||
// Try parsing the module again to make sure we can
|
||||
NpmPackage loadedPackage = NpmPackage.fromPackage(new FileInputStream(igArchive));
|
||||
|
|
|
@ -27,12 +27,16 @@ import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt;
|
|||
import ca.uhn.fhir.model.dstu2.composite.CodingDt;
|
||||
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40;
|
||||
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50;
|
||||
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_14_40;
|
||||
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_14_50;
|
||||
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40;
|
||||
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_50;
|
||||
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50;
|
||||
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_43_50;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_40;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_14_40;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_14_50;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
|
||||
|
@ -40,14 +44,17 @@ import org.hl7.fhir.convertors.factory.VersionConvertorFactory_43_50;
|
|||
import org.hl7.fhir.dstu2.model.Resource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseCoding;
|
||||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||
import org.hl7.fhir.instance.model.api.IBaseParameters;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.r4.model.CodeSystem;
|
||||
import org.hl7.fhir.r4.model.CodeableConcept;
|
||||
import org.hl7.fhir.r4.model.Coding;
|
||||
import org.hl7.fhir.r4.model.ConceptMap;
|
||||
import org.hl7.fhir.r4.model.Parameters;
|
||||
import org.hl7.fhir.r4.model.ValueSet;
|
||||
import org.hl7.fhir.r5.model.CapabilityStatement;
|
||||
import org.hl7.fhir.r5.model.SearchParameter;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -71,13 +78,16 @@ public class VersionCanonicalizer {
|
|||
private static final BaseAdvisor_10_50 ADVISOR_10_50 = new BaseAdvisor_10_50(false);
|
||||
private static final BaseAdvisor_40_50 ADVISOR_40_50 = new BaseAdvisor_40_50(false);
|
||||
private static final BaseAdvisor_43_50 ADVISOR_43_50 = new BaseAdvisor_43_50(false);
|
||||
private static final BaseAdvisor_14_40 ADVISOR_14_40 = new BaseAdvisor_14_40(false);
|
||||
private static final BaseAdvisor_14_50 ADVISOR_14_50 = new BaseAdvisor_14_50(false);
|
||||
|
||||
private final IStrategy myStrategy;
|
||||
|
||||
public VersionCanonicalizer(FhirContext theTargetContext) {
|
||||
this(theTargetContext.getVersion().getVersion());
|
||||
}
|
||||
|
||||
@SuppressWarnings({"EnumSwitchStatementWhichMissesCases", "EnhancedSwitchMigration"})
|
||||
@SuppressWarnings({"EnhancedSwitchMigration"})
|
||||
public VersionCanonicalizer(FhirVersionEnum theTargetVersion) {
|
||||
switch (theTargetVersion) {
|
||||
case DSTU2:
|
||||
|
@ -86,6 +96,9 @@ public class VersionCanonicalizer {
|
|||
case DSTU2_HL7ORG:
|
||||
myStrategy = new Dstu2Strategy(true);
|
||||
break;
|
||||
case DSTU2_1:
|
||||
myStrategy = new Dstu21Strategy();
|
||||
break;
|
||||
case DSTU3:
|
||||
myStrategy = new Dstu3Strategy();
|
||||
break;
|
||||
|
@ -166,6 +179,39 @@ public class VersionCanonicalizer {
|
|||
return myStrategy.searchParameterToCanonical(theSearchParameter);
|
||||
}
|
||||
|
||||
public IBaseParameters parametersFromCanonical(Parameters theParameters) {
|
||||
return myStrategy.parametersFromCanonical(theParameters);
|
||||
}
|
||||
|
||||
public StructureDefinition structureDefinitionToCanonical(IBaseResource theResource) {
|
||||
StructureDefinition retVal = myStrategy.structureDefinitionToCanonical(theResource);
|
||||
String packageUserData = (String) theResource.getUserData("package");
|
||||
if (packageUserData != null) {
|
||||
retVal.setUserData("package", packageUserData);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public IBaseResource structureDefinitionFromCanonical(StructureDefinition theResource) {
|
||||
return myStrategy.structureDefinitionFromCanonical(theResource);
|
||||
}
|
||||
|
||||
public IBaseResource valueSetFromValidatorCanonical(org.hl7.fhir.r5.model.ValueSet theResource) {
|
||||
return myStrategy.valueSetFromValidatorCanonical(theResource);
|
||||
}
|
||||
|
||||
public org.hl7.fhir.r5.model.Resource resourceToValidatorCanonical(IBaseResource theResource) {
|
||||
return myStrategy.resourceToValidatorCanonical(theResource);
|
||||
}
|
||||
|
||||
public org.hl7.fhir.r5.model.ValueSet valueSetToValidatorCanonical(IBaseResource theResource) {
|
||||
return myStrategy.valueSetToValidatorCanonical(theResource);
|
||||
}
|
||||
|
||||
public org.hl7.fhir.r5.model.CodeSystem codeSystemToValidatorCanonical(IBaseResource theResource) {
|
||||
return myStrategy.codeSystemToValidatorCanonical(theResource);
|
||||
}
|
||||
|
||||
private interface IStrategy {
|
||||
|
||||
CapabilityStatement capabilityStatementToCanonical(IBaseResource theCapabilityStatement);
|
||||
|
@ -183,6 +229,20 @@ public class VersionCanonicalizer {
|
|||
ConceptMap conceptMapToCanonical(IBaseResource theConceptMap);
|
||||
|
||||
SearchParameter searchParameterToCanonical(IBaseResource theSearchParameter);
|
||||
|
||||
IBaseParameters parametersFromCanonical(Parameters theParameters);
|
||||
|
||||
StructureDefinition structureDefinitionToCanonical(IBaseResource theResource);
|
||||
|
||||
IBaseResource structureDefinitionFromCanonical(StructureDefinition theResource);
|
||||
|
||||
IBaseResource valueSetFromValidatorCanonical(org.hl7.fhir.r5.model.ValueSet theResource);
|
||||
|
||||
org.hl7.fhir.r5.model.Resource resourceToValidatorCanonical(IBaseResource theResource);
|
||||
|
||||
org.hl7.fhir.r5.model.ValueSet valueSetToValidatorCanonical(IBaseResource theResource);
|
||||
|
||||
org.hl7.fhir.r5.model.CodeSystem codeSystemToValidatorCanonical(IBaseResource theResource);
|
||||
}
|
||||
|
||||
private static class Dstu2Strategy implements IStrategy {
|
||||
|
@ -292,6 +352,48 @@ public class VersionCanonicalizer {
|
|||
return retVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseParameters parametersFromCanonical(Parameters theParameters) {
|
||||
Resource converted = VersionConvertorFactory_10_40.convertResource(theParameters, ADVISOR_10_40);
|
||||
return (IBaseParameters) reencodeToHl7Org(converted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureDefinition structureDefinitionToCanonical(IBaseResource theResource) {
|
||||
org.hl7.fhir.dstu2.model.Resource reencoded = reencodeToHl7Org(theResource);
|
||||
return (StructureDefinition) VersionConvertorFactory_10_50.convertResource(reencoded, ADVISOR_10_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseResource structureDefinitionFromCanonical(StructureDefinition theResource) {
|
||||
Resource converted = VersionConvertorFactory_10_50.convertResource(theResource, ADVISOR_10_50);
|
||||
return reencodeToHl7Org(converted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseResource valueSetFromValidatorCanonical(org.hl7.fhir.r5.model.ValueSet theResource) {
|
||||
Resource converted = VersionConvertorFactory_10_50.convertResource(theResource, ADVISOR_10_50);
|
||||
return reencodeToHl7Org(converted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.hl7.fhir.r5.model.Resource resourceToValidatorCanonical(IBaseResource theResource) {
|
||||
org.hl7.fhir.dstu2.model.Resource reencoded = reencodeToHl7Org(theResource);
|
||||
return VersionConvertorFactory_10_50.convertResource(reencoded, ADVISOR_10_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.hl7.fhir.r5.model.ValueSet valueSetToValidatorCanonical(IBaseResource theResource) {
|
||||
org.hl7.fhir.dstu2.model.Resource reencoded = reencodeToHl7Org(theResource);
|
||||
return (org.hl7.fhir.r5.model.ValueSet) VersionConvertorFactory_10_50.convertResource(reencoded, ADVISOR_10_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.hl7.fhir.r5.model.CodeSystem codeSystemToValidatorCanonical(IBaseResource theResource) {
|
||||
org.hl7.fhir.dstu2.model.Resource reencoded = reencodeToHl7Org(theResource);
|
||||
return (org.hl7.fhir.r5.model.CodeSystem) VersionConvertorFactory_10_50.convertResource(reencoded, ADVISOR_10_50);
|
||||
}
|
||||
|
||||
private Resource reencodeToHl7Org(IBaseResource theInput) {
|
||||
if (myHl7OrgStructures) {
|
||||
return (Resource) theInput;
|
||||
|
@ -308,6 +410,84 @@ public class VersionCanonicalizer {
|
|||
|
||||
}
|
||||
|
||||
private static class Dstu21Strategy implements IStrategy {
|
||||
|
||||
@Override
|
||||
public CapabilityStatement capabilityStatementToCanonical(IBaseResource theCapabilityStatement) {
|
||||
return (CapabilityStatement) VersionConvertorFactory_14_50.convertResource((org.hl7.fhir.dstu2016may.model.Resource) theCapabilityStatement, ADVISOR_14_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Coding codingToCanonical(IBaseCoding theCoding) {
|
||||
return (org.hl7.fhir.r4.model.Coding) VersionConvertorFactory_14_40.convertType((org.hl7.fhir.dstu2016may.model.Coding) theCoding, ADVISOR_14_40);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeableConcept codeableConceptToCanonical(IBaseDatatype theCodeableConcept) {
|
||||
return (org.hl7.fhir.r4.model.CodeableConcept) VersionConvertorFactory_14_40.convertType((org.hl7.fhir.dstu2016may.model.CodeableConcept) theCodeableConcept, ADVISOR_14_40);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueSet valueSetToCanonical(IBaseResource theValueSet) {
|
||||
return (ValueSet) VersionConvertorFactory_14_40.convertResource((org.hl7.fhir.dstu2016may.model.Resource) theValueSet, ADVISOR_14_40);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeSystem codeSystemToCanonical(IBaseResource theCodeSystem) {
|
||||
return (CodeSystem) VersionConvertorFactory_14_40.convertResource((org.hl7.fhir.dstu2016may.model.Resource) theCodeSystem, ADVISOR_14_40);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseResource valueSetFromCanonical(ValueSet theValueSet) {
|
||||
return VersionConvertorFactory_14_40.convertResource(theValueSet, ADVISOR_14_40);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConceptMap conceptMapToCanonical(IBaseResource theConceptMap) {
|
||||
return (ConceptMap) VersionConvertorFactory_14_40.convertResource((org.hl7.fhir.dstu2016may.model.Resource) theConceptMap, ADVISOR_14_40);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchParameter searchParameterToCanonical(IBaseResource theSearchParameter) {
|
||||
return (SearchParameter) VersionConvertorFactory_14_50.convertResource((org.hl7.fhir.dstu2016may.model.Resource) theSearchParameter, ADVISOR_14_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseParameters parametersFromCanonical(Parameters theParameters) {
|
||||
return (IBaseParameters) VersionConvertorFactory_14_40.convertResource(theParameters, ADVISOR_14_40);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureDefinition structureDefinitionToCanonical(IBaseResource theResource) {
|
||||
return (StructureDefinition) VersionConvertorFactory_14_50.convertResource((org.hl7.fhir.dstu2016may.model.Resource) theResource, ADVISOR_14_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseResource structureDefinitionFromCanonical(StructureDefinition theResource) {
|
||||
return VersionConvertorFactory_14_50.convertResource(theResource, ADVISOR_14_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseResource valueSetFromValidatorCanonical(org.hl7.fhir.r5.model.ValueSet theResource) {
|
||||
return VersionConvertorFactory_14_50.convertResource(theResource, ADVISOR_14_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.hl7.fhir.r5.model.Resource resourceToValidatorCanonical(IBaseResource theResource) {
|
||||
return VersionConvertorFactory_14_50.convertResource((org.hl7.fhir.dstu2016may.model.Resource) theResource, ADVISOR_14_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.hl7.fhir.r5.model.ValueSet valueSetToValidatorCanonical(IBaseResource theResource) {
|
||||
return (org.hl7.fhir.r5.model.ValueSet) VersionConvertorFactory_14_50.convertResource((org.hl7.fhir.dstu2016may.model.Resource) theResource, ADVISOR_14_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.hl7.fhir.r5.model.CodeSystem codeSystemToValidatorCanonical(IBaseResource theResource) {
|
||||
return (org.hl7.fhir.r5.model.CodeSystem) VersionConvertorFactory_14_50.convertResource((org.hl7.fhir.dstu2016may.model.Resource) theResource, ADVISOR_14_50);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Dstu3Strategy implements IStrategy {
|
||||
|
||||
@Override
|
||||
|
@ -349,6 +529,41 @@ public class VersionCanonicalizer {
|
|||
public SearchParameter searchParameterToCanonical(IBaseResource theSearchParameter) {
|
||||
return (SearchParameter) VersionConvertorFactory_30_50.convertResource((org.hl7.fhir.dstu3.model.Resource) theSearchParameter, ADVISOR_30_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseParameters parametersFromCanonical(Parameters theParameters) {
|
||||
return (IBaseParameters) VersionConvertorFactory_30_40.convertResource(theParameters, ADVISOR_30_40);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureDefinition structureDefinitionToCanonical(IBaseResource theResource) {
|
||||
return (StructureDefinition) VersionConvertorFactory_30_50.convertResource((org.hl7.fhir.dstu3.model.Resource) theResource, ADVISOR_30_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseResource structureDefinitionFromCanonical(StructureDefinition theResource) {
|
||||
return VersionConvertorFactory_30_50.convertResource(theResource, ADVISOR_30_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseResource valueSetFromValidatorCanonical(org.hl7.fhir.r5.model.ValueSet theResource) {
|
||||
return VersionConvertorFactory_30_50.convertResource(theResource, ADVISOR_30_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.hl7.fhir.r5.model.Resource resourceToValidatorCanonical(IBaseResource theResource) {
|
||||
return VersionConvertorFactory_30_50.convertResource((org.hl7.fhir.dstu3.model.Resource) theResource, ADVISOR_30_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.hl7.fhir.r5.model.ValueSet valueSetToValidatorCanonical(IBaseResource theResource) {
|
||||
return (org.hl7.fhir.r5.model.ValueSet) VersionConvertorFactory_30_50.convertResource((org.hl7.fhir.dstu3.model.Resource) theResource, ADVISOR_30_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.hl7.fhir.r5.model.CodeSystem codeSystemToValidatorCanonical(IBaseResource theResource) {
|
||||
return (org.hl7.fhir.r5.model.CodeSystem) VersionConvertorFactory_30_50.convertResource((org.hl7.fhir.dstu3.model.Resource) theResource, ADVISOR_30_50);
|
||||
}
|
||||
}
|
||||
|
||||
private static class R4Strategy implements IStrategy {
|
||||
|
@ -392,6 +607,41 @@ public class VersionCanonicalizer {
|
|||
return (SearchParameter) VersionConvertorFactory_40_50.convertResource((org.hl7.fhir.r4.model.Resource) theSearchParameter, ADVISOR_40_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseParameters parametersFromCanonical(Parameters theParameters) {
|
||||
return theParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureDefinition structureDefinitionToCanonical(IBaseResource theResource) {
|
||||
return (StructureDefinition) VersionConvertorFactory_40_50.convertResource((org.hl7.fhir.r4.model.Resource) theResource, ADVISOR_40_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseResource structureDefinitionFromCanonical(StructureDefinition theResource) {
|
||||
return VersionConvertorFactory_40_50.convertResource(theResource, ADVISOR_40_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseResource valueSetFromValidatorCanonical(org.hl7.fhir.r5.model.ValueSet theResource) {
|
||||
return VersionConvertorFactory_40_50.convertResource(theResource, ADVISOR_40_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.hl7.fhir.r5.model.Resource resourceToValidatorCanonical(IBaseResource theResource) {
|
||||
return VersionConvertorFactory_40_50.convertResource((org.hl7.fhir.r4.model.Resource) theResource, ADVISOR_40_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.hl7.fhir.r5.model.ValueSet valueSetToValidatorCanonical(IBaseResource theResource) {
|
||||
return (org.hl7.fhir.r5.model.ValueSet) VersionConvertorFactory_40_50.convertResource((org.hl7.fhir.r4.model.Resource) theResource, ADVISOR_40_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.hl7.fhir.r5.model.CodeSystem codeSystemToValidatorCanonical(IBaseResource theResource) {
|
||||
return (org.hl7.fhir.r5.model.CodeSystem) VersionConvertorFactory_40_50.convertResource((org.hl7.fhir.r4.model.Resource) theResource, ADVISOR_40_50);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class R4BStrategy implements IStrategy {
|
||||
|
@ -442,6 +692,42 @@ public class VersionCanonicalizer {
|
|||
return (SearchParameter) VersionConvertorFactory_43_50.convertResource((org.hl7.fhir.r4b.model.Resource) theSearchParameter, ADVISOR_43_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseParameters parametersFromCanonical(Parameters theParameters) {
|
||||
org.hl7.fhir.r5.model.Parameters parametersR5 = (org.hl7.fhir.r5.model.Parameters) VersionConvertorFactory_40_50.convertResource(theParameters, ADVISOR_40_50);
|
||||
return (IBaseParameters) VersionConvertorFactory_43_50.convertResource(parametersR5, ADVISOR_43_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureDefinition structureDefinitionToCanonical(IBaseResource theResource) {
|
||||
return (StructureDefinition) VersionConvertorFactory_43_50.convertResource((org.hl7.fhir.r4b.model.Resource) theResource, ADVISOR_43_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseResource structureDefinitionFromCanonical(StructureDefinition theResource) {
|
||||
return VersionConvertorFactory_43_50.convertResource(theResource, ADVISOR_43_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseResource valueSetFromValidatorCanonical(org.hl7.fhir.r5.model.ValueSet theResource) {
|
||||
return VersionConvertorFactory_43_50.convertResource(theResource, ADVISOR_43_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.hl7.fhir.r5.model.Resource resourceToValidatorCanonical(IBaseResource theResource) {
|
||||
return VersionConvertorFactory_43_50.convertResource((org.hl7.fhir.r4b.model.Resource) theResource, ADVISOR_43_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.hl7.fhir.r5.model.ValueSet valueSetToValidatorCanonical(IBaseResource theResource) {
|
||||
return (org.hl7.fhir.r5.model.ValueSet) VersionConvertorFactory_43_50.convertResource((org.hl7.fhir.r4b.model.Resource) theResource, ADVISOR_43_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.hl7.fhir.r5.model.CodeSystem codeSystemToValidatorCanonical(IBaseResource theResource) {
|
||||
return (org.hl7.fhir.r5.model.CodeSystem) VersionConvertorFactory_43_50.convertResource((org.hl7.fhir.r4b.model.Resource) theResource, ADVISOR_43_50);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -487,6 +773,41 @@ public class VersionCanonicalizer {
|
|||
return (SearchParameter) theSearchParameter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseParameters parametersFromCanonical(Parameters theParameters) {
|
||||
return (IBaseParameters) VersionConvertorFactory_40_50.convertResource(theParameters, ADVISOR_40_50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureDefinition structureDefinitionToCanonical(IBaseResource theResource) {
|
||||
return (StructureDefinition) theResource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseResource structureDefinitionFromCanonical(StructureDefinition theResource) {
|
||||
return theResource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseResource valueSetFromValidatorCanonical(org.hl7.fhir.r5.model.ValueSet theResource) {
|
||||
return theResource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.hl7.fhir.r5.model.Resource resourceToValidatorCanonical(IBaseResource theResource) {
|
||||
return (org.hl7.fhir.r5.model.Resource) theResource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.hl7.fhir.r5.model.ValueSet valueSetToValidatorCanonical(IBaseResource theResource) {
|
||||
return (org.hl7.fhir.r5.model.ValueSet) theResource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.hl7.fhir.r5.model.CodeSystem codeSystemToValidatorCanonical(IBaseResource theResource) {
|
||||
return (org.hl7.fhir.r5.model.CodeSystem) theResource;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
type: fix
|
||||
issue: 4289
|
||||
title: "The ConceptMap/$translate operation did not work for transation against
|
||||
a ConceptMap resource ID if the ID was non-numeric. This has been fixed. Thanks to
|
||||
Panayiotis Savva for the report!"
|
|
@ -10,6 +10,7 @@
|
|||
<li>log4j-to-slf4j (JPA): 2.17.1 -> 2.19.0</li>
|
||||
<li>Jetty (CLI): 9.4.48.v20220622 -> 10.0.12</li>
|
||||
<li>Spring Boot: 2.7.4 -> 2.7.5</li>
|
||||
<li>Graphql-Java (OpenAPI): 17.4 -> 19.2</li>
|
||||
</ul>
|
||||
In addition the following dependencies have been replaced with newer equivalents:
|
||||
<ul>
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
package ca.uhn.fhir.jpa.dao;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR JPA Server
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2022 Smile CDR, Inc.
|
||||
* %%
|
||||
* 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 ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoStructureDefinition;
|
||||
import ca.uhn.fhir.model.dstu2.resource.StructureDefinition;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
|
||||
public class FhirResourceDaoStructureDefinitionDstu2 extends BaseHapiFhirResourceDao<StructureDefinition> implements IFhirResourceDaoStructureDefinition<StructureDefinition> {
|
||||
@Override
|
||||
public StructureDefinition generateSnapshot(StructureDefinition theInput, String theUrl, String theWebUrl, String theName) {
|
||||
throw new InvalidRequestException(Msg.code(943) + "Snapshot generation not supported for DSTU2");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +1,10 @@
|
|||
package ca.uhn.fhir.jpa.dao.r5;
|
||||
package ca.uhn.fhir.jpa.dao;
|
||||
|
||||
import ca.uhn.fhir.context.support.IValidationSupport;
|
||||
import ca.uhn.fhir.context.support.ValidationSupportContext;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoStructureDefinition;
|
||||
import ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/*
|
||||
|
@ -28,14 +27,14 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
public class FhirResourceDaoStructureDefinitionR5 extends BaseHapiFhirResourceDao<StructureDefinition> implements IFhirResourceDaoStructureDefinition<StructureDefinition> {
|
||||
public class JpaResourceDaoStructureDefinition<T extends IBaseResource> extends BaseHapiFhirResourceDao<T> implements IFhirResourceDaoStructureDefinition<T> {
|
||||
|
||||
@Autowired
|
||||
private IValidationSupport myValidationSupport;
|
||||
|
||||
@Override
|
||||
public StructureDefinition generateSnapshot(StructureDefinition theInput, String theUrl, String theWebUrl, String theName) {
|
||||
StructureDefinition output = (StructureDefinition) myValidationSupport.generateSnapshot(new ValidationSupportContext(myValidationSupport), theInput, theUrl, theWebUrl, theName);
|
||||
public T generateSnapshot(T theInput, String theUrl, String theWebUrl, String theName) {
|
||||
T output = (T) myValidationSupport.generateSnapshot(new ValidationSupportContext(myValidationSupport), theInput, theUrl, theWebUrl, theName);
|
||||
Validate.notNull(output);
|
||||
return output;
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
package ca.uhn.fhir.jpa.dao.dstu3;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR JPA Server
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2022 Smile CDR, Inc.
|
||||
* %%
|
||||
* 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 ca.uhn.fhir.context.support.IValidationSupport;
|
||||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.context.support.TranslateConceptResults;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoConceptMap;
|
||||
import ca.uhn.fhir.jpa.api.model.TranslationRequest;
|
||||
import ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao;
|
||||
import ca.uhn.fhir.jpa.model.cross.IBasePersistedResource;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.term.api.ITermConceptMappingSvc;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.api.server.storage.TransactionDetails;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40;
|
||||
import org.hl7.fhir.dstu3.model.ConceptMap;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
|
||||
public class FhirResourceDaoConceptMapDstu3 extends BaseHapiFhirResourceDao<ConceptMap> implements IFhirResourceDaoConceptMap<ConceptMap> {
|
||||
@Autowired
|
||||
private ITermConceptMappingSvc myTermConceptMappingSvc;
|
||||
@Autowired
|
||||
private IValidationSupport myValidationSupport;
|
||||
|
||||
@Override
|
||||
public TranslateConceptResults translate(TranslationRequest theTranslationRequest, RequestDetails theRequestDetails) {
|
||||
IValidationSupport.TranslateCodeRequest translateCodeRequest = theTranslationRequest.asTranslateCodeRequest();
|
||||
return myValidationSupport.translateConcept(translateCodeRequest);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResourceTable updateEntity(RequestDetails theRequestDetails, IBaseResource theResource, IBasePersistedResource theEntity, Date theDeletedTimestampOrNull, boolean thePerformIndexing,
|
||||
boolean theUpdateVersion, TransactionDetails theTransactionDetails, boolean theForceUpdate, boolean theCreateNewHistoryEntry) {
|
||||
ResourceTable retVal = super.updateEntity(theRequestDetails, theResource, theEntity, theDeletedTimestampOrNull, thePerformIndexing, theUpdateVersion, theTransactionDetails, theForceUpdate, theCreateNewHistoryEntry);
|
||||
|
||||
if (!retVal.isUnchangedInCurrentOperation()) {
|
||||
if (retVal.getDeleted() == null) {
|
||||
try {
|
||||
ConceptMap conceptMap = (ConceptMap) theResource;
|
||||
org.hl7.fhir.r4.model.ConceptMap converted = (org.hl7.fhir.r4.model.ConceptMap) VersionConvertorFactory_30_40.convertResource(conceptMap, new BaseAdvisor_30_40(false));
|
||||
myTermConceptMappingSvc.storeTermConceptMapAndChildren(retVal, converted);
|
||||
} catch (FHIRException fe) {
|
||||
throw new InternalErrorException(Msg.code(1083) + fe);
|
||||
}
|
||||
} else {
|
||||
myTermConceptMappingSvc.deleteConceptMapAndChildren(retVal);
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package ca.uhn.fhir.jpa.dao.dstu3;
|
||||
|
||||
import ca.uhn.fhir.context.support.IValidationSupport;
|
||||
import ca.uhn.fhir.context.support.ValidationSupportContext;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoStructureDefinition;
|
||||
import ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.dstu3.model.StructureDefinition;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR JPA Server
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2022 Smile CDR, Inc.
|
||||
* %%
|
||||
* 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%
|
||||
*/
|
||||
|
||||
public class FhirResourceDaoStructureDefinitionDstu3 extends BaseHapiFhirResourceDao<StructureDefinition> implements IFhirResourceDaoStructureDefinition<StructureDefinition> {
|
||||
|
||||
@Autowired
|
||||
private IValidationSupport myValidationSupport;
|
||||
|
||||
@Override
|
||||
public StructureDefinition generateSnapshot(StructureDefinition theInput, String theUrl, String theWebUrl, String theName) {
|
||||
StructureDefinition output = (StructureDefinition) myValidationSupport.generateSnapshot(new ValidationSupportContext(myValidationSupport), theInput, theUrl, theName, null);
|
||||
Validate.notNull(output);
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package ca.uhn.fhir.jpa.dao.r4;
|
||||
|
||||
import ca.uhn.fhir.context.support.IValidationSupport;
|
||||
import ca.uhn.fhir.context.support.ValidationSupportContext;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoStructureDefinition;
|
||||
import ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.r4.model.StructureDefinition;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR JPA Server
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2022 Smile CDR, Inc.
|
||||
* %%
|
||||
* 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%
|
||||
*/
|
||||
|
||||
public class FhirResourceDaoStructureDefinitionR4 extends BaseHapiFhirResourceDao<StructureDefinition> implements IFhirResourceDaoStructureDefinition<StructureDefinition> {
|
||||
|
||||
@Autowired
|
||||
private IValidationSupport myValidationSupport;
|
||||
|
||||
@Override
|
||||
public StructureDefinition generateSnapshot(StructureDefinition theInput, String theUrl, String theWebUrl, String theName) {
|
||||
StructureDefinition output = (StructureDefinition) myValidationSupport.generateSnapshot(new ValidationSupportContext(myValidationSupport), theInput, theUrl, theWebUrl, theName);
|
||||
Validate.notNull(output);
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package ca.uhn.fhir.jpa.dao.r4b;
|
||||
|
||||
/*-
|
||||
* #%L
|
||||
* HAPI FHIR JPA Server
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2022 Smile CDR, Inc.
|
||||
* %%
|
||||
* 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 ca.uhn.fhir.context.support.IValidationSupport;
|
||||
import ca.uhn.fhir.context.support.TranslateConceptResults;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoConceptMap;
|
||||
import ca.uhn.fhir.jpa.api.model.TranslationRequest;
|
||||
import ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao;
|
||||
import ca.uhn.fhir.jpa.term.api.ITermConceptMappingSvc;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import org.hl7.fhir.r4b.model.ConceptMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class FhirResourceDaoConceptMapR4B extends BaseHapiFhirResourceDao<ConceptMap> implements IFhirResourceDaoConceptMap<ConceptMap> {
|
||||
@Autowired
|
||||
private ITermConceptMappingSvc myTermConceptMappingSvc;
|
||||
@Autowired
|
||||
private IValidationSupport myValidationSupport;
|
||||
|
||||
@Override
|
||||
public TranslateConceptResults translate(TranslationRequest theTranslationRequest, RequestDetails theRequestDetails) {
|
||||
IValidationSupport.TranslateCodeRequest translateCodeRequest = theTranslationRequest.asTranslateCodeRequest();
|
||||
return myValidationSupport.translateConcept(translateCodeRequest);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package ca.uhn.fhir.jpa.dao.r4b;
|
||||
|
||||
import ca.uhn.fhir.context.support.IValidationSupport;
|
||||
import ca.uhn.fhir.context.support.ValidationSupportContext;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoStructureDefinition;
|
||||
import ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.r4b.model.StructureDefinition;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR JPA Server
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2022 Smile CDR, Inc.
|
||||
* %%
|
||||
* 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%
|
||||
*/
|
||||
|
||||
public class FhirResourceDaoStructureDefinitionR4B extends BaseHapiFhirResourceDao<StructureDefinition> implements IFhirResourceDaoStructureDefinition<StructureDefinition> {
|
||||
|
||||
@Autowired
|
||||
private IValidationSupport myValidationSupport;
|
||||
|
||||
@Override
|
||||
public StructureDefinition generateSnapshot(StructureDefinition theInput, String theUrl, String theWebUrl, String theName) {
|
||||
StructureDefinition output = (StructureDefinition) myValidationSupport.generateSnapshot(new ValidationSupportContext(myValidationSupport), theInput, theUrl, theWebUrl, theName);
|
||||
Validate.notNull(output);
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
package ca.uhn.fhir.jpa.dao.r5;
|
||||
|
||||
/*-
|
||||
* #%L
|
||||
* HAPI FHIR JPA Server
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2022 Smile CDR, Inc.
|
||||
* %%
|
||||
* 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 ca.uhn.fhir.context.support.IValidationSupport;
|
||||
import ca.uhn.fhir.context.support.TranslateConceptResults;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoConceptMap;
|
||||
import ca.uhn.fhir.jpa.api.model.TranslationRequest;
|
||||
import ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao;
|
||||
import ca.uhn.fhir.jpa.model.cross.IBasePersistedResource;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.term.api.ITermConceptMappingSvc;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.api.server.storage.TransactionDetails;
|
||||
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.r5.model.ConceptMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
|
||||
public class FhirResourceDaoConceptMapR5 extends BaseHapiFhirResourceDao<ConceptMap> implements IFhirResourceDaoConceptMap<ConceptMap> {
|
||||
@Autowired
|
||||
private ITermConceptMappingSvc myTermConceptMappingSvc;
|
||||
@Autowired
|
||||
private IValidationSupport myValidationSupport;
|
||||
|
||||
@Override
|
||||
public TranslateConceptResults translate(TranslationRequest theTranslationRequest, RequestDetails theRequestDetails) {
|
||||
IValidationSupport.TranslateCodeRequest translateCodeRequest = theTranslationRequest.asTranslateCodeRequest();
|
||||
return myValidationSupport.translateConcept(translateCodeRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceTable updateEntity(RequestDetails theRequestDetails, IBaseResource theResource, IBasePersistedResource theEntity, Date theDeletedTimestampOrNull, boolean thePerformIndexing,
|
||||
boolean theUpdateVersion, TransactionDetails theTransactionDetails, boolean theForceUpdate, boolean theCreateNewHistoryEntry) {
|
||||
ResourceTable retVal = super.updateEntity(theRequestDetails, theResource, theEntity, theDeletedTimestampOrNull, thePerformIndexing, theUpdateVersion, theTransactionDetails, theForceUpdate, theCreateNewHistoryEntry);
|
||||
if (!retVal.isUnchangedInCurrentOperation()) {
|
||||
|
||||
if (retVal.getDeleted() == null) {
|
||||
ConceptMap conceptMap = (ConceptMap) theResource;
|
||||
myTermConceptMappingSvc.storeTermConceptMapAndChildren(retVal,
|
||||
(org.hl7.fhir.r4.model.ConceptMap) VersionConvertorFactory_40_50.convertResource(conceptMap, new BaseAdvisor_40_50(false)));
|
||||
} else {
|
||||
myTermConceptMappingSvc.deleteConceptMapAndChildren(retVal);
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
|
@ -36,13 +36,17 @@ import com.google.gson.Gson;
|
|||
import com.google.gson.GsonBuilder;
|
||||
import graphql.ExecutionResult;
|
||||
import graphql.GraphQL;
|
||||
import graphql.language.InterfaceTypeDefinition;
|
||||
import graphql.scalar.GraphqlStringCoercing;
|
||||
import graphql.schema.GraphQLScalarType;
|
||||
import graphql.schema.GraphQLSchema;
|
||||
import graphql.schema.TypeResolver;
|
||||
import graphql.schema.TypeResolverProxy;
|
||||
import graphql.schema.idl.RuntimeWiring;
|
||||
import graphql.schema.idl.SchemaGenerator;
|
||||
import graphql.schema.idl.SchemaParser;
|
||||
import graphql.schema.idl.TypeDefinitionRegistry;
|
||||
import graphql.schema.idl.TypeRuntimeWiring;
|
||||
import org.apache.commons.io.output.StringBuilderWriter;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.common.hapi.validation.validator.VersionSpecificWorkerContextWrapper;
|
||||
|
@ -132,18 +136,36 @@ public class GraphQLProviderWithIntrospection extends GraphQLProvider {
|
|||
|
||||
final StringBuilder schemaBuilder = new StringBuilder();
|
||||
try (Writer writer = new StringBuilderWriter(schemaBuilder)) {
|
||||
|
||||
// Generate FHIR base types schemas
|
||||
myGenerator.generateTypes(writer, theOperations);
|
||||
|
||||
// Fix up a few things that are missing from the generated schema
|
||||
writer
|
||||
.append("\ntype Resource {")
|
||||
.append("\n id: [token]" + "\n}")
|
||||
.append("\n");
|
||||
writer
|
||||
.append("\ninput ResourceInput {")
|
||||
.append("\n id: [token]" + "\n}")
|
||||
.append("\ninterface Element {")
|
||||
.append("\n id: ID")
|
||||
.append("\n}")
|
||||
.append("\n");
|
||||
// writer
|
||||
// .append("\ninterface Quantity {\n")
|
||||
// .append("id: String\n")
|
||||
// .append("extension: [Extension]\n")
|
||||
// .append("value: decimal _value: ElementBase\n")
|
||||
// .append("comparator: code _comparator: ElementBase\n")
|
||||
// .append("unit: String _unit: ElementBase\n")
|
||||
// .append("system: uri _system: ElementBase\n")
|
||||
// .append("code: code _code: ElementBase\n")
|
||||
// .append("\n}")
|
||||
// .append("\n");
|
||||
|
||||
// writer
|
||||
// .append("\ntype Resource {")
|
||||
// .append("\n id: [token]" + "\n}")
|
||||
// .append("\n");
|
||||
// writer
|
||||
// .append("\ninput ResourceInput {")
|
||||
// .append("\n id: [token]" + "\n}")
|
||||
// .append("\n");
|
||||
|
||||
// Generate schemas for the resource types
|
||||
for (String nextResourceType : theResourceTypes) {
|
||||
|
@ -195,6 +217,15 @@ public class GraphQLProviderWithIntrospection extends GraphQLProvider {
|
|||
runtimeWiringBuilder.scalar(new GraphQLScalarType.Builder().name(next).coercing(new GraphqlStringCoercing()).build());
|
||||
}
|
||||
|
||||
for (InterfaceTypeDefinition next : typeDefinitionRegistry.getTypes(InterfaceTypeDefinition.class)) {
|
||||
TypeResolver resolver = new TypeResolverProxy();
|
||||
TypeRuntimeWiring wiring = TypeRuntimeWiring
|
||||
.newTypeWiring(next.getName())
|
||||
.typeResolver(resolver)
|
||||
.build();
|
||||
runtimeWiringBuilder.type(wiring);
|
||||
}
|
||||
|
||||
RuntimeWiring runtimeWiring = runtimeWiringBuilder.build();
|
||||
GraphQLSchema graphQLSchema = schemaGenerator.makeExecutableSchema(typeDefinitionRegistry, runtimeWiring);
|
||||
|
||||
|
|
|
@ -50,13 +50,14 @@ import ca.uhn.fhir.util.SearchParameterUtil;
|
|||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
import org.hl7.fhir.r4.model.Identifier;
|
||||
import org.hl7.fhir.utilities.json.model.JsonElement;
|
||||
import org.hl7.fhir.utilities.json.model.JsonObject;
|
||||
import org.hl7.fhir.utilities.npm.IPackageCacheManager;
|
||||
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -205,8 +206,8 @@ public class PackageInstallerSvcImpl implements IPackageInstallerSvc {
|
|||
* @throws ImplementationGuideInstallationException if installation fails
|
||||
*/
|
||||
private void install(NpmPackage npmPackage, PackageInstallationSpec theInstallationSpec, PackageInstallOutcomeJson theOutcome) throws ImplementationGuideInstallationException {
|
||||
String name = npmPackage.getNpm().get("name").getAsString();
|
||||
String version = npmPackage.getNpm().get("version").getAsString();
|
||||
String name = npmPackage.getNpm().get("name").asJsonString().getValue();
|
||||
String version = npmPackage.getNpm().get("version").asJsonString().getValue();
|
||||
|
||||
String fhirVersion = npmPackage.fhirVersion();
|
||||
String currentFhirVersion = myFhirContext.getVersion().getVersion().getFhirVersionString();
|
||||
|
@ -248,11 +249,9 @@ public class PackageInstallerSvcImpl implements IPackageInstallerSvc {
|
|||
|
||||
private void fetchAndInstallDependencies(NpmPackage npmPackage, PackageInstallationSpec theInstallationSpec, PackageInstallOutcomeJson theOutcome) throws ImplementationGuideInstallationException {
|
||||
if (npmPackage.getNpm().has("dependencies")) {
|
||||
JsonElement dependenciesElement = npmPackage.getNpm().get("dependencies");
|
||||
Map<String, String> dependencies = new Gson().fromJson(dependenciesElement, HashMap.class);
|
||||
for (Map.Entry<String, String> d : dependencies.entrySet()) {
|
||||
String id = d.getKey();
|
||||
String ver = d.getValue();
|
||||
JsonObject dependenciesElement = npmPackage.getNpm().get("dependencies").asJsonObject();
|
||||
for (String id : dependenciesElement.getNames()) {
|
||||
String ver = dependenciesElement.getJsonString(id).asString();
|
||||
try {
|
||||
theOutcome.getMessage().add("Package " + npmPackage.id() + "#" + npmPackage.version() + " depends on package " + id + "#" + ver);
|
||||
|
||||
|
|
|
@ -0,0 +1,158 @@
|
|||
package ca.uhn.fhir.jpa.provider;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR JPA Server
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2022 Smile CDR, Inc.
|
||||
* %%
|
||||
* 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 ca.uhn.fhir.context.support.TranslateConceptResults;
|
||||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoConceptMap;
|
||||
import ca.uhn.fhir.jpa.api.model.TranslationRequest;
|
||||
import ca.uhn.fhir.jpa.model.util.JpaConstants;
|
||||
import ca.uhn.fhir.jpa.term.TermConceptMappingSvcImpl;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Operation;
|
||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.hapi.converters.canonical.VersionCanonicalizer;
|
||||
import org.hl7.fhir.instance.model.api.IBaseCoding;
|
||||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||
import org.hl7.fhir.instance.model.api.IBaseParameters;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
import org.hl7.fhir.r4.model.CodeableConcept;
|
||||
import org.hl7.fhir.r4.model.Coding;
|
||||
import org.hl7.fhir.r4.model.ConceptMap;
|
||||
import org.hl7.fhir.r4.model.Parameters;
|
||||
import org.hl7.fhir.r4.model.StringType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import static ca.uhn.fhir.util.DatatypeUtil.toBooleanValue;
|
||||
import static ca.uhn.fhir.util.DatatypeUtil.toStringValue;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
public abstract class BaseJpaResourceProviderConceptMap<T extends IBaseResource> extends BaseJpaResourceProvider<T> {
|
||||
|
||||
@Autowired
|
||||
private VersionCanonicalizer myVersionCanonicalizer;
|
||||
|
||||
@Operation(name = JpaConstants.OPERATION_TRANSLATE, idempotent = true, returnParameters = {
|
||||
@OperationParam(name = "result", typeName = "boolean", min = 1, max = 1),
|
||||
@OperationParam(name = "message", typeName = "string", min = 0, max = 1),
|
||||
})
|
||||
public IBaseParameters translate(
|
||||
HttpServletRequest theServletRequest,
|
||||
@IdParam(optional = true) IIdType theId,
|
||||
@OperationParam(name = "url", min = 0, max = 1, typeName = "uri") IPrimitiveType<String> theUrl,
|
||||
@OperationParam(name = "conceptMapVersion", min = 0, max = 1, typeName = "string") IPrimitiveType<String> theConceptMapVersion,
|
||||
@OperationParam(name = "code", min = 0, max = 1, typeName = "code") IPrimitiveType<String> theSourceCode,
|
||||
@OperationParam(name = "system", min = 0, max = 1, typeName = "uri") IPrimitiveType<String> theSourceCodeSystem,
|
||||
@OperationParam(name = "version", min = 0, max = 1, typeName = "string") IPrimitiveType<String> theSourceCodeSystemVersion,
|
||||
@OperationParam(name = "source", min = 0, max = 1, typeName = "uri") IPrimitiveType<String> theSourceValueSet,
|
||||
@OperationParam(name = "coding", min = 0, max = 1, typeName = "Coding") IBaseCoding theSourceCoding,
|
||||
@OperationParam(name = "codeableConcept", min = 0, max = 1, typeName = "CodeableConcept") IBaseDatatype theSourceCodeableConcept,
|
||||
@OperationParam(name = "target", min = 0, max = 1, typeName = "uri") IPrimitiveType<String> theTargetValueSet,
|
||||
@OperationParam(name = "targetsystem", min = 0, max = 1, typeName = "uri") IPrimitiveType<String> theTargetCodeSystem,
|
||||
@OperationParam(name = "reverse", min = 0, max = 1, typeName = "boolean") IPrimitiveType<Boolean> theReverse,
|
||||
RequestDetails theRequestDetails
|
||||
) {
|
||||
Coding sourceCoding = myVersionCanonicalizer.codingToCanonical(theSourceCoding);
|
||||
CodeableConcept sourceCodeableConcept = myVersionCanonicalizer.codeableConceptToCanonical(theSourceCodeableConcept);
|
||||
|
||||
boolean haveSourceCode = theSourceCode != null
|
||||
&& isNotBlank(theSourceCode.getValue());
|
||||
boolean haveSourceCodeSystem = theSourceCodeSystem != null
|
||||
&& theSourceCodeSystem.hasValue();
|
||||
boolean haveSourceCodeSystemVersion = theSourceCodeSystemVersion != null
|
||||
&& theSourceCodeSystemVersion.hasValue();
|
||||
boolean haveSourceCoding = sourceCoding != null
|
||||
&& sourceCoding.hasCode();
|
||||
boolean haveSourceCodeableConcept = sourceCodeableConcept != null
|
||||
&& sourceCodeableConcept.hasCoding()
|
||||
&& sourceCodeableConcept.getCodingFirstRep().hasCode();
|
||||
boolean haveReverse = theReverse != null;
|
||||
boolean haveId = theId != null && theId.hasIdPart();
|
||||
|
||||
// <editor-fold desc="Filters">
|
||||
if ((!haveSourceCode && !haveSourceCoding && !haveSourceCodeableConcept)
|
||||
|| moreThanOneTrue(haveSourceCode, haveSourceCoding, haveSourceCodeableConcept)) {
|
||||
throw new InvalidRequestException(Msg.code(1154) + "One (and only one) of the in parameters (code, coding, codeableConcept) must be provided, to identify the code that is to be translated.");
|
||||
}
|
||||
|
||||
TranslationRequest translationRequest = new TranslationRequest();
|
||||
translationRequest.setUrl(toStringValue(theUrl));
|
||||
translationRequest.setConceptMapVersion(toStringValue(theConceptMapVersion));
|
||||
|
||||
if (haveSourceCode) {
|
||||
translationRequest.getCodeableConcept().addCoding().setCode(toStringValue(theSourceCode));
|
||||
|
||||
if (haveSourceCodeSystem) {
|
||||
translationRequest.getCodeableConcept().getCodingFirstRep().setSystem(toStringValue(theSourceCodeSystem));
|
||||
}
|
||||
|
||||
if (haveSourceCodeSystemVersion) {
|
||||
translationRequest.getCodeableConcept().getCodingFirstRep().setVersion(toStringValue(theSourceCodeSystemVersion));
|
||||
}
|
||||
} else if (haveSourceCoding) {
|
||||
translationRequest.getCodeableConcept().addCoding(sourceCoding);
|
||||
} else {
|
||||
translationRequest.setCodeableConcept(sourceCodeableConcept);
|
||||
}
|
||||
|
||||
translationRequest.setSource(toStringValue(theSourceValueSet));
|
||||
translationRequest.setTarget(toStringValue(theTargetValueSet));
|
||||
translationRequest.setTargetSystem(toStringValue(theTargetCodeSystem));
|
||||
|
||||
if (haveReverse) {
|
||||
translationRequest.setReverse(toBooleanValue(theReverse));
|
||||
}
|
||||
|
||||
if (haveId) {
|
||||
translationRequest.setResourceId(theId);
|
||||
}
|
||||
|
||||
startRequest(theServletRequest);
|
||||
try {
|
||||
IFhirResourceDaoConceptMap<ConceptMap> dao = (IFhirResourceDaoConceptMap<ConceptMap>) getDao();
|
||||
TranslateConceptResults result = dao.translate(translationRequest, theRequestDetails);
|
||||
Parameters parameters = TermConceptMappingSvcImpl.toParameters(result);
|
||||
return myVersionCanonicalizer.parametersFromCanonical(parameters);
|
||||
} finally {
|
||||
endRequest(theServletRequest);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean moreThanOneTrue(boolean... theBooleans) {
|
||||
boolean haveOne = false;
|
||||
for (boolean next : theBooleans) {
|
||||
if (next) {
|
||||
if (haveOne) {
|
||||
return true;
|
||||
} else {
|
||||
haveOne = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,180 +0,0 @@
|
|||
package ca.uhn.fhir.jpa.provider.dstu3;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR JPA Server
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2022 Smile CDR, Inc.
|
||||
* %%
|
||||
* 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 ca.uhn.fhir.context.support.TranslateConceptResults;
|
||||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoConceptMap;
|
||||
import ca.uhn.fhir.jpa.api.model.TranslationRequest;
|
||||
import ca.uhn.fhir.jpa.model.util.JpaConstants;
|
||||
import ca.uhn.fhir.jpa.provider.BaseJpaResourceProvider;
|
||||
import ca.uhn.fhir.jpa.term.TermConceptMappingSvcImpl;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Operation;
|
||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40;
|
||||
import org.hl7.fhir.dstu3.model.BooleanType;
|
||||
import org.hl7.fhir.dstu3.model.CodeType;
|
||||
import org.hl7.fhir.dstu3.model.CodeableConcept;
|
||||
import org.hl7.fhir.dstu3.model.Coding;
|
||||
import org.hl7.fhir.dstu3.model.ConceptMap;
|
||||
import org.hl7.fhir.dstu3.model.IdType;
|
||||
import org.hl7.fhir.dstu3.model.Parameters;
|
||||
import org.hl7.fhir.dstu3.model.StringType;
|
||||
import org.hl7.fhir.dstu3.model.UriType;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
public abstract class BaseJpaResourceProviderConceptMapDstu3 extends BaseJpaResourceProvider<ConceptMap> {
|
||||
@Operation(name = JpaConstants.OPERATION_TRANSLATE, idempotent = true, returnParameters = {
|
||||
@OperationParam(name = "result", type = BooleanType.class, min = 1, max = 1),
|
||||
@OperationParam(name = "message", type = StringType.class, min = 0, max = 1),
|
||||
})
|
||||
public Parameters translate(
|
||||
HttpServletRequest theServletRequest,
|
||||
@IdParam(optional = true) IdType theId,
|
||||
@OperationParam(name = "url", min = 0, max = 1) UriType theUrl,
|
||||
@OperationParam(name = "conceptMapVersion", min = 0, max = 1) StringType theConceptMapVersion,
|
||||
@OperationParam(name = "code", min = 0, max = 1) CodeType theSourceCode,
|
||||
@OperationParam(name = "system", min = 0, max = 1) UriType theSourceCodeSystem,
|
||||
@OperationParam(name = "version", min = 0, max = 1) StringType theSourceCodeSystemVersion,
|
||||
@OperationParam(name = "source", min = 0, max = 1) UriType theSourceValueSet,
|
||||
@OperationParam(name = "coding", min = 0, max = 1) Coding theSourceCoding,
|
||||
@OperationParam(name = "codeableConcept", min = 0, max = 1) CodeableConcept theSourceCodeableConcept,
|
||||
@OperationParam(name = "target", min = 0, max = 1) UriType theTargetValueSet,
|
||||
@OperationParam(name = "targetsystem", min = 0, max = 1) UriType theTargetCodeSystem,
|
||||
@OperationParam(name = "reverse", min = 0, max = 1) BooleanType theReverse,
|
||||
RequestDetails theRequestDetails
|
||||
) {
|
||||
boolean haveUrl = theUrl != null
|
||||
&& theUrl.hasValue();
|
||||
boolean haveConceptMapVersion = theConceptMapVersion != null
|
||||
&& theConceptMapVersion.hasValue();
|
||||
boolean haveSourceCode = theSourceCode != null
|
||||
&& theSourceCode.hasValue();
|
||||
boolean haveSourceCodeSystem = theSourceCodeSystem != null
|
||||
&& theSourceCodeSystem.hasValue();
|
||||
boolean haveSourceCodeSystemVersion = theSourceCodeSystemVersion != null
|
||||
&& theSourceCodeSystemVersion.hasValue();
|
||||
boolean haveSourceValueSet = theSourceValueSet != null
|
||||
&& theSourceValueSet.hasValue();
|
||||
boolean haveSourceCoding = theSourceCoding != null
|
||||
&& theSourceCoding.hasCode();
|
||||
boolean haveSourceCodeableConcept = theSourceCodeableConcept != null
|
||||
&& theSourceCodeableConcept.hasCoding()
|
||||
&& theSourceCodeableConcept.getCodingFirstRep().hasCode();
|
||||
boolean haveTargetValueSet = theTargetValueSet != null
|
||||
&& theTargetValueSet.hasValue();
|
||||
boolean haveTargetCodeSystem = theTargetCodeSystem != null
|
||||
&& theTargetCodeSystem.hasValue();
|
||||
boolean haveReverse = theReverse != null;
|
||||
boolean haveId = theId != null && theId.hasIdPart();
|
||||
|
||||
// <editor-fold desc="Filters">
|
||||
if ((!haveSourceCode && !haveSourceCoding && !haveSourceCodeableConcept)
|
||||
|| moreThanOneTrue(haveSourceCode, haveSourceCoding, haveSourceCodeableConcept)) {
|
||||
throw new InvalidRequestException(Msg.code(1149) + "One (and only one) of the in parameters (code, coding, codeableConcept) must be provided, to identify the code that is to be translated.");
|
||||
}
|
||||
|
||||
TranslationRequest translationRequest = new TranslationRequest();
|
||||
try {
|
||||
|
||||
if (haveUrl) {
|
||||
translationRequest.setUrl((org.hl7.fhir.r4.model.UriType) VersionConvertorFactory_30_40.convertType(theUrl, new BaseAdvisor_30_40(false)));
|
||||
}
|
||||
|
||||
if (haveConceptMapVersion) {
|
||||
translationRequest.setConceptMapVersion((org.hl7.fhir.r4.model.StringType) VersionConvertorFactory_30_40.convertType(theConceptMapVersion, new BaseAdvisor_30_40(false)));
|
||||
}
|
||||
|
||||
// Convert from DSTU3 to R4
|
||||
if (haveSourceCode) {
|
||||
translationRequest.getCodeableConcept().addCoding().setCodeElement((org.hl7.fhir.r4.model.CodeType) VersionConvertorFactory_30_40.convertType(theSourceCode, new BaseAdvisor_30_40(false)));
|
||||
|
||||
if (haveSourceCodeSystem) {
|
||||
translationRequest.getCodeableConcept().getCodingFirstRep().setSystemElement((org.hl7.fhir.r4.model.UriType) VersionConvertorFactory_30_40.convertType(theSourceCodeSystem, new BaseAdvisor_30_40(false)));
|
||||
}
|
||||
|
||||
if (haveSourceCodeSystemVersion) {
|
||||
translationRequest.getCodeableConcept().getCodingFirstRep().setVersionElement((org.hl7.fhir.r4.model.StringType) VersionConvertorFactory_30_40.convertType(theSourceCodeSystemVersion, new BaseAdvisor_30_40(false)));
|
||||
}
|
||||
} else if (haveSourceCoding) {
|
||||
translationRequest.getCodeableConcept().addCoding((org.hl7.fhir.r4.model.Coding) VersionConvertorFactory_30_40.convertType(theSourceCoding, new BaseAdvisor_30_40(false)));
|
||||
} else {
|
||||
translationRequest.setCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) VersionConvertorFactory_30_40.convertType(theSourceCodeableConcept, new BaseAdvisor_30_40(false)));
|
||||
}
|
||||
|
||||
if (haveSourceValueSet) {
|
||||
translationRequest.setSource((org.hl7.fhir.r4.model.UriType) VersionConvertorFactory_30_40.convertType(theSourceValueSet, new BaseAdvisor_30_40(false)));
|
||||
}
|
||||
|
||||
if (haveTargetValueSet) {
|
||||
translationRequest.setTarget((org.hl7.fhir.r4.model.UriType) VersionConvertorFactory_30_40.convertType(theTargetValueSet, new BaseAdvisor_30_40(false)));
|
||||
}
|
||||
|
||||
if (haveTargetCodeSystem) {
|
||||
translationRequest.setTargetSystem((org.hl7.fhir.r4.model.UriType) VersionConvertorFactory_30_40.convertType(theTargetCodeSystem, new BaseAdvisor_30_40(false)));
|
||||
}
|
||||
|
||||
if (haveReverse) {
|
||||
translationRequest.setReverse((org.hl7.fhir.r4.model.BooleanType) VersionConvertorFactory_30_40.convertType(theReverse, new BaseAdvisor_30_40(false)));
|
||||
}
|
||||
|
||||
if (haveId) {
|
||||
translationRequest.setResourceId(theId.getIdPartAsLong());
|
||||
}
|
||||
} catch (FHIRException fe) {
|
||||
throw new InternalErrorException(Msg.code(1150) + fe);
|
||||
}
|
||||
|
||||
startRequest(theServletRequest);
|
||||
try {
|
||||
IFhirResourceDaoConceptMap<ConceptMap> dao = (IFhirResourceDaoConceptMap<ConceptMap>) getDao();
|
||||
TranslateConceptResults result = dao.translate(translationRequest, theRequestDetails);
|
||||
|
||||
// Convert from R4 to DSTU3
|
||||
return (Parameters) VersionConvertorFactory_30_40.convertResource(TermConceptMappingSvcImpl.toParameters(result), new BaseAdvisor_30_40(false));
|
||||
} catch (FHIRException fe) {
|
||||
throw new InternalErrorException(Msg.code(1151) + fe);
|
||||
} finally {
|
||||
endRequest(theServletRequest);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean moreThanOneTrue(boolean... theBooleans) {
|
||||
boolean haveOne = false;
|
||||
for (boolean next : theBooleans) {
|
||||
if (next) {
|
||||
if (haveOne) {
|
||||
return true;
|
||||
} else {
|
||||
haveOne = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,167 +0,0 @@
|
|||
package ca.uhn.fhir.jpa.provider.r4;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR JPA Server
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2022 Smile CDR, Inc.
|
||||
* %%
|
||||
* 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 ca.uhn.fhir.context.support.TranslateConceptResults;
|
||||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoConceptMap;
|
||||
import ca.uhn.fhir.jpa.api.model.TranslationRequest;
|
||||
import ca.uhn.fhir.jpa.model.util.JpaConstants;
|
||||
import ca.uhn.fhir.jpa.provider.BaseJpaResourceProvider;
|
||||
import ca.uhn.fhir.jpa.term.TermConceptMappingSvcImpl;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Operation;
|
||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import org.hl7.fhir.r4.model.BooleanType;
|
||||
import org.hl7.fhir.r4.model.CodeType;
|
||||
import org.hl7.fhir.r4.model.CodeableConcept;
|
||||
import org.hl7.fhir.r4.model.Coding;
|
||||
import org.hl7.fhir.r4.model.ConceptMap;
|
||||
import org.hl7.fhir.r4.model.IdType;
|
||||
import org.hl7.fhir.r4.model.Parameters;
|
||||
import org.hl7.fhir.r4.model.StringType;
|
||||
import org.hl7.fhir.r4.model.UriType;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
public abstract class BaseJpaResourceProviderConceptMapR4 extends BaseJpaResourceProvider<ConceptMap> {
|
||||
@Operation(name = JpaConstants.OPERATION_TRANSLATE, idempotent = true, returnParameters = {
|
||||
@OperationParam(name = "result", type = BooleanType.class, min = 1, max = 1),
|
||||
@OperationParam(name = "message", type = StringType.class, min = 0, max = 1),
|
||||
})
|
||||
public Parameters translate(
|
||||
HttpServletRequest theServletRequest,
|
||||
@IdParam(optional = true) IdType theId,
|
||||
@OperationParam(name = "url", min = 0, max = 1) UriType theUrl,
|
||||
@OperationParam(name = "conceptMapVersion", min = 0, max = 1) StringType theConceptMapVersion,
|
||||
@OperationParam(name = "code", min = 0, max = 1) CodeType theSourceCode,
|
||||
@OperationParam(name = "system", min = 0, max = 1) UriType theSourceCodeSystem,
|
||||
@OperationParam(name = "version", min = 0, max = 1) StringType theSourceCodeSystemVersion,
|
||||
@OperationParam(name = "source", min = 0, max = 1) UriType theSourceValueSet,
|
||||
@OperationParam(name = "coding", min = 0, max = 1) Coding theSourceCoding,
|
||||
@OperationParam(name = "codeableConcept", min = 0, max = 1) CodeableConcept theSourceCodeableConcept,
|
||||
@OperationParam(name = "target", min = 0, max = 1) UriType theTargetValueSet,
|
||||
@OperationParam(name = "targetsystem", min = 0, max = 1) UriType theTargetCodeSystem,
|
||||
@OperationParam(name = "reverse", min = 0, max = 1) BooleanType theReverse,
|
||||
RequestDetails theRequestDetails
|
||||
) {
|
||||
boolean haveUrl = theUrl != null
|
||||
&& theUrl.hasValue();
|
||||
boolean haveConceptMapVersion = theConceptMapVersion != null
|
||||
&& theConceptMapVersion.hasValue();
|
||||
boolean haveSourceCode = theSourceCode != null
|
||||
&& theSourceCode.hasCode();
|
||||
boolean haveSourceCodeSystem = theSourceCodeSystem != null
|
||||
&& theSourceCodeSystem.hasValue();
|
||||
boolean haveSourceCodeSystemVersion = theSourceCodeSystemVersion != null
|
||||
&& theSourceCodeSystemVersion.hasValue();
|
||||
boolean haveSourceValueSet = theSourceValueSet != null
|
||||
&& theSourceValueSet.hasValue();
|
||||
boolean haveSourceCoding = theSourceCoding != null
|
||||
&& theSourceCoding.hasCode();
|
||||
boolean haveSourceCodeableConcept = theSourceCodeableConcept != null
|
||||
&& theSourceCodeableConcept.hasCoding()
|
||||
&& theSourceCodeableConcept.getCodingFirstRep().hasCode();
|
||||
boolean haveTargetValueSet = theTargetValueSet != null
|
||||
&& theTargetValueSet.hasValue();
|
||||
boolean haveTargetCodeSystem = theTargetCodeSystem != null
|
||||
&& theTargetCodeSystem.hasValue();
|
||||
boolean haveReverse = theReverse != null;
|
||||
boolean haveId = theId != null && theId.hasIdPart();
|
||||
|
||||
// <editor-fold desc="Filters">
|
||||
if ((!haveSourceCode && !haveSourceCoding && !haveSourceCodeableConcept)
|
||||
|| moreThanOneTrue(haveSourceCode, haveSourceCoding, haveSourceCodeableConcept)) {
|
||||
throw new InvalidRequestException(Msg.code(1154) + "One (and only one) of the in parameters (code, coding, codeableConcept) must be provided, to identify the code that is to be translated.");
|
||||
}
|
||||
|
||||
TranslationRequest translationRequest = new TranslationRequest();
|
||||
|
||||
if (haveUrl) {
|
||||
translationRequest.setUrl(theUrl);
|
||||
}
|
||||
|
||||
if (haveConceptMapVersion) {
|
||||
translationRequest.setConceptMapVersion(theConceptMapVersion);
|
||||
}
|
||||
|
||||
if (haveSourceCode) {
|
||||
translationRequest.getCodeableConcept().addCoding().setCodeElement(theSourceCode);
|
||||
|
||||
if (haveSourceCodeSystem) {
|
||||
translationRequest.getCodeableConcept().getCodingFirstRep().setSystemElement(theSourceCodeSystem);
|
||||
}
|
||||
|
||||
if (haveSourceCodeSystemVersion) {
|
||||
translationRequest.getCodeableConcept().getCodingFirstRep().setVersionElement(theSourceCodeSystemVersion);
|
||||
}
|
||||
} else if (haveSourceCoding) {
|
||||
translationRequest.getCodeableConcept().addCoding(theSourceCoding);
|
||||
} else {
|
||||
translationRequest.setCodeableConcept(theSourceCodeableConcept);
|
||||
}
|
||||
|
||||
if (haveSourceValueSet) {
|
||||
translationRequest.setSource(theSourceValueSet);
|
||||
}
|
||||
|
||||
if (haveTargetValueSet) {
|
||||
translationRequest.setTarget(theTargetValueSet);
|
||||
}
|
||||
|
||||
if (haveTargetCodeSystem) {
|
||||
translationRequest.setTargetSystem(theTargetCodeSystem);
|
||||
}
|
||||
|
||||
if (haveReverse) {
|
||||
translationRequest.setReverse(theReverse);
|
||||
}
|
||||
|
||||
if (haveId) {
|
||||
translationRequest.setResourceId(theId.getIdPartAsLong());
|
||||
}
|
||||
|
||||
startRequest(theServletRequest);
|
||||
try {
|
||||
IFhirResourceDaoConceptMap<ConceptMap> dao = (IFhirResourceDaoConceptMap<ConceptMap>) getDao();
|
||||
TranslateConceptResults result = dao.translate(translationRequest, theRequestDetails);
|
||||
return TermConceptMappingSvcImpl.toParameters(result);
|
||||
} finally {
|
||||
endRequest(theServletRequest);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean moreThanOneTrue(boolean... theBooleans) {
|
||||
boolean haveOne = false;
|
||||
for (boolean next : theBooleans) {
|
||||
if (next) {
|
||||
if (haveOne) {
|
||||
return true;
|
||||
} else {
|
||||
haveOne = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package ca.uhn.fhir.jpa.provider.r4b;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR JPA Server
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2022 Smile CDR, Inc.
|
||||
* %%
|
||||
* 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 ca.uhn.fhir.jpa.provider.BaseJpaResourceProvider;
|
||||
import org.hl7.fhir.r4b.model.ConceptMap;
|
||||
|
||||
public abstract class BaseJpaResourceProviderConceptMapR4B extends BaseJpaResourceProvider<ConceptMap> {
|
||||
}
|
|
@ -1,171 +0,0 @@
|
|||
package ca.uhn.fhir.jpa.provider.r5;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR JPA Server
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2022 Smile CDR, Inc.
|
||||
* %%
|
||||
* 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 ca.uhn.fhir.context.support.TranslateConceptResults;
|
||||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoConceptMap;
|
||||
import ca.uhn.fhir.jpa.api.model.TranslationRequest;
|
||||
import ca.uhn.fhir.jpa.model.util.JpaConstants;
|
||||
import ca.uhn.fhir.jpa.provider.BaseJpaResourceProvider;
|
||||
import ca.uhn.fhir.jpa.term.TermConceptMappingSvcImpl;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Operation;
|
||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
|
||||
import org.hl7.fhir.r5.model.BooleanType;
|
||||
import org.hl7.fhir.r5.model.CodeType;
|
||||
import org.hl7.fhir.r5.model.CodeableConcept;
|
||||
import org.hl7.fhir.r5.model.Coding;
|
||||
import org.hl7.fhir.r5.model.ConceptMap;
|
||||
import org.hl7.fhir.r5.model.IdType;
|
||||
import org.hl7.fhir.r5.model.Parameters;
|
||||
import org.hl7.fhir.r5.model.StringType;
|
||||
import org.hl7.fhir.r5.model.UriType;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
public abstract class BaseJpaResourceProviderConceptMapR5 extends BaseJpaResourceProvider<ConceptMap> {
|
||||
@Operation(name = JpaConstants.OPERATION_TRANSLATE, idempotent = true, returnParameters = {
|
||||
@OperationParam(name = "result", type = BooleanType.class, min = 1, max = 1),
|
||||
@OperationParam(name = "message", type = StringType.class, min = 0, max = 1),
|
||||
})
|
||||
public Parameters translate(
|
||||
HttpServletRequest theServletRequest,
|
||||
@IdParam(optional = true) IdType theId,
|
||||
@OperationParam(name = "url", min = 0, max = 1) UriType theUrl,
|
||||
@OperationParam(name = "conceptMapVersion", min = 0, max = 1) StringType theConceptMapVersion,
|
||||
@OperationParam(name = "code", min = 0, max = 1) CodeType theSourceCode,
|
||||
@OperationParam(name = "system", min = 0, max = 1) UriType theSourceCodeSystem,
|
||||
@OperationParam(name = "version", min = 0, max = 1) StringType theSourceCodeSystemVersion,
|
||||
@OperationParam(name = "source", min = 0, max = 1) UriType theSourceValueSet,
|
||||
@OperationParam(name = "coding", min = 0, max = 1) Coding theSourceCoding,
|
||||
@OperationParam(name = "codeableConcept", min = 0, max = 1) CodeableConcept theSourceCodeableConcept,
|
||||
@OperationParam(name = "target", min = 0, max = 1) UriType theTargetValueSet,
|
||||
@OperationParam(name = "targetsystem", min = 0, max = 1) UriType theTargetCodeSystem,
|
||||
@OperationParam(name = "reverse", min = 0, max = 1) BooleanType theReverse,
|
||||
RequestDetails theRequestDetails
|
||||
) {
|
||||
boolean haveUrl = theUrl != null
|
||||
&& theUrl.hasValue();
|
||||
boolean haveConceptMapVersion = theConceptMapVersion != null
|
||||
&& theConceptMapVersion.hasValue();
|
||||
boolean haveSourceCode = theSourceCode != null
|
||||
&& theSourceCode.hasCode();
|
||||
boolean haveSourceCodeSystem = theSourceCodeSystem != null
|
||||
&& theSourceCodeSystem.hasValue();
|
||||
boolean haveSourceCodeSystemVersion = theSourceCodeSystemVersion != null
|
||||
&& theSourceCodeSystemVersion.hasValue();
|
||||
boolean haveSourceValueSet = theSourceValueSet != null
|
||||
&& theSourceValueSet.hasValue();
|
||||
boolean haveSourceCoding = theSourceCoding != null
|
||||
&& theSourceCoding.hasCode();
|
||||
boolean haveSourceCodeableConcept = theSourceCodeableConcept != null
|
||||
&& theSourceCodeableConcept.hasCoding()
|
||||
&& theSourceCodeableConcept.getCodingFirstRep().hasCode();
|
||||
boolean haveTargetValueSet = theTargetValueSet != null
|
||||
&& theTargetValueSet.hasValue();
|
||||
boolean haveTargetCodeSystem = theTargetCodeSystem != null
|
||||
&& theTargetCodeSystem.hasValue();
|
||||
boolean haveReverse = theReverse != null;
|
||||
boolean haveId = theId != null && theId.hasIdPart();
|
||||
|
||||
// <editor-fold desc="Filters">
|
||||
if ((!haveSourceCode && !haveSourceCoding && !haveSourceCodeableConcept)
|
||||
|| moreThanOneTrue(haveSourceCode, haveSourceCoding, haveSourceCodeableConcept)) {
|
||||
throw new InvalidRequestException(Msg.code(1161) + "One (and only one) of the in parameters (code, coding, codeableConcept) must be provided, to identify the code that is to be translated.");
|
||||
}
|
||||
|
||||
TranslationRequest translationRequest = new TranslationRequest();
|
||||
|
||||
if (haveUrl) {
|
||||
translationRequest.setUrl((org.hl7.fhir.r4.model.UriType) VersionConvertorFactory_40_50.convertType(theUrl, new BaseAdvisor_40_50(false)));
|
||||
}
|
||||
|
||||
if (haveConceptMapVersion) {
|
||||
translationRequest.setConceptMapVersion((org.hl7.fhir.r4.model.StringType) VersionConvertorFactory_40_50.convertType(theConceptMapVersion, new BaseAdvisor_40_50(false)));
|
||||
}
|
||||
|
||||
if (haveSourceCode) {
|
||||
translationRequest.getCodeableConcept().addCoding().setCodeElement((org.hl7.fhir.r4.model.CodeType) VersionConvertorFactory_40_50.convertType(theSourceCode, new BaseAdvisor_40_50(false)));
|
||||
|
||||
if (haveSourceCodeSystem) {
|
||||
translationRequest.getCodeableConcept().getCodingFirstRep().setSystemElement((org.hl7.fhir.r4.model.UriType) VersionConvertorFactory_40_50.convertType(theSourceCodeSystem, new BaseAdvisor_40_50(false)));
|
||||
}
|
||||
|
||||
if (haveSourceCodeSystemVersion) {
|
||||
translationRequest.getCodeableConcept().getCodingFirstRep()
|
||||
.setVersionElement((org.hl7.fhir.r4.model.StringType) VersionConvertorFactory_40_50.convertType(theSourceCodeSystemVersion, new BaseAdvisor_40_50(false)));
|
||||
}
|
||||
} else if (haveSourceCoding) {
|
||||
translationRequest.getCodeableConcept().addCoding((org.hl7.fhir.r4.model.Coding) VersionConvertorFactory_40_50.convertType(theSourceCoding, new BaseAdvisor_40_50(false)));
|
||||
} else {
|
||||
translationRequest.setCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) VersionConvertorFactory_40_50.convertType(theSourceCodeableConcept, new BaseAdvisor_40_50(false)));
|
||||
}
|
||||
|
||||
if (haveSourceValueSet) {
|
||||
translationRequest.setSource((org.hl7.fhir.r4.model.UriType) VersionConvertorFactory_40_50.convertType(theSourceValueSet, new BaseAdvisor_40_50(false)));
|
||||
}
|
||||
|
||||
if (haveTargetValueSet) {
|
||||
translationRequest.setTarget((org.hl7.fhir.r4.model.UriType) VersionConvertorFactory_40_50.convertType(theTargetValueSet, new BaseAdvisor_40_50(false)));
|
||||
}
|
||||
|
||||
if (haveTargetCodeSystem) {
|
||||
translationRequest.setTargetSystem((org.hl7.fhir.r4.model.UriType) VersionConvertorFactory_40_50.convertType(theTargetCodeSystem, new BaseAdvisor_40_50(false)));
|
||||
}
|
||||
|
||||
if (haveReverse) {
|
||||
translationRequest.setReverse((org.hl7.fhir.r4.model.BooleanType) VersionConvertorFactory_40_50.convertType(theReverse, new BaseAdvisor_40_50(false)));
|
||||
}
|
||||
|
||||
if (haveId) {
|
||||
translationRequest.setResourceId(theId.getIdPartAsLong());
|
||||
}
|
||||
|
||||
startRequest(theServletRequest);
|
||||
try {
|
||||
IFhirResourceDaoConceptMap<ConceptMap> dao = (IFhirResourceDaoConceptMap<ConceptMap>) getDao();
|
||||
TranslateConceptResults result = dao.translate(translationRequest, theRequestDetails);
|
||||
org.hl7.fhir.r4.model.Parameters parameters = TermConceptMappingSvcImpl.toParameters(result);
|
||||
return (Parameters) VersionConvertorFactory_40_50.convertResource(parameters, new BaseAdvisor_40_50(false));
|
||||
} finally {
|
||||
endRequest(theServletRequest);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean moreThanOneTrue(boolean... theBooleans) {
|
||||
boolean haveOne = false;
|
||||
for (boolean next : theBooleans) {
|
||||
if (next) {
|
||||
if (haveOne) {
|
||||
return true;
|
||||
} else {
|
||||
haveOne = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -20,12 +20,14 @@ package ca.uhn.fhir.jpa.term;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.support.TranslateConceptResult;
|
||||
import ca.uhn.fhir.context.support.TranslateConceptResults;
|
||||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.interceptor.model.RequestPartitionId;
|
||||
import ca.uhn.fhir.jpa.api.model.TranslationQuery;
|
||||
import ca.uhn.fhir.jpa.api.model.TranslationRequest;
|
||||
import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
|
||||
import ca.uhn.fhir.jpa.dao.data.ITermConceptMapDao;
|
||||
import ca.uhn.fhir.jpa.dao.data.ITermConceptMapGroupDao;
|
||||
import ca.uhn.fhir.jpa.dao.data.ITermConceptMapGroupElementDao;
|
||||
|
@ -38,6 +40,7 @@ import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
|||
import ca.uhn.fhir.jpa.term.api.ITermConceptMappingSvc;
|
||||
import ca.uhn.fhir.jpa.util.MemoryCacheService;
|
||||
import ca.uhn.fhir.jpa.util.ScrollableResultsIterator;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
|
@ -47,6 +50,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.hibernate.ScrollMode;
|
||||
import org.hibernate.ScrollableResults;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4.model.BooleanType;
|
||||
import org.hl7.fhir.r4.model.CodeType;
|
||||
import org.hl7.fhir.r4.model.Coding;
|
||||
|
@ -102,6 +106,8 @@ public class TermConceptMappingSvcImpl implements ITermConceptMappingSvc {
|
|||
private FhirContext myContext;
|
||||
@Autowired
|
||||
private MemoryCacheService myMemoryCacheService;
|
||||
@Autowired
|
||||
private IIdHelperService myIdHelperService;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
|
@ -328,14 +334,14 @@ public class TermConceptMappingSvcImpl implements ITermConceptMappingSvc {
|
|||
}
|
||||
|
||||
if (translationQuery.hasTargetSystem()) {
|
||||
predicates.add(criteriaBuilder.equal(groupJoin.get("myTarget"), translationQuery.getTargetSystem().getValueAsString()));
|
||||
predicates.add(criteriaBuilder.equal(groupJoin.get("myTarget"), translationQuery.getTargetSystem()));
|
||||
}
|
||||
|
||||
if (translationQuery.hasUrl()) {
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myUrl"), translationQuery.getUrl().getValueAsString()));
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myUrl"), translationQuery.getUrl()));
|
||||
if (translationQuery.hasConceptMapVersion()) {
|
||||
// both url and conceptMapVersion
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myVersion"), translationQuery.getConceptMapVersion().getValueAsString()));
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myVersion"), translationQuery.getConceptMapVersion()));
|
||||
} else {
|
||||
if (StringUtils.isNotBlank(latestConceptMapVersion)) {
|
||||
// only url and use latestConceptMapVersion
|
||||
|
@ -347,15 +353,17 @@ public class TermConceptMappingSvcImpl implements ITermConceptMappingSvc {
|
|||
}
|
||||
|
||||
if (translationQuery.hasSource()) {
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("mySource"), translationQuery.getSource().getValueAsString()));
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("mySource"), translationQuery.getSource()));
|
||||
}
|
||||
|
||||
if (translationQuery.hasTarget()) {
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myTarget"), translationQuery.getTarget().getValueAsString()));
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myTarget"), translationQuery.getTarget()));
|
||||
}
|
||||
|
||||
if (translationQuery.hasResourceId()) {
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myResourcePid"), translationQuery.getResourceId()));
|
||||
IIdType resourceId = translationQuery.getResourceId();
|
||||
ResourcePersistentId resourcePid = myIdHelperService.getPidOrThrowException(RequestPartitionId.defaultPartition(), resourceId);
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myResourcePid"), resourcePid.getIdAsLong()));
|
||||
}
|
||||
|
||||
Predicate outerPredicate = criteriaBuilder.and(predicates.toArray(new Predicate[0]));
|
||||
|
@ -455,10 +463,10 @@ public class TermConceptMappingSvcImpl implements ITermConceptMappingSvc {
|
|||
}
|
||||
|
||||
if (translationQuery.hasUrl()) {
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myUrl"), translationQuery.getUrl().getValueAsString()));
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myUrl"), translationQuery.getUrl()));
|
||||
if (translationQuery.hasConceptMapVersion()) {
|
||||
// both url and conceptMapVersion
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myVersion"), translationQuery.getConceptMapVersion().getValueAsString()));
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myVersion"), translationQuery.getConceptMapVersion()));
|
||||
} else {
|
||||
if (StringUtils.isNotBlank(latestConceptMapVersion)) {
|
||||
// only url and use latestConceptMapVersion
|
||||
|
@ -470,19 +478,21 @@ public class TermConceptMappingSvcImpl implements ITermConceptMappingSvc {
|
|||
}
|
||||
|
||||
if (translationQuery.hasTargetSystem()) {
|
||||
predicates.add(criteriaBuilder.equal(groupJoin.get("mySource"), translationQuery.getTargetSystem().getValueAsString()));
|
||||
predicates.add(criteriaBuilder.equal(groupJoin.get("mySource"), translationQuery.getTargetSystem()));
|
||||
}
|
||||
|
||||
if (translationQuery.hasSource()) {
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myTarget"), translationQuery.getSource().getValueAsString()));
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myTarget"), translationQuery.getSource()));
|
||||
}
|
||||
|
||||
if (translationQuery.hasTarget()) {
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("mySource"), translationQuery.getTarget().getValueAsString()));
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("mySource"), translationQuery.getTarget()));
|
||||
}
|
||||
|
||||
if (translationQuery.hasResourceId()) {
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myResourcePid"), translationQuery.getResourceId()));
|
||||
IIdType resourceId = translationQuery.getResourceId();
|
||||
ResourcePersistentId resourcePid = myIdHelperService.getPidOrThrowException(RequestPartitionId.defaultPartition(), resourceId);
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myResourcePid"), resourcePid.getIdAsLong()));
|
||||
}
|
||||
|
||||
Predicate outerPredicate = criteriaBuilder.and(predicates.toArray(new Predicate[0]));
|
||||
|
@ -600,7 +610,7 @@ public class TermConceptMappingSvcImpl implements ITermConceptMappingSvc {
|
|||
|
||||
Pageable page = PageRequest.of(0, 1);
|
||||
List<TermConceptMap> theConceptMapList = myConceptMapDao.getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(page,
|
||||
theTranslationRequest.getUrl().asStringValue());
|
||||
theTranslationRequest.getUrl());
|
||||
if (!theConceptMapList.isEmpty()) {
|
||||
return theConceptMapList.get(0).getVersion();
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ public class MdmControllerSvcImplTest extends BaseLinkR4Test {
|
|||
ServletRequestDetails details = new ServletRequestDetails();
|
||||
details.setTenantId(PARTITION_2);
|
||||
IBaseParameters clearJob = myMdmControllerSvc.submitMdmClearJob(urls, batchSize, details);
|
||||
String jobId = ((StringType) ((Parameters) clearJob).getParameter("jobId")).getValueAsString();
|
||||
String jobId = ((StringType) ((Parameters) clearJob).getParameterValue("jobId")).getValueAsString();
|
||||
myBatch2JobHelper.awaitJobCompletion(jobId);
|
||||
|
||||
assertLinkCount(2);
|
||||
|
|
|
@ -307,16 +307,42 @@ public class FhirResourceDaoDstu2SearchNoFtTest extends BaseJpaDstu2Test {
|
|||
@Test
|
||||
public void testIndexNoDuplicatesUri() {
|
||||
ConceptMap res = new ConceptMap();
|
||||
res.addElement().addTarget().addDependsOn().setElement("http://foo");
|
||||
res.addElement().addTarget().addDependsOn().setElement("http://foo");
|
||||
res.addElement().addTarget().addDependsOn().setElement("http://bar");
|
||||
res.addElement().addTarget().addDependsOn().setElement("http://bar");
|
||||
res.setUrl("http://foo");
|
||||
res.addElement()
|
||||
.setCodeSystem("http://cs")
|
||||
.setCodeSystem("C")
|
||||
.addTarget()
|
||||
.setCodeSystem("http://cs2")
|
||||
.setCode("T")
|
||||
.addDependsOn()
|
||||
.setElement("http://foo");
|
||||
res.addElement()
|
||||
.setCodeSystem("C")
|
||||
.setCodeSystem("http://cs")
|
||||
.addTarget()
|
||||
.setCodeSystem("http://cs2")
|
||||
.setCode("T")
|
||||
.addDependsOn().setElement("http://foo");
|
||||
res.addElement()
|
||||
.setCodeSystem("http://cs")
|
||||
.setCodeSystem("C")
|
||||
.addTarget()
|
||||
.setCodeSystem("http://cs2")
|
||||
.setCode("T")
|
||||
.addDependsOn().setElement("http://bar");
|
||||
res.addElement()
|
||||
.setCodeSystem("http://cs")
|
||||
.setCodeSystem("C")
|
||||
.addTarget()
|
||||
.setCodeSystem("http://cs2")
|
||||
.setCode("T")
|
||||
.addDependsOn().setElement("http://bar");
|
||||
|
||||
IIdType id = myConceptMapDao.create(res, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
runInTransaction(() -> {
|
||||
Class<ResourceIndexedSearchParamUri> type = ResourceIndexedSearchParamUri.class;
|
||||
List<?> results = myEntityManager.createQuery("SELECT i FROM " + type.getSimpleName() + " i WHERE i.myMissing = false", type).getResultList();
|
||||
List<?> results = myEntityManager.createQuery("SELECT i FROM " + type.getSimpleName() + " i WHERE i.myMissing = false AND i.myParamName = 'dependson'", type).getResultList();
|
||||
ourLog.info(toStringMultiline(results));
|
||||
assertEquals(2, results.size());
|
||||
});
|
||||
|
|
|
@ -49,7 +49,7 @@ public class FhirResourceDaoDstu3ConceptMapTest extends BaseJpaDstu3Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL)
|
||||
.setCode("12345");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL_3));
|
||||
translationRequest.setTargetSystem(CS_URL_3);
|
||||
|
||||
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
|
||||
|
||||
|
@ -73,7 +73,7 @@ public class FhirResourceDaoDstu3ConceptMapTest extends BaseJpaDstu3Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL)
|
||||
.setCode("12345");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL_3));
|
||||
translationRequest.setTargetSystem(CS_URL_3);
|
||||
|
||||
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@ import java.io.IOException;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
|
@ -100,7 +102,8 @@ public class NpmDstu3Test extends BaseJpaDstu3Test {
|
|||
ourLog.info("Fail Outcome: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome()));
|
||||
|
||||
OperationOutcome oo = (OperationOutcome) e.getOperationOutcome();
|
||||
assertEquals("Condition.subject: minimum required = 1, but only found 0 (from http://fhir.de/StructureDefinition/condition-de-basis/0.2)", oo.getIssueFirstRep().getDiagnostics());
|
||||
assertThat(oo.getIssueFirstRep().getDiagnostics(),
|
||||
containsString("Condition.subject: minimum required = 1, but only found 0 (from http://fhir.de/StructureDefinition/condition-de-basis/0.2"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -116,6 +116,7 @@ public class CompositionDocumentDstu3Test extends BaseResourceProviderDstu3Test
|
|||
|
||||
String theUrl = myServerBase + "/" + compId + "/$document?_format=json";
|
||||
Bundle bundle = fetchBundle(theUrl, EncodingEnum.JSON);
|
||||
ourLog.info("Resp: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle));
|
||||
|
||||
bundle.getEntry().stream()
|
||||
.forEach(entry -> {
|
||||
|
@ -123,7 +124,7 @@ public class CompositionDocumentDstu3Test extends BaseResourceProviderDstu3Test
|
|||
});
|
||||
|
||||
assertThat(bundle.getType(), is(equalTo(Bundle.BundleType.DOCUMENT)));
|
||||
assertNull(bundle.getLink("next"));
|
||||
assertNull(bundle.getLinkOrCreate("next").getUrl());
|
||||
|
||||
Set<String> actual = new HashSet<>();
|
||||
for (BundleEntryComponent nextEntry : bundle.getEntry()) {
|
||||
|
|
|
@ -84,7 +84,7 @@ public class ResourceProviderQuestionnaireResponseDstu3Test extends BaseResource
|
|||
myClient.create().resource(qr1).execute();
|
||||
fail();
|
||||
} catch (UnprocessableEntityException e) {
|
||||
assertThat(e.toString(), containsString("Answer value must be of type string"));
|
||||
assertThat(e.toString(), containsString("Answer value must be of the type string"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL)
|
||||
.setCode("12345");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL_3));
|
||||
translationRequest.setTargetSystem(CS_URL_3);
|
||||
|
||||
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
|
||||
|
||||
|
@ -94,7 +94,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL)
|
||||
.setCode("12345");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL_3));
|
||||
translationRequest.setTargetSystem(CS_URL_3);
|
||||
|
||||
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
|
||||
|
||||
|
@ -138,7 +138,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL)
|
||||
.setCode("12345");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL_2));
|
||||
translationRequest.setTargetSystem(CS_URL_2);
|
||||
|
||||
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
|
||||
|
||||
|
@ -173,7 +173,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL)
|
||||
.setCode("BOGUS");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL_3));
|
||||
translationRequest.setTargetSystem(CS_URL_3);
|
||||
|
||||
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
|
||||
|
||||
|
@ -256,7 +256,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL)
|
||||
.setCode("12345");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL_2));
|
||||
translationRequest.setTargetSystem(CS_URL_2);
|
||||
|
||||
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
|
||||
|
||||
|
@ -295,7 +295,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL)
|
||||
.setCode("12345");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL_3));
|
||||
translationRequest.setTargetSystem(CS_URL_3);
|
||||
|
||||
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
|
||||
|
||||
|
@ -479,7 +479,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
TranslationRequest translationRequest = new TranslationRequest();
|
||||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setCode("12345");
|
||||
translationRequest.setSource(new UriType(VS_URL));
|
||||
translationRequest.setSource(VS_URL);
|
||||
|
||||
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
|
||||
|
||||
|
@ -532,7 +532,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
TranslationRequest translationRequest = new TranslationRequest();
|
||||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setCode("12345");
|
||||
translationRequest.setTarget(new UriType(VS_URL_2));
|
||||
translationRequest.setTarget(VS_URL_2);
|
||||
|
||||
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
|
||||
|
||||
|
@ -588,7 +588,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL_2)
|
||||
.setCode("34567");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL_4));
|
||||
translationRequest.setTargetSystem(CS_URL_4);
|
||||
translationRequest.setReverse(true);
|
||||
|
||||
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
|
||||
|
@ -736,7 +736,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL_3)
|
||||
.setCode("67890");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL));
|
||||
translationRequest.setTargetSystem(CS_URL);
|
||||
translationRequest.setReverse(true);
|
||||
|
||||
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
|
||||
|
@ -771,7 +771,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL_3)
|
||||
.setCode("BOGUS");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL));
|
||||
translationRequest.setTargetSystem(CS_URL);
|
||||
translationRequest.setReverse(true);
|
||||
|
||||
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
|
||||
|
@ -850,7 +850,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL_2)
|
||||
.setCode("34567");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL));
|
||||
translationRequest.setTargetSystem(CS_URL);
|
||||
translationRequest.setReverse(true);
|
||||
|
||||
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
|
||||
|
@ -891,7 +891,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL_2)
|
||||
.setCode("34567");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL_4));
|
||||
translationRequest.setTargetSystem(CS_URL_4);
|
||||
translationRequest.setReverse(true);
|
||||
|
||||
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
|
||||
|
@ -1026,7 +1026,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
TranslationRequest translationRequest = new TranslationRequest();
|
||||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setCode("34567");
|
||||
translationRequest.setSource(new UriType(VS_URL_2));
|
||||
translationRequest.setSource(VS_URL_2);
|
||||
translationRequest.setReverse(true);
|
||||
|
||||
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
|
||||
|
@ -1073,7 +1073,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
TranslationRequest translationRequest = new TranslationRequest();
|
||||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setCode("34567");
|
||||
translationRequest.setTarget(new UriType(VS_URL));
|
||||
translationRequest.setTarget(VS_URL);
|
||||
translationRequest.setReverse(true);
|
||||
|
||||
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
|
||||
|
@ -1122,7 +1122,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem("http://source")
|
||||
.setCode("source1");
|
||||
translationRequest.setTarget(new UriType("http://target"));
|
||||
translationRequest.setTarget("http://target");
|
||||
|
||||
ourLog.info("*** About to translate");
|
||||
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
|
||||
|
@ -1177,7 +1177,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem("http://source")
|
||||
.setCode("source1");
|
||||
translationRequest.setTarget(new UriType("http://target"));
|
||||
translationRequest.setTarget("http://target");
|
||||
|
||||
ourLog.info("*** About to translate");
|
||||
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
|
||||
|
@ -1209,7 +1209,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
.setCode("263204007");
|
||||
TranslationRequest request = new TranslationRequest();
|
||||
request.setCodeableConcept(sourceCode);
|
||||
request.setTargetSystem(new UriType("http://hl7.org/fhir/sid/icd-10-us"));
|
||||
request.setTargetSystem("http://hl7.org/fhir/sid/icd-10-us");
|
||||
TranslateConceptResults outcome = myConceptMapDao.translate(request, mySrd);
|
||||
|
||||
assertEquals("S52.209A", outcome.getResults().get(0).getCode());
|
||||
|
|
|
@ -151,7 +151,10 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test {
|
|||
encoded = encode(oo);
|
||||
ourLog.info(encoded);
|
||||
assertEquals(1, oo.getIssue().size(), encoded);
|
||||
assertEquals("The code provided (http://cs#code99) is not in the value set http://vs, and a code from this value set is required: Unknown code 'http://cs#code99' for in-memory expansion of ValueSet 'http://vs'", oo.getIssueFirstRep().getDiagnostics(), encoded);
|
||||
assertThat(oo.getIssue().get(0).getDiagnostics(),
|
||||
containsString("The code provided (http://cs#code99) is not in the value set"));
|
||||
assertThat(oo.getIssue().get(0).getDiagnostics(),
|
||||
containsString("Unknown code 'http://cs#code99' for in-memory expansion of ValueSet 'http://vs'"));
|
||||
assertEquals(OperationOutcome.IssueSeverity.ERROR, oo.getIssueFirstRep().getSeverity(), encoded);
|
||||
|
||||
}
|
||||
|
@ -182,7 +185,10 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test {
|
|||
encoded = encode(oo);
|
||||
ourLog.info(encoded);
|
||||
assertEquals(1, oo.getIssue().size());
|
||||
assertEquals("The code provided (http://cs#code99) is not in the value set http://vs, and a code from this value set is required: Unknown code 'http://cs#code99' for in-memory expansion of ValueSet 'http://vs'", oo.getIssueFirstRep().getDiagnostics());
|
||||
assertThat(oo.getIssueFirstRep().getDiagnostics(),
|
||||
containsString("The code provided (http://cs#code99) is not in the value set"));
|
||||
assertThat(oo.getIssueFirstRep().getDiagnostics(),
|
||||
containsString("Unknown code 'http://cs#code99' for in-memory expansion of ValueSet 'http://vs'"));
|
||||
assertEquals(OperationOutcome.IssueSeverity.ERROR, oo.getIssueFirstRep().getSeverity());
|
||||
}
|
||||
|
||||
|
@ -216,9 +222,11 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test {
|
|||
encoded = encode(oo);
|
||||
ourLog.info(encoded);
|
||||
assertEquals(2, oo.getIssue().size());
|
||||
assertEquals("CodeSystem is unknown and can't be validated: http://cs for 'http://cs#code99'", oo.getIssue().get(0).getDiagnostics());
|
||||
assertThat(oo.getIssue().get(0).getDiagnostics(),
|
||||
containsString("CodeSystem is unknown and can't be validated: http://cs for 'http://cs#code99'"));
|
||||
assertEquals(OperationOutcome.IssueSeverity.WARNING, oo.getIssue().get(0).getSeverity());
|
||||
assertEquals("The code provided (http://cs#code99) is not in the value set http://vs, and a code from this value set is required: Unknown code 'http://cs#code99' for in-memory expansion of ValueSet 'http://vs'", oo.getIssue().get(1).getDiagnostics());
|
||||
assertThat(oo.getIssue().get(1).getDiagnostics(),
|
||||
containsString("The code provided (http://cs#code99) is not in the value set 'ValueSet[http://vs]'"));
|
||||
assertEquals(OperationOutcome.IssueSeverity.ERROR, oo.getIssue().get(1).getSeverity());
|
||||
}
|
||||
|
||||
|
@ -257,9 +265,8 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test {
|
|||
encoded = encode(oo);
|
||||
ourLog.info(encoded);
|
||||
assertEquals(1, oo.getIssue().size());
|
||||
assertTrue(oo.getIssueFirstRep()
|
||||
.getDiagnostics().contains("The code provided (http://cs#code99) is not in the value set http://vs, and a code from this value set is required: Unknown code 'http://cs#code99' for in-memory expansion of ValueSet 'http://vs'")
|
||||
);
|
||||
assertThat(oo.getIssue().get(0).getDiagnostics(),
|
||||
containsString("The code provided (http://cs#code99) is not in the value set"));
|
||||
assertEquals(OperationOutcome.IssueSeverity.ERROR, oo.getIssueFirstRep().getSeverity());
|
||||
}
|
||||
|
||||
|
@ -354,7 +361,12 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test {
|
|||
encoded = encode(oo);
|
||||
ourLog.info(encoded);
|
||||
assertEquals(1, oo.getIssue().size());
|
||||
assertEquals("The code provided (http://cs#code1) is not in the value set http://vs, and a code from this value set is required: Failed to expand ValueSet 'http://vs' (in-memory). Could not validate code http://cs#code1. Error was: HAPI-0702: Unable to expand ValueSet because CodeSystem could not be found: http://cs", oo.getIssueFirstRep().getDiagnostics());
|
||||
assertThat(oo.getIssue().get(0).getDiagnostics(),
|
||||
containsString("The code provided (http://cs#code1) is not in the value set"));
|
||||
assertThat(oo.getIssue().get(0).getDiagnostics(),
|
||||
containsString("Failed to expand ValueSet 'http://vs' (in-memory). Could not validate code http://cs#code1"));
|
||||
assertThat(oo.getIssue().get(0).getDiagnostics(),
|
||||
containsString("HAPI-0702: Unable to expand ValueSet because CodeSystem could not be found: http://cs"));
|
||||
assertEquals(OperationOutcome.IssueSeverity.ERROR, oo.getIssueFirstRep().getSeverity());
|
||||
|
||||
}
|
||||
|
@ -520,7 +532,8 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test {
|
|||
outcome = (OperationOutcome) e.getOperationOutcome();
|
||||
String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome);
|
||||
ourLog.info("Validation outcome: {}", outcomeStr);
|
||||
assertThat(outcomeStr, containsString("The code provided (http://unitsofmeasure.org#cm) is not in the value set https://bb/ValueSet/BBDemographicAgeUnit, and a code from this value set is required"));
|
||||
assertThat(outcomeStr,
|
||||
containsString("The code provided (http://unitsofmeasure.org#cm) is not in the value set"));
|
||||
}
|
||||
|
||||
// Before, the VS wasn't pre-expanded. Try again with it pre-expanded
|
||||
|
@ -554,7 +567,8 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test {
|
|||
outcome = (OperationOutcome) e.getOperationOutcome();
|
||||
String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome);
|
||||
ourLog.info("Validation outcome: {}", outcomeStr);
|
||||
assertThat(outcomeStr, containsString("The code provided (http://unitsofmeasure.org#cm) is not in the value set https://bb/ValueSet/BBDemographicAgeUnit, and a code from this value set is required"));
|
||||
assertThat(outcomeStr,
|
||||
containsString("The code provided (http://unitsofmeasure.org#cm) is not in the value set"));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1043,7 +1057,8 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test {
|
|||
} catch (PreconditionFailedException e) {
|
||||
outcome = (OperationOutcome) e.getOperationOutcome();
|
||||
ourLog.info("Outcome: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome));
|
||||
assertEquals("None of the codings provided are in the value set 'MessageCategory' (http://example.com/valueset), and a coding from this value set is required) (codes = http://example.com/foo-foo#some-code)", outcome.getIssueFirstRep().getDiagnostics());
|
||||
assertThat(outcome.getIssueFirstRep().getDiagnostics(),
|
||||
containsString("None of the codings provided are in the value set 'MessageCategory'"));
|
||||
assertEquals(OperationOutcome.IssueSeverity.ERROR, outcome.getIssueFirstRep().getSeverity());
|
||||
}
|
||||
}
|
||||
|
@ -1396,7 +1411,10 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test {
|
|||
|
||||
// It would be ok for this to produce 0 issues, or just an information message too
|
||||
assertEquals(1, OperationOutcomeUtil.getIssueCount(myFhirContext, oo));
|
||||
assertEquals("None of the codings provided are in the value set 'IdentifierType' (http://hl7.org/fhir/ValueSet/identifier-type), and a coding should come from this value set unless it has no suitable code (note that the validator cannot judge what is suitable) (codes = http://foo#bar)", OperationOutcomeUtil.getFirstIssueDetails(myFhirContext, oo));
|
||||
assertThat(OperationOutcomeUtil.getFirstIssueDetails(myFhirContext, oo),
|
||||
containsString("None of the codings provided are in the value set 'IdentifierType'"));
|
||||
assertThat(OperationOutcomeUtil.getFirstIssueDetails(myFhirContext, oo),
|
||||
containsString("a coding should come from this value set unless it has no suitable code (note that the validator cannot judge what is suitable) (codes = http://foo#bar)"));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -386,7 +386,8 @@ public class RepositoryValidatingInterceptorR4Test extends BaseJpaR4Test {
|
|||
fail();
|
||||
} catch (PreconditionFailedException e) {
|
||||
OperationOutcome oo = (OperationOutcome) e.getOperationOutcome();
|
||||
assertEquals("Observation.status: minimum required = 1, but only found 0 (from http://hl7.org/fhir/StructureDefinition/Observation)", oo.getIssue().get(0).getDiagnostics());
|
||||
assertThat(oo.getIssue().get(0).getDiagnostics(),
|
||||
containsString("Observation.status: minimum required = 1, but only found 0"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -89,9 +89,9 @@ public class PartitionManagementProviderTest {
|
|||
verify(myPartitionConfigSvc, times(1)).createPartition(any());
|
||||
verifyNoMoreInteractions(myPartitionConfigSvc);
|
||||
|
||||
assertEquals(123, ((IntegerType) response.getParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_ID)).getValue().intValue());
|
||||
assertEquals("PARTITION-123", ((StringType) response.getParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_NAME)).getValue());
|
||||
assertEquals("a description", ((StringType) response.getParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_DESC)).getValue());
|
||||
assertEquals(123, ((IntegerType) response.getParameterValue(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_ID)).getValue().intValue());
|
||||
assertEquals("PARTITION-123", ((StringType) response.getParameterValue(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_NAME)).getValue());
|
||||
assertEquals("a description", ((StringType) response.getParameterValue(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_DESC)).getValue());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -141,9 +141,9 @@ public class PartitionManagementProviderTest {
|
|||
verify(myPartitionConfigSvc, times(1)).getPartitionById(any());
|
||||
verifyNoMoreInteractions(myPartitionConfigSvc);
|
||||
|
||||
assertEquals(123, ((IntegerType) response.getParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_ID)).getValue().intValue());
|
||||
assertEquals("PARTITION-123", ((StringType) response.getParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_NAME)).getValue());
|
||||
assertEquals("a description", ((StringType) response.getParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_DESC)).getValue());
|
||||
assertEquals(123, ((IntegerType) response.getParameterValue(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_ID)).getValue().intValue());
|
||||
assertEquals("PARTITION-123", ((StringType) response.getParameterValue(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_NAME)).getValue());
|
||||
assertEquals("a description", ((StringType) response.getParameterValue(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_DESC)).getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -182,9 +182,9 @@ public class PartitionManagementProviderTest {
|
|||
verify(myPartitionConfigSvc, times(1)).updatePartition(any());
|
||||
verifyNoMoreInteractions(myPartitionConfigSvc);
|
||||
|
||||
assertEquals(123, ((IntegerType) response.getParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_ID)).getValue().intValue());
|
||||
assertEquals("PARTITION-123", ((StringType) response.getParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_NAME)).getValue());
|
||||
assertEquals("a description", ((StringType) response.getParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_DESC)).getValue());
|
||||
assertEquals(123, ((IntegerType) response.getParameterValue(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_ID)).getValue().intValue());
|
||||
assertEquals("PARTITION-123", ((StringType) response.getParameterValue(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_NAME)).getValue());
|
||||
assertEquals("a description", ((StringType) response.getParameterValue(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_DESC)).getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -152,7 +152,7 @@ public class MultitenantBatchOperationR4Test extends BaseMultitenantResourceProv
|
|||
.withParameters(input)
|
||||
.execute();
|
||||
ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(response));
|
||||
StringType jobId = (StringType) response.getParameter(ProviderConstants.OPERATION_REINDEX_RESPONSE_JOB_ID);
|
||||
StringType jobId = (StringType) response.getParameterValue(ProviderConstants.OPERATION_REINDEX_RESPONSE_JOB_ID);
|
||||
|
||||
myBatch2JobHelper.awaitJobCompletion(jobId.getValue());
|
||||
|
||||
|
@ -176,7 +176,7 @@ public class MultitenantBatchOperationR4Test extends BaseMultitenantResourceProv
|
|||
.withParameters(input)
|
||||
.execute();
|
||||
ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(response));
|
||||
jobId = (StringType) response.getParameter(ProviderConstants.OPERATION_REINDEX_RESPONSE_JOB_ID);
|
||||
jobId = (StringType) response.getParameterValue(ProviderConstants.OPERATION_REINDEX_RESPONSE_JOB_ID);
|
||||
|
||||
myBatch2JobHelper.awaitJobCompletion(jobId.getValue());
|
||||
|
||||
|
@ -219,7 +219,7 @@ public class MultitenantBatchOperationR4Test extends BaseMultitenantResourceProv
|
|||
.withParameters(input)
|
||||
.execute();
|
||||
ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(response));
|
||||
StringType jobId = (StringType) response.getParameter(ProviderConstants.OPERATION_REINDEX_RESPONSE_JOB_ID);
|
||||
StringType jobId = (StringType) response.getParameterValue(ProviderConstants.OPERATION_REINDEX_RESPONSE_JOB_ID);
|
||||
|
||||
myBatch2JobHelper.awaitJobCompletion(jobId.getValue());
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ public class RemoteTerminologyServiceResourceProviderR4Test {
|
|||
assertEquals(CODE, myCodeSystemProvider.myLastCode.getCode());
|
||||
assertEquals(DISPLAY, myCodeSystemProvider.myLastDisplay.getValue());
|
||||
assertEquals(CODE_SYSTEM, myCodeSystemProvider.myLastUrl.getValueAsString());
|
||||
assertEquals(SAMPLE_MESSAGE, myCodeSystemProvider.myNextReturnParams.getParameter("message").toString());
|
||||
assertEquals(SAMPLE_MESSAGE, myCodeSystemProvider.myNextReturnParams.getParameterValue("message").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -112,7 +112,7 @@ public class RemoteTerminologyServiceResourceProviderR4Test {
|
|||
assertEquals(IValidationSupport.IssueSeverity.ERROR, outcome.getSeverity());
|
||||
assertEquals(SAMPLE_MESSAGE, outcome.getMessage());
|
||||
|
||||
assertEquals(false, ((BooleanType)myCodeSystemProvider.myNextReturnParams.getParameter("result")).booleanValue());
|
||||
assertEquals(false, ((BooleanType)myCodeSystemProvider.myNextReturnParams.getParameterValue("result")).booleanValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -143,7 +143,7 @@ public class RemoteTerminologyServiceResourceProviderR4Test {
|
|||
assertEquals(CODE, myValueSetProvider.myLastCode.getCode());
|
||||
assertEquals(DISPLAY, myValueSetProvider.myLastDisplay.getValue());
|
||||
assertEquals(VALUE_SET_URL, myValueSetProvider.myLastUrl.getValueAsString());
|
||||
assertEquals(SAMPLE_MESSAGE, myValueSetProvider.myNextReturnParams.getParameter("message").toString());
|
||||
assertEquals(SAMPLE_MESSAGE, myValueSetProvider.myNextReturnParams.getParameterValue("message").toString());
|
||||
}
|
||||
|
||||
private void createNextCodeSystemReturnParameters(boolean theResult, String theDisplay, String theMessage) {
|
||||
|
|
|
@ -118,7 +118,7 @@ public class ResourceProviderQuestionnaireResponseR4Test extends BaseResourcePro
|
|||
myClient.create().resource(qr1).execute();
|
||||
fail();
|
||||
} catch (UnprocessableEntityException e) {
|
||||
assertThat(myFhirContext.newJsonParser().encodeResourceToString(e.getOperationOutcome()), containsString("Answer value must be of type string"));
|
||||
assertThat(myFhirContext.newJsonParser().encodeResourceToString(e.getOperationOutcome()), containsString("Answer value must be of the type string"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,10 @@ package ca.uhn.fhir.jpa.provider.r4;
|
|||
|
||||
import ca.uhn.fhir.jpa.provider.BaseResourceProviderR4Test;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.param.TokenParam;
|
||||
import com.ctc.wstx.shaded.msv_core.util.Uri;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4.model.BooleanType;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
|
@ -24,7 +28,10 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
@ -1958,4 +1965,43 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
|
|||
part = getPartByName(param, "source");
|
||||
assertEquals(CM_URL, ((UriType) part.getValue()).getValueAsString());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* See #4289
|
||||
*/
|
||||
@Test
|
||||
public void testConceptMapWithNonNumericId() {
|
||||
ConceptMap cm = new ConceptMap();
|
||||
cm.setId("cyehr-cm-allergytype-snomed2hl7fhir");
|
||||
cm.setUrl("ttp://ig.ehealth4u.eu/fhir/ConceptMap/cyehr-cm-allergytype-snomed2hl7fhir");
|
||||
cm.setSource(new UriType("http://ig.ehealth4u.eu/fhir/ValueSet/cyehr-vs-ehdsiadverseeventtype"));
|
||||
cm.setTarget(new UriType("http://hl7.org/fhir/ValueSet/allergy-intolerance-type"));
|
||||
ConceptMapGroupComponent group = cm.addGroup();
|
||||
group.setSource("http://snomed.info/sct");
|
||||
group.setTarget("http://hl7.org/fhir/allergy-intolerance-type");
|
||||
group.addElement()
|
||||
.setCode("609328004")
|
||||
.setDisplay("Allergic disposition")
|
||||
.addTarget()
|
||||
.setCode("allergy")
|
||||
.setDisplay("Allergy")
|
||||
.setEquivalence(ConceptMapEquivalence.WIDER);
|
||||
|
||||
myConceptMapDao.update(cm, mySrd);
|
||||
|
||||
Parameters outcome = myClient
|
||||
.operation()
|
||||
.onInstance("ConceptMap/cyehr-cm-allergytype-snomed2hl7fhir")
|
||||
.named("$translate")
|
||||
.withParameter(Parameters.class, "code", new CodeType("609328004"))
|
||||
.andParameter("system", new UriType("http://snomed.info/sct"))
|
||||
.andParameter("target", new UriType("http://hl7.org/fhir/ValueSet/allergy-intolerance-type"))
|
||||
.execute();
|
||||
|
||||
ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -110,8 +110,8 @@ public class ResourceProviderR4RemoteTerminologyTest extends BaseResourceProvide
|
|||
String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
|
||||
ourLog.info(resp);
|
||||
|
||||
assertEquals(true, ((BooleanType)respParam.getParameter("result")).booleanValue());
|
||||
assertEquals(DISPLAY, respParam.getParameter("display").toString());
|
||||
assertEquals(true, ((BooleanType)respParam.getParameterValue("result")).booleanValue());
|
||||
assertEquals(DISPLAY, respParam.getParameterValue("display").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -135,8 +135,8 @@ public class ResourceProviderR4RemoteTerminologyTest extends BaseResourceProvide
|
|||
String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
|
||||
ourLog.info(resp);
|
||||
|
||||
assertEquals(true, ((BooleanType)respParam.getParameter("result")).booleanValue());
|
||||
assertEquals(DISPLAY, respParam.getParameter("display").toString());
|
||||
assertEquals(true, ((BooleanType)respParam.getParameterValue("result")).booleanValue());
|
||||
assertEquals(DISPLAY, respParam.getParameterValue("display").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -159,8 +159,8 @@ public class ResourceProviderR4RemoteTerminologyTest extends BaseResourceProvide
|
|||
String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
|
||||
ourLog.info(resp);
|
||||
|
||||
assertEquals(true, ((BooleanType)respParam.getParameter("result")).booleanValue());
|
||||
assertEquals(DISPLAY_BODY_MASS_INDEX, respParam.getParameter("display").toString());
|
||||
assertEquals(true, ((BooleanType)respParam.getParameterValue("result")).booleanValue());
|
||||
assertEquals(DISPLAY_BODY_MASS_INDEX, respParam.getParameterValue("display").toString());
|
||||
}
|
||||
|
||||
private void createNextCodeSystemReturnParameters(boolean theResult, String theDisplay, String theMessage) {
|
||||
|
|
|
@ -6864,7 +6864,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
ourLog.info(resp);
|
||||
assertEquals(412, response.getStatusLine().getStatusCode());
|
||||
|
||||
assertThat(resp, stringContainsInOrder("Duplicated property name: name"));
|
||||
assertThat(resp, stringContainsInOrder("The JSON property 'name' is a duplicate and will be ignored"));
|
||||
} finally {
|
||||
response.getEntity().getContent().close();
|
||||
response.close();
|
||||
|
|
|
@ -1400,7 +1400,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv
|
|||
.named(ProviderConstants.OPERATION_INVALIDATE_EXPANSION)
|
||||
.withNoParameters(Parameters.class)
|
||||
.execute();
|
||||
assertEquals("ValueSet with URL \"http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2\" precaluclated expansion with 24 concept(s) has been invalidated", outcome.getParameter("message").primitiveValue());
|
||||
assertEquals("ValueSet with URL \"http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2\" precaluclated expansion with 24 concept(s) has been invalidated", outcome.getParameterValue("message").toString());
|
||||
|
||||
assertEquals(TermValueSetPreExpansionStatusEnum.NOT_EXPANDED, runInTransaction(()->myTermValueSetDao.findTermValueSetByUrlAndNullVersion("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2").orElseThrow(()->new IllegalStateException()).getExpansionStatus()));
|
||||
|
||||
|
@ -1410,7 +1410,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv
|
|||
.named(ProviderConstants.OPERATION_INVALIDATE_EXPANSION)
|
||||
.withNoParameters(Parameters.class)
|
||||
.execute();
|
||||
assertEquals("ValueSet with URL \"http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2\" already has status: NOT_EXPANDED", outcome.getParameter("message").primitiveValue());
|
||||
assertEquals("ValueSet with URL \"http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2\" already has status: NOT_EXPANDED", outcome.getParameterValue("message").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.hl7.fhir.r4.model.CodeableConcept;
|
|||
import org.hl7.fhir.r4.model.Coding;
|
||||
import org.hl7.fhir.r4.model.ConceptMap;
|
||||
import org.hl7.fhir.r4.model.Enumerations;
|
||||
import org.hl7.fhir.r4.model.IdType;
|
||||
import org.hl7.fhir.r4.model.StringType;
|
||||
import org.hl7.fhir.r4.model.UriType;
|
||||
import org.hl7.fhir.r4.model.codesystems.HttpVerb;
|
||||
|
@ -83,7 +84,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL)
|
||||
.setCode("12345");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL_3));
|
||||
translationRequest.setTargetSystem(CS_URL_3);
|
||||
|
||||
List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults();
|
||||
assertNotNull(targets);
|
||||
|
@ -137,7 +138,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL)
|
||||
.setCode("12345");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL_2));
|
||||
translationRequest.setTargetSystem(CS_URL_2);
|
||||
|
||||
List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults();
|
||||
assertNotNull(targets);
|
||||
|
@ -179,7 +180,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL)
|
||||
.setCode("BOGUS");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL_3));
|
||||
translationRequest.setTargetSystem(CS_URL_3);
|
||||
|
||||
List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults();
|
||||
assertNotNull(targets);
|
||||
|
@ -211,7 +212,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|||
|
||||
TranslationRequest translationRequest = new TranslationRequest()
|
||||
.addCode(CS_URL, "12345")
|
||||
.setTargetSystem(new UriType(CS_URL_2));
|
||||
.setTargetSystem(CS_URL_2);
|
||||
|
||||
TranslateConceptResults resp = myConceptMappingSvc.translate(translationRequest);
|
||||
assertEquals(1, resp.size());
|
||||
|
@ -306,7 +307,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL)
|
||||
.setCode("12345");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL_2));
|
||||
translationRequest.setTargetSystem(CS_URL_2);
|
||||
|
||||
List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults();
|
||||
assertNotNull(targets);
|
||||
|
@ -354,7 +355,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL)
|
||||
.setCode("12345");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL_3));
|
||||
translationRequest.setTargetSystem(CS_URL_3);
|
||||
|
||||
List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults();
|
||||
assertNotNull(targets);
|
||||
|
@ -590,7 +591,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|||
TranslationRequest translationRequest = new TranslationRequest();
|
||||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setCode("12345");
|
||||
translationRequest.setSource(new UriType(VS_URL));
|
||||
translationRequest.setSource(VS_URL);
|
||||
|
||||
List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults();
|
||||
assertNotNull(targets);
|
||||
|
@ -660,7 +661,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|||
TranslationRequest translationRequest = new TranslationRequest();
|
||||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setCode("12345");
|
||||
translationRequest.setTarget(new UriType(VS_URL_2));
|
||||
translationRequest.setTarget(VS_URL_2);
|
||||
|
||||
List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults();
|
||||
assertNotNull(targets);
|
||||
|
@ -733,7 +734,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL_2)
|
||||
.setCode("34567");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL_4));
|
||||
translationRequest.setTargetSystem(CS_URL_4);
|
||||
translationRequest.setReverse(true);
|
||||
|
||||
TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest);
|
||||
|
@ -775,7 +776,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL_3)
|
||||
.setCode("BOGUS");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL));
|
||||
translationRequest.setTargetSystem(CS_URL);
|
||||
|
||||
TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest);
|
||||
assertNotNull(elements);
|
||||
|
@ -861,7 +862,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL_2)
|
||||
.setCode("34567");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL));
|
||||
translationRequest.setTargetSystem(CS_URL);
|
||||
translationRequest.setReverse(true);
|
||||
|
||||
TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest);
|
||||
|
@ -910,7 +911,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL_2)
|
||||
.setCode("34567");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL_4));
|
||||
translationRequest.setTargetSystem(CS_URL_4);
|
||||
translationRequest.setReverse(true);
|
||||
|
||||
TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest);
|
||||
|
@ -1075,7 +1076,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|||
TranslationRequest translationRequest = new TranslationRequest();
|
||||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setCode("34567");
|
||||
translationRequest.setSource(new UriType(VS_URL_2));
|
||||
translationRequest.setSource(VS_URL_2);
|
||||
translationRequest.setReverse(true);
|
||||
|
||||
TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest);
|
||||
|
@ -1133,7 +1134,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|||
TranslationRequest translationRequest = new TranslationRequest();
|
||||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setCode("34567");
|
||||
translationRequest.setTarget(new UriType(VS_URL));
|
||||
translationRequest.setTarget(VS_URL);
|
||||
translationRequest.setReverse(true);
|
||||
|
||||
TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest);
|
||||
|
@ -1570,7 +1571,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|||
"theConceptMapVersion",
|
||||
"theSourceValueSetUrl",
|
||||
"theTargetValueSetUrl",
|
||||
0L,
|
||||
new IdType("ConceptMap/2"),
|
||||
false
|
||||
);
|
||||
|
||||
|
@ -1582,12 +1583,12 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|||
|
||||
TranslationRequest expected = new TranslationRequest();
|
||||
expected.setCodeableConcept(sourceCodeableConcept);
|
||||
expected.setConceptMapVersion(new StringType(theRequest.getConceptMapVersion()));
|
||||
expected.setUrl(new UriType(theRequest.getConceptMapUrl()));
|
||||
expected.setSource(new UriType(theRequest.getSourceValueSetUrl()));
|
||||
expected.setTarget(new UriType(theRequest.getTargetValueSetUrl()));
|
||||
expected.setTargetSystem(new UriType(theRequest.getTargetSystemUrl()));
|
||||
expected.setResourceId(theRequest.getResourcePid());
|
||||
expected.setConceptMapVersion((theRequest.getConceptMapVersion()));
|
||||
expected.setUrl((theRequest.getConceptMapUrl()));
|
||||
expected.setSource((theRequest.getSourceValueSetUrl()));
|
||||
expected.setTarget((theRequest.getTargetValueSetUrl()));
|
||||
expected.setTargetSystem((theRequest.getTargetSystemUrl()));
|
||||
expected.setResourceId(theRequest.getResourceId());
|
||||
expected.setReverse(theRequest.isReverse());
|
||||
|
||||
ITermConceptMappingSvc mock = mock(TermConceptMappingSvcImpl.class);
|
||||
|
@ -1612,7 +1613,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|||
"theConceptMapVersion",
|
||||
"theSourceValueSetUrl",
|
||||
"theTargetValueSetUrl",
|
||||
0L,
|
||||
new IdType("ConceptMap/A"),
|
||||
true
|
||||
);
|
||||
|
||||
|
@ -1624,12 +1625,12 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|||
|
||||
TranslationRequest expected = new TranslationRequest();
|
||||
expected.setCodeableConcept(sourceCodeableConcept);
|
||||
expected.setConceptMapVersion(new StringType(theRequest.getConceptMapVersion()));
|
||||
expected.setUrl(new UriType(theRequest.getConceptMapUrl()));
|
||||
expected.setSource(new UriType(theRequest.getSourceValueSetUrl()));
|
||||
expected.setTarget(new UriType(theRequest.getTargetValueSetUrl()));
|
||||
expected.setTargetSystem(new UriType(theRequest.getTargetSystemUrl()));
|
||||
expected.setResourceId(theRequest.getResourcePid());
|
||||
expected.setConceptMapVersion((theRequest.getConceptMapVersion()));
|
||||
expected.setUrl((theRequest.getConceptMapUrl()));
|
||||
expected.setSource((theRequest.getSourceValueSetUrl()));
|
||||
expected.setTarget((theRequest.getTargetValueSetUrl()));
|
||||
expected.setTargetSystem((theRequest.getTargetSystemUrl()));
|
||||
expected.setResourceId(theRequest.getResourceId());
|
||||
expected.setReverse(theRequest.isReverse());
|
||||
|
||||
ITermConceptMappingSvc mock = mock(TermConceptMappingSvcImpl.class);
|
||||
|
@ -1643,11 +1644,11 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|||
|
||||
private static void assertSameTranslationRequest(TranslationRequest expected, TranslationRequest actual) {
|
||||
assertTrue(expected.getCodeableConcept().equalsDeep(actual.getCodeableConcept()));
|
||||
assertEquals(expected.getConceptMapVersion().asStringValue(), actual.getConceptMapVersion().asStringValue());
|
||||
assertEquals(expected.getUrl().asStringValue(), actual.getUrl().asStringValue());
|
||||
assertEquals(expected.getSource().asStringValue(), actual.getSource().asStringValue());
|
||||
assertEquals(expected.getTarget().asStringValue(), actual.getTarget().asStringValue());
|
||||
assertEquals(expected.getTargetSystem().asStringValue(), actual.getTargetSystem().asStringValue());
|
||||
assertEquals(expected.getConceptMapVersion(), actual.getConceptMapVersion());
|
||||
assertEquals(expected.getUrl(), actual.getUrl());
|
||||
assertEquals(expected.getSource(), actual.getSource());
|
||||
assertEquals(expected.getTarget(), actual.getTarget());
|
||||
assertEquals(expected.getTargetSystem(), actual.getTargetSystem());
|
||||
assertEquals(expected.getResourceId(), actual.getResourceId());
|
||||
assertEquals(expected.getReverseAsBoolean(), actual.getReverseAsBoolean());
|
||||
}
|
||||
|
|
|
@ -492,8 +492,8 @@ public class TerminologySvcDeltaR4Test extends BaseJpaR4Test {
|
|||
Parameters output = (Parameters) result.toParameters(myFhirContext, null);
|
||||
ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output));
|
||||
|
||||
assertEquals("Description of my life", ((StringType) output.getParameter("name")).getValue());
|
||||
assertEquals("1.2.3", ((StringType) output.getParameter("version")).getValue());
|
||||
assertEquals("Description of my life", ((StringType) output.getParameterValue("name")).getValue());
|
||||
assertEquals("1.2.3", ((StringType) output.getParameterValue("version")).getValue());
|
||||
assertEquals(false, output.getParameterBool("abstract"));
|
||||
|
||||
List<Parameters.ParametersParameterComponent> designations = output.getParameter().stream().filter(t -> t.getName().equals("designation")).collect(Collectors.toList());
|
||||
|
|
|
@ -112,7 +112,7 @@ public class ReindexProviderTest {
|
|||
// Verify
|
||||
|
||||
ourLog.info(myCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(response));
|
||||
StringType jobId = (StringType) response.getParameter(ProviderConstants.OPERATION_REINDEX_RESPONSE_JOB_ID);
|
||||
StringType jobId = (StringType) response.getParameterValue(ProviderConstants.OPERATION_REINDEX_RESPONSE_JOB_ID);
|
||||
assertEquals(TEST_JOB_ID, jobId.getValue());
|
||||
|
||||
verify(myJobCoordinator, times(1)).startInstance(myStartRequestCaptor.capture());
|
||||
|
@ -144,7 +144,7 @@ public class ReindexProviderTest {
|
|||
// Verify
|
||||
|
||||
ourLog.info(myCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(response));
|
||||
StringType jobId = (StringType) response.getParameter(ProviderConstants.OPERATION_REINDEX_RESPONSE_JOB_ID);
|
||||
StringType jobId = (StringType) response.getParameterValue(ProviderConstants.OPERATION_REINDEX_RESPONSE_JOB_ID);
|
||||
assertEquals(TEST_JOB_ID, jobId.getValue());
|
||||
|
||||
verify(myJobCoordinator, times(1)).startInstance(myStartRequestCaptor.capture());
|
||||
|
|
|
@ -22,18 +22,19 @@ package ca.uhn.fhir.jpa.api.model;
|
|||
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4.model.Coding;
|
||||
import org.hl7.fhir.r4.model.StringType;
|
||||
import org.hl7.fhir.r4.model.UriType;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
public class TranslationQuery {
|
||||
private Coding myCoding;
|
||||
private Long myResourceId;
|
||||
private UriType myUrl;
|
||||
private StringType myConceptMapVersion;
|
||||
private UriType mySource;
|
||||
private UriType myTarget;
|
||||
private UriType myTargetSystem;
|
||||
private IIdType myResourceId;
|
||||
private String myUrl;
|
||||
private String myConceptMapVersion;
|
||||
private String mySource;
|
||||
private String myTarget;
|
||||
private String myTargetSystem;
|
||||
|
||||
public TranslationQuery() {
|
||||
super();
|
||||
|
@ -53,71 +54,71 @@ public class TranslationQuery {
|
|||
return myResourceId != null;
|
||||
}
|
||||
|
||||
public Long getResourceId() {
|
||||
public IIdType getResourceId() {
|
||||
return myResourceId;
|
||||
}
|
||||
|
||||
public void setResourceId(Long theResourceId) {
|
||||
public void setResourceId(IIdType theResourceId) {
|
||||
myResourceId = theResourceId;
|
||||
}
|
||||
|
||||
public boolean hasUrl() {
|
||||
return myUrl != null && myUrl.hasValue();
|
||||
return isNotBlank(myUrl);
|
||||
}
|
||||
|
||||
public UriType getUrl() {
|
||||
public String getUrl() {
|
||||
return myUrl;
|
||||
}
|
||||
|
||||
public void setUrl(UriType theUrl) {
|
||||
public void setUrl(String theUrl) {
|
||||
myUrl = theUrl;
|
||||
}
|
||||
|
||||
public boolean hasConceptMapVersion() {
|
||||
return myConceptMapVersion != null && myConceptMapVersion.hasValue();
|
||||
return isNotBlank(myConceptMapVersion);
|
||||
}
|
||||
|
||||
public StringType getConceptMapVersion() {
|
||||
public String getConceptMapVersion() {
|
||||
return myConceptMapVersion;
|
||||
}
|
||||
|
||||
public void setConceptMapVersion(StringType theConceptMapVersion) {
|
||||
public void setConceptMapVersion(String theConceptMapVersion) {
|
||||
myConceptMapVersion = theConceptMapVersion;
|
||||
}
|
||||
|
||||
public boolean hasSource() {
|
||||
return mySource != null && mySource.hasValue();
|
||||
return isNotBlank(mySource);
|
||||
}
|
||||
|
||||
public UriType getSource() {
|
||||
public String getSource() {
|
||||
return mySource;
|
||||
}
|
||||
|
||||
public void setSource(UriType theSource) {
|
||||
public void setSource(String theSource) {
|
||||
mySource = theSource;
|
||||
}
|
||||
|
||||
public boolean hasTarget() {
|
||||
return myTarget != null && myTarget.hasValue();
|
||||
return isNotBlank(myTarget);
|
||||
}
|
||||
|
||||
public UriType getTarget() {
|
||||
public String getTarget() {
|
||||
return myTarget;
|
||||
}
|
||||
|
||||
public void setTarget(UriType theTarget) {
|
||||
public void setTarget(String theTarget) {
|
||||
myTarget = theTarget;
|
||||
}
|
||||
|
||||
public boolean hasTargetSystem() {
|
||||
return myTargetSystem != null && myTargetSystem.hasValue();
|
||||
return isNotBlank(myTargetSystem);
|
||||
}
|
||||
|
||||
public UriType getTargetSystem() {
|
||||
public String getTargetSystem() {
|
||||
return myTargetSystem;
|
||||
}
|
||||
|
||||
public void setTargetSystem(UriType theTargetSystem) {
|
||||
public void setTargetSystem(String theTargetSystem) {
|
||||
myTargetSystem = theTargetSystem;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,25 +23,25 @@ package ca.uhn.fhir.jpa.api.model;
|
|||
import ca.uhn.fhir.context.support.IValidationSupport;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.instance.model.api.IBaseCoding;
|
||||
import org.hl7.fhir.r4.model.BooleanType;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4.model.CodeableConcept;
|
||||
import org.hl7.fhir.r4.model.Coding;
|
||||
import org.hl7.fhir.r4.model.StringType;
|
||||
import org.hl7.fhir.r4.model.UriType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
public class TranslationRequest {
|
||||
private CodeableConcept myCodeableConcept;
|
||||
private Long myResourceId;
|
||||
private BooleanType myReverse;
|
||||
private UriType myUrl;
|
||||
private StringType myConceptMapVersion;
|
||||
private UriType mySource;
|
||||
private UriType myTarget;
|
||||
private UriType myTargetSystem;
|
||||
private IIdType myResourceId;
|
||||
private Boolean myReverse;
|
||||
private String myUrl;
|
||||
private String myConceptMapVersion;
|
||||
private String mySource;
|
||||
private String myTarget;
|
||||
private String myTargetSystem;
|
||||
|
||||
public TranslationRequest() {
|
||||
super();
|
||||
|
@ -72,75 +72,71 @@ public class TranslationRequest {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Long getResourceId() {
|
||||
public IIdType getResourceId() {
|
||||
return myResourceId;
|
||||
}
|
||||
|
||||
public void setResourceId(Long theResourceId) {
|
||||
public void setResourceId(IIdType theResourceId) {
|
||||
myResourceId = theResourceId;
|
||||
}
|
||||
|
||||
public BooleanType getReverse() {
|
||||
public Boolean getReverse() {
|
||||
return myReverse;
|
||||
}
|
||||
|
||||
public void setReverse(BooleanType theReverse) {
|
||||
public void setReverse(Boolean theReverse) {
|
||||
myReverse = theReverse;
|
||||
}
|
||||
|
||||
public void setReverse(boolean theReverse) {
|
||||
myReverse = new BooleanType(theReverse);
|
||||
}
|
||||
|
||||
public boolean getReverseAsBoolean() {
|
||||
if (hasReverse()) {
|
||||
return myReverse.booleanValue();
|
||||
return myReverse;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public UriType getUrl() {
|
||||
public String getUrl() {
|
||||
return myUrl;
|
||||
}
|
||||
|
||||
public TranslationRequest setUrl(UriType theUrl) {
|
||||
public TranslationRequest setUrl(String theUrl) {
|
||||
myUrl = theUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public StringType getConceptMapVersion() {
|
||||
public String getConceptMapVersion() {
|
||||
return myConceptMapVersion;
|
||||
}
|
||||
|
||||
public TranslationRequest setConceptMapVersion(StringType theConceptMapVersion) {
|
||||
public TranslationRequest setConceptMapVersion(String theConceptMapVersion) {
|
||||
myConceptMapVersion = theConceptMapVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriType getSource() {
|
||||
public String getSource() {
|
||||
return mySource;
|
||||
}
|
||||
|
||||
public TranslationRequest setSource(UriType theSource) {
|
||||
public TranslationRequest setSource(String theSource) {
|
||||
mySource = theSource;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriType getTarget() {
|
||||
public String getTarget() {
|
||||
return myTarget;
|
||||
}
|
||||
|
||||
public TranslationRequest setTarget(UriType theTarget) {
|
||||
public TranslationRequest setTarget(String theTarget) {
|
||||
myTarget = theTarget;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriType getTargetSystem() {
|
||||
public String getTargetSystem() {
|
||||
return myTargetSystem;
|
||||
}
|
||||
|
||||
public TranslationRequest setTargetSystem(UriType theTargetSystem) {
|
||||
public TranslationRequest setTargetSystem(String theTargetSystem) {
|
||||
myTargetSystem = theTargetSystem;
|
||||
return this;
|
||||
}
|
||||
|
@ -193,33 +189,33 @@ public class TranslationRequest {
|
|||
}
|
||||
|
||||
public boolean hasUrl() {
|
||||
return myUrl != null && myUrl.hasValue();
|
||||
return isNotBlank(myUrl);
|
||||
}
|
||||
|
||||
public boolean hasConceptMapVersion() {
|
||||
return myConceptMapVersion != null && myConceptMapVersion.hasValue();
|
||||
return isNotBlank(myConceptMapVersion);
|
||||
}
|
||||
|
||||
public boolean hasSource() {
|
||||
return mySource != null && mySource.hasValue();
|
||||
return isNotBlank(mySource);
|
||||
}
|
||||
|
||||
public boolean hasTarget() {
|
||||
return myTarget != null && myTarget.hasValue();
|
||||
return isNotBlank(myTarget);
|
||||
}
|
||||
|
||||
public boolean hasTargetSystem() {
|
||||
return myTargetSystem != null && myTargetSystem.hasValue();
|
||||
return isNotBlank(myTargetSystem);
|
||||
}
|
||||
|
||||
public IValidationSupport.TranslateCodeRequest asTranslateCodeRequest() {
|
||||
return new IValidationSupport.TranslateCodeRequest(
|
||||
Collections.unmodifiableList(this.getCodeableConcept().getCoding()),
|
||||
this.getTargetSystem() != null ? this.getTargetSystem().asStringValue() : null,
|
||||
this.getUrl() != null ? this.getUrl().asStringValue() : null,
|
||||
this.getConceptMapVersion() != null ? this.getConceptMapVersion().asStringValue() : null,
|
||||
this.getSource() != null ? this.getSource().asStringValue() : null,
|
||||
this.getTarget() != null ? this.getTarget().asStringValue() : null,
|
||||
this.getTargetSystem(),
|
||||
this.getUrl(),
|
||||
this.getConceptMapVersion(),
|
||||
this.getSource(),
|
||||
this.getTarget(),
|
||||
this.getResourceId(),
|
||||
this.getReverseAsBoolean()
|
||||
);
|
||||
|
@ -237,12 +233,12 @@ public class TranslationRequest {
|
|||
|
||||
TranslationRequest translationRequest = new TranslationRequest();
|
||||
translationRequest.setCodeableConcept(sourceCodeableConcept);
|
||||
translationRequest.setConceptMapVersion(new StringType(theRequest.getConceptMapVersion()));
|
||||
translationRequest.setUrl(new UriType(theRequest.getConceptMapUrl()));
|
||||
translationRequest.setSource(new UriType(theRequest.getSourceValueSetUrl()));
|
||||
translationRequest.setTarget(new UriType(theRequest.getTargetValueSetUrl()));
|
||||
translationRequest.setTargetSystem(new UriType(theRequest.getTargetSystemUrl()));
|
||||
translationRequest.setResourceId(theRequest.getResourcePid());
|
||||
translationRequest.setConceptMapVersion(theRequest.getConceptMapVersion());
|
||||
translationRequest.setUrl(theRequest.getConceptMapUrl());
|
||||
translationRequest.setSource(theRequest.getSourceValueSetUrl());
|
||||
translationRequest.setTarget(theRequest.getTargetValueSetUrl());
|
||||
translationRequest.setTargetSystem(theRequest.getTargetSystemUrl());
|
||||
translationRequest.setResourceId(theRequest.getResourceId());
|
||||
translationRequest.setReverse(theRequest.isReverse());
|
||||
return translationRequest;
|
||||
|
||||
|
|
|
@ -11,13 +11,13 @@ public class BatchHelperR4 {
|
|||
|
||||
@Nonnull
|
||||
public static Long jobIdFromParameters(Parameters response) {
|
||||
DecimalType jobIdDecimal = (DecimalType) response.getParameter(ProviderConstants.OPERATION_BATCH_RESPONSE_JOB_ID);
|
||||
DecimalType jobIdDecimal = (DecimalType) response.getParameterValue(ProviderConstants.OPERATION_BATCH_RESPONSE_JOB_ID);
|
||||
return jobIdDecimal.getValue().longValue();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static String jobIdFromBatch2Parameters(Parameters response) {
|
||||
StringType jobIdString = (StringType) response.getParameter(ProviderConstants.OPERATION_BATCH_RESPONSE_JOB_ID);
|
||||
StringType jobIdString = (StringType) response.getParameterValue(ProviderConstants.OPERATION_BATCH_RESPONSE_JOB_ID);
|
||||
return jobIdString.getValue();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.fhir.ucum.UcumService;
|
|||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.TerminologyServiceException;
|
||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.context.IWorkerContextManager;
|
||||
import org.hl7.fhir.r5.formats.IParser;
|
||||
import org.hl7.fhir.r5.formats.ParserType;
|
||||
import org.hl7.fhir.r5.model.CanonicalResource;
|
||||
|
@ -73,16 +74,6 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext
|
|||
setValidationMessageLanguage(getLocale());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StructureDefinition> allStructures() {
|
||||
return myValidationSupport.fetchAllStructureDefinitions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StructureDefinition> getStructures() {
|
||||
return allStructures();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeSystem fetchCodeSystem(String theSystem) {
|
||||
if (myValidationSupport == null) {
|
||||
|
@ -101,25 +92,6 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConceptMap> findMapsForSource(String theUrl) {
|
||||
throw new UnsupportedOperationException(Msg.code(201));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAbbreviation(String theName) {
|
||||
throw new UnsupportedOperationException(Msg.code(202));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IParser getParser(ParserType theType) {
|
||||
throw new UnsupportedOperationException(Msg.code(203));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IParser getParser(String theType) {
|
||||
throw new UnsupportedOperationException(Msg.code(204));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getResourceNames() {
|
||||
|
@ -131,26 +103,12 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IParser newJsonParser() {
|
||||
throw new UnsupportedOperationException(Msg.code(205));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IResourceValidator newValidator() {
|
||||
throw new UnsupportedOperationException(Msg.code(206));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IParser newXmlParser() {
|
||||
throw new UnsupportedOperationException(Msg.code(207));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String oid2Uri(String theCode) {
|
||||
throw new UnsupportedOperationException(Msg.code(208));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, NamingSystem> getNSUrlMap() {
|
||||
throw new UnsupportedOperationException(Msg.code(2107));
|
||||
|
@ -245,21 +203,6 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext
|
|||
return validateCode(theOptions, null, null, code, null, vs);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CoverageIgnore
|
||||
public List<CanonicalResource> allConformanceResources() {
|
||||
throw new UnsupportedOperationException(Msg.code(210));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateSnapshot(StructureDefinition p) throws FHIRException {
|
||||
myValidationSupport.generateSnapshot(new ValidationSupportContext(myValidationSupport), p, "", "", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateSnapshot(StructureDefinition mr, boolean ifLogical) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Parameters getExpansionParameters() {
|
||||
|
@ -271,12 +214,6 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext
|
|||
myExpansionProfile = theExpParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
@CoverageIgnore
|
||||
public boolean hasCache() {
|
||||
throw new UnsupportedOperationException(Msg.code(211));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueSetExpander.ValueSetExpansionOutcome expandVS(ValueSet theSource, boolean theCacheOk, boolean theHierarchical) {
|
||||
throw new UnsupportedOperationException(Msg.code(2128));
|
||||
|
@ -316,10 +253,6 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext
|
|||
return myCtx.getVersion().getVersion().getFhirVersionString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSpecUrl() {
|
||||
throw new UnsupportedOperationException(Msg.code(215));
|
||||
}
|
||||
|
||||
@Override
|
||||
public UcumService getUcumService() {
|
||||
|
@ -346,40 +279,13 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext
|
|||
throw new UnsupportedOperationException(Msg.code(219));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StructureMap> listTransforms() {
|
||||
throw new UnsupportedOperationException(Msg.code(220));
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureMap getTransform(String url) {
|
||||
throw new UnsupportedOperationException(Msg.code(221));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverrideVersionNs() {
|
||||
return myOverrideVersionNs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOverrideVersionNs(String value) {
|
||||
myOverrideVersionNs = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureDefinition fetchTypeDefinition(String typeName) {
|
||||
return fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/" + typeName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureDefinition fetchRawProfile(String url) {
|
||||
throw new UnsupportedOperationException(Msg.code(222));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTypeNames() {
|
||||
throw new UnsupportedOperationException(Msg.code(223));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends org.hl7.fhir.r5.model.Resource> T fetchResource(Class<T> theClass, String theUri) {
|
||||
|
@ -441,10 +347,6 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext
|
|||
return myCtx.getResourceTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCanonicalResourceNames() {
|
||||
throw new UnsupportedOperationException(Msg.code(2113));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueSetExpander.ValueSetExpansionOutcome expandVS(ElementDefinitionBindingComponent theBinding, boolean theCacheOk, boolean theHierarchical) throws FHIRException {
|
||||
|
@ -452,10 +354,6 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getLinkForUrl(String corePath, String url) {
|
||||
throw new UnsupportedOperationException(Msg.code(231));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getBinaryKeysAsSet() {
|
||||
|
@ -518,16 +416,10 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext
|
|||
}
|
||||
|
||||
@Override
|
||||
public IPackageLoadingTracker getPackageTracker() {
|
||||
public IWorkerContextManager.IPackageLoadingTracker getPackageTracker() {
|
||||
throw new UnsupportedOperationException(Msg.code(2112));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWorkerContext setPackageTracker(
|
||||
IPackageLoadingTracker packageTracker) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackageVersion getPackageForUrl(String s) {
|
||||
return null;
|
||||
|
@ -541,4 +433,18 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext
|
|||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <T extends Resource> List<T> fetchResourcesByType(Class<T> theClass) {
|
||||
if (theClass.equals(StructureDefinition.class)) {
|
||||
return myValidationSupport.fetchAllStructureDefinitions();
|
||||
}
|
||||
|
||||
throw new UnsupportedOperationException(Msg.code(2113) + "Can't fetch all resources of type: " + theClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWorkerContext setPackageTracker(IWorkerContextManager.IPackageLoadingTracker theIPackageLoadingTracker) {
|
||||
throw new UnsupportedOperationException(Msg.code(220));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package org.hl7.fhir.common.hapi.validation.support;
|
||||
|
||||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.support.ConceptValidationOptions;
|
||||
import ca.uhn.fhir.context.support.IValidationSupport;
|
||||
import ca.uhn.fhir.context.support.ValidationSupportContext;
|
||||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.util.ClasspathUtil;
|
||||
import ca.uhn.hapi.converters.canonical.VersionCanonicalizer;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
|
@ -15,7 +16,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.apache.commons.lang3.Validate;
|
||||
import org.fhir.ucum.UcumEssenceService;
|
||||
import org.fhir.ucum.UcumException;
|
||||
import org.hl7.fhir.common.hapi.validation.validator.VersionSpecificWorkerContextWrapper;
|
||||
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40;
|
||||
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40;
|
||||
|
@ -37,7 +37,6 @@ import java.util.Optional;
|
|||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
import static org.hl7.fhir.common.hapi.validation.support.SnapshotGeneratingValidationSupport.newVersionTypeConverter;
|
||||
|
||||
/**
|
||||
* This {@link IValidationSupport validation support module} can be used to validate codes against common
|
||||
|
@ -62,11 +61,11 @@ public class CommonCodeSystemsTerminologyService implements IValidationSupport {
|
|||
private static final String USPS_CODESYSTEM_URL = "https://www.usps.com/";
|
||||
private static final String USPS_VALUESET_URL = "http://hl7.org/fhir/us/core/ValueSet/us-core-usps-state";
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(CommonCodeSystemsTerminologyService.class);
|
||||
private static Map<String, String> USPS_CODES = Collections.unmodifiableMap(buildUspsCodes());
|
||||
private static Map<String, String> ISO_4217_CODES = Collections.unmodifiableMap(buildIso4217Codes());
|
||||
private static Map<String, String> ISO_3166_CODES = Collections.unmodifiableMap(buildIso3166Codes());
|
||||
private static final Map<String, String> USPS_CODES = Collections.unmodifiableMap(buildUspsCodes());
|
||||
private static final Map<String, String> ISO_4217_CODES = Collections.unmodifiableMap(buildIso4217Codes());
|
||||
private static final Map<String, String> ISO_3166_CODES = Collections.unmodifiableMap(buildIso3166Codes());
|
||||
private final FhirContext myFhirContext;
|
||||
private final VersionSpecificWorkerContextWrapper.IVersionTypeConverter myVersionConverter;
|
||||
private final VersionCanonicalizer myVersionCanonicalizer;
|
||||
private volatile org.hl7.fhir.r5.model.ValueSet myLanguagesVs;
|
||||
private volatile Map<String, String> myLanguagesLanugageMap;
|
||||
private volatile Map<String, String> myLanguagesRegionMap;
|
||||
|
@ -78,7 +77,7 @@ public class CommonCodeSystemsTerminologyService implements IValidationSupport {
|
|||
Validate.notNull(theFhirContext);
|
||||
|
||||
myFhirContext = theFhirContext;
|
||||
myVersionConverter = newVersionTypeConverter(myFhirContext.getVersion().getVersion());
|
||||
myVersionCanonicalizer = new VersionCanonicalizer(theFhirContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -117,7 +116,7 @@ public class CommonCodeSystemsTerminologyService implements IValidationSupport {
|
|||
IBaseResource languagesVs = myLanguagesVs;
|
||||
if (languagesVs == null) {
|
||||
languagesVs = theValidationSupportContext.getRootValidationSupport().fetchValueSet("http://hl7.org/fhir/ValueSet/languages");
|
||||
myLanguagesVs = (org.hl7.fhir.r5.model.ValueSet) myVersionConverter.toCanonical(languagesVs);
|
||||
myLanguagesVs = myVersionCanonicalizer.valueSetToValidatorCanonical(languagesVs);
|
||||
}
|
||||
Optional<org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent> match = myLanguagesVs
|
||||
.getCompose()
|
||||
|
@ -288,12 +287,14 @@ public class CommonCodeSystemsTerminologyService implements IValidationSupport {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private LookupCodeResult buildLookupResultForLanguageAndRegion(@Nonnull String theOriginalCode, @Nonnull String theLanguage, @Nonnull String theRegion) {
|
||||
LookupCodeResult lookupCodeResult = buildNotFoundLookupCodeResult(theOriginalCode);
|
||||
lookupCodeResult.setCodeDisplay(theLanguage + " " + theRegion);
|
||||
lookupCodeResult.setFound(true);
|
||||
return lookupCodeResult;
|
||||
}
|
||||
|
||||
private LookupCodeResult buildLookupResultForLanguage(@Nonnull String theOriginalCode, @Nonnull String theLanguage) {
|
||||
LookupCodeResult lookupCodeResult = buildNotFoundLookupCodeResult(theOriginalCode);
|
||||
lookupCodeResult.setCodeDisplay(theLanguage);
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
package org.hl7.fhir.common.hapi.validation.support;
|
||||
|
||||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.context.support.IValidationSupport;
|
||||
import ca.uhn.fhir.context.support.ValidationSupportContext;
|
||||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
|
||||
import ca.uhn.hapi.converters.canonical.VersionCanonicalizer;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.common.hapi.validation.validator.ProfileKnowledgeWorkerR5;
|
||||
import org.hl7.fhir.common.hapi.validation.validator.VersionSpecificWorkerContextWrapper;
|
||||
import org.hl7.fhir.common.hapi.validation.validator.VersionTypeConverterDstu3;
|
||||
import org.hl7.fhir.common.hapi.validation.validator.VersionTypeConverterR4;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.r5.conformance.ProfileUtilities;
|
||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
|
@ -20,7 +19,6 @@ import org.hl7.fhir.utilities.validation.ValidationMessage;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
|
@ -38,6 +36,7 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
|
|||
public class SnapshotGeneratingValidationSupport implements IValidationSupport {
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(SnapshotGeneratingValidationSupport.class);
|
||||
private final FhirContext myCtx;
|
||||
private final VersionCanonicalizer myVersionCanonicalizer;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -45,8 +44,10 @@ public class SnapshotGeneratingValidationSupport implements IValidationSupport {
|
|||
public SnapshotGeneratingValidationSupport(FhirContext theCtx) {
|
||||
Validate.notNull(theCtx);
|
||||
myCtx = theCtx;
|
||||
myVersionCanonicalizer = new VersionCanonicalizer(theCtx);
|
||||
}
|
||||
|
||||
@SuppressWarnings("EnumSwitchStatementWhichMissesCases")
|
||||
@Override
|
||||
public IBaseResource generateSnapshot(ValidationSupportContext theValidationSupportContext, IBaseResource theInput, String theUrl, String theWebUrl, String theProfileName) {
|
||||
|
||||
|
@ -55,10 +56,7 @@ public class SnapshotGeneratingValidationSupport implements IValidationSupport {
|
|||
FhirVersionEnum version = theInput.getStructureFhirVersionEnum();
|
||||
assert version == myCtx.getVersion().getVersion();
|
||||
|
||||
VersionSpecificWorkerContextWrapper.IVersionTypeConverter converter = newVersionTypeConverter(version);
|
||||
Validate.notNull(converter, "Can not generate snapshot for version: %s", version);
|
||||
|
||||
org.hl7.fhir.r5.model.StructureDefinition inputCanonical = (org.hl7.fhir.r5.model.StructureDefinition) converter.toCanonical(theInput);
|
||||
org.hl7.fhir.r5.model.StructureDefinition inputCanonical = myVersionCanonicalizer.structureDefinitionToCanonical(theInput);
|
||||
|
||||
inputUrl = inputCanonical.getUrl();
|
||||
if (theValidationSupportContext.getCurrentlyGeneratingSnapshots().contains(inputUrl)) {
|
||||
|
@ -77,33 +75,33 @@ public class SnapshotGeneratingValidationSupport implements IValidationSupport {
|
|||
throw new PreconditionFailedException(Msg.code(705) + "Unknown base definition: " + baseDefinition);
|
||||
}
|
||||
|
||||
org.hl7.fhir.r5.model.StructureDefinition baseCanonical = (org.hl7.fhir.r5.model.StructureDefinition) converter.toCanonical(base);
|
||||
org.hl7.fhir.r5.model.StructureDefinition baseCanonical = myVersionCanonicalizer.structureDefinitionToCanonical(base);
|
||||
|
||||
if (baseCanonical.getSnapshot().getElement().isEmpty()) {
|
||||
// If the base definition also doesn't have a snapshot, generate that first
|
||||
theValidationSupportContext.getRootValidationSupport().generateSnapshot(theValidationSupportContext, base, null, null, null);
|
||||
baseCanonical = (org.hl7.fhir.r5.model.StructureDefinition) converter.toCanonical(base);
|
||||
baseCanonical = myVersionCanonicalizer.structureDefinitionToCanonical(base);
|
||||
}
|
||||
|
||||
ArrayList<ValidationMessage> messages = new ArrayList<>();
|
||||
org.hl7.fhir.r5.conformance.ProfileUtilities.ProfileKnowledgeProvider profileKnowledgeProvider = new ProfileKnowledgeWorkerR5(myCtx);
|
||||
IWorkerContext context = new VersionSpecificWorkerContextWrapper(theValidationSupportContext, converter);
|
||||
IWorkerContext context = new VersionSpecificWorkerContextWrapper(theValidationSupportContext, myVersionCanonicalizer);
|
||||
ProfileUtilities profileUtilities = new ProfileUtilities(context, messages, profileKnowledgeProvider);
|
||||
profileUtilities.generateSnapshot(baseCanonical, inputCanonical, theUrl, theWebUrl, theProfileName);
|
||||
|
||||
switch (version) {
|
||||
case DSTU3:
|
||||
org.hl7.fhir.dstu3.model.StructureDefinition generatedDstu3 = (org.hl7.fhir.dstu3.model.StructureDefinition) converter.fromCanonical(inputCanonical);
|
||||
org.hl7.fhir.dstu3.model.StructureDefinition generatedDstu3 = (org.hl7.fhir.dstu3.model.StructureDefinition) myVersionCanonicalizer.structureDefinitionFromCanonical(inputCanonical);
|
||||
((org.hl7.fhir.dstu3.model.StructureDefinition) theInput).getSnapshot().getElement().clear();
|
||||
((org.hl7.fhir.dstu3.model.StructureDefinition) theInput).getSnapshot().getElement().addAll(generatedDstu3.getSnapshot().getElement());
|
||||
break;
|
||||
case R4:
|
||||
org.hl7.fhir.r4.model.StructureDefinition generatedR4 = (org.hl7.fhir.r4.model.StructureDefinition) converter.fromCanonical(inputCanonical);
|
||||
org.hl7.fhir.r4.model.StructureDefinition generatedR4 = (org.hl7.fhir.r4.model.StructureDefinition) myVersionCanonicalizer.structureDefinitionFromCanonical(inputCanonical);
|
||||
((org.hl7.fhir.r4.model.StructureDefinition) theInput).getSnapshot().getElement().clear();
|
||||
((org.hl7.fhir.r4.model.StructureDefinition) theInput).getSnapshot().getElement().addAll(generatedR4.getSnapshot().getElement());
|
||||
break;
|
||||
case R5:
|
||||
org.hl7.fhir.r5.model.StructureDefinition generatedR5 = (org.hl7.fhir.r5.model.StructureDefinition) converter.fromCanonical(inputCanonical);
|
||||
org.hl7.fhir.r5.model.StructureDefinition generatedR5 = (org.hl7.fhir.r5.model.StructureDefinition) myVersionCanonicalizer.structureDefinitionFromCanonical(inputCanonical);
|
||||
((org.hl7.fhir.r5.model.StructureDefinition) theInput).getSnapshot().getElement().clear();
|
||||
((org.hl7.fhir.r5.model.StructureDefinition) theInput).getSnapshot().getElement().addAll(generatedR5.getSnapshot().getElement());
|
||||
break;
|
||||
|
@ -132,27 +130,4 @@ public class SnapshotGeneratingValidationSupport implements IValidationSupport {
|
|||
return myCtx;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static VersionSpecificWorkerContextWrapper.IVersionTypeConverter newVersionTypeConverter(FhirVersionEnum version) {
|
||||
VersionSpecificWorkerContextWrapper.IVersionTypeConverter converter;
|
||||
switch (version) {
|
||||
case DSTU3:
|
||||
converter = new VersionTypeConverterDstu3();
|
||||
break;
|
||||
case R4:
|
||||
converter = new VersionTypeConverterR4();
|
||||
break;
|
||||
case R5:
|
||||
converter = VersionSpecificWorkerContextWrapper.IDENTITY_VERSION_TYPE_CONVERTER;
|
||||
break;
|
||||
case DSTU2:
|
||||
case DSTU2_HL7ORG:
|
||||
case DSTU2_1:
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return converter;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,14 @@ public class ProfileKnowledgeWorkerR5 implements org.hl7.fhir.r5.conformance.Pro
|
|||
return (def instanceof RuntimePrimitiveDatatypeDefinition) || (def instanceof RuntimeCompositeDatatypeDefinition);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isPrimitiveType(String typeSimple) {
|
||||
BaseRuntimeElementDefinition<?> def = myCtx.getElementDefinition(typeSimple);
|
||||
Validate.notNull(typeSimple);
|
||||
return (def instanceof RuntimePrimitiveDatatypeDefinition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResource(String typeSimple) {
|
||||
BaseRuntimeElementDefinition<?> def = myCtx.getElementDefinition(typeSimple);
|
||||
Validate.notNull(typeSimple);
|
||||
|
|
|
@ -10,7 +10,6 @@ import com.google.gson.GsonBuilder;
|
|||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.apache.commons.codec.Charsets;
|
||||
import org.apache.commons.io.input.ReaderInputStream;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
|
@ -32,6 +31,7 @@ import org.w3c.dom.NodeList;
|
|||
|
||||
import java.io.InputStream;
|
||||
import java.io.StringReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
@ -137,9 +137,9 @@ class ValidatorWrapper {
|
|||
|
||||
List<ValidationMessage> messages = new ArrayList<>();
|
||||
|
||||
List<StructureDefinition> profileUrls = new ArrayList<>();
|
||||
for (String next : theValidationContext.getOptions().getProfiles()) {
|
||||
fetchAndAddProfile(theWorkerContext, profileUrls, next);
|
||||
List<StructureDefinition> profiles = new ArrayList<>();
|
||||
for (String nextProfileUrl : theValidationContext.getOptions().getProfiles()) {
|
||||
fetchAndAddProfile(theWorkerContext, profiles, nextProfileUrl, messages);
|
||||
}
|
||||
|
||||
String input = theValidationContext.getResourceAsString();
|
||||
|
@ -158,16 +158,16 @@ class ValidatorWrapper {
|
|||
}
|
||||
|
||||
// Determine if meta/profiles are present...
|
||||
ArrayList<String> profiles = determineIfProfilesSpecified(document);
|
||||
for (String nextProfile : profiles) {
|
||||
fetchAndAddProfile(theWorkerContext, profileUrls, nextProfile);
|
||||
ArrayList<String> profileUrls = determineIfProfilesSpecified(document);
|
||||
for (String nextProfileUrl : profileUrls) {
|
||||
fetchAndAddProfile(theWorkerContext, profiles, nextProfileUrl, messages);
|
||||
}
|
||||
|
||||
String resourceAsString = theValidationContext.getResourceAsString();
|
||||
InputStream inputStream = new ReaderInputStream(new StringReader(resourceAsString), Charsets.UTF_8);
|
||||
InputStream inputStream = new ReaderInputStream(new StringReader(resourceAsString), StandardCharsets.UTF_8);
|
||||
|
||||
Manager.FhirFormat format = Manager.FhirFormat.XML;
|
||||
v.validate(null, messages, inputStream, format, profileUrls);
|
||||
v.validate(null, messages, inputStream, format, profiles);
|
||||
|
||||
} else if (encoding == EncodingEnum.JSON) {
|
||||
|
||||
|
@ -178,19 +178,19 @@ class ValidatorWrapper {
|
|||
if (meta != null) {
|
||||
JsonElement profileElement = meta.get("profile");
|
||||
if (profileElement != null && profileElement.isJsonArray()) {
|
||||
JsonArray profiles = profileElement.getAsJsonArray();
|
||||
for (JsonElement element : profiles) {
|
||||
String nextProfile = element.getAsString();
|
||||
fetchAndAddProfile(theWorkerContext, profileUrls, nextProfile);
|
||||
JsonArray profilesArray = profileElement.getAsJsonArray();
|
||||
for (JsonElement element : profilesArray) {
|
||||
String nextProfileUrl = element.getAsString();
|
||||
fetchAndAddProfile(theWorkerContext, profiles, nextProfileUrl, messages);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String resourceAsString = theValidationContext.getResourceAsString();
|
||||
InputStream inputStream = new ReaderInputStream(new StringReader(resourceAsString), Charsets.UTF_8);
|
||||
InputStream inputStream = new ReaderInputStream(new StringReader(resourceAsString), StandardCharsets.UTF_8);
|
||||
|
||||
Manager.FhirFormat format = Manager.FhirFormat.JSON;
|
||||
v.validate(null, messages, inputStream, format, profileUrls);
|
||||
v.validate(null, messages, inputStream, format, profiles);
|
||||
|
||||
} else {
|
||||
throw new IllegalArgumentException(Msg.code(649) + "Unknown encoding: " + encoding);
|
||||
|
@ -211,13 +211,12 @@ class ValidatorWrapper {
|
|||
return messages;
|
||||
}
|
||||
|
||||
private void fetchAndAddProfile(IWorkerContext theWorkerContext, List<StructureDefinition> theProfileStructureDefinitions, String theUrl) throws org.hl7.fhir.exceptions.FHIRException {
|
||||
private void fetchAndAddProfile(IWorkerContext theWorkerContext, List<StructureDefinition> theProfileStructureDefinitions, String theUrl, List<ValidationMessage> theMessages) {
|
||||
try {
|
||||
|
||||
// NOTE: We expect the following call to generate a snapshot if needed
|
||||
StructureDefinition structureDefinition = theWorkerContext.fetchRawProfile(theUrl);
|
||||
|
||||
theProfileStructureDefinitions.add(structureDefinition);
|
||||
StructureDefinition structureDefinition = theWorkerContext.fetchResource(StructureDefinition.class, theUrl);
|
||||
if (structureDefinition != null) {
|
||||
theProfileStructureDefinitions.add(structureDefinition);
|
||||
}
|
||||
} catch (FHIRException e) {
|
||||
ourLog.debug("Failed to load profile: {}", theUrl);
|
||||
}
|
||||
|
|
|
@ -1,28 +1,24 @@
|
|||
package org.hl7.fhir.common.hapi.validation.validator;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.context.support.ConceptValidationOptions;
|
||||
import ca.uhn.fhir.context.support.IValidationSupport;
|
||||
import ca.uhn.fhir.context.support.ValidationSupportContext;
|
||||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
|
||||
import ca.uhn.fhir.sl.cache.CacheFactory;
|
||||
import ca.uhn.fhir.sl.cache.LoadingCache;
|
||||
import ca.uhn.fhir.system.HapiSystemProperties;
|
||||
import ca.uhn.hapi.converters.canonical.VersionCanonicalizer;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import org.fhir.ucum.UcumService;
|
||||
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.TerminologyServiceException;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.formats.IParser;
|
||||
import org.hl7.fhir.r5.formats.ParserType;
|
||||
import org.hl7.fhir.r5.context.IWorkerContextManager;
|
||||
import org.hl7.fhir.r5.model.CanonicalResource;
|
||||
import org.hl7.fhir.r5.model.CodeSystem;
|
||||
import org.hl7.fhir.r5.model.Coding;
|
||||
|
@ -55,67 +51,55 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
|
|||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWorkerContext {
|
||||
public static final IVersionTypeConverter IDENTITY_VERSION_TYPE_CONVERTER = new VersionTypeConverterR5();
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(VersionSpecificWorkerContextWrapper.class);
|
||||
private static final FhirContext ourR5Context = FhirContext.forR5();
|
||||
private final ValidationSupportContext myValidationSupportContext;
|
||||
private final IVersionTypeConverter myModelConverter;
|
||||
private final VersionCanonicalizer myVersionCanonicalizer;
|
||||
private final LoadingCache<ResourceKey, IBaseResource> myFetchResourceCache;
|
||||
private volatile List<StructureDefinition> myAllStructures;
|
||||
private org.hl7.fhir.r5.model.Parameters myExpansionProfile;
|
||||
|
||||
public VersionSpecificWorkerContextWrapper(ValidationSupportContext theValidationSupportContext, IVersionTypeConverter theModelConverter) {
|
||||
public VersionSpecificWorkerContextWrapper(ValidationSupportContext theValidationSupportContext, VersionCanonicalizer theVersionCanonicalizer) {
|
||||
myValidationSupportContext = theValidationSupportContext;
|
||||
myModelConverter = theModelConverter;
|
||||
myVersionCanonicalizer = theVersionCanonicalizer;
|
||||
|
||||
long timeoutMillis = HapiSystemProperties.getTestValidationResourceCachesMs();
|
||||
|
||||
myFetchResourceCache = CacheFactory.build(timeoutMillis, 10000, key -> {
|
||||
|
||||
String fetchResourceName = key.getResourceName();
|
||||
if (myValidationSupportContext.getRootValidationSupport().getFhirContext().getVersion().getVersion() == FhirVersionEnum.DSTU2) {
|
||||
if ("CodeSystem".equals(fetchResourceName)) {
|
||||
fetchResourceName = "ValueSet";
|
||||
}
|
||||
String fetchResourceName = key.getResourceName();
|
||||
if (myValidationSupportContext.getRootValidationSupport().getFhirContext().getVersion().getVersion() == FhirVersionEnum.DSTU2) {
|
||||
if ("CodeSystem".equals(fetchResourceName)) {
|
||||
fetchResourceName = "ValueSet";
|
||||
}
|
||||
}
|
||||
|
||||
Class<? extends IBaseResource> fetchResourceType;
|
||||
if (fetchResourceName.equals("Resource")) {
|
||||
fetchResourceType = null;
|
||||
} else {
|
||||
fetchResourceType = myValidationSupportContext.getRootValidationSupport().getFhirContext().getResourceDefinition(fetchResourceName).getImplementingClass();
|
||||
Class<? extends IBaseResource> fetchResourceType;
|
||||
if (fetchResourceName.equals("Resource")) {
|
||||
fetchResourceType = null;
|
||||
} else {
|
||||
fetchResourceType = myValidationSupportContext.getRootValidationSupport().getFhirContext().getResourceDefinition(fetchResourceName).getImplementingClass();
|
||||
}
|
||||
|
||||
IBaseResource fetched = myValidationSupportContext.getRootValidationSupport().fetchResource(fetchResourceType, key.getUri());
|
||||
|
||||
Resource canonical = myVersionCanonicalizer.resourceToValidatorCanonical(fetched);
|
||||
|
||||
if (canonical instanceof StructureDefinition) {
|
||||
StructureDefinition canonicalSd = (StructureDefinition) canonical;
|
||||
if (canonicalSd.getSnapshot().isEmpty()) {
|
||||
ourLog.info("Generating snapshot for StructureDefinition: {}", canonicalSd.getUrl());
|
||||
fetched = myValidationSupportContext.getRootValidationSupport().generateSnapshot(theValidationSupportContext, fetched, "", null, "");
|
||||
Validate.isTrue(fetched != null, "StructureDefinition %s has no snapshot, and no snapshot generator is configured", key.getUri());
|
||||
canonical = myVersionCanonicalizer.resourceToValidatorCanonical(fetched);
|
||||
}
|
||||
}
|
||||
|
||||
IBaseResource fetched = myValidationSupportContext.getRootValidationSupport().fetchResource(fetchResourceType, key.getUri());
|
||||
|
||||
Resource canonical = myModelConverter.toCanonical(fetched);
|
||||
|
||||
if (canonical instanceof StructureDefinition) {
|
||||
StructureDefinition canonicalSd = (StructureDefinition) canonical;
|
||||
if (canonicalSd.getSnapshot().isEmpty()) {
|
||||
ourLog.info("Generating snapshot for StructureDefinition: {}", canonicalSd.getUrl());
|
||||
fetched = myValidationSupportContext.getRootValidationSupport().generateSnapshot(theValidationSupportContext, fetched, "", null, "");
|
||||
Validate.isTrue(fetched != null, "StructureDefinition %s has no snapshot, and no snapshot generator is configured", key.getUri());
|
||||
canonical = myModelConverter.toCanonical(fetched);
|
||||
}
|
||||
}
|
||||
|
||||
return canonical;
|
||||
});
|
||||
return canonical;
|
||||
});
|
||||
|
||||
setValidationMessageLanguage(getLocale());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CanonicalResource> allConformanceResources() {
|
||||
throw new UnsupportedOperationException(Msg.code(650));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLinkForUrl(String corePath, String url) {
|
||||
throw new UnsupportedOperationException(Msg.code(651));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getBinaryKeysAsSet() {
|
||||
throw new UnsupportedOperationException(Msg.code(2118));
|
||||
|
@ -177,13 +161,13 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
|
|||
}
|
||||
|
||||
@Override
|
||||
public IPackageLoadingTracker getPackageTracker() {
|
||||
public IWorkerContextManager.IPackageLoadingTracker getPackageTracker() {
|
||||
throw new UnsupportedOperationException(Msg.code(2108));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWorkerContext setPackageTracker(
|
||||
IPackageLoadingTracker packageTracker) {
|
||||
IWorkerContextManager.IPackageLoadingTracker packageTracker) {
|
||||
throw new UnsupportedOperationException(Msg.code(2114));
|
||||
}
|
||||
|
||||
|
@ -192,27 +176,6 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
|
|||
throw new UnsupportedOperationException(Msg.code(2109));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateSnapshot(StructureDefinition input) throws FHIRException {
|
||||
if (input.hasSnapshot()) {
|
||||
return;
|
||||
}
|
||||
|
||||
org.hl7.fhir.r5.conformance.ProfileUtilities.ProfileKnowledgeProvider profileKnowledgeProvider = new ProfileKnowledgeWorkerR5(ourR5Context);
|
||||
ArrayList<ValidationMessage> messages = new ArrayList<>();
|
||||
org.hl7.fhir.r5.model.StructureDefinition base = fetchResource(StructureDefinition.class, input.getBaseDefinition());
|
||||
if (base == null) {
|
||||
throw new PreconditionFailedException(Msg.code(658) + "Unknown base definition: " + input.getBaseDefinition());
|
||||
}
|
||||
new org.hl7.fhir.r5.conformance.ProfileUtilities(this, messages, profileKnowledgeProvider).generateSnapshot(base, input, "", null, "");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateSnapshot(StructureDefinition theStructureDefinition, boolean theB) {
|
||||
// nothing yet
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.hl7.fhir.r5.model.Parameters getExpansionParameters() {
|
||||
return myExpansionProfile;
|
||||
|
@ -223,16 +186,15 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
|
|||
myExpansionProfile = expParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StructureDefinition> allStructures() {
|
||||
private List<StructureDefinition> allStructures() {
|
||||
|
||||
List<StructureDefinition> retVal = myAllStructures;
|
||||
if (retVal == null) {
|
||||
retVal = new ArrayList<>();
|
||||
for (IBaseResource next : myValidationSupportContext.getRootValidationSupport().fetchAllStructureDefinitions()) {
|
||||
try {
|
||||
Resource converted = myModelConverter.toCanonical(next);
|
||||
retVal.add((StructureDefinition) converted);
|
||||
StructureDefinition converted = myVersionCanonicalizer.structureDefinitionToCanonical(next);
|
||||
retVal.add(converted);
|
||||
} catch (FHIRException e) {
|
||||
throw new InternalErrorException(Msg.code(659) + e);
|
||||
}
|
||||
|
@ -243,11 +205,6 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
|
|||
return retVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StructureDefinition> getStructures() {
|
||||
return allStructures();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cacheResource(Resource res) {
|
||||
|
||||
|
@ -292,7 +249,7 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
|
|||
public ValueSetExpander.ValueSetExpansionOutcome expandVS(org.hl7.fhir.r5.model.ValueSet source, boolean cacheOk, boolean Hierarchical) {
|
||||
IBaseResource convertedSource;
|
||||
try {
|
||||
convertedSource = myModelConverter.fromCanonical(source);
|
||||
convertedSource = myVersionCanonicalizer.valueSetFromValidatorCanonical(source);
|
||||
} catch (FHIRException e) {
|
||||
throw new InternalErrorException(Msg.code(661) + e);
|
||||
}
|
||||
|
@ -301,7 +258,7 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
|
|||
org.hl7.fhir.r5.model.ValueSet convertedResult = null;
|
||||
if (expanded.getValueSet() != null) {
|
||||
try {
|
||||
convertedResult = (ValueSet) myModelConverter.toCanonical(expanded.getValueSet());
|
||||
convertedResult = myVersionCanonicalizer.valueSetToValidatorCanonical(expanded.getValueSet());
|
||||
} catch (FHIRException e) {
|
||||
throw new InternalErrorException(Msg.code(662) + e);
|
||||
}
|
||||
|
@ -340,7 +297,7 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
|
|||
return null;
|
||||
}
|
||||
try {
|
||||
return (org.hl7.fhir.r5.model.CodeSystem) myModelConverter.toCanonical(fetched);
|
||||
return (org.hl7.fhir.r5.model.CodeSystem) myVersionCanonicalizer.codeSystemToValidatorCanonical(fetched);
|
||||
} catch (FHIRException e) {
|
||||
throw new InternalErrorException(Msg.code(665) + e);
|
||||
}
|
||||
|
@ -353,7 +310,7 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
|
|||
return null;
|
||||
}
|
||||
try {
|
||||
return (org.hl7.fhir.r5.model.CodeSystem) myModelConverter.toCanonical(fetched);
|
||||
return (org.hl7.fhir.r5.model.CodeSystem) myVersionCanonicalizer.codeSystemToValidatorCanonical(fetched);
|
||||
} catch (FHIRException e) {
|
||||
throw new InternalErrorException(Msg.code(1992) + e);
|
||||
}
|
||||
|
@ -397,26 +354,6 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
|
|||
throw new UnsupportedOperationException(Msg.code(668));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<org.hl7.fhir.r5.model.ConceptMap> findMapsForSource(String url) {
|
||||
throw new UnsupportedOperationException(Msg.code(669));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAbbreviation(String name) {
|
||||
throw new UnsupportedOperationException(Msg.code(670));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IParser getParser(ParserType type) {
|
||||
throw new UnsupportedOperationException(Msg.code(671));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IParser getParser(String type) {
|
||||
throw new UnsupportedOperationException(Msg.code(672));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getResourceNames() {
|
||||
return new ArrayList<>(myValidationSupportContext.getRootValidationSupport().getFhirContext().getResourceTypes());
|
||||
|
@ -427,47 +364,11 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
|
|||
return myValidationSupportContext.getRootValidationSupport().getFhirContext().getResourceTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCanonicalResourceNames() {
|
||||
throw new UnsupportedOperationException(Msg.code(2110));
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.hl7.fhir.r5.model.StructureMap getTransform(String url) {
|
||||
throw new UnsupportedOperationException(Msg.code(673));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverrideVersionNs() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOverrideVersionNs(String value) {
|
||||
throw new UnsupportedOperationException(Msg.code(674));
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureDefinition fetchTypeDefinition(String typeName) {
|
||||
return fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/" + typeName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureDefinition fetchRawProfile(String url) {
|
||||
StructureDefinition retVal = fetchResource(StructureDefinition.class, url);
|
||||
|
||||
if (retVal != null && retVal.getSnapshot().isEmpty()) {
|
||||
generateSnapshot(retVal);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTypeNames() {
|
||||
throw new UnsupportedOperationException(Msg.code(675));
|
||||
}
|
||||
|
||||
@Override
|
||||
public UcumService getUcumService() {
|
||||
throw new UnsupportedOperationException(Msg.code(676));
|
||||
|
@ -483,16 +384,6 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
|
|||
return myValidationSupportContext.getRootValidationSupport().getFhirContext().getVersion().getVersion().getFhirVersionString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSpecUrl() {
|
||||
throw new UnsupportedOperationException(Msg.code(678));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCache() {
|
||||
throw new UnsupportedOperationException(Msg.code(679));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Resource> boolean hasResource(Class<T> class_, String uri) {
|
||||
throw new UnsupportedOperationException(Msg.code(680));
|
||||
|
@ -508,31 +399,11 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
|
|||
throw new UnsupportedOperationException(Msg.code(681));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<org.hl7.fhir.r5.model.StructureMap> listTransforms() {
|
||||
throw new UnsupportedOperationException(Msg.code(682));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IParser newJsonParser() {
|
||||
throw new UnsupportedOperationException(Msg.code(683));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IResourceValidator newValidator() {
|
||||
throw new UnsupportedOperationException(Msg.code(684));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IParser newXmlParser() {
|
||||
throw new UnsupportedOperationException(Msg.code(685));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String oid2Uri(String code) {
|
||||
throw new UnsupportedOperationException(Msg.code(686));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, NamingSystem> getNSUrlMap() {
|
||||
throw new UnsupportedOperationException(Msg.code(2111));
|
||||
|
@ -575,7 +446,7 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
|
|||
|
||||
try {
|
||||
if (theValueSet != null) {
|
||||
convertedVs = myModelConverter.fromCanonical(theValueSet);
|
||||
convertedVs = myVersionCanonicalizer.valueSetFromValidatorCanonical(theValueSet);
|
||||
}
|
||||
} catch (FHIRException e) {
|
||||
throw new InternalErrorException(Msg.code(689) + e);
|
||||
|
@ -591,7 +462,7 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
|
|||
IBaseResource convertedVs = null;
|
||||
try {
|
||||
if (theValueSet != null) {
|
||||
convertedVs = myModelConverter.fromCanonical(theValueSet);
|
||||
convertedVs = myVersionCanonicalizer.valueSetFromValidatorCanonical(theValueSet);
|
||||
}
|
||||
} catch (FHIRException e) {
|
||||
throw new InternalErrorException(Msg.code(690) + e);
|
||||
|
@ -608,7 +479,7 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
|
|||
|
||||
try {
|
||||
if (theValueSet != null) {
|
||||
convertedVs = myModelConverter.fromCanonical(theValueSet);
|
||||
convertedVs = myVersionCanonicalizer.valueSetFromValidatorCanonical(theValueSet);
|
||||
}
|
||||
} catch (FHIRException e) {
|
||||
throw new InternalErrorException(Msg.code(691) + e);
|
||||
|
@ -662,12 +533,12 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
|
|||
myFetchResourceCache.invalidateAll();
|
||||
}
|
||||
|
||||
public interface IVersionTypeConverter {
|
||||
|
||||
org.hl7.fhir.r5.model.Resource toCanonical(IBaseResource theNonCanonical);
|
||||
|
||||
IBaseResource fromCanonical(org.hl7.fhir.r5.model.Resource theCanonical);
|
||||
|
||||
@Override
|
||||
public <T extends Resource> List<T> fetchResourcesByType(Class<T> theClass) {
|
||||
if (theClass.equals(StructureDefinition.class)) {
|
||||
return (List<T>) allStructures();
|
||||
}
|
||||
throw new UnsupportedOperationException(Msg.code(650) + "Unable to fetch resources of type: " + theClass);
|
||||
}
|
||||
|
||||
private static class ResourceKey {
|
||||
|
@ -716,18 +587,6 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
|
|||
}
|
||||
}
|
||||
|
||||
private static class VersionTypeConverterR5 implements IVersionTypeConverter {
|
||||
@Override
|
||||
public Resource toCanonical(IBaseResource theNonCanonical) {
|
||||
return (Resource) theNonCanonical;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseResource fromCanonical(Resource theCanonical) {
|
||||
return theCanonical;
|
||||
}
|
||||
}
|
||||
|
||||
public static ConceptValidationOptions convertConceptValidationOptions(ValidationOptions theOptions) {
|
||||
ConceptValidationOptions retVal = new ConceptValidationOptions();
|
||||
if (theOptions.isGuessSystem()) {
|
||||
|
@ -738,65 +597,8 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
|
|||
|
||||
@Nonnull
|
||||
public static VersionSpecificWorkerContextWrapper newVersionSpecificWorkerContextWrapper(IValidationSupport theValidationSupport) {
|
||||
IVersionTypeConverter converter;
|
||||
|
||||
switch (theValidationSupport.getFhirContext().getVersion().getVersion()) {
|
||||
case DSTU2:
|
||||
case DSTU2_HL7ORG: {
|
||||
converter = new IVersionTypeConverter() {
|
||||
@Override
|
||||
public Resource toCanonical(IBaseResource theNonCanonical) {
|
||||
Resource retVal = VersionConvertorFactory_10_50.convertResource((org.hl7.fhir.dstu2.model.Resource) theNonCanonical, new BaseAdvisor_10_50(false));
|
||||
if (theNonCanonical instanceof org.hl7.fhir.dstu2.model.ValueSet) {
|
||||
org.hl7.fhir.dstu2.model.ValueSet valueSet = (org.hl7.fhir.dstu2.model.ValueSet) theNonCanonical;
|
||||
if (valueSet.hasCodeSystem() && valueSet.getCodeSystem().hasSystem()) {
|
||||
if (!valueSet.hasCompose()) {
|
||||
ValueSet valueSetR5 = (ValueSet) retVal;
|
||||
valueSetR5.getCompose().addInclude().setSystem(valueSet.getCodeSystem().getSystem());
|
||||
}
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseResource fromCanonical(Resource theCanonical) {
|
||||
return VersionConvertorFactory_10_50.convertResource(theCanonical, new BaseAdvisor_10_50(false));
|
||||
}
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
case DSTU2_1: {
|
||||
converter = new VersionTypeConverterDstu21();
|
||||
break;
|
||||
}
|
||||
|
||||
case DSTU3: {
|
||||
converter = new VersionTypeConverterDstu3();
|
||||
break;
|
||||
}
|
||||
|
||||
case R4: {
|
||||
converter = new VersionTypeConverterR4();
|
||||
break;
|
||||
}
|
||||
|
||||
case R4B: {
|
||||
converter = new VersionTypeConverterR4B();
|
||||
break;
|
||||
}
|
||||
|
||||
case R5: {
|
||||
converter = IDENTITY_VERSION_TYPE_CONVERTER;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new IllegalStateException(Msg.code(692));
|
||||
}
|
||||
|
||||
return new VersionSpecificWorkerContextWrapper(new ValidationSupportContext(theValidationSupport), converter);
|
||||
VersionCanonicalizer versionCanonicalizer = new VersionCanonicalizer(theValidationSupport.getFhirContext());
|
||||
return new VersionSpecificWorkerContextWrapper(new ValidationSupportContext(theValidationSupport), versionCanonicalizer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
package org.hl7.fhir.common.hapi.validation.validator;
|
||||
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_14_50;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
|
||||
public class VersionTypeConverterDstu21 implements VersionSpecificWorkerContextWrapper.IVersionTypeConverter {
|
||||
@Override
|
||||
public Resource toCanonical(IBaseResource theNonCanonical) {
|
||||
return VersionConvertorFactory_14_50.convertResource((org.hl7.fhir.dstu2016may.model.Resource) theNonCanonical, new VersionTypeAdvisorDstu21());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseResource fromCanonical(Resource theCanonical) {
|
||||
return VersionConvertorFactory_14_50.convertResource(theCanonical);
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package org.hl7.fhir.common.hapi.validation.validator;
|
||||
|
||||
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_50;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
|
||||
public class VersionTypeConverterDstu3 implements VersionSpecificWorkerContextWrapper.IVersionTypeConverter {
|
||||
@Override
|
||||
public Resource toCanonical(IBaseResource theNonCanonical) {
|
||||
return VersionConvertorFactory_30_50.convertResource((org.hl7.fhir.dstu3.model.Resource) theNonCanonical, new BaseAdvisor_30_50(false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseResource fromCanonical(Resource theCanonical) {
|
||||
return VersionConvertorFactory_30_50.convertResource(theCanonical, new BaseAdvisor_30_50(false));
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package org.hl7.fhir.common.hapi.validation.validator;
|
||||
|
||||
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
|
||||
public class VersionTypeConverterR4 implements VersionSpecificWorkerContextWrapper.IVersionTypeConverter {
|
||||
@Override
|
||||
public Resource toCanonical(IBaseResource theNonCanonical) {
|
||||
return VersionConvertorFactory_40_50.convertResource((org.hl7.fhir.r4.model.Resource) theNonCanonical, new BaseAdvisor_40_50(false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseResource fromCanonical(Resource theCanonical) {
|
||||
return VersionConvertorFactory_40_50.convertResource(theCanonical, new BaseAdvisor_40_50(false));
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package org.hl7.fhir.common.hapi.validation.validator;
|
||||
|
||||
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_43_50;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_43_50;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
|
||||
public class VersionTypeConverterR4B implements VersionSpecificWorkerContextWrapper.IVersionTypeConverter {
|
||||
@Override
|
||||
public Resource toCanonical(IBaseResource theNonCanonical) {
|
||||
return VersionConvertorFactory_43_50.convertResource((org.hl7.fhir.r4b.model.Resource) theNonCanonical, new BaseAdvisor_43_50(false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBaseResource fromCanonical(Resource theCanonical) {
|
||||
return VersionConvertorFactory_43_50.convertResource(theCanonical, new BaseAdvisor_43_50(false));
|
||||
}
|
||||
}
|
|
@ -127,8 +127,8 @@ public class RemoteTerminologyServiceValidationSupportTest {
|
|||
|
||||
assertEquals(CODE, myCodeSystemProvider.myLastCode.getCode());
|
||||
assertEquals(CODE_SYSTEM, myCodeSystemProvider.myLastUrl.getValueAsString());
|
||||
assertEquals(CODE_SYSTEM_VERSION_AS_TEXT, myCodeSystemProvider.myNextReturnParams.getParameter("name").toString());
|
||||
assertTrue(Boolean.parseBoolean(myCodeSystemProvider.myNextReturnParams.getParameter("result").primitiveValue()));
|
||||
assertEquals(CODE_SYSTEM_VERSION_AS_TEXT, myCodeSystemProvider.myNextReturnParams.getParameterValue("name").toString());
|
||||
assertTrue(Boolean.parseBoolean(myCodeSystemProvider.myNextReturnParams.getParameterValue("result").primitiveValue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -141,11 +141,11 @@ public class RemoteTerminologyServiceValidationSupportTest {
|
|||
assertNotNull(outcome, "Call to lookupCode() should return a non-NULL result!");
|
||||
assertEquals(DISPLAY, outcome.getCodeDisplay());
|
||||
assertEquals(CODE_SYSTEM_VERSION, outcome.getCodeSystemVersion());
|
||||
assertEquals(CODE_SYSTEM_VERSION_AS_TEXT, myCodeSystemProvider.myNextReturnParams.getParameter("name").toString());
|
||||
assertEquals(CODE_SYSTEM_VERSION_AS_TEXT, myCodeSystemProvider.myNextReturnParams.getParameterValue("name").toString());
|
||||
|
||||
assertEquals(CODE, myCodeSystemProvider.myLastCode.getCode());
|
||||
assertEquals(CODE_SYSTEM, myCodeSystemProvider.myLastUrl.getValueAsString());
|
||||
assertTrue(Boolean.parseBoolean(myCodeSystemProvider.myNextReturnParams.getParameter("result").primitiveValue()));
|
||||
assertTrue(Boolean.parseBoolean(myCodeSystemProvider.myNextReturnParams.getParameterValue("result").primitiveValue()));
|
||||
|
||||
validateExtraCodeSystemParams();
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import ca.uhn.fhir.context.FhirVersionEnum;
|
|||
import ca.uhn.fhir.context.support.IValidationSupport;
|
||||
import ca.uhn.fhir.context.support.ValidationSupportContext;
|
||||
import ca.uhn.fhir.i18n.HapiLocalizer;
|
||||
import ca.uhn.hapi.converters.canonical.VersionCanonicalizer;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -29,12 +30,12 @@ public class VersionSpecificWorkerContextWrapperTest {
|
|||
IValidationSupport validationSupport = mockValidationSupportWithTwoBinaries();
|
||||
|
||||
ValidationSupportContext mockContext = mockValidationSupportContext(validationSupport);
|
||||
VersionSpecificWorkerContextWrapper.IVersionTypeConverter converter = mock(VersionSpecificWorkerContextWrapper.IVersionTypeConverter.class);
|
||||
|
||||
VersionSpecificWorkerContextWrapper wrapper = new VersionSpecificWorkerContextWrapper(mockContext, converter);
|
||||
VersionCanonicalizer versionCanonicalizer = new VersionCanonicalizer(FhirContext.forR5Cached());
|
||||
VersionSpecificWorkerContextWrapper wrapper = new VersionSpecificWorkerContextWrapper(mockContext, versionCanonicalizer);
|
||||
|
||||
assertTrue(wrapper.hasBinaryKey(EXPECTED_BINARY_KEY_1), "wrapper should have binary key " + EXPECTED_BINARY_KEY_1 );
|
||||
assertTrue(wrapper.hasBinaryKey(EXPECTED_BINARY_KEY_2), "wrapper should have binary key " + EXPECTED_BINARY_KEY_1 );
|
||||
assertTrue(wrapper.hasBinaryKey(EXPECTED_BINARY_KEY_1), "wrapper should have binary key " + EXPECTED_BINARY_KEY_1);
|
||||
assertTrue(wrapper.hasBinaryKey(EXPECTED_BINARY_KEY_2), "wrapper should have binary key " + EXPECTED_BINARY_KEY_1);
|
||||
assertFalse(wrapper.hasBinaryKey(NON_EXISTENT_BINARY_KEY), "wrapper should not have binary key " + NON_EXISTENT_BINARY_KEY);
|
||||
|
||||
}
|
||||
|
@ -45,9 +46,9 @@ public class VersionSpecificWorkerContextWrapperTest {
|
|||
IValidationSupport validationSupport = mockValidationSupportWithTwoBinaries();
|
||||
|
||||
ValidationSupportContext mockContext = mockValidationSupportContext(validationSupport);
|
||||
VersionSpecificWorkerContextWrapper.IVersionTypeConverter converter = mock(VersionSpecificWorkerContextWrapper.IVersionTypeConverter.class);
|
||||
|
||||
VersionSpecificWorkerContextWrapper wrapper = new VersionSpecificWorkerContextWrapper(mockContext, converter);
|
||||
VersionCanonicalizer versionCanonicalizer = new VersionCanonicalizer(FhirContext.forR5Cached());
|
||||
VersionSpecificWorkerContextWrapper wrapper = new VersionSpecificWorkerContextWrapper(mockContext, versionCanonicalizer);
|
||||
|
||||
assertArrayEquals(EXPECTED_BINARY_CONTENT_1, wrapper.getBinaryForKey(EXPECTED_BINARY_KEY_1));
|
||||
assertArrayEquals(EXPECTED_BINARY_CONTENT_2, wrapper.getBinaryForKey(EXPECTED_BINARY_KEY_2));
|
||||
|
@ -60,9 +61,9 @@ public class VersionSpecificWorkerContextWrapperTest {
|
|||
IValidationSupport validationSupport = mockValidationSupport();
|
||||
|
||||
ValidationSupportContext mockContext = mockValidationSupportContext(validationSupport);
|
||||
VersionSpecificWorkerContextWrapper.IVersionTypeConverter converter = mock(VersionSpecificWorkerContextWrapper.IVersionTypeConverter.class);
|
||||
|
||||
VersionSpecificWorkerContextWrapper wrapper = new VersionSpecificWorkerContextWrapper(mockContext, converter);
|
||||
VersionCanonicalizer versionCanonicalizer = new VersionCanonicalizer(FhirContext.forR5Cached());
|
||||
VersionSpecificWorkerContextWrapper wrapper = new VersionSpecificWorkerContextWrapper(mockContext, versionCanonicalizer);
|
||||
|
||||
wrapper.cacheResource(mock(Resource.class));
|
||||
}
|
||||
|
|
|
@ -598,7 +598,7 @@ public class FhirInstanceValidatorDstu3Test {
|
|||
List<SingleValidationMessage> issues = logResultsAndReturnNonInformationalOnes(output);
|
||||
|
||||
assertThat(issues.stream().map(SingleValidationMessage::getMessage).collect(Collectors.toList()).toString(),
|
||||
containsString("None of the codings provided are in the value set 'Value Set Finnish PHR Medication Context' (http://phr.kanta.fi/ValueSet/fiphr-vs-medicationcontext), and a coding from this value set is required) (codes = http://phr.kanta.fi/fiphr-cs-medicationcontext#13)"));
|
||||
containsString("None of the codings provided are in the value set 'Value Set Finnish PHR Medication Context'"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -669,7 +669,10 @@ public class FhirInstanceValidatorDstu3Test {
|
|||
} else if (t.getMessage().contains("The valueSet reference http://www.rfc-editor.org/bcp/bcp13.txt on element")) {
|
||||
return false;
|
||||
} else if (t.getMessage().contains("The Unicode sequence has unterminated bi-di control characters")) {
|
||||
// Some DSTU3 structures conain bi-di control characters, and a check for this was added recently.
|
||||
// Some DSTU3 structures contain bi-di control characters, and a check for this was added recently.
|
||||
return false;
|
||||
} else if (t.getMessage().contains("The markdown contains content that appears to be an embedded")) {
|
||||
// Some DSTU3 structures contain URLs with <> around them
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
|
@ -783,7 +786,7 @@ public class FhirInstanceValidatorDstu3Test {
|
|||
Patient resource = loadResource("/dstu3/nl/nl-core-patient-01.json", Patient.class);
|
||||
ValidationResult results = myVal.validateWithResult(resource);
|
||||
List<SingleValidationMessage> outcome = logResultsAndReturnNonInformationalOnes(results);
|
||||
assertThat(outcome.toString(), containsString("Could not confirm that the codes provided are in the value set http://decor.nictiz.nl/fhir/ValueSet/2.16.840.1.113883.2.4.3.11.60.40.2.20.5.1--20171231000000"));
|
||||
assertThat(outcome.toString(), containsString("Could not confirm that the codes provided are in the value set 'LandGBACodelijst'"));
|
||||
}
|
||||
|
||||
private void loadNL() throws IOException {
|
||||
|
@ -867,7 +870,7 @@ public class FhirInstanceValidatorDstu3Test {
|
|||
ourLog.info(output.getMessages().get(0).getLocationString());
|
||||
ourLog.info(output.getMessages().get(0).getMessage());
|
||||
assertEquals("Patient", output.getMessages().get(0).getLocationString());
|
||||
assertEquals("Unrecognised property '@foo'", output.getMessages().get(0).getMessage());
|
||||
assertEquals("Unrecognized property 'foo'", output.getMessages().get(0).getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1185,9 +1188,10 @@ public class FhirInstanceValidatorDstu3Test {
|
|||
|
||||
ValidationResult output = myVal.validateWithResult(input);
|
||||
logResultsAndReturnAll(output);
|
||||
assertEquals(
|
||||
"The value provided ('notvalidcode') is not in the value set 'ObservationStatus' (http://hl7.org/fhir/ValueSet/observation-status), and a code is required from this value set) (error message = Unknown code 'notvalidcode' for in-memory expansion of ValueSet 'http://hl7.org/fhir/ValueSet/observation-status')",
|
||||
output.getMessages().get(0).getMessage());
|
||||
assertThat(
|
||||
output.getMessages().get(0).getMessage(),
|
||||
containsString("The value provided ('notvalidcode') is not in the value set 'ObservationStatus'")
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1282,9 +1286,9 @@ public class FhirInstanceValidatorDstu3Test {
|
|||
List<SingleValidationMessage> all = logResultsAndReturnAll(output);
|
||||
assertEquals(1, all.size());
|
||||
assertEquals("Patient.identifier[0].type", all.get(0).getLocationString());
|
||||
assertEquals(
|
||||
"None of the codings provided are in the value set 'Identifier Type Codes' (http://hl7.org/fhir/ValueSet/identifier-type), and a coding should come from this value set unless it has no suitable code (note that the validator cannot judge what is suitable) (codes = http://example.com/foo/bar#bar)",
|
||||
all.get(0).getMessage());
|
||||
assertThat(
|
||||
all.get(0).getMessage(),
|
||||
containsString("None of the codings provided are in the value set 'Identifier Type Codes'"));
|
||||
assertEquals(ResultSeverityEnum.WARNING, all.get(0).getSeverity());
|
||||
|
||||
}
|
||||
|
|
|
@ -211,7 +211,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
|||
ValidationResult errors = myVal.validateWithResult(qa);
|
||||
|
||||
ourLog.info(errors.toString());
|
||||
assertThat(errors.toString(), containsString("Answer value must be of type boolean"));
|
||||
assertThat(errors.toString(), containsString("Answer value must be of the type boolean"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -166,7 +166,7 @@ public class ResourceValidatorDstu3Test {
|
|||
ValidationResult output = val.validateWithResult(p);
|
||||
List<SingleValidationMessage> all = logResultsAndReturnNonInformationalOnes(output);
|
||||
|
||||
assertEquals("None of the codings provided are in the value set 'Marital Status Codes' (http://hl7.org/fhir/ValueSet/marital-status), and a coding should come from this value set unless it has no suitable code (note that the validator cannot judge what is suitable) (codes = http://hl7.org/fhir/v3/MaritalStatus#FOO)", output.getMessages().get(0).getMessage());
|
||||
assertThat(output.getMessages().get(0).getMessage(), containsString("None of the codings provided are in the value set 'Marital Status Codes'"));
|
||||
assertEquals(ResultSeverityEnum.WARNING, output.getMessages().get(0).getSeverity());
|
||||
}
|
||||
|
||||
|
|
|
@ -44,8 +44,8 @@ public class CustomResourceGenerationTest extends BaseTest {
|
|||
|
||||
assertEquals(3, result.getMessages().size());
|
||||
assertEquals("Error parsing JSON: the primitive value must be a boolean", result.getMessages().get(0).getMessage());
|
||||
assertEquals("This property must be an Array, not a primitive property", result.getMessages().get(1).getMessage());
|
||||
assertEquals("Unrecognised property '@id1'", result.getMessages().get(2).getMessage());
|
||||
assertEquals("This property must be an Array, not a Primitive property", result.getMessages().get(1).getMessage());
|
||||
assertEquals("Unrecognized property 'id1'", result.getMessages().get(2).getMessage());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -445,7 +445,7 @@ public class FhirInstanceValidatorR4Test extends BaseTest {
|
|||
ValidationResult result = val.validateWithResult(operationDefinition);
|
||||
List<SingleValidationMessage> all = logResultsAndReturnAll(result);
|
||||
assertFalse(result.isSuccessful());
|
||||
assertEquals("This property must be an Array, not a primitive property", all.get(0).getMessage());
|
||||
assertEquals("This property must be an Array, not a Primitive property", all.get(0).getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -704,7 +704,7 @@ public class FhirInstanceValidatorR4Test extends BaseTest {
|
|||
ValidationResult output = myFhirValidator.validateWithResult(input);
|
||||
List<SingleValidationMessage> errors = logResultsAndReturnAll(output);
|
||||
assertEquals(2, errors.size());
|
||||
assertEquals("None of the codings provided are in the value set 'LOINC Diagnostic Report Codes' (http://hl7.org/fhir/ValueSet/report-codes), and a coding is recommended to come from this value set) (codes = http://loinc.org#1-8)", errors.get(0).getMessage());
|
||||
assertThat(errors.get(0).getMessage(), containsString("None of the codings provided are in the value set 'LOINC Diagnostic Report Codes'"));
|
||||
assertEquals("Base64 encoded values SHOULD not contain any whitespace (per RFC 4648). Note that non-validating readers are encouraged to accept whitespace anyway", errors.get(1).getMessage());
|
||||
}
|
||||
|
||||
|
@ -802,7 +802,7 @@ public class FhirInstanceValidatorR4Test extends BaseTest {
|
|||
|
||||
ValidationResult output = myFhirValidator.validateWithResult(patient);
|
||||
logResultsAndReturnNonInformationalOnes(output);
|
||||
assertThat(output.getMessages().toString(), containsString("Error parsing JSON source: Duplicated property name"));
|
||||
assertThat(output.getMessages().toString(), containsString("The JSON property 'name' is a duplicate and will be ignored"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -930,13 +930,13 @@ public class FhirInstanceValidatorR4Test extends BaseTest {
|
|||
ourLog.info(output.getMessages().get(0).getLocationString());
|
||||
ourLog.info(output.getMessages().get(0).getMessage());
|
||||
assertEquals("Patient", output.getMessages().get(0).getLocationString());
|
||||
assertEquals("Unrecognised property '@foo'", output.getMessages().get(0).getMessage());
|
||||
assertEquals("Unrecognized property 'foo'", output.getMessages().get(0).getMessage());
|
||||
|
||||
OperationOutcome operationOutcome = (OperationOutcome) output.toOperationOutcome();
|
||||
ourLog.info(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(operationOutcome));
|
||||
assertEquals("Unrecognised property '@foo'", operationOutcome.getIssue().get(0).getDiagnostics());
|
||||
assertEquals("Unrecognized property 'foo'", operationOutcome.getIssue().get(0).getDiagnostics());
|
||||
assertEquals("Patient", operationOutcome.getIssue().get(0).getLocation().get(0).getValue());
|
||||
assertEquals("Line 5, Col 24", operationOutcome.getIssue().get(0).getLocation().get(1).getValue());
|
||||
assertEquals("Line 5, Col 23", operationOutcome.getIssue().get(0).getLocation().get(1).getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1243,7 +1243,7 @@ public class FhirInstanceValidatorR4Test extends BaseTest {
|
|||
|
||||
ValidationResult output = myFhirValidator.validateWithResult(input);
|
||||
assertThat(output.getMessages().size(), greaterThan(0));
|
||||
assertEquals("Observation.status: minimum required = 1, but only found 0 (from http://hl7.org/fhir/StructureDefinition/Observation)", output.getMessages().get(0).getMessage());
|
||||
assertThat(output.getMessages().get(0).getMessage(), containsString("Observation.status: minimum required = 1, but only found 0"));
|
||||
|
||||
}
|
||||
|
||||
|
@ -1409,7 +1409,7 @@ public class FhirInstanceValidatorR4Test extends BaseTest {
|
|||
List<SingleValidationMessage> all = logResultsAndReturnAll(output);
|
||||
assertEquals(1, all.size());
|
||||
assertEquals("Patient.identifier[0].type", all.get(0).getLocationString());
|
||||
assertThat(all.get(0).getMessage(), containsString("None of the codings provided are in the value set 'IdentifierType' (http://hl7.org/fhir/ValueSet/identifier-type), and a coding should come from this value set unless it has no suitable code (note that the validator cannot judge what is suitable) (codes = http://example.com/foo/bar#bar)"));
|
||||
assertThat(all.get(0).getMessage(), containsString("None of the codings provided are in the value set 'IdentifierType'"));
|
||||
assertEquals(ResultSeverityEnum.WARNING, all.get(0).getSeverity());
|
||||
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ public class QuestionnaireResponseValidatorR4Test {
|
|||
ValidationResult errors = myVal.validateWithResult(qa);
|
||||
|
||||
ourLog.info(errors.toString());
|
||||
assertThat(errors.toString(), containsString("Answer value must be of type boolean"));
|
||||
assertThat(errors.toString(), containsString("Answer value must be of the type boolean"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -505,7 +505,7 @@ public class FhirInstanceValidatorR5Test {
|
|||
ourLog.info(output.getMessages().get(0).getLocationString());
|
||||
ourLog.info(output.getMessages().get(0).getMessage());
|
||||
assertEquals("Patient", output.getMessages().get(0).getLocationString());
|
||||
assertEquals("Unrecognised property '@foo'", output.getMessages().get(0).getMessage());
|
||||
assertEquals("Unrecognized property 'foo'", output.getMessages().get(0).getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -835,7 +835,7 @@ public class FhirInstanceValidatorR5Test {
|
|||
|
||||
ValidationResult output = myVal.validateWithResult(input);
|
||||
assertThat(output.getMessages().size(), greaterThan(0));
|
||||
assertEquals("Observation.status: minimum required = 1, but only found 0 (from http://hl7.org/fhir/StructureDefinition/Observation)", output.getMessages().get(0).getMessage());
|
||||
assertThat(output.getMessages().get(0).getMessage(), containsString("Observation.status: minimum required = 1, but only found 0"));
|
||||
|
||||
}
|
||||
|
||||
|
@ -972,9 +972,9 @@ public class FhirInstanceValidatorR5Test {
|
|||
List<SingleValidationMessage> all = logResultsAndReturnAll(output);
|
||||
assertEquals(1, all.size());
|
||||
assertEquals("Patient.identifier[0].type", all.get(0).getLocationString());
|
||||
assertEquals(
|
||||
"None of the codings provided are in the value set 'Identifier Type Codes' (http://hl7.org/fhir/ValueSet/identifier-type), and a coding should come from this value set unless it has no suitable code (note that the validator cannot judge what is suitable) (codes = http://example.com/foo/bar#bar)",
|
||||
all.get(0).getMessage());
|
||||
assertThat(
|
||||
all.get(0).getMessage(),
|
||||
containsString("None of the codings provided are in the value set 'Identifier Type Codes'"));
|
||||
assertEquals(ResultSeverityEnum.WARNING, all.get(0).getSeverity());
|
||||
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ public class QuestionnaireResponseValidatorR5Test {
|
|||
ValidationResult errors = myVal.validateWithResult(qa);
|
||||
|
||||
ourLog.info(errors.toString());
|
||||
assertThat(errors.toString(), containsString("Answer value must be of type boolean"));
|
||||
assertThat(errors.toString(), containsString("Answer value must be of the type boolean"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -5,7 +5,6 @@ import java.util.*;
|
|||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import ca.uhn.fhir.jpa.provider${package_suffix}.*;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
import ca.uhn.fhir.model.api.annotation.*;
|
||||
|
@ -25,9 +24,9 @@ import ca.uhn.fhir.rest.api.SearchContainedModeEnum;
|
|||
public class ${className}ResourceProvider extends
|
||||
## We have specialized base classes for RPs that handle certain resource types. These
|
||||
## RPs implement type specific operations
|
||||
#if ( ${className} == 'CodeSystem' || ${className} == 'Composition' || ${className} == 'Encounter' || ${className} == 'Observation' || ${className} == 'Patient' || ${className} == 'StructureDefinition' )
|
||||
#if ( ${className} == 'CodeSystem' || ${className} == 'Composition' || ${className} == 'ConceptMap' || ${className} == 'Encounter' || ${className} == 'Observation' || ${className} == 'Patient' || ${className} == 'StructureDefinition' )
|
||||
ca.uhn.fhir.jpa.provider.BaseJpaResourceProvider${className}<${className}>
|
||||
#elseif ( $version != 'dstu' && (${className} == 'QuestionnaireAnswers' || ${className} == 'CodeSystem' || ($version != 'dstu2' && ${className} == 'ConceptMap') || ${className} == 'Composition' || ${className} == 'StructureDefinition'))
|
||||
#elseif ( $version != 'dstu' && (${className} == 'QuestionnaireAnswers' || ${className} == 'CodeSystem' || ${className} == 'Composition' || ${className} == 'StructureDefinition'))
|
||||
BaseJpaResourceProvider${className}${versionCapitalized}
|
||||
#else
|
||||
ca.uhn.fhir.jpa.provider.BaseJpaResourceProvider<${className}>
|
||||
|
|
|
@ -55,22 +55,17 @@ FhirContext myFhirContext;
|
|||
#foreach ( $res in $resources )
|
||||
@Bean(name="my${res.name}Dao${versionCapitalized}")
|
||||
public
|
||||
#if ( (${versionCapitalized.startsWith('R')} || ${versionCapitalized} == 'Dstu3') && (${res.name} == 'ConceptMap') )
|
||||
IFhirResourceDao${res.name}<org.hl7.fhir.${version}.model.${res.name}>
|
||||
#elseif ( ${res.name} == 'CodeSystem' || ${res.name} == 'Composition' || ${res.name} == 'Encounter' || ${res.name} == 'Everything' || ${res.name} == 'Observation' || ${res.name} == 'Patient' || ${res.name} == 'Subscription' || ${res.name} == 'SearchParameter' || ${res.name} == 'StructureDefinition' || ${res.name} == 'ValueSet' )
|
||||
#if ( ${res.name} == 'CodeSystem' || ${res.name} == 'Composition' || ${res.name} == 'ConceptMap' || ${res.name} == 'Encounter' || ${res.name} == 'Everything' || ${res.name} == 'Observation' || ${res.name} == 'Patient' || ${res.name} == 'Subscription' || ${res.name} == 'SearchParameter' || ${res.name} == 'StructureDefinition' || ${res.name} == 'ValueSet' )
|
||||
IFhirResourceDao${res.name}<${resourcePackage}.${res.declaringClassNameComplete}>
|
||||
#else
|
||||
IFhirResourceDao<${resourcePackage}.${res.declaringClassNameComplete}>
|
||||
#end
|
||||
dao${res.declaringClassNameComplete}${versionCapitalized}() {
|
||||
|
||||
#if ( ${res.name} == 'Bundle' || ${res.name} == 'CodeSystem' || ${res.name} == 'Composition' || ${res.name} == 'Encounter' || ${res.name} == 'Observation' || ${res.name} == 'Patient' || ${res.name} == 'SearchParameter' || ${res.name} == 'ValueSet' )
|
||||
#if ( ${res.name} == 'Bundle' || ${res.name} == 'CodeSystem' || ${res.name} == 'Composition' || ${res.name} == 'ConceptMap' || ${res.name} == 'Encounter' || ${res.name} == 'Observation' || ${res.name} == 'Patient' || ${res.name} == 'SearchParameter' || ${res.name} == 'StructureDefinition' || ${res.name} == 'ValueSet' )
|
||||
ca.uhn.fhir.jpa.dao.JpaResourceDao${res.name}<${resourcePackage}.${res.declaringClassNameComplete}> retVal;
|
||||
retVal = new ca.uhn.fhir.jpa.dao.JpaResourceDao${res.name}<>();
|
||||
#elseif ( (${versionCapitalized.startsWith('R')} || ${versionCapitalized} == 'Dstu3') && (${res.name} == 'ConceptMap') )
|
||||
ca.uhn.fhir.jpa.dao.JpaResourceDao${res.name}<org.hl7.fhir.${version}.model.${res.name}> retVal;
|
||||
retVal = new ca.uhn.fhir.jpa.dao.JpaResourceDao${res.name}<>();
|
||||
#elseif ( ${res.name} == 'Everything' || ${res.name} == 'Subscription' || ${res.name} == 'StructureDefinition')
|
||||
#elseif ( ${res.name} == 'Everything' || ${res.name} == 'Subscription')
|
||||
ca.uhn.fhir.jpa.dao${package_suffix}.FhirResourceDao${res.name}${versionCapitalized} retVal;
|
||||
retVal = new ca.uhn.fhir.jpa.dao${package_suffix}.FhirResourceDao${res.name}${versionCapitalized}();
|
||||
#else
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -845,7 +845,7 @@
|
|||
|
||||
<properties>
|
||||
|
||||
<fhir_core_version>5.6.68</fhir_core_version>
|
||||
<fhir_core_version>5.6.82-SNAPSHOT</fhir_core_version>
|
||||
<ucum_version>1.0.3</ucum_version>
|
||||
|
||||
<surefire_jvm_args>-Dfile.encoding=UTF-8 -Xmx2048m</surefire_jvm_args>
|
||||
|
@ -1028,7 +1028,7 @@
|
|||
<dependency>
|
||||
<groupId>com.graphql-java</groupId>
|
||||
<artifactId>graphql-java</artifactId>
|
||||
<version>17.4</version>
|
||||
<version>19.2</version>
|
||||
</dependency>
|
||||
<!-- mail start -->
|
||||
<dependency>
|
||||
|
|
Loading…
Reference in New Issue