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:
James Agnew 2022-11-30 05:31:26 -05:00 committed by GitHub
parent 50ca94eded
commit 312128754b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
71 changed files with 1073 additions and 1707 deletions

View File

@ -43,6 +43,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Properties; import java.util.Properties;
@ -341,6 +342,12 @@ public class DefaultProfileValidationSupport implements IValidationSupport {
private void loadStructureDefinitions(Map<String, IBaseResource> theCodeSystems, String theClasspath) { private void loadStructureDefinitions(Map<String, IBaseResource> theCodeSystems, String theClasspath) {
ourLog.info("Loading structure definitions from classpath: {}", 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)) { try (InputStream valueSetText = DefaultProfileValidationSupport.class.getResourceAsStream(theClasspath)) {
if (valueSetText != null) { if (valueSetText != null) {
try (InputStreamReader reader = new InputStreamReader(valueSetText, Constants.CHARSET_UTF8)) { 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 { } else {

View File

@ -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.IBaseCoding;
import org.hl7.fhir.instance.model.api.IBaseParameters; import org.hl7.fhir.instance.model.api.IBaseParameters;
import org.hl7.fhir.instance.model.api.IBaseResource; 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.instance.model.api.IPrimitiveType;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@ -257,10 +258,13 @@ public interface IValidationSupport {
/** /**
* Fetch the given binary data by key. * Fetch the given binary data by key.
*
* @param binaryKey * @param binaryKey
* @return * @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 * Validates that the given code exists and if possible returns a display
@ -814,14 +818,14 @@ public interface IValidationSupport {
class TranslateCodeRequest { class TranslateCodeRequest {
private List<IBaseCoding> myCodings;
private final String myTargetSystemUrl; private final String myTargetSystemUrl;
private final String myConceptMapUrl; private final String myConceptMapUrl;
private final String myConceptMapVersion; private final String myConceptMapVersion;
private final String mySourceValueSetUrl; private final String mySourceValueSetUrl;
private final String myTargetValueSetUrl; private final String myTargetValueSetUrl;
private final Long myResourcePid; private final IIdType myResourceId;
private final boolean myReverse; private final boolean myReverse;
private List<IBaseCoding> myCodings;
public TranslateCodeRequest(List<IBaseCoding> theCodings, String theTargetSystemUrl) { public TranslateCodeRequest(List<IBaseCoding> theCodings, String theTargetSystemUrl) {
myCodings = theCodings; myCodings = theCodings;
@ -830,7 +834,7 @@ public interface IValidationSupport {
myConceptMapVersion = null; myConceptMapVersion = null;
mySourceValueSetUrl = null; mySourceValueSetUrl = null;
myTargetValueSetUrl = null; myTargetValueSetUrl = null;
myResourcePid = null; myResourceId = null;
myReverse = false; myReverse = false;
} }
@ -841,7 +845,7 @@ public interface IValidationSupport {
String theConceptMapVersion, String theConceptMapVersion,
String theSourceValueSetUrl, String theSourceValueSetUrl,
String theTargetValueSetUrl, String theTargetValueSetUrl,
Long theResourcePid, IIdType theResourceId,
boolean theReverse) { boolean theReverse) {
myCodings = theCodings; myCodings = theCodings;
myTargetSystemUrl = theTargetSystemUrl; myTargetSystemUrl = theTargetSystemUrl;
@ -849,7 +853,7 @@ public interface IValidationSupport {
myConceptMapVersion = theConceptMapVersion; myConceptMapVersion = theConceptMapVersion;
mySourceValueSetUrl = theSourceValueSetUrl; mySourceValueSetUrl = theSourceValueSetUrl;
myTargetValueSetUrl = theTargetValueSetUrl; myTargetValueSetUrl = theTargetValueSetUrl;
myResourcePid = theResourcePid; myResourceId = theResourceId;
myReverse = theReverse; myReverse = theReverse;
} }
@ -872,7 +876,7 @@ public interface IValidationSupport {
.append(myConceptMapVersion, that.myConceptMapVersion) .append(myConceptMapVersion, that.myConceptMapVersion)
.append(mySourceValueSetUrl, that.mySourceValueSetUrl) .append(mySourceValueSetUrl, that.mySourceValueSetUrl)
.append(myTargetValueSetUrl, that.myTargetValueSetUrl) .append(myTargetValueSetUrl, that.myTargetValueSetUrl)
.append(myResourcePid, that.myResourcePid) .append(myResourceId, that.myResourceId)
.append(myReverse, that.myReverse) .append(myReverse, that.myReverse)
.isEquals(); .isEquals();
} }
@ -886,7 +890,7 @@ public interface IValidationSupport {
.append(myConceptMapVersion) .append(myConceptMapVersion)
.append(mySourceValueSetUrl) .append(mySourceValueSetUrl)
.append(myTargetValueSetUrl) .append(myTargetValueSetUrl)
.append(myResourcePid) .append(myResourceId)
.append(myReverse) .append(myReverse)
.toHashCode(); .toHashCode();
} }
@ -915,8 +919,8 @@ public interface IValidationSupport {
return myTargetValueSetUrl; return myTargetValueSetUrl;
} }
public Long getResourcePid() { public IIdType getResourceId() {
return myResourcePid; return myResourceId;
} }
public boolean isReverse() { public boolean isReverse() {

View File

@ -68,4 +68,11 @@ public class DatatypeUtil {
return thePrimitiveType != null ? thePrimitiveType.getValueAsString() : null; 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;
}
} }

View File

@ -34,6 +34,13 @@ public class SingleValidationMessage {
private String myMessageId; private String myMessageId;
private ResultSeverityEnum mySeverity; private ResultSeverityEnum mySeverity;
/**
* Constructor
*/
public SingleValidationMessage() {
super();
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -25,8 +25,6 @@ import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.rest.api.EncodingEnum; import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import com.google.common.io.Files; 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.CommandLine;
import org.apache.commons.cli.Options; import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException; 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.FalseFileFilter;
import org.apache.commons.io.filefilter.IOFileFilter; import org.apache.commons.io.filefilter.IOFileFilter;
import org.apache.commons.io.filefilter.WildcardFileFilter; 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.NpmPackage;
import org.hl7.fhir.utilities.npm.PackageGenerator; import org.hl7.fhir.utilities.npm.PackageGenerator;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -53,7 +53,6 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
@SuppressWarnings("UnstableApiUsage") @SuppressWarnings("UnstableApiUsage")
public class CreatePackageCommand extends BaseCommand { 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 TARGET_DIRECTORY_OPT = "target-directory";
public static final String DEPENDENCY_OPT = "dependency"; public static final String DEPENDENCY_OPT = "dependency";
public static final String INCLUDE_EXAMPLE_OPT = "include-example"; 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 VERSION_OPT = "version";
public static final String NAME_OPT = "name"; public static final String NAME_OPT = "name";
public static final String DESCRIPTION_OPT = "description"; public static final String DESCRIPTION_OPT = "description";
private static final Logger ourLog = LoggerFactory.getLogger(CreatePackageCommand.class);
private File myWorkDirectory; private File myWorkDirectory;
private String myPackageName; private String myPackageName;
private String myPackageVersion; private String myPackageVersion;

View File

@ -99,18 +99,19 @@ public class CreatePackageCommandTest extends BaseTest {
String packageJsonContents = IOUtils.toString(new FileInputStream(new File(myExtractDirectory, "package/package.json")), Charsets.UTF_8); String packageJsonContents = IOUtils.toString(new FileInputStream(new File(myExtractDirectory, "package/package.json")), Charsets.UTF_8);
ourLog.info("Package.json:\n{}", packageJsonContents); ourLog.info("Package.json:\n{}", packageJsonContents);
String expectedPackageJson = "{\n" + String expectedPackageJson = """
" \"name\": \"com.example.ig\",\n" + {
" \"version\": \"1.0.1\",\n" + "name" : "com.example.ig",
" \"fhirVersions\": [\n" + "version" : "1.0.1",
" \"4.0.1\"\n" + "description" : "",
" ],\n" + "fhirVersions" : ["4.0.1"],
" \"dependencies\": {\n" + "dependencies" : {
" \"hl7.fhir.core\": \"4.0.1\",\n" + "hl7.fhir.core" : "4.0.1",
" \"foo.bar\": \"1.2.3\"\n" + "foo.bar" : "1.2.3"
" }\n" + }
"}"; }
assertEquals(expectedPackageJson, packageJsonContents); """;
assertEquals(expectedPackageJson.trim(), packageJsonContents.trim());
// Try parsing the module again to make sure we can // Try parsing the module again to make sure we can
NpmPackage loadedPackage = NpmPackage.fromPackage(new FileInputStream(igArchive)); 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); String packageJsonContents = IOUtils.toString(new FileInputStream(new File(myExtractDirectory, "package/package.json")), Charsets.UTF_8);
ourLog.info("Package.json:\n{}", packageJsonContents); ourLog.info("Package.json:\n{}", packageJsonContents);
String expectedPackageJson = "{\n" + String expectedPackageJson = """
" \"name\": \"com.example.ig\",\n" + {
" \"version\": \"1.0.1\",\n" + "name" : "com.example.ig",
" \"fhirVersions\": [\n" + "version" : "1.0.1",
" \"4.0.1\"\n" + "description" : "",
" ]\n" + "fhirVersions" : ["4.0.1"]
"}"; }
assertEquals(expectedPackageJson, packageJsonContents); """;
assertEquals(expectedPackageJson.trim(), packageJsonContents.trim());
// Try parsing the module again to make sure we can // Try parsing the module again to make sure we can
NpmPackage loadedPackage = NpmPackage.fromPackage(new FileInputStream(igArchive)); NpmPackage loadedPackage = NpmPackage.fromPackage(new FileInputStream(igArchive));

View File

@ -27,12 +27,16 @@ import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt;
import ca.uhn.fhir.model.dstu2.composite.CodingDt; 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_40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50; 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_40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_50; 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_40_50;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_43_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_40;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50; 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_40;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50; import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_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.dstu2.model.Resource;
import org.hl7.fhir.instance.model.api.IBaseCoding; import org.hl7.fhir.instance.model.api.IBaseCoding;
import org.hl7.fhir.instance.model.api.IBaseDatatype; 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.IBaseResource;
import org.hl7.fhir.r4.model.CodeSystem; import org.hl7.fhir.r4.model.CodeSystem;
import org.hl7.fhir.r4.model.CodeableConcept; import org.hl7.fhir.r4.model.CodeableConcept;
import org.hl7.fhir.r4.model.Coding; import org.hl7.fhir.r4.model.Coding;
import org.hl7.fhir.r4.model.ConceptMap; 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.r4.model.ValueSet;
import org.hl7.fhir.r5.model.CapabilityStatement; import org.hl7.fhir.r5.model.CapabilityStatement;
import org.hl7.fhir.r5.model.SearchParameter; import org.hl7.fhir.r5.model.SearchParameter;
import org.hl7.fhir.r5.model.StructureDefinition;
import java.util.List; 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_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_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_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; private final IStrategy myStrategy;
public VersionCanonicalizer(FhirContext theTargetContext) { public VersionCanonicalizer(FhirContext theTargetContext) {
this(theTargetContext.getVersion().getVersion()); this(theTargetContext.getVersion().getVersion());
} }
@SuppressWarnings({"EnumSwitchStatementWhichMissesCases", "EnhancedSwitchMigration"}) @SuppressWarnings({"EnhancedSwitchMigration"})
public VersionCanonicalizer(FhirVersionEnum theTargetVersion) { public VersionCanonicalizer(FhirVersionEnum theTargetVersion) {
switch (theTargetVersion) { switch (theTargetVersion) {
case DSTU2: case DSTU2:
@ -86,6 +96,9 @@ public class VersionCanonicalizer {
case DSTU2_HL7ORG: case DSTU2_HL7ORG:
myStrategy = new Dstu2Strategy(true); myStrategy = new Dstu2Strategy(true);
break; break;
case DSTU2_1:
myStrategy = new Dstu21Strategy();
break;
case DSTU3: case DSTU3:
myStrategy = new Dstu3Strategy(); myStrategy = new Dstu3Strategy();
break; break;
@ -166,6 +179,39 @@ public class VersionCanonicalizer {
return myStrategy.searchParameterToCanonical(theSearchParameter); 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 { private interface IStrategy {
CapabilityStatement capabilityStatementToCanonical(IBaseResource theCapabilityStatement); CapabilityStatement capabilityStatementToCanonical(IBaseResource theCapabilityStatement);
@ -183,6 +229,20 @@ public class VersionCanonicalizer {
ConceptMap conceptMapToCanonical(IBaseResource theConceptMap); ConceptMap conceptMapToCanonical(IBaseResource theConceptMap);
SearchParameter searchParameterToCanonical(IBaseResource theSearchParameter); 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 { private static class Dstu2Strategy implements IStrategy {
@ -292,6 +352,48 @@ public class VersionCanonicalizer {
return retVal; 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) { private Resource reencodeToHl7Org(IBaseResource theInput) {
if (myHl7OrgStructures) { if (myHl7OrgStructures) {
return (Resource) theInput; 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 { private static class Dstu3Strategy implements IStrategy {
@Override @Override
@ -349,6 +529,41 @@ public class VersionCanonicalizer {
public SearchParameter searchParameterToCanonical(IBaseResource theSearchParameter) { public SearchParameter searchParameterToCanonical(IBaseResource theSearchParameter) {
return (SearchParameter) VersionConvertorFactory_30_50.convertResource((org.hl7.fhir.dstu3.model.Resource) theSearchParameter, ADVISOR_30_50); 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 { 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); 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 { 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); 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; 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;
}
} }

View File

@ -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!"

View File

@ -10,6 +10,7 @@
<li>log4j-to-slf4j (JPA): 2.17.1 -> 2.19.0</li> <li>log4j-to-slf4j (JPA): 2.17.1 -> 2.19.0</li>
<li>Jetty (CLI): 9.4.48.v20220622 -> 10.0.12</li> <li>Jetty (CLI): 9.4.48.v20220622 -> 10.0.12</li>
<li>Spring Boot: 2.7.4 -> 2.7.5</li> <li>Spring Boot: 2.7.4 -> 2.7.5</li>
<li>Graphql-Java (OpenAPI): 17.4 -> 19.2</li>
</ul> </ul>
In addition the following dependencies have been replaced with newer equivalents: In addition the following dependencies have been replaced with newer equivalents:
<ul> <ul>

View File

@ -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");
}
}

View File

@ -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.IValidationSupport;
import ca.uhn.fhir.context.support.ValidationSupportContext; import ca.uhn.fhir.context.support.ValidationSupportContext;
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoStructureDefinition; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoStructureDefinition;
import ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao;
import org.apache.commons.lang3.Validate; 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; import org.springframework.beans.factory.annotation.Autowired;
/* /*
@ -28,14 +27,14 @@ import org.springframework.beans.factory.annotation.Autowired;
* #L% * #L%
*/ */
public class FhirResourceDaoStructureDefinitionR5 extends BaseHapiFhirResourceDao<StructureDefinition> implements IFhirResourceDaoStructureDefinition<StructureDefinition> { public class JpaResourceDaoStructureDefinition<T extends IBaseResource> extends BaseHapiFhirResourceDao<T> implements IFhirResourceDaoStructureDefinition<T> {
@Autowired @Autowired
private IValidationSupport myValidationSupport; private IValidationSupport myValidationSupport;
@Override @Override
public StructureDefinition generateSnapshot(StructureDefinition theInput, String theUrl, String theWebUrl, String theName) { public T generateSnapshot(T theInput, String theUrl, String theWebUrl, String theName) {
StructureDefinition output = (StructureDefinition) myValidationSupport.generateSnapshot(new ValidationSupportContext(myValidationSupport), theInput, theUrl, theWebUrl, theName); T output = (T) myValidationSupport.generateSnapshot(new ValidationSupportContext(myValidationSupport), theInput, theUrl, theWebUrl, theName);
Validate.notNull(output); Validate.notNull(output);
return output; return output;
} }

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -36,13 +36,17 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import graphql.ExecutionResult; import graphql.ExecutionResult;
import graphql.GraphQL; import graphql.GraphQL;
import graphql.language.InterfaceTypeDefinition;
import graphql.scalar.GraphqlStringCoercing; import graphql.scalar.GraphqlStringCoercing;
import graphql.schema.GraphQLScalarType; import graphql.schema.GraphQLScalarType;
import graphql.schema.GraphQLSchema; import graphql.schema.GraphQLSchema;
import graphql.schema.TypeResolver;
import graphql.schema.TypeResolverProxy;
import graphql.schema.idl.RuntimeWiring; import graphql.schema.idl.RuntimeWiring;
import graphql.schema.idl.SchemaGenerator; import graphql.schema.idl.SchemaGenerator;
import graphql.schema.idl.SchemaParser; import graphql.schema.idl.SchemaParser;
import graphql.schema.idl.TypeDefinitionRegistry; import graphql.schema.idl.TypeDefinitionRegistry;
import graphql.schema.idl.TypeRuntimeWiring;
import org.apache.commons.io.output.StringBuilderWriter; import org.apache.commons.io.output.StringBuilderWriter;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import org.hl7.fhir.common.hapi.validation.validator.VersionSpecificWorkerContextWrapper; import org.hl7.fhir.common.hapi.validation.validator.VersionSpecificWorkerContextWrapper;
@ -132,18 +136,36 @@ public class GraphQLProviderWithIntrospection extends GraphQLProvider {
final StringBuilder schemaBuilder = new StringBuilder(); final StringBuilder schemaBuilder = new StringBuilder();
try (Writer writer = new StringBuilderWriter(schemaBuilder)) { try (Writer writer = new StringBuilderWriter(schemaBuilder)) {
// Generate FHIR base types schemas // Generate FHIR base types schemas
myGenerator.generateTypes(writer, theOperations); myGenerator.generateTypes(writer, theOperations);
// Fix up a few things that are missing from the generated schema // Fix up a few things that are missing from the generated schema
writer writer
.append("\ntype Resource {") .append("\ninterface Element {")
.append("\n id: [token]" + "\n}") .append("\n id: ID")
.append("\n"); .append("\n}")
writer
.append("\ninput ResourceInput {")
.append("\n id: [token]" + "\n}")
.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 // Generate schemas for the resource types
for (String nextResourceType : theResourceTypes) { for (String nextResourceType : theResourceTypes) {
@ -195,6 +217,15 @@ public class GraphQLProviderWithIntrospection extends GraphQLProvider {
runtimeWiringBuilder.scalar(new GraphQLScalarType.Builder().name(next).coercing(new GraphqlStringCoercing()).build()); 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(); RuntimeWiring runtimeWiring = runtimeWiringBuilder.build();
GraphQLSchema graphQLSchema = schemaGenerator.makeExecutableSchema(typeDefinitionRegistry, runtimeWiring); GraphQLSchema graphQLSchema = schemaGenerator.makeExecutableSchema(typeDefinitionRegistry, runtimeWiring);

View File

@ -50,13 +50,14 @@ import ca.uhn.fhir.util.SearchParameterUtil;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonElement;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.IBase;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.instance.model.api.IPrimitiveType; import org.hl7.fhir.instance.model.api.IPrimitiveType;
import org.hl7.fhir.r4.model.Identifier; 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.IPackageCacheManager;
import org.hl7.fhir.utilities.npm.NpmPackage; import org.hl7.fhir.utilities.npm.NpmPackage;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -205,8 +206,8 @@ public class PackageInstallerSvcImpl implements IPackageInstallerSvc {
* @throws ImplementationGuideInstallationException if installation fails * @throws ImplementationGuideInstallationException if installation fails
*/ */
private void install(NpmPackage npmPackage, PackageInstallationSpec theInstallationSpec, PackageInstallOutcomeJson theOutcome) throws ImplementationGuideInstallationException { private void install(NpmPackage npmPackage, PackageInstallationSpec theInstallationSpec, PackageInstallOutcomeJson theOutcome) throws ImplementationGuideInstallationException {
String name = npmPackage.getNpm().get("name").getAsString(); String name = npmPackage.getNpm().get("name").asJsonString().getValue();
String version = npmPackage.getNpm().get("version").getAsString(); String version = npmPackage.getNpm().get("version").asJsonString().getValue();
String fhirVersion = npmPackage.fhirVersion(); String fhirVersion = npmPackage.fhirVersion();
String currentFhirVersion = myFhirContext.getVersion().getVersion().getFhirVersionString(); 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 { private void fetchAndInstallDependencies(NpmPackage npmPackage, PackageInstallationSpec theInstallationSpec, PackageInstallOutcomeJson theOutcome) throws ImplementationGuideInstallationException {
if (npmPackage.getNpm().has("dependencies")) { if (npmPackage.getNpm().has("dependencies")) {
JsonElement dependenciesElement = npmPackage.getNpm().get("dependencies"); JsonObject dependenciesElement = npmPackage.getNpm().get("dependencies").asJsonObject();
Map<String, String> dependencies = new Gson().fromJson(dependenciesElement, HashMap.class); for (String id : dependenciesElement.getNames()) {
for (Map.Entry<String, String> d : dependencies.entrySet()) { String ver = dependenciesElement.getJsonString(id).asString();
String id = d.getKey();
String ver = d.getValue();
try { try {
theOutcome.getMessage().add("Package " + npmPackage.id() + "#" + npmPackage.version() + " depends on package " + id + "#" + ver); theOutcome.getMessage().add("Package " + npmPackage.id() + "#" + npmPackage.version() + " depends on package " + id + "#" + ver);

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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> {
}

View File

@ -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;
}
}

View File

@ -20,12 +20,14 @@ package ca.uhn.fhir.jpa.term;
* #L% * #L%
*/ */
import ca.uhn.fhir.i18n.Msg;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.support.TranslateConceptResult; import ca.uhn.fhir.context.support.TranslateConceptResult;
import ca.uhn.fhir.context.support.TranslateConceptResults; 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.TranslationQuery;
import ca.uhn.fhir.jpa.api.model.TranslationRequest; 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.ITermConceptMapDao;
import ca.uhn.fhir.jpa.dao.data.ITermConceptMapGroupDao; import ca.uhn.fhir.jpa.dao.data.ITermConceptMapGroupDao;
import ca.uhn.fhir.jpa.dao.data.ITermConceptMapGroupElementDao; 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.term.api.ITermConceptMappingSvc;
import ca.uhn.fhir.jpa.util.MemoryCacheService; import ca.uhn.fhir.jpa.util.MemoryCacheService;
import ca.uhn.fhir.jpa.util.ScrollableResultsIterator; 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.InternalErrorException;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; 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.ScrollMode;
import org.hibernate.ScrollableResults; import org.hibernate.ScrollableResults;
import org.hl7.fhir.exceptions.FHIRException; 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.BooleanType;
import org.hl7.fhir.r4.model.CodeType; import org.hl7.fhir.r4.model.CodeType;
import org.hl7.fhir.r4.model.Coding; import org.hl7.fhir.r4.model.Coding;
@ -102,6 +106,8 @@ public class TermConceptMappingSvcImpl implements ITermConceptMappingSvc {
private FhirContext myContext; private FhirContext myContext;
@Autowired @Autowired
private MemoryCacheService myMemoryCacheService; private MemoryCacheService myMemoryCacheService;
@Autowired
private IIdHelperService myIdHelperService;
@Override @Override
@Transactional @Transactional
@ -328,14 +334,14 @@ public class TermConceptMappingSvcImpl implements ITermConceptMappingSvc {
} }
if (translationQuery.hasTargetSystem()) { 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()) { 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()) { if (translationQuery.hasConceptMapVersion()) {
// both url and conceptMapVersion // both url and conceptMapVersion
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myVersion"), translationQuery.getConceptMapVersion().getValueAsString())); predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myVersion"), translationQuery.getConceptMapVersion()));
} else { } else {
if (StringUtils.isNotBlank(latestConceptMapVersion)) { if (StringUtils.isNotBlank(latestConceptMapVersion)) {
// only url and use latestConceptMapVersion // only url and use latestConceptMapVersion
@ -347,15 +353,17 @@ public class TermConceptMappingSvcImpl implements ITermConceptMappingSvc {
} }
if (translationQuery.hasSource()) { 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()) { 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()) { 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])); Predicate outerPredicate = criteriaBuilder.and(predicates.toArray(new Predicate[0]));
@ -455,10 +463,10 @@ public class TermConceptMappingSvcImpl implements ITermConceptMappingSvc {
} }
if (translationQuery.hasUrl()) { 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()) { if (translationQuery.hasConceptMapVersion()) {
// both url and conceptMapVersion // both url and conceptMapVersion
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myVersion"), translationQuery.getConceptMapVersion().getValueAsString())); predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myVersion"), translationQuery.getConceptMapVersion()));
} else { } else {
if (StringUtils.isNotBlank(latestConceptMapVersion)) { if (StringUtils.isNotBlank(latestConceptMapVersion)) {
// only url and use latestConceptMapVersion // only url and use latestConceptMapVersion
@ -470,19 +478,21 @@ public class TermConceptMappingSvcImpl implements ITermConceptMappingSvc {
} }
if (translationQuery.hasTargetSystem()) { 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()) { 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()) { 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()) { 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])); Predicate outerPredicate = criteriaBuilder.and(predicates.toArray(new Predicate[0]));
@ -600,7 +610,7 @@ public class TermConceptMappingSvcImpl implements ITermConceptMappingSvc {
Pageable page = PageRequest.of(0, 1); Pageable page = PageRequest.of(0, 1);
List<TermConceptMap> theConceptMapList = myConceptMapDao.getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(page, List<TermConceptMap> theConceptMapList = myConceptMapDao.getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(page,
theTranslationRequest.getUrl().asStringValue()); theTranslationRequest.getUrl());
if (!theConceptMapList.isEmpty()) { if (!theConceptMapList.isEmpty()) {
return theConceptMapList.get(0).getVersion(); return theConceptMapList.get(0).getVersion();
} }

View File

@ -151,7 +151,7 @@ public class MdmControllerSvcImplTest extends BaseLinkR4Test {
ServletRequestDetails details = new ServletRequestDetails(); ServletRequestDetails details = new ServletRequestDetails();
details.setTenantId(PARTITION_2); details.setTenantId(PARTITION_2);
IBaseParameters clearJob = myMdmControllerSvc.submitMdmClearJob(urls, batchSize, details); 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); myBatch2JobHelper.awaitJobCompletion(jobId);
assertLinkCount(2); assertLinkCount(2);

View File

@ -307,16 +307,42 @@ public class FhirResourceDaoDstu2SearchNoFtTest extends BaseJpaDstu2Test {
@Test @Test
public void testIndexNoDuplicatesUri() { public void testIndexNoDuplicatesUri() {
ConceptMap res = new ConceptMap(); ConceptMap res = new ConceptMap();
res.addElement().addTarget().addDependsOn().setElement("http://foo"); res.setUrl("http://foo");
res.addElement().addTarget().addDependsOn().setElement("http://foo"); res.addElement()
res.addElement().addTarget().addDependsOn().setElement("http://bar"); .setCodeSystem("http://cs")
res.addElement().addTarget().addDependsOn().setElement("http://bar"); .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(); IIdType id = myConceptMapDao.create(res, mySrd).getId().toUnqualifiedVersionless();
runInTransaction(() -> { runInTransaction(() -> {
Class<ResourceIndexedSearchParamUri> type = ResourceIndexedSearchParamUri.class; 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)); ourLog.info(toStringMultiline(results));
assertEquals(2, results.size()); assertEquals(2, results.size());
}); });

View File

@ -49,7 +49,7 @@ public class FhirResourceDaoDstu3ConceptMapTest extends BaseJpaDstu3Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL) .setSystem(CS_URL)
.setCode("12345"); .setCode("12345");
translationRequest.setTargetSystem(new UriType(CS_URL_3)); translationRequest.setTargetSystem(CS_URL_3);
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null); TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
@ -73,7 +73,7 @@ public class FhirResourceDaoDstu3ConceptMapTest extends BaseJpaDstu3Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL) .setSystem(CS_URL)
.setCode("12345"); .setCode("12345");
translationRequest.setTargetSystem(new UriType(CS_URL_3)); translationRequest.setTargetSystem(CS_URL_3);
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null); TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);

View File

@ -29,6 +29,8 @@ import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; 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.assertEquals;
import static org.junit.jupiter.api.Assertions.fail; 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())); ourLog.info("Fail Outcome: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome()));
OperationOutcome oo = (OperationOutcome) 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"));
} }
} }

View File

@ -116,6 +116,7 @@ public class CompositionDocumentDstu3Test extends BaseResourceProviderDstu3Test
String theUrl = myServerBase + "/" + compId + "/$document?_format=json"; String theUrl = myServerBase + "/" + compId + "/$document?_format=json";
Bundle bundle = fetchBundle(theUrl, EncodingEnum.JSON); Bundle bundle = fetchBundle(theUrl, EncodingEnum.JSON);
ourLog.info("Resp: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle));
bundle.getEntry().stream() bundle.getEntry().stream()
.forEach(entry -> { .forEach(entry -> {
@ -123,7 +124,7 @@ public class CompositionDocumentDstu3Test extends BaseResourceProviderDstu3Test
}); });
assertThat(bundle.getType(), is(equalTo(Bundle.BundleType.DOCUMENT))); assertThat(bundle.getType(), is(equalTo(Bundle.BundleType.DOCUMENT)));
assertNull(bundle.getLink("next")); assertNull(bundle.getLinkOrCreate("next").getUrl());
Set<String> actual = new HashSet<>(); Set<String> actual = new HashSet<>();
for (BundleEntryComponent nextEntry : bundle.getEntry()) { for (BundleEntryComponent nextEntry : bundle.getEntry()) {

View File

@ -84,7 +84,7 @@ public class ResourceProviderQuestionnaireResponseDstu3Test extends BaseResource
myClient.create().resource(qr1).execute(); myClient.create().resource(qr1).execute();
fail(); fail();
} catch (UnprocessableEntityException e) { } 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"));
} }
} }

View File

@ -70,7 +70,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL) .setSystem(CS_URL)
.setCode("12345"); .setCode("12345");
translationRequest.setTargetSystem(new UriType(CS_URL_3)); translationRequest.setTargetSystem(CS_URL_3);
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null); TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
@ -94,7 +94,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL) .setSystem(CS_URL)
.setCode("12345"); .setCode("12345");
translationRequest.setTargetSystem(new UriType(CS_URL_3)); translationRequest.setTargetSystem(CS_URL_3);
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null); TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
@ -138,7 +138,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL) .setSystem(CS_URL)
.setCode("12345"); .setCode("12345");
translationRequest.setTargetSystem(new UriType(CS_URL_2)); translationRequest.setTargetSystem(CS_URL_2);
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null); TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
@ -173,7 +173,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL) .setSystem(CS_URL)
.setCode("BOGUS"); .setCode("BOGUS");
translationRequest.setTargetSystem(new UriType(CS_URL_3)); translationRequest.setTargetSystem(CS_URL_3);
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null); TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
@ -256,7 +256,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL) .setSystem(CS_URL)
.setCode("12345"); .setCode("12345");
translationRequest.setTargetSystem(new UriType(CS_URL_2)); translationRequest.setTargetSystem(CS_URL_2);
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null); TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
@ -295,7 +295,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL) .setSystem(CS_URL)
.setCode("12345"); .setCode("12345");
translationRequest.setTargetSystem(new UriType(CS_URL_3)); translationRequest.setTargetSystem(CS_URL_3);
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null); TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
@ -479,7 +479,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
TranslationRequest translationRequest = new TranslationRequest(); TranslationRequest translationRequest = new TranslationRequest();
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setCode("12345"); .setCode("12345");
translationRequest.setSource(new UriType(VS_URL)); translationRequest.setSource(VS_URL);
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null); TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
@ -532,7 +532,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
TranslationRequest translationRequest = new TranslationRequest(); TranslationRequest translationRequest = new TranslationRequest();
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setCode("12345"); .setCode("12345");
translationRequest.setTarget(new UriType(VS_URL_2)); translationRequest.setTarget(VS_URL_2);
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null); TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
@ -588,7 +588,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL_2) .setSystem(CS_URL_2)
.setCode("34567"); .setCode("34567");
translationRequest.setTargetSystem(new UriType(CS_URL_4)); translationRequest.setTargetSystem(CS_URL_4);
translationRequest.setReverse(true); translationRequest.setReverse(true);
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null); TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
@ -736,7 +736,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL_3) .setSystem(CS_URL_3)
.setCode("67890"); .setCode("67890");
translationRequest.setTargetSystem(new UriType(CS_URL)); translationRequest.setTargetSystem(CS_URL);
translationRequest.setReverse(true); translationRequest.setReverse(true);
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null); TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
@ -771,7 +771,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL_3) .setSystem(CS_URL_3)
.setCode("BOGUS"); .setCode("BOGUS");
translationRequest.setTargetSystem(new UriType(CS_URL)); translationRequest.setTargetSystem(CS_URL);
translationRequest.setReverse(true); translationRequest.setReverse(true);
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null); TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
@ -850,7 +850,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL_2) .setSystem(CS_URL_2)
.setCode("34567"); .setCode("34567");
translationRequest.setTargetSystem(new UriType(CS_URL)); translationRequest.setTargetSystem(CS_URL);
translationRequest.setReverse(true); translationRequest.setReverse(true);
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null); TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
@ -891,7 +891,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL_2) .setSystem(CS_URL_2)
.setCode("34567"); .setCode("34567");
translationRequest.setTargetSystem(new UriType(CS_URL_4)); translationRequest.setTargetSystem(CS_URL_4);
translationRequest.setReverse(true); translationRequest.setReverse(true);
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null); TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
@ -1026,7 +1026,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
TranslationRequest translationRequest = new TranslationRequest(); TranslationRequest translationRequest = new TranslationRequest();
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setCode("34567"); .setCode("34567");
translationRequest.setSource(new UriType(VS_URL_2)); translationRequest.setSource(VS_URL_2);
translationRequest.setReverse(true); translationRequest.setReverse(true);
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null); TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
@ -1073,7 +1073,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
TranslationRequest translationRequest = new TranslationRequest(); TranslationRequest translationRequest = new TranslationRequest();
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setCode("34567"); .setCode("34567");
translationRequest.setTarget(new UriType(VS_URL)); translationRequest.setTarget(VS_URL);
translationRequest.setReverse(true); translationRequest.setReverse(true);
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null); TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
@ -1122,7 +1122,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem("http://source") .setSystem("http://source")
.setCode("source1"); .setCode("source1");
translationRequest.setTarget(new UriType("http://target")); translationRequest.setTarget("http://target");
ourLog.info("*** About to translate"); ourLog.info("*** About to translate");
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null); TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
@ -1177,7 +1177,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem("http://source") .setSystem("http://source")
.setCode("source1"); .setCode("source1");
translationRequest.setTarget(new UriType("http://target")); translationRequest.setTarget("http://target");
ourLog.info("*** About to translate"); ourLog.info("*** About to translate");
TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null); TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
@ -1209,7 +1209,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
.setCode("263204007"); .setCode("263204007");
TranslationRequest request = new TranslationRequest(); TranslationRequest request = new TranslationRequest();
request.setCodeableConcept(sourceCode); 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); TranslateConceptResults outcome = myConceptMapDao.translate(request, mySrd);
assertEquals("S52.209A", outcome.getResults().get(0).getCode()); assertEquals("S52.209A", outcome.getResults().get(0).getCode());

View File

@ -151,7 +151,10 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test {
encoded = encode(oo); encoded = encode(oo);
ourLog.info(encoded); ourLog.info(encoded);
assertEquals(1, oo.getIssue().size(), 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); assertEquals(OperationOutcome.IssueSeverity.ERROR, oo.getIssueFirstRep().getSeverity(), encoded);
} }
@ -182,7 +185,10 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test {
encoded = encode(oo); encoded = encode(oo);
ourLog.info(encoded); ourLog.info(encoded);
assertEquals(1, oo.getIssue().size()); 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()); assertEquals(OperationOutcome.IssueSeverity.ERROR, oo.getIssueFirstRep().getSeverity());
} }
@ -216,9 +222,11 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test {
encoded = encode(oo); encoded = encode(oo);
ourLog.info(encoded); ourLog.info(encoded);
assertEquals(2, oo.getIssue().size()); 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(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()); assertEquals(OperationOutcome.IssueSeverity.ERROR, oo.getIssue().get(1).getSeverity());
} }
@ -257,9 +265,8 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test {
encoded = encode(oo); encoded = encode(oo);
ourLog.info(encoded); ourLog.info(encoded);
assertEquals(1, oo.getIssue().size()); assertEquals(1, oo.getIssue().size());
assertTrue(oo.getIssueFirstRep() assertThat(oo.getIssue().get(0).getDiagnostics(),
.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'") containsString("The code provided (http://cs#code99) is not in the value set"));
);
assertEquals(OperationOutcome.IssueSeverity.ERROR, oo.getIssueFirstRep().getSeverity()); assertEquals(OperationOutcome.IssueSeverity.ERROR, oo.getIssueFirstRep().getSeverity());
} }
@ -354,7 +361,12 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test {
encoded = encode(oo); encoded = encode(oo);
ourLog.info(encoded); ourLog.info(encoded);
assertEquals(1, oo.getIssue().size()); 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()); assertEquals(OperationOutcome.IssueSeverity.ERROR, oo.getIssueFirstRep().getSeverity());
} }
@ -520,7 +532,8 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test {
outcome = (OperationOutcome) e.getOperationOutcome(); outcome = (OperationOutcome) e.getOperationOutcome();
String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome);
ourLog.info("Validation outcome: {}", outcomeStr); 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 // 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(); outcome = (OperationOutcome) e.getOperationOutcome();
String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome); String outcomeStr = myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome);
ourLog.info("Validation outcome: {}", outcomeStr); 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) { } catch (PreconditionFailedException e) {
outcome = (OperationOutcome) e.getOperationOutcome(); outcome = (OperationOutcome) e.getOperationOutcome();
ourLog.info("Outcome: {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome)); 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()); 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 // It would be ok for this to produce 0 issues, or just an information message too
assertEquals(1, OperationOutcomeUtil.getIssueCount(myFhirContext, oo)); 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)"));
} }

View File

@ -386,7 +386,8 @@ public class RepositoryValidatingInterceptorR4Test extends BaseJpaR4Test {
fail(); fail();
} catch (PreconditionFailedException e) { } catch (PreconditionFailedException e) {
OperationOutcome oo = (OperationOutcome) e.getOperationOutcome(); 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"));
} }
} }

View File

@ -89,9 +89,9 @@ public class PartitionManagementProviderTest {
verify(myPartitionConfigSvc, times(1)).createPartition(any()); verify(myPartitionConfigSvc, times(1)).createPartition(any());
verifyNoMoreInteractions(myPartitionConfigSvc); verifyNoMoreInteractions(myPartitionConfigSvc);
assertEquals(123, ((IntegerType) response.getParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_ID)).getValue().intValue()); assertEquals(123, ((IntegerType) response.getParameterValue(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_ID)).getValue().intValue());
assertEquals("PARTITION-123", ((StringType) response.getParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_NAME)).getValue()); assertEquals("PARTITION-123", ((StringType) response.getParameterValue(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_NAME)).getValue());
assertEquals("a description", ((StringType) response.getParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_DESC)).getValue()); assertEquals("a description", ((StringType) response.getParameterValue(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_DESC)).getValue());
} }
@Nonnull @Nonnull
@ -141,9 +141,9 @@ public class PartitionManagementProviderTest {
verify(myPartitionConfigSvc, times(1)).getPartitionById(any()); verify(myPartitionConfigSvc, times(1)).getPartitionById(any());
verifyNoMoreInteractions(myPartitionConfigSvc); verifyNoMoreInteractions(myPartitionConfigSvc);
assertEquals(123, ((IntegerType) response.getParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_ID)).getValue().intValue()); assertEquals(123, ((IntegerType) response.getParameterValue(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_ID)).getValue().intValue());
assertEquals("PARTITION-123", ((StringType) response.getParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_NAME)).getValue()); assertEquals("PARTITION-123", ((StringType) response.getParameterValue(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_NAME)).getValue());
assertEquals("a description", ((StringType) response.getParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_DESC)).getValue()); assertEquals("a description", ((StringType) response.getParameterValue(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_DESC)).getValue());
} }
@Test @Test
@ -182,9 +182,9 @@ public class PartitionManagementProviderTest {
verify(myPartitionConfigSvc, times(1)).updatePartition(any()); verify(myPartitionConfigSvc, times(1)).updatePartition(any());
verifyNoMoreInteractions(myPartitionConfigSvc); verifyNoMoreInteractions(myPartitionConfigSvc);
assertEquals(123, ((IntegerType) response.getParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_ID)).getValue().intValue()); assertEquals(123, ((IntegerType) response.getParameterValue(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_ID)).getValue().intValue());
assertEquals("PARTITION-123", ((StringType) response.getParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_NAME)).getValue()); assertEquals("PARTITION-123", ((StringType) response.getParameterValue(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_NAME)).getValue());
assertEquals("a description", ((StringType) response.getParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_DESC)).getValue()); assertEquals("a description", ((StringType) response.getParameterValue(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_DESC)).getValue());
} }
@Test @Test

View File

@ -152,7 +152,7 @@ public class MultitenantBatchOperationR4Test extends BaseMultitenantResourceProv
.withParameters(input) .withParameters(input)
.execute(); .execute();
ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); 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()); myBatch2JobHelper.awaitJobCompletion(jobId.getValue());
@ -176,7 +176,7 @@ public class MultitenantBatchOperationR4Test extends BaseMultitenantResourceProv
.withParameters(input) .withParameters(input)
.execute(); .execute();
ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); 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()); myBatch2JobHelper.awaitJobCompletion(jobId.getValue());
@ -219,7 +219,7 @@ public class MultitenantBatchOperationR4Test extends BaseMultitenantResourceProv
.withParameters(input) .withParameters(input)
.execute(); .execute();
ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); 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()); myBatch2JobHelper.awaitJobCompletion(jobId.getValue());

View File

@ -100,7 +100,7 @@ public class RemoteTerminologyServiceResourceProviderR4Test {
assertEquals(CODE, myCodeSystemProvider.myLastCode.getCode()); assertEquals(CODE, myCodeSystemProvider.myLastCode.getCode());
assertEquals(DISPLAY, myCodeSystemProvider.myLastDisplay.getValue()); assertEquals(DISPLAY, myCodeSystemProvider.myLastDisplay.getValue());
assertEquals(CODE_SYSTEM, myCodeSystemProvider.myLastUrl.getValueAsString()); assertEquals(CODE_SYSTEM, myCodeSystemProvider.myLastUrl.getValueAsString());
assertEquals(SAMPLE_MESSAGE, myCodeSystemProvider.myNextReturnParams.getParameter("message").toString()); assertEquals(SAMPLE_MESSAGE, myCodeSystemProvider.myNextReturnParams.getParameterValue("message").toString());
} }
@Test @Test
@ -112,7 +112,7 @@ public class RemoteTerminologyServiceResourceProviderR4Test {
assertEquals(IValidationSupport.IssueSeverity.ERROR, outcome.getSeverity()); assertEquals(IValidationSupport.IssueSeverity.ERROR, outcome.getSeverity());
assertEquals(SAMPLE_MESSAGE, outcome.getMessage()); assertEquals(SAMPLE_MESSAGE, outcome.getMessage());
assertEquals(false, ((BooleanType)myCodeSystemProvider.myNextReturnParams.getParameter("result")).booleanValue()); assertEquals(false, ((BooleanType)myCodeSystemProvider.myNextReturnParams.getParameterValue("result")).booleanValue());
} }
@Test @Test
@ -143,7 +143,7 @@ public class RemoteTerminologyServiceResourceProviderR4Test {
assertEquals(CODE, myValueSetProvider.myLastCode.getCode()); assertEquals(CODE, myValueSetProvider.myLastCode.getCode());
assertEquals(DISPLAY, myValueSetProvider.myLastDisplay.getValue()); assertEquals(DISPLAY, myValueSetProvider.myLastDisplay.getValue());
assertEquals(VALUE_SET_URL, myValueSetProvider.myLastUrl.getValueAsString()); 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) { private void createNextCodeSystemReturnParameters(boolean theResult, String theDisplay, String theMessage) {

View File

@ -118,7 +118,7 @@ public class ResourceProviderQuestionnaireResponseR4Test extends BaseResourcePro
myClient.create().resource(qr1).execute(); myClient.create().resource(qr1).execute();
fail(); fail();
} catch (UnprocessableEntityException e) { } 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"));
} }
} }

View File

@ -2,6 +2,10 @@ package ca.uhn.fhir.jpa.provider.r4;
import ca.uhn.fhir.jpa.provider.BaseResourceProviderR4Test; import ca.uhn.fhir.jpa.provider.BaseResourceProviderR4Test;
import ca.uhn.fhir.rest.api.MethodOutcome; 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.instance.model.api.IIdType;
import org.hl7.fhir.r4.model.BooleanType; import org.hl7.fhir.r4.model.BooleanType;
import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.Bundle;
@ -24,7 +28,10 @@ import org.slf4j.LoggerFactory;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.io.IOException; 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.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertNull;
@ -1958,4 +1965,43 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
part = getPartByName(param, "source"); part = getPartByName(param, "source");
assertEquals(CM_URL, ((UriType) part.getValue()).getValueAsString()); 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));
}
} }

View File

@ -110,8 +110,8 @@ public class ResourceProviderR4RemoteTerminologyTest extends BaseResourceProvide
String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
ourLog.info(resp); ourLog.info(resp);
assertEquals(true, ((BooleanType)respParam.getParameter("result")).booleanValue()); assertEquals(true, ((BooleanType)respParam.getParameterValue("result")).booleanValue());
assertEquals(DISPLAY, respParam.getParameter("display").toString()); assertEquals(DISPLAY, respParam.getParameterValue("display").toString());
} }
@Test @Test
@ -135,8 +135,8 @@ public class ResourceProviderR4RemoteTerminologyTest extends BaseResourceProvide
String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
ourLog.info(resp); ourLog.info(resp);
assertEquals(true, ((BooleanType)respParam.getParameter("result")).booleanValue()); assertEquals(true, ((BooleanType)respParam.getParameterValue("result")).booleanValue());
assertEquals(DISPLAY, respParam.getParameter("display").toString()); assertEquals(DISPLAY, respParam.getParameterValue("display").toString());
} }
@Test @Test
@ -159,8 +159,8 @@ public class ResourceProviderR4RemoteTerminologyTest extends BaseResourceProvide
String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam); String resp = myFhirContext.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
ourLog.info(resp); ourLog.info(resp);
assertEquals(true, ((BooleanType)respParam.getParameter("result")).booleanValue()); assertEquals(true, ((BooleanType)respParam.getParameterValue("result")).booleanValue());
assertEquals(DISPLAY_BODY_MASS_INDEX, respParam.getParameter("display").toString()); assertEquals(DISPLAY_BODY_MASS_INDEX, respParam.getParameterValue("display").toString());
} }
private void createNextCodeSystemReturnParameters(boolean theResult, String theDisplay, String theMessage) { private void createNextCodeSystemReturnParameters(boolean theResult, String theDisplay, String theMessage) {

View File

@ -6864,7 +6864,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
ourLog.info(resp); ourLog.info(resp);
assertEquals(412, response.getStatusLine().getStatusCode()); 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 { } finally {
response.getEntity().getContent().close(); response.getEntity().getContent().close();
response.close(); response.close();

View File

@ -1400,7 +1400,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv
.named(ProviderConstants.OPERATION_INVALIDATE_EXPANSION) .named(ProviderConstants.OPERATION_INVALIDATE_EXPANSION)
.withNoParameters(Parameters.class) .withNoParameters(Parameters.class)
.execute(); .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())); 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) .named(ProviderConstants.OPERATION_INVALIDATE_EXPANSION)
.withNoParameters(Parameters.class) .withNoParameters(Parameters.class)
.execute(); .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 @Test

View File

@ -17,6 +17,7 @@ import org.hl7.fhir.r4.model.CodeableConcept;
import org.hl7.fhir.r4.model.Coding; import org.hl7.fhir.r4.model.Coding;
import org.hl7.fhir.r4.model.ConceptMap; import org.hl7.fhir.r4.model.ConceptMap;
import org.hl7.fhir.r4.model.Enumerations; 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.StringType;
import org.hl7.fhir.r4.model.UriType; import org.hl7.fhir.r4.model.UriType;
import org.hl7.fhir.r4.model.codesystems.HttpVerb; import org.hl7.fhir.r4.model.codesystems.HttpVerb;
@ -83,7 +84,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL) .setSystem(CS_URL)
.setCode("12345"); .setCode("12345");
translationRequest.setTargetSystem(new UriType(CS_URL_3)); translationRequest.setTargetSystem(CS_URL_3);
List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults(); List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults();
assertNotNull(targets); assertNotNull(targets);
@ -137,7 +138,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL) .setSystem(CS_URL)
.setCode("12345"); .setCode("12345");
translationRequest.setTargetSystem(new UriType(CS_URL_2)); translationRequest.setTargetSystem(CS_URL_2);
List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults(); List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults();
assertNotNull(targets); assertNotNull(targets);
@ -179,7 +180,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL) .setSystem(CS_URL)
.setCode("BOGUS"); .setCode("BOGUS");
translationRequest.setTargetSystem(new UriType(CS_URL_3)); translationRequest.setTargetSystem(CS_URL_3);
List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults(); List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults();
assertNotNull(targets); assertNotNull(targets);
@ -211,7 +212,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
TranslationRequest translationRequest = new TranslationRequest() TranslationRequest translationRequest = new TranslationRequest()
.addCode(CS_URL, "12345") .addCode(CS_URL, "12345")
.setTargetSystem(new UriType(CS_URL_2)); .setTargetSystem(CS_URL_2);
TranslateConceptResults resp = myConceptMappingSvc.translate(translationRequest); TranslateConceptResults resp = myConceptMappingSvc.translate(translationRequest);
assertEquals(1, resp.size()); assertEquals(1, resp.size());
@ -306,7 +307,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL) .setSystem(CS_URL)
.setCode("12345"); .setCode("12345");
translationRequest.setTargetSystem(new UriType(CS_URL_2)); translationRequest.setTargetSystem(CS_URL_2);
List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults(); List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults();
assertNotNull(targets); assertNotNull(targets);
@ -354,7 +355,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL) .setSystem(CS_URL)
.setCode("12345"); .setCode("12345");
translationRequest.setTargetSystem(new UriType(CS_URL_3)); translationRequest.setTargetSystem(CS_URL_3);
List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults(); List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults();
assertNotNull(targets); assertNotNull(targets);
@ -590,7 +591,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
TranslationRequest translationRequest = new TranslationRequest(); TranslationRequest translationRequest = new TranslationRequest();
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setCode("12345"); .setCode("12345");
translationRequest.setSource(new UriType(VS_URL)); translationRequest.setSource(VS_URL);
List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults(); List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults();
assertNotNull(targets); assertNotNull(targets);
@ -660,7 +661,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
TranslationRequest translationRequest = new TranslationRequest(); TranslationRequest translationRequest = new TranslationRequest();
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setCode("12345"); .setCode("12345");
translationRequest.setTarget(new UriType(VS_URL_2)); translationRequest.setTarget(VS_URL_2);
List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults(); List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults();
assertNotNull(targets); assertNotNull(targets);
@ -733,7 +734,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL_2) .setSystem(CS_URL_2)
.setCode("34567"); .setCode("34567");
translationRequest.setTargetSystem(new UriType(CS_URL_4)); translationRequest.setTargetSystem(CS_URL_4);
translationRequest.setReverse(true); translationRequest.setReverse(true);
TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest); TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest);
@ -775,7 +776,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL_3) .setSystem(CS_URL_3)
.setCode("BOGUS"); .setCode("BOGUS");
translationRequest.setTargetSystem(new UriType(CS_URL)); translationRequest.setTargetSystem(CS_URL);
TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest); TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest);
assertNotNull(elements); assertNotNull(elements);
@ -861,7 +862,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL_2) .setSystem(CS_URL_2)
.setCode("34567"); .setCode("34567");
translationRequest.setTargetSystem(new UriType(CS_URL)); translationRequest.setTargetSystem(CS_URL);
translationRequest.setReverse(true); translationRequest.setReverse(true);
TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest); TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest);
@ -910,7 +911,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL_2) .setSystem(CS_URL_2)
.setCode("34567"); .setCode("34567");
translationRequest.setTargetSystem(new UriType(CS_URL_4)); translationRequest.setTargetSystem(CS_URL_4);
translationRequest.setReverse(true); translationRequest.setReverse(true);
TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest); TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest);
@ -1075,7 +1076,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
TranslationRequest translationRequest = new TranslationRequest(); TranslationRequest translationRequest = new TranslationRequest();
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setCode("34567"); .setCode("34567");
translationRequest.setSource(new UriType(VS_URL_2)); translationRequest.setSource(VS_URL_2);
translationRequest.setReverse(true); translationRequest.setReverse(true);
TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest); TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest);
@ -1133,7 +1134,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
TranslationRequest translationRequest = new TranslationRequest(); TranslationRequest translationRequest = new TranslationRequest();
translationRequest.getCodeableConcept().addCoding() translationRequest.getCodeableConcept().addCoding()
.setCode("34567"); .setCode("34567");
translationRequest.setTarget(new UriType(VS_URL)); translationRequest.setTarget(VS_URL);
translationRequest.setReverse(true); translationRequest.setReverse(true);
TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest); TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest);
@ -1570,7 +1571,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
"theConceptMapVersion", "theConceptMapVersion",
"theSourceValueSetUrl", "theSourceValueSetUrl",
"theTargetValueSetUrl", "theTargetValueSetUrl",
0L, new IdType("ConceptMap/2"),
false false
); );
@ -1582,12 +1583,12 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
TranslationRequest expected = new TranslationRequest(); TranslationRequest expected = new TranslationRequest();
expected.setCodeableConcept(sourceCodeableConcept); expected.setCodeableConcept(sourceCodeableConcept);
expected.setConceptMapVersion(new StringType(theRequest.getConceptMapVersion())); expected.setConceptMapVersion((theRequest.getConceptMapVersion()));
expected.setUrl(new UriType(theRequest.getConceptMapUrl())); expected.setUrl((theRequest.getConceptMapUrl()));
expected.setSource(new UriType(theRequest.getSourceValueSetUrl())); expected.setSource((theRequest.getSourceValueSetUrl()));
expected.setTarget(new UriType(theRequest.getTargetValueSetUrl())); expected.setTarget((theRequest.getTargetValueSetUrl()));
expected.setTargetSystem(new UriType(theRequest.getTargetSystemUrl())); expected.setTargetSystem((theRequest.getTargetSystemUrl()));
expected.setResourceId(theRequest.getResourcePid()); expected.setResourceId(theRequest.getResourceId());
expected.setReverse(theRequest.isReverse()); expected.setReverse(theRequest.isReverse());
ITermConceptMappingSvc mock = mock(TermConceptMappingSvcImpl.class); ITermConceptMappingSvc mock = mock(TermConceptMappingSvcImpl.class);
@ -1612,7 +1613,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
"theConceptMapVersion", "theConceptMapVersion",
"theSourceValueSetUrl", "theSourceValueSetUrl",
"theTargetValueSetUrl", "theTargetValueSetUrl",
0L, new IdType("ConceptMap/A"),
true true
); );
@ -1624,12 +1625,12 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
TranslationRequest expected = new TranslationRequest(); TranslationRequest expected = new TranslationRequest();
expected.setCodeableConcept(sourceCodeableConcept); expected.setCodeableConcept(sourceCodeableConcept);
expected.setConceptMapVersion(new StringType(theRequest.getConceptMapVersion())); expected.setConceptMapVersion((theRequest.getConceptMapVersion()));
expected.setUrl(new UriType(theRequest.getConceptMapUrl())); expected.setUrl((theRequest.getConceptMapUrl()));
expected.setSource(new UriType(theRequest.getSourceValueSetUrl())); expected.setSource((theRequest.getSourceValueSetUrl()));
expected.setTarget(new UriType(theRequest.getTargetValueSetUrl())); expected.setTarget((theRequest.getTargetValueSetUrl()));
expected.setTargetSystem(new UriType(theRequest.getTargetSystemUrl())); expected.setTargetSystem((theRequest.getTargetSystemUrl()));
expected.setResourceId(theRequest.getResourcePid()); expected.setResourceId(theRequest.getResourceId());
expected.setReverse(theRequest.isReverse()); expected.setReverse(theRequest.isReverse());
ITermConceptMappingSvc mock = mock(TermConceptMappingSvcImpl.class); ITermConceptMappingSvc mock = mock(TermConceptMappingSvcImpl.class);
@ -1643,11 +1644,11 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
private static void assertSameTranslationRequest(TranslationRequest expected, TranslationRequest actual) { private static void assertSameTranslationRequest(TranslationRequest expected, TranslationRequest actual) {
assertTrue(expected.getCodeableConcept().equalsDeep(actual.getCodeableConcept())); assertTrue(expected.getCodeableConcept().equalsDeep(actual.getCodeableConcept()));
assertEquals(expected.getConceptMapVersion().asStringValue(), actual.getConceptMapVersion().asStringValue()); assertEquals(expected.getConceptMapVersion(), actual.getConceptMapVersion());
assertEquals(expected.getUrl().asStringValue(), actual.getUrl().asStringValue()); assertEquals(expected.getUrl(), actual.getUrl());
assertEquals(expected.getSource().asStringValue(), actual.getSource().asStringValue()); assertEquals(expected.getSource(), actual.getSource());
assertEquals(expected.getTarget().asStringValue(), actual.getTarget().asStringValue()); assertEquals(expected.getTarget(), actual.getTarget());
assertEquals(expected.getTargetSystem().asStringValue(), actual.getTargetSystem().asStringValue()); assertEquals(expected.getTargetSystem(), actual.getTargetSystem());
assertEquals(expected.getResourceId(), actual.getResourceId()); assertEquals(expected.getResourceId(), actual.getResourceId());
assertEquals(expected.getReverseAsBoolean(), actual.getReverseAsBoolean()); assertEquals(expected.getReverseAsBoolean(), actual.getReverseAsBoolean());
} }

View File

@ -492,8 +492,8 @@ public class TerminologySvcDeltaR4Test extends BaseJpaR4Test {
Parameters output = (Parameters) result.toParameters(myFhirContext, null); Parameters output = (Parameters) result.toParameters(myFhirContext, null);
ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output)); ourLog.info(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output));
assertEquals("Description of my life", ((StringType) output.getParameter("name")).getValue()); assertEquals("Description of my life", ((StringType) output.getParameterValue("name")).getValue());
assertEquals("1.2.3", ((StringType) output.getParameter("version")).getValue()); assertEquals("1.2.3", ((StringType) output.getParameterValue("version")).getValue());
assertEquals(false, output.getParameterBool("abstract")); assertEquals(false, output.getParameterBool("abstract"));
List<Parameters.ParametersParameterComponent> designations = output.getParameter().stream().filter(t -> t.getName().equals("designation")).collect(Collectors.toList()); List<Parameters.ParametersParameterComponent> designations = output.getParameter().stream().filter(t -> t.getName().equals("designation")).collect(Collectors.toList());

View File

@ -112,7 +112,7 @@ public class ReindexProviderTest {
// Verify // Verify
ourLog.info(myCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); 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()); assertEquals(TEST_JOB_ID, jobId.getValue());
verify(myJobCoordinator, times(1)).startInstance(myStartRequestCaptor.capture()); verify(myJobCoordinator, times(1)).startInstance(myStartRequestCaptor.capture());
@ -144,7 +144,7 @@ public class ReindexProviderTest {
// Verify // Verify
ourLog.info(myCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); 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()); assertEquals(TEST_JOB_ID, jobId.getValue());
verify(myJobCoordinator, times(1)).startInstance(myStartRequestCaptor.capture()); verify(myJobCoordinator, times(1)).startInstance(myStartRequestCaptor.capture());

View File

@ -22,18 +22,19 @@ package ca.uhn.fhir.jpa.api.model;
import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder; 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.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 { public class TranslationQuery {
private Coding myCoding; private Coding myCoding;
private Long myResourceId; private IIdType myResourceId;
private UriType myUrl; private String myUrl;
private StringType myConceptMapVersion; private String myConceptMapVersion;
private UriType mySource; private String mySource;
private UriType myTarget; private String myTarget;
private UriType myTargetSystem; private String myTargetSystem;
public TranslationQuery() { public TranslationQuery() {
super(); super();
@ -53,71 +54,71 @@ public class TranslationQuery {
return myResourceId != null; return myResourceId != null;
} }
public Long getResourceId() { public IIdType getResourceId() {
return myResourceId; return myResourceId;
} }
public void setResourceId(Long theResourceId) { public void setResourceId(IIdType theResourceId) {
myResourceId = theResourceId; myResourceId = theResourceId;
} }
public boolean hasUrl() { public boolean hasUrl() {
return myUrl != null && myUrl.hasValue(); return isNotBlank(myUrl);
} }
public UriType getUrl() { public String getUrl() {
return myUrl; return myUrl;
} }
public void setUrl(UriType theUrl) { public void setUrl(String theUrl) {
myUrl = theUrl; myUrl = theUrl;
} }
public boolean hasConceptMapVersion() { public boolean hasConceptMapVersion() {
return myConceptMapVersion != null && myConceptMapVersion.hasValue(); return isNotBlank(myConceptMapVersion);
} }
public StringType getConceptMapVersion() { public String getConceptMapVersion() {
return myConceptMapVersion; return myConceptMapVersion;
} }
public void setConceptMapVersion(StringType theConceptMapVersion) { public void setConceptMapVersion(String theConceptMapVersion) {
myConceptMapVersion = theConceptMapVersion; myConceptMapVersion = theConceptMapVersion;
} }
public boolean hasSource() { public boolean hasSource() {
return mySource != null && mySource.hasValue(); return isNotBlank(mySource);
} }
public UriType getSource() { public String getSource() {
return mySource; return mySource;
} }
public void setSource(UriType theSource) { public void setSource(String theSource) {
mySource = theSource; mySource = theSource;
} }
public boolean hasTarget() { public boolean hasTarget() {
return myTarget != null && myTarget.hasValue(); return isNotBlank(myTarget);
} }
public UriType getTarget() { public String getTarget() {
return myTarget; return myTarget;
} }
public void setTarget(UriType theTarget) { public void setTarget(String theTarget) {
myTarget = theTarget; myTarget = theTarget;
} }
public boolean hasTargetSystem() { public boolean hasTargetSystem() {
return myTargetSystem != null && myTargetSystem.hasValue(); return isNotBlank(myTargetSystem);
} }
public UriType getTargetSystem() { public String getTargetSystem() {
return myTargetSystem; return myTargetSystem;
} }
public void setTargetSystem(UriType theTargetSystem) { public void setTargetSystem(String theTargetSystem) {
myTargetSystem = theTargetSystem; myTargetSystem = theTargetSystem;
} }

View File

@ -23,25 +23,25 @@ package ca.uhn.fhir.jpa.api.model;
import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.IValidationSupport;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import org.hl7.fhir.instance.model.api.IBaseCoding; 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.CodeableConcept;
import org.hl7.fhir.r4.model.Coding; 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.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
public class TranslationRequest { public class TranslationRequest {
private CodeableConcept myCodeableConcept; private CodeableConcept myCodeableConcept;
private Long myResourceId; private IIdType myResourceId;
private BooleanType myReverse; private Boolean myReverse;
private UriType myUrl; private String myUrl;
private StringType myConceptMapVersion; private String myConceptMapVersion;
private UriType mySource; private String mySource;
private UriType myTarget; private String myTarget;
private UriType myTargetSystem; private String myTargetSystem;
public TranslationRequest() { public TranslationRequest() {
super(); super();
@ -72,75 +72,71 @@ public class TranslationRequest {
return this; return this;
} }
public Long getResourceId() { public IIdType getResourceId() {
return myResourceId; return myResourceId;
} }
public void setResourceId(Long theResourceId) { public void setResourceId(IIdType theResourceId) {
myResourceId = theResourceId; myResourceId = theResourceId;
} }
public BooleanType getReverse() { public Boolean getReverse() {
return myReverse; return myReverse;
} }
public void setReverse(BooleanType theReverse) { public void setReverse(Boolean theReverse) {
myReverse = theReverse; myReverse = theReverse;
} }
public void setReverse(boolean theReverse) {
myReverse = new BooleanType(theReverse);
}
public boolean getReverseAsBoolean() { public boolean getReverseAsBoolean() {
if (hasReverse()) { if (hasReverse()) {
return myReverse.booleanValue(); return myReverse;
} }
return false; return false;
} }
public UriType getUrl() { public String getUrl() {
return myUrl; return myUrl;
} }
public TranslationRequest setUrl(UriType theUrl) { public TranslationRequest setUrl(String theUrl) {
myUrl = theUrl; myUrl = theUrl;
return this; return this;
} }
public StringType getConceptMapVersion() { public String getConceptMapVersion() {
return myConceptMapVersion; return myConceptMapVersion;
} }
public TranslationRequest setConceptMapVersion(StringType theConceptMapVersion) { public TranslationRequest setConceptMapVersion(String theConceptMapVersion) {
myConceptMapVersion = theConceptMapVersion; myConceptMapVersion = theConceptMapVersion;
return this; return this;
} }
public UriType getSource() { public String getSource() {
return mySource; return mySource;
} }
public TranslationRequest setSource(UriType theSource) { public TranslationRequest setSource(String theSource) {
mySource = theSource; mySource = theSource;
return this; return this;
} }
public UriType getTarget() { public String getTarget() {
return myTarget; return myTarget;
} }
public TranslationRequest setTarget(UriType theTarget) { public TranslationRequest setTarget(String theTarget) {
myTarget = theTarget; myTarget = theTarget;
return this; return this;
} }
public UriType getTargetSystem() { public String getTargetSystem() {
return myTargetSystem; return myTargetSystem;
} }
public TranslationRequest setTargetSystem(UriType theTargetSystem) { public TranslationRequest setTargetSystem(String theTargetSystem) {
myTargetSystem = theTargetSystem; myTargetSystem = theTargetSystem;
return this; return this;
} }
@ -193,33 +189,33 @@ public class TranslationRequest {
} }
public boolean hasUrl() { public boolean hasUrl() {
return myUrl != null && myUrl.hasValue(); return isNotBlank(myUrl);
} }
public boolean hasConceptMapVersion() { public boolean hasConceptMapVersion() {
return myConceptMapVersion != null && myConceptMapVersion.hasValue(); return isNotBlank(myConceptMapVersion);
} }
public boolean hasSource() { public boolean hasSource() {
return mySource != null && mySource.hasValue(); return isNotBlank(mySource);
} }
public boolean hasTarget() { public boolean hasTarget() {
return myTarget != null && myTarget.hasValue(); return isNotBlank(myTarget);
} }
public boolean hasTargetSystem() { public boolean hasTargetSystem() {
return myTargetSystem != null && myTargetSystem.hasValue(); return isNotBlank(myTargetSystem);
} }
public IValidationSupport.TranslateCodeRequest asTranslateCodeRequest() { public IValidationSupport.TranslateCodeRequest asTranslateCodeRequest() {
return new IValidationSupport.TranslateCodeRequest( return new IValidationSupport.TranslateCodeRequest(
Collections.unmodifiableList(this.getCodeableConcept().getCoding()), Collections.unmodifiableList(this.getCodeableConcept().getCoding()),
this.getTargetSystem() != null ? this.getTargetSystem().asStringValue() : null, this.getTargetSystem(),
this.getUrl() != null ? this.getUrl().asStringValue() : null, this.getUrl(),
this.getConceptMapVersion() != null ? this.getConceptMapVersion().asStringValue() : null, this.getConceptMapVersion(),
this.getSource() != null ? this.getSource().asStringValue() : null, this.getSource(),
this.getTarget() != null ? this.getTarget().asStringValue() : null, this.getTarget(),
this.getResourceId(), this.getResourceId(),
this.getReverseAsBoolean() this.getReverseAsBoolean()
); );
@ -237,12 +233,12 @@ public class TranslationRequest {
TranslationRequest translationRequest = new TranslationRequest(); TranslationRequest translationRequest = new TranslationRequest();
translationRequest.setCodeableConcept(sourceCodeableConcept); translationRequest.setCodeableConcept(sourceCodeableConcept);
translationRequest.setConceptMapVersion(new StringType(theRequest.getConceptMapVersion())); translationRequest.setConceptMapVersion(theRequest.getConceptMapVersion());
translationRequest.setUrl(new UriType(theRequest.getConceptMapUrl())); translationRequest.setUrl(theRequest.getConceptMapUrl());
translationRequest.setSource(new UriType(theRequest.getSourceValueSetUrl())); translationRequest.setSource(theRequest.getSourceValueSetUrl());
translationRequest.setTarget(new UriType(theRequest.getTargetValueSetUrl())); translationRequest.setTarget(theRequest.getTargetValueSetUrl());
translationRequest.setTargetSystem(new UriType(theRequest.getTargetSystemUrl())); translationRequest.setTargetSystem(theRequest.getTargetSystemUrl());
translationRequest.setResourceId(theRequest.getResourcePid()); translationRequest.setResourceId(theRequest.getResourceId());
translationRequest.setReverse(theRequest.isReverse()); translationRequest.setReverse(theRequest.isReverse());
return translationRequest; return translationRequest;

View File

@ -11,13 +11,13 @@ public class BatchHelperR4 {
@Nonnull @Nonnull
public static Long jobIdFromParameters(Parameters response) { 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(); return jobIdDecimal.getValue().longValue();
} }
@Nonnull @Nonnull
public static String jobIdFromBatch2Parameters(Parameters response) { 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(); return jobIdString.getValue();
} }
} }

View File

@ -15,6 +15,7 @@ import org.fhir.ucum.UcumService;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.TerminologyServiceException; import org.hl7.fhir.exceptions.TerminologyServiceException;
import org.hl7.fhir.r5.context.IWorkerContext; 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.IParser;
import org.hl7.fhir.r5.formats.ParserType; import org.hl7.fhir.r5.formats.ParserType;
import org.hl7.fhir.r5.model.CanonicalResource; import org.hl7.fhir.r5.model.CanonicalResource;
@ -73,16 +74,6 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext
setValidationMessageLanguage(getLocale()); setValidationMessageLanguage(getLocale());
} }
@Override
public List<StructureDefinition> allStructures() {
return myValidationSupport.fetchAllStructureDefinitions();
}
@Override
public List<StructureDefinition> getStructures() {
return allStructures();
}
@Override @Override
public CodeSystem fetchCodeSystem(String theSystem) { public CodeSystem fetchCodeSystem(String theSystem) {
if (myValidationSupport == null) { 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 @Override
public List<String> getResourceNames() { public List<String> getResourceNames() {
@ -131,26 +103,12 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext
return result; return result;
} }
@Override
public IParser newJsonParser() {
throw new UnsupportedOperationException(Msg.code(205));
}
@Override @Override
public IResourceValidator newValidator() { public IResourceValidator newValidator() {
throw new UnsupportedOperationException(Msg.code(206)); 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 @Override
public Map<String, NamingSystem> getNSUrlMap() { public Map<String, NamingSystem> getNSUrlMap() {
throw new UnsupportedOperationException(Msg.code(2107)); 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); 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 @Override
public Parameters getExpansionParameters() { public Parameters getExpansionParameters() {
@ -271,12 +214,6 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext
myExpansionProfile = theExpParameters; myExpansionProfile = theExpParameters;
} }
@Override
@CoverageIgnore
public boolean hasCache() {
throw new UnsupportedOperationException(Msg.code(211));
}
@Override @Override
public ValueSetExpander.ValueSetExpansionOutcome expandVS(ValueSet theSource, boolean theCacheOk, boolean theHierarchical) { public ValueSetExpander.ValueSetExpansionOutcome expandVS(ValueSet theSource, boolean theCacheOk, boolean theHierarchical) {
throw new UnsupportedOperationException(Msg.code(2128)); throw new UnsupportedOperationException(Msg.code(2128));
@ -316,10 +253,6 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext
return myCtx.getVersion().getVersion().getFhirVersionString(); return myCtx.getVersion().getVersion().getFhirVersionString();
} }
@Override
public String getSpecUrl() {
throw new UnsupportedOperationException(Msg.code(215));
}
@Override @Override
public UcumService getUcumService() { public UcumService getUcumService() {
@ -346,40 +279,13 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext
throw new UnsupportedOperationException(Msg.code(219)); 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 @Override
public StructureDefinition fetchTypeDefinition(String typeName) { public StructureDefinition fetchTypeDefinition(String typeName) {
return fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/" + 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 @Override
public <T extends org.hl7.fhir.r5.model.Resource> T fetchResource(Class<T> theClass, String theUri) { 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(); return myCtx.getResourceTypes();
} }
@Override
public List<String> getCanonicalResourceNames() {
throw new UnsupportedOperationException(Msg.code(2113));
}
@Override @Override
public ValueSetExpander.ValueSetExpansionOutcome expandVS(ElementDefinitionBindingComponent theBinding, boolean theCacheOk, boolean theHierarchical) throws FHIRException { 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 @Override
public Set<String> getBinaryKeysAsSet() { public Set<String> getBinaryKeysAsSet() {
@ -518,16 +416,10 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext
} }
@Override @Override
public IPackageLoadingTracker getPackageTracker() { public IWorkerContextManager.IPackageLoadingTracker getPackageTracker() {
throw new UnsupportedOperationException(Msg.code(2112)); throw new UnsupportedOperationException(Msg.code(2112));
} }
@Override
public IWorkerContext setPackageTracker(
IPackageLoadingTracker packageTracker) {
return null;
}
@Override @Override
public PackageVersion getPackageForUrl(String s) { public PackageVersion getPackageForUrl(String s) {
return null; return null;
@ -541,4 +433,18 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext
return retVal; 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));
}
} }

View File

@ -1,12 +1,13 @@
package org.hl7.fhir.common.hapi.validation.support; 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.ConfigurationException;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.support.ConceptValidationOptions; import ca.uhn.fhir.context.support.ConceptValidationOptions;
import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.IValidationSupport;
import ca.uhn.fhir.context.support.ValidationSupportContext; import ca.uhn.fhir.context.support.ValidationSupportContext;
import ca.uhn.fhir.i18n.Msg;
import ca.uhn.fhir.util.ClasspathUtil; import ca.uhn.fhir.util.ClasspathUtil;
import ca.uhn.hapi.converters.canonical.VersionCanonicalizer;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode; 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.apache.commons.lang3.Validate;
import org.fhir.ucum.UcumEssenceService; import org.fhir.ucum.UcumEssenceService;
import org.fhir.ucum.UcumException; 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_30_40;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50; import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; 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.defaultString;
import static org.apache.commons.lang3.StringUtils.isBlank; import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank; 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 * 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_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 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 final Logger ourLog = LoggerFactory.getLogger(CommonCodeSystemsTerminologyService.class);
private static Map<String, String> USPS_CODES = Collections.unmodifiableMap(buildUspsCodes()); private static final Map<String, String> USPS_CODES = Collections.unmodifiableMap(buildUspsCodes());
private static Map<String, String> ISO_4217_CODES = Collections.unmodifiableMap(buildIso4217Codes()); private static final 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> ISO_3166_CODES = Collections.unmodifiableMap(buildIso3166Codes());
private final FhirContext myFhirContext; private final FhirContext myFhirContext;
private final VersionSpecificWorkerContextWrapper.IVersionTypeConverter myVersionConverter; private final VersionCanonicalizer myVersionCanonicalizer;
private volatile org.hl7.fhir.r5.model.ValueSet myLanguagesVs; private volatile org.hl7.fhir.r5.model.ValueSet myLanguagesVs;
private volatile Map<String, String> myLanguagesLanugageMap; private volatile Map<String, String> myLanguagesLanugageMap;
private volatile Map<String, String> myLanguagesRegionMap; private volatile Map<String, String> myLanguagesRegionMap;
@ -78,7 +77,7 @@ public class CommonCodeSystemsTerminologyService implements IValidationSupport {
Validate.notNull(theFhirContext); Validate.notNull(theFhirContext);
myFhirContext = theFhirContext; myFhirContext = theFhirContext;
myVersionConverter = newVersionTypeConverter(myFhirContext.getVersion().getVersion()); myVersionCanonicalizer = new VersionCanonicalizer(theFhirContext);
} }
@Override @Override
@ -117,7 +116,7 @@ public class CommonCodeSystemsTerminologyService implements IValidationSupport {
IBaseResource languagesVs = myLanguagesVs; IBaseResource languagesVs = myLanguagesVs;
if (languagesVs == null) { if (languagesVs == null) {
languagesVs = theValidationSupportContext.getRootValidationSupport().fetchValueSet("http://hl7.org/fhir/ValueSet/languages"); 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 Optional<org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent> match = myLanguagesVs
.getCompose() .getCompose()
@ -288,12 +287,14 @@ public class CommonCodeSystemsTerminologyService implements IValidationSupport {
} }
} }
} }
private LookupCodeResult buildLookupResultForLanguageAndRegion(@Nonnull String theOriginalCode, @Nonnull String theLanguage, @Nonnull String theRegion) { private LookupCodeResult buildLookupResultForLanguageAndRegion(@Nonnull String theOriginalCode, @Nonnull String theLanguage, @Nonnull String theRegion) {
LookupCodeResult lookupCodeResult = buildNotFoundLookupCodeResult(theOriginalCode); LookupCodeResult lookupCodeResult = buildNotFoundLookupCodeResult(theOriginalCode);
lookupCodeResult.setCodeDisplay(theLanguage + " " + theRegion); lookupCodeResult.setCodeDisplay(theLanguage + " " + theRegion);
lookupCodeResult.setFound(true); lookupCodeResult.setFound(true);
return lookupCodeResult; return lookupCodeResult;
} }
private LookupCodeResult buildLookupResultForLanguage(@Nonnull String theOriginalCode, @Nonnull String theLanguage) { private LookupCodeResult buildLookupResultForLanguage(@Nonnull String theOriginalCode, @Nonnull String theLanguage) {
LookupCodeResult lookupCodeResult = buildNotFoundLookupCodeResult(theOriginalCode); LookupCodeResult lookupCodeResult = buildNotFoundLookupCodeResult(theOriginalCode);
lookupCodeResult.setCodeDisplay(theLanguage); lookupCodeResult.setCodeDisplay(theLanguage);

View File

@ -1,18 +1,17 @@
package org.hl7.fhir.common.hapi.validation.support; 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.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.IValidationSupport;
import ca.uhn.fhir.context.support.ValidationSupportContext; 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.BaseServerResponseException;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException; import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
import ca.uhn.hapi.converters.canonical.VersionCanonicalizer;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import org.hl7.fhir.common.hapi.validation.validator.ProfileKnowledgeWorkerR5; 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.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.instance.model.api.IBaseResource;
import org.hl7.fhir.r5.conformance.ProfileUtilities; import org.hl7.fhir.r5.conformance.ProfileUtilities;
import org.hl7.fhir.r5.context.IWorkerContext; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import static org.apache.commons.lang3.StringUtils.isBlank; 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 { public class SnapshotGeneratingValidationSupport implements IValidationSupport {
private static final Logger ourLog = LoggerFactory.getLogger(SnapshotGeneratingValidationSupport.class); private static final Logger ourLog = LoggerFactory.getLogger(SnapshotGeneratingValidationSupport.class);
private final FhirContext myCtx; private final FhirContext myCtx;
private final VersionCanonicalizer myVersionCanonicalizer;
/** /**
* Constructor * Constructor
@ -45,8 +44,10 @@ public class SnapshotGeneratingValidationSupport implements IValidationSupport {
public SnapshotGeneratingValidationSupport(FhirContext theCtx) { public SnapshotGeneratingValidationSupport(FhirContext theCtx) {
Validate.notNull(theCtx); Validate.notNull(theCtx);
myCtx = theCtx; myCtx = theCtx;
myVersionCanonicalizer = new VersionCanonicalizer(theCtx);
} }
@SuppressWarnings("EnumSwitchStatementWhichMissesCases")
@Override @Override
public IBaseResource generateSnapshot(ValidationSupportContext theValidationSupportContext, IBaseResource theInput, String theUrl, String theWebUrl, String theProfileName) { 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(); FhirVersionEnum version = theInput.getStructureFhirVersionEnum();
assert version == myCtx.getVersion().getVersion(); assert version == myCtx.getVersion().getVersion();
VersionSpecificWorkerContextWrapper.IVersionTypeConverter converter = newVersionTypeConverter(version); org.hl7.fhir.r5.model.StructureDefinition inputCanonical = myVersionCanonicalizer.structureDefinitionToCanonical(theInput);
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);
inputUrl = inputCanonical.getUrl(); inputUrl = inputCanonical.getUrl();
if (theValidationSupportContext.getCurrentlyGeneratingSnapshots().contains(inputUrl)) { if (theValidationSupportContext.getCurrentlyGeneratingSnapshots().contains(inputUrl)) {
@ -77,33 +75,33 @@ public class SnapshotGeneratingValidationSupport implements IValidationSupport {
throw new PreconditionFailedException(Msg.code(705) + "Unknown base definition: " + baseDefinition); 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 (baseCanonical.getSnapshot().getElement().isEmpty()) {
// If the base definition also doesn't have a snapshot, generate that first // If the base definition also doesn't have a snapshot, generate that first
theValidationSupportContext.getRootValidationSupport().generateSnapshot(theValidationSupportContext, base, null, null, null); 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<>(); ArrayList<ValidationMessage> messages = new ArrayList<>();
org.hl7.fhir.r5.conformance.ProfileUtilities.ProfileKnowledgeProvider profileKnowledgeProvider = new ProfileKnowledgeWorkerR5(myCtx); 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 profileUtilities = new ProfileUtilities(context, messages, profileKnowledgeProvider);
profileUtilities.generateSnapshot(baseCanonical, inputCanonical, theUrl, theWebUrl, theProfileName); profileUtilities.generateSnapshot(baseCanonical, inputCanonical, theUrl, theWebUrl, theProfileName);
switch (version) { switch (version) {
case DSTU3: 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().clear();
((org.hl7.fhir.dstu3.model.StructureDefinition) theInput).getSnapshot().getElement().addAll(generatedDstu3.getSnapshot().getElement()); ((org.hl7.fhir.dstu3.model.StructureDefinition) theInput).getSnapshot().getElement().addAll(generatedDstu3.getSnapshot().getElement());
break; break;
case R4: 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().clear();
((org.hl7.fhir.r4.model.StructureDefinition) theInput).getSnapshot().getElement().addAll(generatedR4.getSnapshot().getElement()); ((org.hl7.fhir.r4.model.StructureDefinition) theInput).getSnapshot().getElement().addAll(generatedR4.getSnapshot().getElement());
break; break;
case R5: 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().clear();
((org.hl7.fhir.r5.model.StructureDefinition) theInput).getSnapshot().getElement().addAll(generatedR5.getSnapshot().getElement()); ((org.hl7.fhir.r5.model.StructureDefinition) theInput).getSnapshot().getElement().addAll(generatedR5.getSnapshot().getElement());
break; break;
@ -132,27 +130,4 @@ public class SnapshotGeneratingValidationSupport implements IValidationSupport {
return myCtx; 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;
}
} }

View File

@ -25,6 +25,13 @@ public class ProfileKnowledgeWorkerR5 implements org.hl7.fhir.r5.conformance.Pro
return (def instanceof RuntimePrimitiveDatatypeDefinition) || (def instanceof RuntimeCompositeDatatypeDefinition); return (def instanceof RuntimePrimitiveDatatypeDefinition) || (def instanceof RuntimeCompositeDatatypeDefinition);
} }
@Override
public boolean isPrimitiveType(String typeSimple) {
BaseRuntimeElementDefinition<?> def = myCtx.getElementDefinition(typeSimple);
Validate.notNull(typeSimple);
return (def instanceof RuntimePrimitiveDatatypeDefinition);
}
@Override @Override
public boolean isResource(String typeSimple) { public boolean isResource(String typeSimple) {
BaseRuntimeElementDefinition<?> def = myCtx.getElementDefinition(typeSimple); BaseRuntimeElementDefinition<?> def = myCtx.getElementDefinition(typeSimple);

View File

@ -10,7 +10,6 @@ import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import org.apache.commons.codec.Charsets;
import org.apache.commons.io.input.ReaderInputStream; import org.apache.commons.io.input.ReaderInputStream;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.r5.context.IWorkerContext;
@ -32,6 +31,7 @@ import org.w3c.dom.NodeList;
import java.io.InputStream; import java.io.InputStream;
import java.io.StringReader; import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -137,9 +137,9 @@ class ValidatorWrapper {
List<ValidationMessage> messages = new ArrayList<>(); List<ValidationMessage> messages = new ArrayList<>();
List<StructureDefinition> profileUrls = new ArrayList<>(); List<StructureDefinition> profiles = new ArrayList<>();
for (String next : theValidationContext.getOptions().getProfiles()) { for (String nextProfileUrl : theValidationContext.getOptions().getProfiles()) {
fetchAndAddProfile(theWorkerContext, profileUrls, next); fetchAndAddProfile(theWorkerContext, profiles, nextProfileUrl, messages);
} }
String input = theValidationContext.getResourceAsString(); String input = theValidationContext.getResourceAsString();
@ -158,16 +158,16 @@ class ValidatorWrapper {
} }
// Determine if meta/profiles are present... // Determine if meta/profiles are present...
ArrayList<String> profiles = determineIfProfilesSpecified(document); ArrayList<String> profileUrls = determineIfProfilesSpecified(document);
for (String nextProfile : profiles) { for (String nextProfileUrl : profileUrls) {
fetchAndAddProfile(theWorkerContext, profileUrls, nextProfile); fetchAndAddProfile(theWorkerContext, profiles, nextProfileUrl, messages);
} }
String resourceAsString = theValidationContext.getResourceAsString(); 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; 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) { } else if (encoding == EncodingEnum.JSON) {
@ -178,19 +178,19 @@ class ValidatorWrapper {
if (meta != null) { if (meta != null) {
JsonElement profileElement = meta.get("profile"); JsonElement profileElement = meta.get("profile");
if (profileElement != null && profileElement.isJsonArray()) { if (profileElement != null && profileElement.isJsonArray()) {
JsonArray profiles = profileElement.getAsJsonArray(); JsonArray profilesArray = profileElement.getAsJsonArray();
for (JsonElement element : profiles) { for (JsonElement element : profilesArray) {
String nextProfile = element.getAsString(); String nextProfileUrl = element.getAsString();
fetchAndAddProfile(theWorkerContext, profileUrls, nextProfile); fetchAndAddProfile(theWorkerContext, profiles, nextProfileUrl, messages);
} }
} }
} }
String resourceAsString = theValidationContext.getResourceAsString(); 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; Manager.FhirFormat format = Manager.FhirFormat.JSON;
v.validate(null, messages, inputStream, format, profileUrls); v.validate(null, messages, inputStream, format, profiles);
} else { } else {
throw new IllegalArgumentException(Msg.code(649) + "Unknown encoding: " + encoding); throw new IllegalArgumentException(Msg.code(649) + "Unknown encoding: " + encoding);
@ -211,13 +211,12 @@ class ValidatorWrapper {
return messages; 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 { try {
StructureDefinition structureDefinition = theWorkerContext.fetchResource(StructureDefinition.class, theUrl);
// NOTE: We expect the following call to generate a snapshot if needed if (structureDefinition != null) {
StructureDefinition structureDefinition = theWorkerContext.fetchRawProfile(theUrl);
theProfileStructureDefinitions.add(structureDefinition); theProfileStructureDefinitions.add(structureDefinition);
}
} catch (FHIRException e) { } catch (FHIRException e) {
ourLog.debug("Failed to load profile: {}", theUrl); ourLog.debug("Failed to load profile: {}", theUrl);
} }

View File

@ -1,28 +1,24 @@
package org.hl7.fhir.common.hapi.validation.validator; 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.FhirVersionEnum;
import ca.uhn.fhir.context.support.ConceptValidationOptions; import ca.uhn.fhir.context.support.ConceptValidationOptions;
import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.IValidationSupport;
import ca.uhn.fhir.context.support.ValidationSupportContext; import ca.uhn.fhir.context.support.ValidationSupportContext;
import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.i18n.Msg;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; 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.CacheFactory;
import ca.uhn.fhir.sl.cache.LoadingCache; import ca.uhn.fhir.sl.cache.LoadingCache;
import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.system.HapiSystemProperties;
import ca.uhn.hapi.converters.canonical.VersionCanonicalizer;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.fhir.ucum.UcumService; 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.FHIRException;
import org.hl7.fhir.exceptions.TerminologyServiceException; import org.hl7.fhir.exceptions.TerminologyServiceException;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.formats.IParser; import org.hl7.fhir.r5.context.IWorkerContextManager;
import org.hl7.fhir.r5.formats.ParserType;
import org.hl7.fhir.r5.model.CanonicalResource; import org.hl7.fhir.r5.model.CanonicalResource;
import org.hl7.fhir.r5.model.CodeSystem; import org.hl7.fhir.r5.model.CodeSystem;
import org.hl7.fhir.r5.model.Coding; import org.hl7.fhir.r5.model.Coding;
@ -55,18 +51,16 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank; import static org.apache.commons.lang3.StringUtils.isNotBlank;
public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWorkerContext { 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 Logger ourLog = LoggerFactory.getLogger(VersionSpecificWorkerContextWrapper.class);
private static final FhirContext ourR5Context = FhirContext.forR5();
private final ValidationSupportContext myValidationSupportContext; private final ValidationSupportContext myValidationSupportContext;
private final IVersionTypeConverter myModelConverter; private final VersionCanonicalizer myVersionCanonicalizer;
private final LoadingCache<ResourceKey, IBaseResource> myFetchResourceCache; private final LoadingCache<ResourceKey, IBaseResource> myFetchResourceCache;
private volatile List<StructureDefinition> myAllStructures; private volatile List<StructureDefinition> myAllStructures;
private org.hl7.fhir.r5.model.Parameters myExpansionProfile; private org.hl7.fhir.r5.model.Parameters myExpansionProfile;
public VersionSpecificWorkerContextWrapper(ValidationSupportContext theValidationSupportContext, IVersionTypeConverter theModelConverter) { public VersionSpecificWorkerContextWrapper(ValidationSupportContext theValidationSupportContext, VersionCanonicalizer theVersionCanonicalizer) {
myValidationSupportContext = theValidationSupportContext; myValidationSupportContext = theValidationSupportContext;
myModelConverter = theModelConverter; myVersionCanonicalizer = theVersionCanonicalizer;
long timeoutMillis = HapiSystemProperties.getTestValidationResourceCachesMs(); long timeoutMillis = HapiSystemProperties.getTestValidationResourceCachesMs();
@ -88,7 +82,7 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
IBaseResource fetched = myValidationSupportContext.getRootValidationSupport().fetchResource(fetchResourceType, key.getUri()); IBaseResource fetched = myValidationSupportContext.getRootValidationSupport().fetchResource(fetchResourceType, key.getUri());
Resource canonical = myModelConverter.toCanonical(fetched); Resource canonical = myVersionCanonicalizer.resourceToValidatorCanonical(fetched);
if (canonical instanceof StructureDefinition) { if (canonical instanceof StructureDefinition) {
StructureDefinition canonicalSd = (StructureDefinition) canonical; StructureDefinition canonicalSd = (StructureDefinition) canonical;
@ -96,7 +90,7 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
ourLog.info("Generating snapshot for StructureDefinition: {}", canonicalSd.getUrl()); ourLog.info("Generating snapshot for StructureDefinition: {}", canonicalSd.getUrl());
fetched = myValidationSupportContext.getRootValidationSupport().generateSnapshot(theValidationSupportContext, fetched, "", null, ""); fetched = myValidationSupportContext.getRootValidationSupport().generateSnapshot(theValidationSupportContext, fetched, "", null, "");
Validate.isTrue(fetched != null, "StructureDefinition %s has no snapshot, and no snapshot generator is configured", key.getUri()); Validate.isTrue(fetched != null, "StructureDefinition %s has no snapshot, and no snapshot generator is configured", key.getUri());
canonical = myModelConverter.toCanonical(fetched); canonical = myVersionCanonicalizer.resourceToValidatorCanonical(fetched);
} }
} }
@ -106,16 +100,6 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
setValidationMessageLanguage(getLocale()); 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 @Override
public Set<String> getBinaryKeysAsSet() { public Set<String> getBinaryKeysAsSet() {
throw new UnsupportedOperationException(Msg.code(2118)); throw new UnsupportedOperationException(Msg.code(2118));
@ -177,13 +161,13 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
} }
@Override @Override
public IPackageLoadingTracker getPackageTracker() { public IWorkerContextManager.IPackageLoadingTracker getPackageTracker() {
throw new UnsupportedOperationException(Msg.code(2108)); throw new UnsupportedOperationException(Msg.code(2108));
} }
@Override @Override
public IWorkerContext setPackageTracker( public IWorkerContext setPackageTracker(
IPackageLoadingTracker packageTracker) { IWorkerContextManager.IPackageLoadingTracker packageTracker) {
throw new UnsupportedOperationException(Msg.code(2114)); throw new UnsupportedOperationException(Msg.code(2114));
} }
@ -192,27 +176,6 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
throw new UnsupportedOperationException(Msg.code(2109)); 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 @Override
public org.hl7.fhir.r5.model.Parameters getExpansionParameters() { public org.hl7.fhir.r5.model.Parameters getExpansionParameters() {
return myExpansionProfile; return myExpansionProfile;
@ -223,16 +186,15 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
myExpansionProfile = expParameters; myExpansionProfile = expParameters;
} }
@Override private List<StructureDefinition> allStructures() {
public List<StructureDefinition> allStructures() {
List<StructureDefinition> retVal = myAllStructures; List<StructureDefinition> retVal = myAllStructures;
if (retVal == null) { if (retVal == null) {
retVal = new ArrayList<>(); retVal = new ArrayList<>();
for (IBaseResource next : myValidationSupportContext.getRootValidationSupport().fetchAllStructureDefinitions()) { for (IBaseResource next : myValidationSupportContext.getRootValidationSupport().fetchAllStructureDefinitions()) {
try { try {
Resource converted = myModelConverter.toCanonical(next); StructureDefinition converted = myVersionCanonicalizer.structureDefinitionToCanonical(next);
retVal.add((StructureDefinition) converted); retVal.add(converted);
} catch (FHIRException e) { } catch (FHIRException e) {
throw new InternalErrorException(Msg.code(659) + e); throw new InternalErrorException(Msg.code(659) + e);
} }
@ -243,11 +205,6 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
return retVal; return retVal;
} }
@Override
public List<StructureDefinition> getStructures() {
return allStructures();
}
@Override @Override
public void cacheResource(Resource res) { 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) { public ValueSetExpander.ValueSetExpansionOutcome expandVS(org.hl7.fhir.r5.model.ValueSet source, boolean cacheOk, boolean Hierarchical) {
IBaseResource convertedSource; IBaseResource convertedSource;
try { try {
convertedSource = myModelConverter.fromCanonical(source); convertedSource = myVersionCanonicalizer.valueSetFromValidatorCanonical(source);
} catch (FHIRException e) { } catch (FHIRException e) {
throw new InternalErrorException(Msg.code(661) + 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; org.hl7.fhir.r5.model.ValueSet convertedResult = null;
if (expanded.getValueSet() != null) { if (expanded.getValueSet() != null) {
try { try {
convertedResult = (ValueSet) myModelConverter.toCanonical(expanded.getValueSet()); convertedResult = myVersionCanonicalizer.valueSetToValidatorCanonical(expanded.getValueSet());
} catch (FHIRException e) { } catch (FHIRException e) {
throw new InternalErrorException(Msg.code(662) + e); throw new InternalErrorException(Msg.code(662) + e);
} }
@ -340,7 +297,7 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
return null; return null;
} }
try { try {
return (org.hl7.fhir.r5.model.CodeSystem) myModelConverter.toCanonical(fetched); return (org.hl7.fhir.r5.model.CodeSystem) myVersionCanonicalizer.codeSystemToValidatorCanonical(fetched);
} catch (FHIRException e) { } catch (FHIRException e) {
throw new InternalErrorException(Msg.code(665) + e); throw new InternalErrorException(Msg.code(665) + e);
} }
@ -353,7 +310,7 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
return null; return null;
} }
try { try {
return (org.hl7.fhir.r5.model.CodeSystem) myModelConverter.toCanonical(fetched); return (org.hl7.fhir.r5.model.CodeSystem) myVersionCanonicalizer.codeSystemToValidatorCanonical(fetched);
} catch (FHIRException e) { } catch (FHIRException e) {
throw new InternalErrorException(Msg.code(1992) + 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)); 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 @Override
public List<String> getResourceNames() { public List<String> getResourceNames() {
return new ArrayList<>(myValidationSupportContext.getRootValidationSupport().getFhirContext().getResourceTypes()); return new ArrayList<>(myValidationSupportContext.getRootValidationSupport().getFhirContext().getResourceTypes());
@ -427,47 +364,11 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
return myValidationSupportContext.getRootValidationSupport().getFhirContext().getResourceTypes(); 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 @Override
public StructureDefinition fetchTypeDefinition(String typeName) { public StructureDefinition fetchTypeDefinition(String typeName) {
return fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/" + 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 @Override
public UcumService getUcumService() { public UcumService getUcumService() {
throw new UnsupportedOperationException(Msg.code(676)); throw new UnsupportedOperationException(Msg.code(676));
@ -483,16 +384,6 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
return myValidationSupportContext.getRootValidationSupport().getFhirContext().getVersion().getVersion().getFhirVersionString(); 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 @Override
public <T extends Resource> boolean hasResource(Class<T> class_, String uri) { public <T extends Resource> boolean hasResource(Class<T> class_, String uri) {
throw new UnsupportedOperationException(Msg.code(680)); throw new UnsupportedOperationException(Msg.code(680));
@ -508,31 +399,11 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
throw new UnsupportedOperationException(Msg.code(681)); 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 @Override
public IResourceValidator newValidator() { public IResourceValidator newValidator() {
throw new UnsupportedOperationException(Msg.code(684)); 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 @Override
public Map<String, NamingSystem> getNSUrlMap() { public Map<String, NamingSystem> getNSUrlMap() {
throw new UnsupportedOperationException(Msg.code(2111)); throw new UnsupportedOperationException(Msg.code(2111));
@ -575,7 +446,7 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
try { try {
if (theValueSet != null) { if (theValueSet != null) {
convertedVs = myModelConverter.fromCanonical(theValueSet); convertedVs = myVersionCanonicalizer.valueSetFromValidatorCanonical(theValueSet);
} }
} catch (FHIRException e) { } catch (FHIRException e) {
throw new InternalErrorException(Msg.code(689) + e); throw new InternalErrorException(Msg.code(689) + e);
@ -591,7 +462,7 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
IBaseResource convertedVs = null; IBaseResource convertedVs = null;
try { try {
if (theValueSet != null) { if (theValueSet != null) {
convertedVs = myModelConverter.fromCanonical(theValueSet); convertedVs = myVersionCanonicalizer.valueSetFromValidatorCanonical(theValueSet);
} }
} catch (FHIRException e) { } catch (FHIRException e) {
throw new InternalErrorException(Msg.code(690) + e); throw new InternalErrorException(Msg.code(690) + e);
@ -608,7 +479,7 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
try { try {
if (theValueSet != null) { if (theValueSet != null) {
convertedVs = myModelConverter.fromCanonical(theValueSet); convertedVs = myVersionCanonicalizer.valueSetFromValidatorCanonical(theValueSet);
} }
} catch (FHIRException e) { } catch (FHIRException e) {
throw new InternalErrorException(Msg.code(691) + e); throw new InternalErrorException(Msg.code(691) + e);
@ -662,12 +533,12 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
myFetchResourceCache.invalidateAll(); myFetchResourceCache.invalidateAll();
} }
public interface IVersionTypeConverter { @Override
public <T extends Resource> List<T> fetchResourcesByType(Class<T> theClass) {
org.hl7.fhir.r5.model.Resource toCanonical(IBaseResource theNonCanonical); if (theClass.equals(StructureDefinition.class)) {
return (List<T>) allStructures();
IBaseResource fromCanonical(org.hl7.fhir.r5.model.Resource theCanonical); }
throw new UnsupportedOperationException(Msg.code(650) + "Unable to fetch resources of type: " + theClass);
} }
private static class ResourceKey { 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) { public static ConceptValidationOptions convertConceptValidationOptions(ValidationOptions theOptions) {
ConceptValidationOptions retVal = new ConceptValidationOptions(); ConceptValidationOptions retVal = new ConceptValidationOptions();
if (theOptions.isGuessSystem()) { if (theOptions.isGuessSystem()) {
@ -738,65 +597,8 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
@Nonnull @Nonnull
public static VersionSpecificWorkerContextWrapper newVersionSpecificWorkerContextWrapper(IValidationSupport theValidationSupport) { public static VersionSpecificWorkerContextWrapper newVersionSpecificWorkerContextWrapper(IValidationSupport theValidationSupport) {
IVersionTypeConverter converter; VersionCanonicalizer versionCanonicalizer = new VersionCanonicalizer(theValidationSupport.getFhirContext());
return new VersionSpecificWorkerContextWrapper(new ValidationSupportContext(theValidationSupport), versionCanonicalizer);
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);
} }
} }

View File

@ -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);
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -127,8 +127,8 @@ public class RemoteTerminologyServiceValidationSupportTest {
assertEquals(CODE, myCodeSystemProvider.myLastCode.getCode()); assertEquals(CODE, myCodeSystemProvider.myLastCode.getCode());
assertEquals(CODE_SYSTEM, myCodeSystemProvider.myLastUrl.getValueAsString()); assertEquals(CODE_SYSTEM, myCodeSystemProvider.myLastUrl.getValueAsString());
assertEquals(CODE_SYSTEM_VERSION_AS_TEXT, myCodeSystemProvider.myNextReturnParams.getParameter("name").toString()); assertEquals(CODE_SYSTEM_VERSION_AS_TEXT, myCodeSystemProvider.myNextReturnParams.getParameterValue("name").toString());
assertTrue(Boolean.parseBoolean(myCodeSystemProvider.myNextReturnParams.getParameter("result").primitiveValue())); assertTrue(Boolean.parseBoolean(myCodeSystemProvider.myNextReturnParams.getParameterValue("result").primitiveValue()));
} }
@Test @Test
@ -141,11 +141,11 @@ public class RemoteTerminologyServiceValidationSupportTest {
assertNotNull(outcome, "Call to lookupCode() should return a non-NULL result!"); assertNotNull(outcome, "Call to lookupCode() should return a non-NULL result!");
assertEquals(DISPLAY, outcome.getCodeDisplay()); assertEquals(DISPLAY, outcome.getCodeDisplay());
assertEquals(CODE_SYSTEM_VERSION, outcome.getCodeSystemVersion()); 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, myCodeSystemProvider.myLastCode.getCode());
assertEquals(CODE_SYSTEM, myCodeSystemProvider.myLastUrl.getValueAsString()); assertEquals(CODE_SYSTEM, myCodeSystemProvider.myLastUrl.getValueAsString());
assertTrue(Boolean.parseBoolean(myCodeSystemProvider.myNextReturnParams.getParameter("result").primitiveValue())); assertTrue(Boolean.parseBoolean(myCodeSystemProvider.myNextReturnParams.getParameterValue("result").primitiveValue()));
validateExtraCodeSystemParams(); validateExtraCodeSystemParams();
} }

View File

@ -5,6 +5,7 @@ import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.IValidationSupport;
import ca.uhn.fhir.context.support.ValidationSupportContext; import ca.uhn.fhir.context.support.ValidationSupportContext;
import ca.uhn.fhir.i18n.HapiLocalizer; import ca.uhn.fhir.i18n.HapiLocalizer;
import ca.uhn.hapi.converters.canonical.VersionCanonicalizer;
import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.Resource;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -29,9 +30,9 @@ public class VersionSpecificWorkerContextWrapperTest {
IValidationSupport validationSupport = mockValidationSupportWithTwoBinaries(); IValidationSupport validationSupport = mockValidationSupportWithTwoBinaries();
ValidationSupportContext mockContext = mockValidationSupportContext(validationSupport); 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_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_2), "wrapper should have binary key " + EXPECTED_BINARY_KEY_1);
@ -45,9 +46,9 @@ public class VersionSpecificWorkerContextWrapperTest {
IValidationSupport validationSupport = mockValidationSupportWithTwoBinaries(); IValidationSupport validationSupport = mockValidationSupportWithTwoBinaries();
ValidationSupportContext mockContext = mockValidationSupportContext(validationSupport); 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_1, wrapper.getBinaryForKey(EXPECTED_BINARY_KEY_1));
assertArrayEquals(EXPECTED_BINARY_CONTENT_2, wrapper.getBinaryForKey(EXPECTED_BINARY_KEY_2)); assertArrayEquals(EXPECTED_BINARY_CONTENT_2, wrapper.getBinaryForKey(EXPECTED_BINARY_KEY_2));
@ -60,9 +61,9 @@ public class VersionSpecificWorkerContextWrapperTest {
IValidationSupport validationSupport = mockValidationSupport(); IValidationSupport validationSupport = mockValidationSupport();
ValidationSupportContext mockContext = mockValidationSupportContext(validationSupport); 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)); wrapper.cacheResource(mock(Resource.class));
} }

View File

@ -598,7 +598,7 @@ public class FhirInstanceValidatorDstu3Test {
List<SingleValidationMessage> issues = logResultsAndReturnNonInformationalOnes(output); List<SingleValidationMessage> issues = logResultsAndReturnNonInformationalOnes(output);
assertThat(issues.stream().map(SingleValidationMessage::getMessage).collect(Collectors.toList()).toString(), 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 @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")) { } else if (t.getMessage().contains("The valueSet reference http://www.rfc-editor.org/bcp/bcp13.txt on element")) {
return false; return false;
} else if (t.getMessage().contains("The Unicode sequence has unterminated bi-di control characters")) { } 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; return false;
} else { } else {
return true; return true;
@ -783,7 +786,7 @@ public class FhirInstanceValidatorDstu3Test {
Patient resource = loadResource("/dstu3/nl/nl-core-patient-01.json", Patient.class); Patient resource = loadResource("/dstu3/nl/nl-core-patient-01.json", Patient.class);
ValidationResult results = myVal.validateWithResult(resource); ValidationResult results = myVal.validateWithResult(resource);
List<SingleValidationMessage> outcome = logResultsAndReturnNonInformationalOnes(results); 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 { 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).getLocationString());
ourLog.info(output.getMessages().get(0).getMessage()); ourLog.info(output.getMessages().get(0).getMessage());
assertEquals("Patient", output.getMessages().get(0).getLocationString()); 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 @Test
@ -1185,9 +1188,10 @@ public class FhirInstanceValidatorDstu3Test {
ValidationResult output = myVal.validateWithResult(input); ValidationResult output = myVal.validateWithResult(input);
logResultsAndReturnAll(output); logResultsAndReturnAll(output);
assertEquals( assertThat(
"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(),
output.getMessages().get(0).getMessage()); containsString("The value provided ('notvalidcode') is not in the value set 'ObservationStatus'")
);
} }
@Test @Test
@ -1282,9 +1286,9 @@ public class FhirInstanceValidatorDstu3Test {
List<SingleValidationMessage> all = logResultsAndReturnAll(output); List<SingleValidationMessage> all = logResultsAndReturnAll(output);
assertEquals(1, all.size()); assertEquals(1, all.size());
assertEquals("Patient.identifier[0].type", all.get(0).getLocationString()); assertEquals("Patient.identifier[0].type", all.get(0).getLocationString());
assertEquals( assertThat(
"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(),
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()); assertEquals(ResultSeverityEnum.WARNING, all.get(0).getSeverity());
} }

View File

@ -211,7 +211,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
ValidationResult errors = myVal.validateWithResult(qa); ValidationResult errors = myVal.validateWithResult(qa);
ourLog.info(errors.toString()); 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 @Test

View File

@ -166,7 +166,7 @@ public class ResourceValidatorDstu3Test {
ValidationResult output = val.validateWithResult(p); ValidationResult output = val.validateWithResult(p);
List<SingleValidationMessage> all = logResultsAndReturnNonInformationalOnes(output); 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()); assertEquals(ResultSeverityEnum.WARNING, output.getMessages().get(0).getSeverity());
} }

View File

@ -44,8 +44,8 @@ public class CustomResourceGenerationTest extends BaseTest {
assertEquals(3, result.getMessages().size()); assertEquals(3, result.getMessages().size());
assertEquals("Error parsing JSON: the primitive value must be a boolean", result.getMessages().get(0).getMessage()); 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("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("Unrecognized property 'id1'", result.getMessages().get(2).getMessage());
} }

View File

@ -445,7 +445,7 @@ public class FhirInstanceValidatorR4Test extends BaseTest {
ValidationResult result = val.validateWithResult(operationDefinition); ValidationResult result = val.validateWithResult(operationDefinition);
List<SingleValidationMessage> all = logResultsAndReturnAll(result); List<SingleValidationMessage> all = logResultsAndReturnAll(result);
assertFalse(result.isSuccessful()); 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 @Test
@ -704,7 +704,7 @@ public class FhirInstanceValidatorR4Test extends BaseTest {
ValidationResult output = myFhirValidator.validateWithResult(input); ValidationResult output = myFhirValidator.validateWithResult(input);
List<SingleValidationMessage> errors = logResultsAndReturnAll(output); List<SingleValidationMessage> errors = logResultsAndReturnAll(output);
assertEquals(2, errors.size()); 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()); 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); ValidationResult output = myFhirValidator.validateWithResult(patient);
logResultsAndReturnNonInformationalOnes(output); 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 @Test
@ -930,13 +930,13 @@ public class FhirInstanceValidatorR4Test extends BaseTest {
ourLog.info(output.getMessages().get(0).getLocationString()); ourLog.info(output.getMessages().get(0).getLocationString());
ourLog.info(output.getMessages().get(0).getMessage()); ourLog.info(output.getMessages().get(0).getMessage());
assertEquals("Patient", output.getMessages().get(0).getLocationString()); 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(); OperationOutcome operationOutcome = (OperationOutcome) output.toOperationOutcome();
ourLog.info(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(operationOutcome)); 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("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 @Test
@ -1243,7 +1243,7 @@ public class FhirInstanceValidatorR4Test extends BaseTest {
ValidationResult output = myFhirValidator.validateWithResult(input); ValidationResult output = myFhirValidator.validateWithResult(input);
assertThat(output.getMessages().size(), greaterThan(0)); 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); List<SingleValidationMessage> all = logResultsAndReturnAll(output);
assertEquals(1, all.size()); assertEquals(1, all.size());
assertEquals("Patient.identifier[0].type", all.get(0).getLocationString()); 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()); assertEquals(ResultSeverityEnum.WARNING, all.get(0).getSeverity());
} }

View File

@ -187,7 +187,7 @@ public class QuestionnaireResponseValidatorR4Test {
ValidationResult errors = myVal.validateWithResult(qa); ValidationResult errors = myVal.validateWithResult(qa);
ourLog.info(errors.toString()); 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 @Test

View File

@ -505,7 +505,7 @@ public class FhirInstanceValidatorR5Test {
ourLog.info(output.getMessages().get(0).getLocationString()); ourLog.info(output.getMessages().get(0).getLocationString());
ourLog.info(output.getMessages().get(0).getMessage()); ourLog.info(output.getMessages().get(0).getMessage());
assertEquals("Patient", output.getMessages().get(0).getLocationString()); 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 @Test
@ -835,7 +835,7 @@ public class FhirInstanceValidatorR5Test {
ValidationResult output = myVal.validateWithResult(input); ValidationResult output = myVal.validateWithResult(input);
assertThat(output.getMessages().size(), greaterThan(0)); 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); List<SingleValidationMessage> all = logResultsAndReturnAll(output);
assertEquals(1, all.size()); assertEquals(1, all.size());
assertEquals("Patient.identifier[0].type", all.get(0).getLocationString()); assertEquals("Patient.identifier[0].type", all.get(0).getLocationString());
assertEquals( assertThat(
"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(),
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()); assertEquals(ResultSeverityEnum.WARNING, all.get(0).getSeverity());
} }

View File

@ -205,7 +205,7 @@ public class QuestionnaireResponseValidatorR5Test {
ValidationResult errors = myVal.validateWithResult(qa); ValidationResult errors = myVal.validateWithResult(qa);
ourLog.info(errors.toString()); 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 @Test

View File

@ -5,7 +5,6 @@ import java.util.*;
import org.apache.commons.lang3.StringUtils; 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.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.model.api.Include;
import ca.uhn.fhir.model.api.annotation.*; import ca.uhn.fhir.model.api.annotation.*;
@ -25,9 +24,9 @@ import ca.uhn.fhir.rest.api.SearchContainedModeEnum;
public class ${className}ResourceProvider extends public class ${className}ResourceProvider extends
## We have specialized base classes for RPs that handle certain resource types. These ## We have specialized base classes for RPs that handle certain resource types. These
## RPs implement type specific operations ## 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}> 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} BaseJpaResourceProvider${className}${versionCapitalized}
#else #else
ca.uhn.fhir.jpa.provider.BaseJpaResourceProvider<${className}> ca.uhn.fhir.jpa.provider.BaseJpaResourceProvider<${className}>

View File

@ -55,22 +55,17 @@ FhirContext myFhirContext;
#foreach ( $res in $resources ) #foreach ( $res in $resources )
@Bean(name="my${res.name}Dao${versionCapitalized}") @Bean(name="my${res.name}Dao${versionCapitalized}")
public public
#if ( (${versionCapitalized.startsWith('R')} || ${versionCapitalized} == 'Dstu3') && (${res.name} == 'ConceptMap') ) #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}<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' )
IFhirResourceDao${res.name}<${resourcePackage}.${res.declaringClassNameComplete}> IFhirResourceDao${res.name}<${resourcePackage}.${res.declaringClassNameComplete}>
#else #else
IFhirResourceDao<${resourcePackage}.${res.declaringClassNameComplete}> IFhirResourceDao<${resourcePackage}.${res.declaringClassNameComplete}>
#end #end
dao${res.declaringClassNameComplete}${versionCapitalized}() { 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; ca.uhn.fhir.jpa.dao.JpaResourceDao${res.name}<${resourcePackage}.${res.declaringClassNameComplete}> retVal;
retVal = new ca.uhn.fhir.jpa.dao.JpaResourceDao${res.name}<>(); retVal = new ca.uhn.fhir.jpa.dao.JpaResourceDao${res.name}<>();
#elseif ( (${versionCapitalized.startsWith('R')} || ${versionCapitalized} == 'Dstu3') && (${res.name} == 'ConceptMap') ) #elseif ( ${res.name} == 'Everything' || ${res.name} == 'Subscription')
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')
ca.uhn.fhir.jpa.dao${package_suffix}.FhirResourceDao${res.name}${versionCapitalized} retVal; 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}(); retVal = new ca.uhn.fhir.jpa.dao${package_suffix}.FhirResourceDao${res.name}${versionCapitalized}();
#else #else

View File

@ -845,7 +845,7 @@
<properties> <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> <ucum_version>1.0.3</ucum_version>
<surefire_jvm_args>-Dfile.encoding=UTF-8 -Xmx2048m</surefire_jvm_args> <surefire_jvm_args>-Dfile.encoding=UTF-8 -Xmx2048m</surefire_jvm_args>
@ -1028,7 +1028,7 @@
<dependency> <dependency>
<groupId>com.graphql-java</groupId> <groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId> <artifactId>graphql-java</artifactId>
<version>17.4</version> <version>19.2</version>
</dependency> </dependency>
<!-- mail start --> <!-- mail start -->
<dependency> <dependency>