Placeholder extension moved to resource body from meta; tests passing.

This commit is contained in:
Diederik Muylwyk 2021-03-05 12:09:17 -05:00
parent 35645999d7
commit a195eebdec
3 changed files with 6 additions and 10 deletions

View File

@ -1071,7 +1071,7 @@ public class DaoConfig {
* as they are never allowed to be client supplied in HAPI FHIR JPA. * as they are never allowed to be client supplied in HAPI FHIR JPA.
* *
* All placeholder resources created in this way have a meta extension * All placeholder resources created in this way have a meta extension
* with the URL {@link HapiExtensions#EXT_RESOURCE_META_PLACEHOLDER} and the value "true". * with the URL {@link HapiExtensions#EXT_RESOURCE_PLACEHOLDER} and the value "true".
* </p> * </p>
*/ */
public boolean isAutoCreatePlaceholderReferenceTargets() { public boolean isAutoCreatePlaceholderReferenceTargets() {
@ -1095,7 +1095,7 @@ public class DaoConfig {
* as they are never allowed to be client supplied in HAPI FHIR JPA. * as they are never allowed to be client supplied in HAPI FHIR JPA.
* *
* All placeholder resources created in this way have a meta extension * All placeholder resources created in this way have a meta extension
* with the URL {@link HapiExtensions#EXT_RESOURCE_META_PLACEHOLDER} and the value "true". * with the URL {@link HapiExtensions#EXT_RESOURCE_PLACEHOLDER} and the value "true".
* </p> * </p>
*/ */
public void setAutoCreatePlaceholderReferenceTargets(boolean theAutoCreatePlaceholderReferenceTargets) { public void setAutoCreatePlaceholderReferenceTargets(boolean theAutoCreatePlaceholderReferenceTargets) {

View File

@ -41,7 +41,6 @@ import ca.uhn.fhir.util.HapiExtensions;
import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.IBase;
import org.hl7.fhir.instance.model.api.IBaseExtension; import org.hl7.fhir.instance.model.api.IBaseExtension;
import org.hl7.fhir.instance.model.api.IBaseHasExtensions; import org.hl7.fhir.instance.model.api.IBaseHasExtensions;
import org.hl7.fhir.instance.model.api.IBaseMetaType;
import org.hl7.fhir.instance.model.api.IBaseReference; import org.hl7.fhir.instance.model.api.IBaseReference;
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;
@ -123,11 +122,9 @@ public class DaoResourceLinkResolver implements IResourceLinkResolver {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
T newResource = (T) missingResourceDef.newInstance(); T newResource = (T) missingResourceDef.newInstance();
// FIXME: DM 2021-03-04 - This is where the placeholder extension is added; should be in resource body instead of meta? if (newResource instanceof IBaseHasExtensions) {
IBaseMetaType meta = newResource.getMeta(); IBaseExtension<?, ?> extension = ((IBaseHasExtensions) newResource).addExtension();
if (meta instanceof IBaseHasExtensions) { extension.setUrl(HapiExtensions.EXT_RESOURCE_PLACEHOLDER);
IBaseExtension<?, ?> extension = ((IBaseHasExtensions) meta).addExtension();
extension.setUrl(HapiExtensions.EXT_RESOURCE_META_PLACEHOLDER);
extension.setValue(myContext.getPrimitiveBoolean(true)); extension.setValue(myContext.getPrimitiveBoolean(true));
} }

View File

@ -177,7 +177,6 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test {
assertEquals("Patient/999999999999999", outcome.getResources(0,1).get(0).getIdElement().toUnqualifiedVersionless().getValue()); assertEquals("Patient/999999999999999", outcome.getResources(0,1).get(0).getIdElement().toUnqualifiedVersionless().getValue());
} }
// FIXME: DM 2021-03-04 - This test fails; extension isn't being created correctly.
@Test @Test
public void testCreatePlaceholderExtension_WithUpdateToTarget() { public void testCreatePlaceholderExtension_WithUpdateToTarget() {
myDaoConfig.setAutoCreatePlaceholderReferenceTargets(true); myDaoConfig.setAutoCreatePlaceholderReferenceTargets(true);
@ -201,7 +200,7 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test {
ourLog.info("\nPlaceholder Patient created:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(placeholderPat)); ourLog.info("\nPlaceholder Patient created:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(placeholderPat));
assertEquals(0, placeholderPat.getIdentifier().size()); assertEquals(0, placeholderPat.getIdentifier().size());
Extension extension = placeholderPat.getExtensionByUrl(HapiExtensions.EXT_RESOURCE_PLACEHOLDER); Extension extension = placeholderPat.getExtensionByUrl(HapiExtensions.EXT_RESOURCE_PLACEHOLDER);
assertNotNull(extension); // FIXME: DM 2021-03-04 - This assertion fails for now. assertNotNull(extension);
assertTrue(extension.hasValue()); assertTrue(extension.hasValue());
assertTrue(((BooleanType) extension.getValue()).booleanValue()); assertTrue(((BooleanType) extension.getValue()).booleanValue());