From cd7142faa1fc7d8445aae3af22231ec981dcb5c3 Mon Sep 17 00:00:00 2001 From: dotasek Date: Wed, 11 May 2022 12:01:23 -0400 Subject: [PATCH] Repair output of GraphQL response to include only idPart (#808) * Repair output of GraphQL response to include only idPart * Fix for breaking test. Co-authored-by: dotasek --- .../org/hl7/fhir/r5/utils/GraphQLEngine.java | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/GraphQLEngine.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/GraphQLEngine.java index fb0d8aeb8..277b9321f 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/GraphQLEngine.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/GraphQLEngine.java @@ -2,10 +2,7 @@ package org.hl7.fhir.r5.utils; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /* Copyright (c) 2011+, HL7, Inc. @@ -41,20 +38,9 @@ import java.util.Map; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r5.context.IWorkerContext; -import org.hl7.fhir.r5.model.BackboneElement; -import org.hl7.fhir.r5.model.Base; -import org.hl7.fhir.r5.model.Bundle; +import org.hl7.fhir.r5.model.*; import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent; import org.hl7.fhir.r5.model.Bundle.BundleLinkComponent; -import org.hl7.fhir.r5.model.CanonicalType; -import org.hl7.fhir.r5.model.DomainResource; -import org.hl7.fhir.r5.model.Element; -import org.hl7.fhir.r5.model.ExpressionNode; -import org.hl7.fhir.r5.model.IntegerType; -import org.hl7.fhir.r5.model.Property; -import org.hl7.fhir.r5.model.Reference; -import org.hl7.fhir.r5.model.Resource; -import org.hl7.fhir.r5.model.StringType; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.graphql.Argument; import org.hl7.fhir.utilities.graphql.Argument.ArgumentListStatus; @@ -571,6 +557,10 @@ public class GraphQLEngine implements IGraphQLEngine { if (!isPrimitive(prop.getTypeCode()) && sel.getField().getName().startsWith("_")) throw new EGraphQLException("Unknown property "+sel.getField().getName()+" on "+source.fhirType()); + if ("id".equals(prop.getName()) && context != null) { + prop.getValues().set(0, new IdType(context.getIdPart())); + } + List vl = filter(context, prop, sel.getField().getName(), sel.getField().getArguments(), prop.getValues(), sel.getField().getName().startsWith("_")); if (!vl.isEmpty()) processValues(context, sel, prop, target, vl, sel.getField().getName().startsWith("_"), inheritedList, suffix);