Fix resource reference encoding for JSON parser - Thanks Tommy Nguyen for reporting!
This commit is contained in:
parent
6bc9140def
commit
71e6efbc31
|
@ -7,9 +7,11 @@
|
|||
</properties>
|
||||
<body>
|
||||
<release version="0.6" date="TBD">
|
||||
<!--
|
||||
<action type="add">
|
||||
Allow generic client ... OAUTH
|
||||
</action>
|
||||
-->
|
||||
<action type="fix">
|
||||
Tester UI created double _format and _pretty param entries in searches. Thanks to Gered King of University
|
||||
Health Network for reporting!
|
||||
|
@ -72,10 +74,6 @@
|
|||
is "yyyy-mm-dd" anyhow, and this is correctly handled). Thanks to Jeffrey Ting of Systems Made Simple
|
||||
for reporting!
|
||||
</action>
|
||||
<action type="add">
|
||||
Server now adds a profile tag to returned results if the resource being returned
|
||||
doesn't already have one
|
||||
</action>
|
||||
<action type="fix">
|
||||
Server search method for an unnamed query gets called if the client requests a named query
|
||||
with the same parameter list. Thanks to Neal Acharya of University Health Network for reporting!
|
||||
|
@ -91,6 +89,11 @@
|
|||
HAPI parsers now use field access to get/set values instead of method accessors and mutators.
|
||||
This should give a small performance boost.
|
||||
</action>
|
||||
<action type="fix">
|
||||
JSON parser encodes resource references incorrectly, using the name "resource" instead
|
||||
of the name "reference" for the actual reference. Thanks to
|
||||
Ricky Nguyen for reporting and tracking down the issue!
|
||||
</action>
|
||||
</release>
|
||||
<release version="0.5" date="2014-Jul-30">
|
||||
<action type="add">
|
||||
|
|
|
@ -297,10 +297,10 @@ public class JsonParser extends BaseParser implements IParser {
|
|||
}
|
||||
|
||||
if (StringUtils.isNotBlank(reference)) {
|
||||
theWriter.write("resource", reference);
|
||||
theWriter.write(XmlParser.RESREF_REFERENCE, reference);
|
||||
}
|
||||
if (referenceDt.getDisplay().isEmpty() == false) {
|
||||
theWriter.write("display", referenceDt.getDisplay().getValueAsString());
|
||||
theWriter.write(XmlParser.RESREF_DISPLAY, referenceDt.getDisplay().getValueAsString());
|
||||
}
|
||||
theWriter.writeEnd();
|
||||
break;
|
||||
|
|
|
@ -80,6 +80,8 @@ import ca.uhn.fhir.util.NonPrettyPrintWriterWrapper;
|
|||
import ca.uhn.fhir.util.PrettyPrintWriterWrapper;
|
||||
|
||||
public class XmlParser extends BaseParser implements IParser {
|
||||
static final String RESREF_DISPLAY = "display";
|
||||
static final String RESREF_REFERENCE = "reference";
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(XmlParser.class);
|
||||
static final String ATOM_NS = "http://www.w3.org/2005/Atom";
|
||||
static final String FHIR_NS = "http://hl7.org/fhir";
|
||||
|
@ -556,12 +558,12 @@ public class XmlParser extends BaseParser implements IParser {
|
|||
// }
|
||||
|
||||
if (!(theRef.getDisplay().isEmpty())) {
|
||||
theEventWriter.writeStartElement("display");
|
||||
theEventWriter.writeStartElement(RESREF_DISPLAY);
|
||||
theEventWriter.writeAttribute("value", theRef.getDisplay().getValue());
|
||||
theEventWriter.writeEndElement();
|
||||
}
|
||||
if (StringUtils.isNotBlank(reference)) {
|
||||
theEventWriter.writeStartElement("reference");
|
||||
theEventWriter.writeStartElement(RESREF_REFERENCE);
|
||||
theEventWriter.writeAttribute("value", reference);
|
||||
theEventWriter.writeEndElement();
|
||||
}
|
||||
|
|
|
@ -97,7 +97,6 @@ public class Constants {
|
|||
public static final int STATUS_HTTP_422_UNPROCESSABLE_ENTITY = 422;
|
||||
public static final int STATUS_HTTP_500_INTERNAL_ERROR = 500;
|
||||
public static final int STATUS_HTTP_501_NOT_IMPLEMENTED = 501;
|
||||
public static final String TAG_SCHEME_PROFILE = "http://hl7.org/fhir/tag/profile ";
|
||||
public static final String URL_TOKEN_HISTORY = "_history";
|
||||
|
||||
static {
|
||||
|
|
|
@ -848,8 +848,8 @@ public class RestfulServer extends HttpServlet {
|
|||
|
||||
} while (references.isEmpty() == false);
|
||||
|
||||
BundleEntry entry = bundle.addResource(next, theContext, theServerBase);
|
||||
addProfileToBundleEntry(theContext, next, entry);
|
||||
bundle.addResource(next, theContext, theServerBase);
|
||||
// addProfileToBundleEntry(theContext, next, entry);
|
||||
|
||||
}
|
||||
|
||||
|
@ -857,25 +857,27 @@ public class RestfulServer extends HttpServlet {
|
|||
* Actually add the resources to the bundle
|
||||
*/
|
||||
for (IResource next : addedResources) {
|
||||
BundleEntry entry = bundle.addResource(next, theContext, theServerBase);
|
||||
addProfileToBundleEntry(theContext, next, entry);
|
||||
bundle.addResource(next, theContext, theServerBase);
|
||||
// addProfileToBundleEntry(theContext, next, entry);
|
||||
}
|
||||
|
||||
bundle.getTotalResults().setValue(theTotalResults);
|
||||
return bundle;
|
||||
}
|
||||
|
||||
/*
|
||||
private static void addProfileToBundleEntry(FhirContext theContext, IResource next, BundleEntry entry) {
|
||||
List<Tag> profileTags = entry.getCategories().getTagsWithScheme(Constants.TAG_SCHEME_PROFILE);
|
||||
List<Tag> profileTags = entry.getCategories().getTagsWithScheme(Tag.HL7_ORG_PROFILE_TAG);
|
||||
if (profileTags.isEmpty()) {
|
||||
RuntimeResourceDefinition nextDef = theContext.getResourceDefinition(next);
|
||||
String profile = nextDef.getResourceProfile();
|
||||
if (isNotBlank(profile)) {
|
||||
entry.addCategory(new Tag(Constants.TAG_SCHEME_PROFILE, profile, null));
|
||||
entry.addCategory(new Tag(Tag.HL7_ORG_PROFILE_TAG, profile, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
public static String createPagingLink(String theServerBase, String theSearchId, int theOffset, int theCount, EncodingEnum theResponseEncoding, boolean thePrettyPrint) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append(theServerBase);
|
||||
|
|
|
@ -564,7 +564,7 @@ public class JsonParserTest {
|
|||
|
||||
patient.setManagingOrganization(new ResourceReferenceDt("Organization/123"));
|
||||
str = p.encodeResourceToString(patient);
|
||||
assertThat(str, StringContains.containsString("\"managingOrganization\":{\"resource\":\"Organization/123\"}"));
|
||||
assertThat(str, StringContains.containsString("\"managingOrganization\":{\"reference\":\"Organization/123\"}"));
|
||||
|
||||
Organization org = new Organization();
|
||||
org.addIdentifier().setSystem("foo").setValue("bar");
|
||||
|
|
|
@ -63,7 +63,7 @@ public class CustomTypeTest {
|
|||
assertEquals(1, bundle.getEntries().size());
|
||||
|
||||
BundleEntry entry = bundle.getEntries().get(0);
|
||||
List<Tag> profileTags = entry.getCategories().getTagsWithScheme(Constants.TAG_SCHEME_PROFILE);
|
||||
List<Tag> profileTags = entry.getCategories().getTagsWithScheme(Tag.HL7_ORG_PROFILE_TAG);
|
||||
assertEquals(1, profileTags.size());
|
||||
assertEquals("http://foo/profiles/Profile", profileTags.get(0).getTerm());
|
||||
|
||||
|
|
Loading…
Reference in New Issue