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>
|
</properties>
|
||||||
<body>
|
<body>
|
||||||
<release version="0.6" date="TBD">
|
<release version="0.6" date="TBD">
|
||||||
|
<!--
|
||||||
<action type="add">
|
<action type="add">
|
||||||
Allow generic client ... OAUTH
|
Allow generic client ... OAUTH
|
||||||
</action>
|
</action>
|
||||||
|
-->
|
||||||
<action type="fix">
|
<action type="fix">
|
||||||
Tester UI created double _format and _pretty param entries in searches. Thanks to Gered King of University
|
Tester UI created double _format and _pretty param entries in searches. Thanks to Gered King of University
|
||||||
Health Network for reporting!
|
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
|
is "yyyy-mm-dd" anyhow, and this is correctly handled). Thanks to Jeffrey Ting of Systems Made Simple
|
||||||
for reporting!
|
for reporting!
|
||||||
</action>
|
</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">
|
<action type="fix">
|
||||||
Server search method for an unnamed query gets called if the client requests a named query
|
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!
|
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.
|
HAPI parsers now use field access to get/set values instead of method accessors and mutators.
|
||||||
This should give a small performance boost.
|
This should give a small performance boost.
|
||||||
</action>
|
</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>
|
||||||
<release version="0.5" date="2014-Jul-30">
|
<release version="0.5" date="2014-Jul-30">
|
||||||
<action type="add">
|
<action type="add">
|
||||||
|
|
|
@ -297,10 +297,10 @@ public class JsonParser extends BaseParser implements IParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(reference)) {
|
if (StringUtils.isNotBlank(reference)) {
|
||||||
theWriter.write("resource", reference);
|
theWriter.write(XmlParser.RESREF_REFERENCE, reference);
|
||||||
}
|
}
|
||||||
if (referenceDt.getDisplay().isEmpty() == false) {
|
if (referenceDt.getDisplay().isEmpty() == false) {
|
||||||
theWriter.write("display", referenceDt.getDisplay().getValueAsString());
|
theWriter.write(XmlParser.RESREF_DISPLAY, referenceDt.getDisplay().getValueAsString());
|
||||||
}
|
}
|
||||||
theWriter.writeEnd();
|
theWriter.writeEnd();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -80,6 +80,8 @@ import ca.uhn.fhir.util.NonPrettyPrintWriterWrapper;
|
||||||
import ca.uhn.fhir.util.PrettyPrintWriterWrapper;
|
import ca.uhn.fhir.util.PrettyPrintWriterWrapper;
|
||||||
|
|
||||||
public class XmlParser extends BaseParser implements IParser {
|
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);
|
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 ATOM_NS = "http://www.w3.org/2005/Atom";
|
||||||
static final String FHIR_NS = "http://hl7.org/fhir";
|
static final String FHIR_NS = "http://hl7.org/fhir";
|
||||||
|
@ -556,12 +558,12 @@ public class XmlParser extends BaseParser implements IParser {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (!(theRef.getDisplay().isEmpty())) {
|
if (!(theRef.getDisplay().isEmpty())) {
|
||||||
theEventWriter.writeStartElement("display");
|
theEventWriter.writeStartElement(RESREF_DISPLAY);
|
||||||
theEventWriter.writeAttribute("value", theRef.getDisplay().getValue());
|
theEventWriter.writeAttribute("value", theRef.getDisplay().getValue());
|
||||||
theEventWriter.writeEndElement();
|
theEventWriter.writeEndElement();
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(reference)) {
|
if (StringUtils.isNotBlank(reference)) {
|
||||||
theEventWriter.writeStartElement("reference");
|
theEventWriter.writeStartElement(RESREF_REFERENCE);
|
||||||
theEventWriter.writeAttribute("value", reference);
|
theEventWriter.writeAttribute("value", reference);
|
||||||
theEventWriter.writeEndElement();
|
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_422_UNPROCESSABLE_ENTITY = 422;
|
||||||
public static final int STATUS_HTTP_500_INTERNAL_ERROR = 500;
|
public static final int STATUS_HTTP_500_INTERNAL_ERROR = 500;
|
||||||
public static final int STATUS_HTTP_501_NOT_IMPLEMENTED = 501;
|
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";
|
public static final String URL_TOKEN_HISTORY = "_history";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
|
@ -848,8 +848,8 @@ public class RestfulServer extends HttpServlet {
|
||||||
|
|
||||||
} while (references.isEmpty() == false);
|
} while (references.isEmpty() == false);
|
||||||
|
|
||||||
BundleEntry entry = bundle.addResource(next, theContext, theServerBase);
|
bundle.addResource(next, theContext, theServerBase);
|
||||||
addProfileToBundleEntry(theContext, next, entry);
|
// addProfileToBundleEntry(theContext, next, entry);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -857,25 +857,27 @@ public class RestfulServer extends HttpServlet {
|
||||||
* Actually add the resources to the bundle
|
* Actually add the resources to the bundle
|
||||||
*/
|
*/
|
||||||
for (IResource next : addedResources) {
|
for (IResource next : addedResources) {
|
||||||
BundleEntry entry = bundle.addResource(next, theContext, theServerBase);
|
bundle.addResource(next, theContext, theServerBase);
|
||||||
addProfileToBundleEntry(theContext, next, entry);
|
// addProfileToBundleEntry(theContext, next, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
bundle.getTotalResults().setValue(theTotalResults);
|
bundle.getTotalResults().setValue(theTotalResults);
|
||||||
return bundle;
|
return bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
private static void addProfileToBundleEntry(FhirContext theContext, IResource next, BundleEntry entry) {
|
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()) {
|
if (profileTags.isEmpty()) {
|
||||||
RuntimeResourceDefinition nextDef = theContext.getResourceDefinition(next);
|
RuntimeResourceDefinition nextDef = theContext.getResourceDefinition(next);
|
||||||
String profile = nextDef.getResourceProfile();
|
String profile = nextDef.getResourceProfile();
|
||||||
if (isNotBlank(profile)) {
|
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) {
|
public static String createPagingLink(String theServerBase, String theSearchId, int theOffset, int theCount, EncodingEnum theResponseEncoding, boolean thePrettyPrint) {
|
||||||
StringBuilder b = new StringBuilder();
|
StringBuilder b = new StringBuilder();
|
||||||
b.append(theServerBase);
|
b.append(theServerBase);
|
||||||
|
|
|
@ -564,7 +564,7 @@ public class JsonParserTest {
|
||||||
|
|
||||||
patient.setManagingOrganization(new ResourceReferenceDt("Organization/123"));
|
patient.setManagingOrganization(new ResourceReferenceDt("Organization/123"));
|
||||||
str = p.encodeResourceToString(patient);
|
str = p.encodeResourceToString(patient);
|
||||||
assertThat(str, StringContains.containsString("\"managingOrganization\":{\"resource\":\"Organization/123\"}"));
|
assertThat(str, StringContains.containsString("\"managingOrganization\":{\"reference\":\"Organization/123\"}"));
|
||||||
|
|
||||||
Organization org = new Organization();
|
Organization org = new Organization();
|
||||||
org.addIdentifier().setSystem("foo").setValue("bar");
|
org.addIdentifier().setSystem("foo").setValue("bar");
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class CustomTypeTest {
|
||||||
assertEquals(1, bundle.getEntries().size());
|
assertEquals(1, bundle.getEntries().size());
|
||||||
|
|
||||||
BundleEntry entry = bundle.getEntries().get(0);
|
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(1, profileTags.size());
|
||||||
assertEquals("http://foo/profiles/Profile", profileTags.get(0).getTerm());
|
assertEquals("http://foo/profiles/Profile", profileTags.get(0).getTerm());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue