Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import ca.uhn.fhir.rest.api.SummaryEnum;
import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.gclient.IQuery;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.util.BundleUtil;
import ca.uhn.fhir.util.ParametersUtil;
import jakarta.annotation.Nonnull;
Expand Down Expand Up @@ -315,7 +314,9 @@ private static BaseConceptProperty createBaseConceptPropertyDstu3(List<org.hl7.f
propertyName, coding.getSystem(), coding.getCode(), coding.getDisplay());
break;
default:
throw new InternalErrorException(Msg.code(2450) + "Property type " + fhirType + " is not supported.");
conceptProperty = new StringConceptProperty(propertyName, value.toString());
// throw new InternalErrorException(Msg.code(2450) + "Property type " + fhirType + " is not
// supported.");
}
return conceptProperty;
}
Expand Down Expand Up @@ -348,7 +349,9 @@ private static BaseConceptProperty createConceptPropertyDstu3(
new CodingConceptProperty(theName, coding.getSystem(), coding.getCode(), coding.getDisplay());
break;
default:
throw new InternalErrorException(Msg.code(2451) + "Property type " + fhirType + " is not supported.");
conceptProperty = new StringConceptProperty(theName, theValue.toString());
// throw new InternalErrorException(Msg.code(2451) + "Property type " + fhirType + " is not supportedis
// not supported.");
}
return conceptProperty;
}
Expand Down Expand Up @@ -448,7 +451,9 @@ private static BaseConceptProperty createBaseConceptPropertyR4(List<Base> values
propertyName, coding.getSystem(), coding.getCode(), coding.getDisplay());
break;
default:
throw new InternalErrorException(Msg.code(2452) + "Property type " + fhirType + " is not supported.");
conceptProperty = new StringConceptProperty(propertyName, value.toString());
// throw new InternalErrorException(Msg.code(2452) + "Property type " + fhirType + " is not
// supported.");
}
return conceptProperty;
}
Expand All @@ -468,7 +473,9 @@ private static BaseConceptProperty createConceptPropertyR4(final String theName,
new CodingConceptProperty(theName, coding.getSystem(), coding.getCode(), coding.getDisplay());
break;
default:
throw new InternalErrorException(Msg.code(2453) + "Property type " + fhirType + " is not supported.");
conceptProperty = new StringConceptProperty(theName, theValue.toString());
// throw new InternalErrorException(Msg.code(2453) + "Property type " + fhirType + " is not
// supported.");
}
return conceptProperty;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import org.hl7.fhir.common.hapi.validation.support.RemoteTerminologyServiceValidationSupport;
import org.hl7.fhir.instance.model.api.IBaseDatatype;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -49,6 +50,8 @@ interface ILookupCodeUnsupportedPropertyTypeTest extends IValidationTest {
@Override
IMySimpleCodeSystemProvider getCodeSystemProvider();

//TODO: workaround for unsupported types, enable this test when rest of the types are supported
@Disabled
@Test
default void testLookupCode_forCodeSystemWithPropertyInvalidValue_throwsException() {
// test and verify
Expand All @@ -60,6 +63,8 @@ default void testLookupCode_forCodeSystemWithPropertyInvalidValue_throwsExceptio
}
}

//TODO: workaround for unsupported types, enable this test when rest of the types are supported
@Disabled
@Test
default void testCreateConceptProperty_forCodeSystemWithPropertyInvalidValue_throwsException() {
// test and verify
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,24 @@
import org.hl7.fhir.dstu3.model.CodeSystem;
import org.hl7.fhir.dstu3.model.CodeType;
import org.hl7.fhir.dstu3.model.Coding;
import org.hl7.fhir.dstu3.model.IdType;
import org.hl7.fhir.dstu3.model.Parameters;
import org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent;
import org.hl7.fhir.dstu3.model.StringType;
import org.hl7.fhir.dstu3.model.Type;
import org.hl7.fhir.dstu3.model.UriType;
import org.hl7.fhir.instance.model.api.IBaseDatatype;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r4.model.DateTimeType;
import org.hl7.fhir.r4.model.DecimalType;
import org.hl7.fhir.r4.model.IntegerType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.provider.Arguments;

import java.util.Calendar;
import java.util.List;
import java.util.stream.Stream;

Expand Down Expand Up @@ -84,9 +89,8 @@ public String getInvalidValueErrorCodeForConvert() {

@BeforeEach
public void before() {
// TODO: use another type when "code" is added to the supported types
myMySimplePropertyCodeSystemProvider.myPropertyName = "somePropertyName";
myMySimplePropertyCodeSystemProvider.myPropertyValue = new CodeType("someCode");
myMySimplePropertyCodeSystemProvider.myPropertyValue = new IdType(123);
ourRestfulServerExtension.getRestfulServer().registerProvider(myMySimplePropertyCodeSystemProvider);
}
}
Expand Down Expand Up @@ -116,8 +120,13 @@ public void verifyProperty(BaseConceptProperty theConceptProperty, String theExp
String type = theConceptProperty.getType();
switch (type) {
case IValidationSupport.TYPE_STRING -> {
assertTrue(theExpectedValue instanceof StringType);
StringType stringValue = (StringType) theExpectedValue;
if (!(theExpectedValue instanceof StringType stringValue)) {
// TODO: workaround for unsupported types, remove this branch when rest of the types are supported
IValidationSupport.StringConceptProperty stringConceptProperty = (IValidationSupport.StringConceptProperty) theConceptProperty;
assertEquals(theExpectedValue.toString(), stringConceptProperty.getValue());
break;
}
// StringType stringValue = (StringType) theExpectedValue;
assertTrue(theConceptProperty instanceof StringConceptProperty);
StringConceptProperty stringConceptProperty = (StringConceptProperty) theConceptProperty;
assertEquals(stringValue.getValue(), stringConceptProperty.getValue());
Expand Down Expand Up @@ -150,7 +159,12 @@ public Stream<Arguments> getEmptyPropertyValues() {
public Stream<Arguments> getPropertyValues() {
return Stream.of(
Arguments.arguments(new StringType("value")),
Arguments.arguments(new Coding("code", "system", "display"))
Arguments.arguments(new Coding("code", "system", "display")),
Arguments.arguments(new CodeType("code")),
Arguments.arguments(new BooleanType(true)),
Arguments.arguments(new IntegerType(1)),
Arguments.arguments(new DecimalType(1.1)),
Arguments.arguments(new DateTimeType(Calendar.getInstance()))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
import org.hl7.fhir.r4.model.CodeSystem;
import org.hl7.fhir.r4.model.CodeType;
import org.hl7.fhir.r4.model.Coding;
import org.hl7.fhir.r4.model.DateTimeType;
import org.hl7.fhir.r4.model.DecimalType;
import org.hl7.fhir.r4.model.IdType;
import org.hl7.fhir.r4.model.IntegerType;
import org.hl7.fhir.r4.model.Parameters;
import org.hl7.fhir.r4.model.StringType;
import org.hl7.fhir.r4.model.Type;
Expand All @@ -33,6 +37,7 @@
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.provider.Arguments;

import java.util.Calendar;
import java.util.List;
import java.util.stream.Stream;

Expand Down Expand Up @@ -80,9 +85,8 @@ public String getInvalidValueErrorCodeForConvert() {

@BeforeEach
public void before() {
// TODO: use another type when "code" is added to the supported types
myMySimplePropertyCodeSystemProvider.myPropertyName = "somePropertyName";
myMySimplePropertyCodeSystemProvider.myPropertyValue = new CodeType("someCode");
myMySimplePropertyCodeSystemProvider.myPropertyValue = new IdType(123);
ourRestfulServerExtension.getRestfulServer().registerProvider(myMySimplePropertyCodeSystemProvider);
}
}
Expand Down Expand Up @@ -113,8 +117,13 @@ public void verifyProperty(IValidationSupport.BaseConceptProperty theConceptProp
String type = theConceptProperty.getType();
switch (type) {
case IValidationSupport.TYPE_STRING -> {
assertTrue(theExpectedValue instanceof StringType);
StringType stringValue = (StringType) theExpectedValue;
if (!(theExpectedValue instanceof StringType stringValue)) {
// TODO: workaround for unsupported types, remove this when rest of the types are supported
IValidationSupport.StringConceptProperty stringConceptProperty = (IValidationSupport.StringConceptProperty) theConceptProperty;
assertEquals(theExpectedValue.toString(), stringConceptProperty.getValue());
break;
}
// StringType stringValue = (StringType) theExpectedValue;
assertTrue(theConceptProperty instanceof IValidationSupport.StringConceptProperty);
IValidationSupport.StringConceptProperty stringConceptProperty = (IValidationSupport.StringConceptProperty) theConceptProperty;
assertEquals(stringValue.getValue(), stringConceptProperty.getValue());
Expand Down Expand Up @@ -147,12 +156,15 @@ public Stream<Arguments> getEmptyPropertyValues() {
public Stream<Arguments> getPropertyValues() {
return Stream.of(
Arguments.arguments(new StringType("value")),
Arguments.arguments(new Coding("code", "system", "display"))
Arguments.arguments(new Coding("code", "system", "display")),
Arguments.arguments(new CodeType("code")),
Arguments.arguments(new BooleanType(true)),
Arguments.arguments(new IntegerType(1)),
Arguments.arguments(new DecimalType(1.1)),
Arguments.arguments(new DateTimeType(Calendar.getInstance()))
);
}



public Stream<Arguments> getDesignations() {
return Stream.of(
Arguments.arguments(new IValidationSupport.ConceptDesignation().setLanguage("en").setUseCode("code1").setUseSystem("system-1").setUseDisplay("display").setValue("some value")),
Expand Down