add test to check that json parsing also fails with identically named contained resources
This commit is contained in:
parent
a9b6864988
commit
2c1ec8fb0d
|
@ -5,7 +5,10 @@ import ca.uhn.fhir.rest.api.Constants;
|
|||
import ca.uhn.fhir.test.BaseTest;
|
||||
import ca.uhn.fhir.util.StopWatch;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.io.Resources;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.io.output.NullWriter;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
@ -18,6 +21,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
@ -150,6 +154,23 @@ public class JsonParserR4Test extends BaseTest {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseBundleWithMultipleNestedContainedResources() throws Exception {
|
||||
URL url = Resources.getResource("bundle-with-two-patient-resources.json");
|
||||
String text = Resources.toString(url, Charsets.UTF_8);
|
||||
|
||||
Bundle bundle = ourCtx.newJsonParser().parseResource(Bundle.class, text);
|
||||
|
||||
assertEquals("12346", getPatientIdValue(bundle, 0));
|
||||
assertEquals("12345", getPatientIdValue(bundle, 1));
|
||||
}
|
||||
|
||||
private String getPatientIdValue(Bundle input, int entry) {
|
||||
final DocumentReference documentReference = (DocumentReference)input.getEntry().get(entry).getResource();
|
||||
final Patient patient = (Patient) documentReference.getSubject().getResource();
|
||||
return patient.getIdentifier().get(0).getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* See #814
|
||||
*/
|
||||
|
|
|
@ -90,9 +90,11 @@ public class XmlParserR4Test extends BaseTest {
|
|||
public void testParseBundleWithMultipleNestedContainedResources() throws Exception {
|
||||
URL url = Resources.getResource("bundle-with-two-patient-resources.xml");
|
||||
String text = Resources.toString(url, Charsets.UTF_8);
|
||||
Bundle input = ourCtx.newXmlParser().parseResource(Bundle.class, text);
|
||||
assertEquals("12346", getPatientIdValue(input, 0));
|
||||
assertEquals("12345", getPatientIdValue(input, 1));
|
||||
|
||||
Bundle bundle = ourCtx.newXmlParser().parseResource(Bundle.class, text);
|
||||
|
||||
assertEquals("12346", getPatientIdValue(bundle, 0));
|
||||
assertEquals("12345", getPatientIdValue(bundle, 1));
|
||||
}
|
||||
|
||||
private String getPatientIdValue(Bundle input, int entry) {
|
||||
|
|
|
@ -0,0 +1,260 @@
|
|||
{
|
||||
"resourceType": "Bundle",
|
||||
"meta": {
|
||||
"profile": [
|
||||
"http://forcare.com/fhir/createCda"
|
||||
]
|
||||
},
|
||||
"type": "transaction",
|
||||
"entry": [
|
||||
{
|
||||
"resource": {
|
||||
"resourceType": "DocumentReference",
|
||||
"id": "doc1",
|
||||
"contained": [
|
||||
{
|
||||
"resourceType": "Patient",
|
||||
"id": "patient",
|
||||
"identifier": [
|
||||
{
|
||||
"system": "urn:oid:1.3.6.1.4.1.21367.2005.3.7",
|
||||
"value": "12346"
|
||||
}
|
||||
],
|
||||
"name": [
|
||||
{
|
||||
"use": "official",
|
||||
"family": "Beugels",
|
||||
"given": [
|
||||
"Kees"
|
||||
]
|
||||
}
|
||||
],
|
||||
"gender": "male",
|
||||
"birthDate": "1970-01-01"
|
||||
}
|
||||
],
|
||||
"status": "current",
|
||||
"type": {
|
||||
"coding": [
|
||||
{
|
||||
"system": "2.16.840.1.113883.6.1",
|
||||
"code": "57016-8",
|
||||
"display": "Privacy Policy Acknowledgment"
|
||||
}
|
||||
]
|
||||
},
|
||||
"category": [
|
||||
{
|
||||
"coding": [
|
||||
{
|
||||
"system": "2.16.840.1.113883.6.1",
|
||||
"code": "57016-8",
|
||||
"display": "Privacy Policy Acknowledgment"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"subject": {
|
||||
"reference": "#patient"
|
||||
},
|
||||
"date": "2016-05-04T08:18:03.203Z",
|
||||
"author": [
|
||||
{
|
||||
"reference": "#patient"
|
||||
}
|
||||
],
|
||||
"description": "Hospital Privacy Consent",
|
||||
"securityLabel": [
|
||||
{
|
||||
"coding": [
|
||||
{
|
||||
"system": "2.16.840.1.113883.5.25",
|
||||
"code": "N",
|
||||
"display": "Normal"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"content": [
|
||||
{
|
||||
"attachment": {
|
||||
"contentType": "text/xml",
|
||||
"language": "en-US",
|
||||
"url": "urn:uuid:d7d8ffca-e364-484b-bbf9-6a730854aea5"
|
||||
},
|
||||
"format": {
|
||||
"system": "1.3.6.1.4.1.19376.1.2.3",
|
||||
"code": "urn:ihe:iti:bppc-sd:2007",
|
||||
"display": "Basic Patient Privacy Consent (scanned part)"
|
||||
}
|
||||
}
|
||||
],
|
||||
"context": {
|
||||
"event": [
|
||||
{
|
||||
"coding": [
|
||||
{
|
||||
"system": "1.2.826.0.1.3680043.2.1611.2.10",
|
||||
"code": "allowMedicalDoctorsFromHospitalAToSeeDocuments",
|
||||
"display": "I allow Medical Doctors in Hospital A to access my medical record"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"coding": [
|
||||
{
|
||||
"system": "1.2.826.0.1.3680043.2.1611.2.10",
|
||||
"code": "denyMedicalDoctorsFromHospitalBToSeeDocuments",
|
||||
"display": "I deny Medical Doctors in Hospital B to access my medical record"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"period": {
|
||||
"start": "2016-05-04T08:18:03.203Z",
|
||||
"end": "2016-09-04T08:18:03.203Z"
|
||||
},
|
||||
"facilityType": {
|
||||
"coding": [
|
||||
{
|
||||
"system": "2.16.840.1.113883.5.10588",
|
||||
"code": "HOSP",
|
||||
"display": "Hospital"
|
||||
}
|
||||
]
|
||||
},
|
||||
"practiceSetting": {
|
||||
"coding": [
|
||||
{
|
||||
"system": "2.16.840.1.113883.2.1.6.8",
|
||||
"code": "300",
|
||||
"display": "General Medicine"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"resource": {
|
||||
"resourceType": "DocumentReference",
|
||||
"id": "doc2",
|
||||
"contained": [
|
||||
{
|
||||
"resourceType": "Patient",
|
||||
"id": "patient",
|
||||
"identifier": [
|
||||
{
|
||||
"system": "urn:oid:1.3.6.1.4.1.21367.2005.3.7",
|
||||
"value": "12345"
|
||||
}
|
||||
],
|
||||
"name": [
|
||||
{
|
||||
"use": "official",
|
||||
"family": "Baker",
|
||||
"given": [
|
||||
"Rob"
|
||||
]
|
||||
}
|
||||
],
|
||||
"gender": "male",
|
||||
"birthDate": "1970-01-01"
|
||||
}
|
||||
],
|
||||
"status": "current",
|
||||
"type": {
|
||||
"coding": [
|
||||
{
|
||||
"system": "2.16.840.1.113883.6.1",
|
||||
"code": "57016-8",
|
||||
"display": "Privacy Policy Acknowledgment"
|
||||
}
|
||||
]
|
||||
},
|
||||
"category": [
|
||||
{
|
||||
"coding": [
|
||||
{
|
||||
"system": "2.16.840.1.113883.6.1",
|
||||
"code": "57016-8",
|
||||
"display": "Privacy Policy Acknowledgment"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"subject": {
|
||||
"reference": "#patient"
|
||||
},
|
||||
"date": "2016-05-04T08:18:03.203Z",
|
||||
"author": [
|
||||
{
|
||||
"reference": "#patient"
|
||||
}
|
||||
],
|
||||
"description": "GPs Privacy Consent",
|
||||
"securityLabel": [
|
||||
{
|
||||
"coding": [
|
||||
{
|
||||
"system": "2.16.840.1.113883.5.25",
|
||||
"code": "N",
|
||||
"display": "Normal"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"content": [
|
||||
{
|
||||
"attachment": {
|
||||
"contentType": "text/xml",
|
||||
"language": "en-US",
|
||||
"url": "urn:uuid:d7d8ffca-e364-484b-bbf9-6a730854aea5"
|
||||
},
|
||||
"format": {
|
||||
"system": "1.3.6.1.4.1.19376.1.2.3",
|
||||
"code": "urn:ihe:iti:bppc-sd:2007",
|
||||
"display": "Basic Patient Privacy Consent (scanned part)"
|
||||
}
|
||||
}
|
||||
],
|
||||
"context": {
|
||||
"event": [
|
||||
{
|
||||
"coding": [
|
||||
{
|
||||
"system": "1.2.826.0.1.3680043.2.1611.2.10",
|
||||
"code": "denyGeneralPractitionersFromHestiaToSeeDocuments",
|
||||
"display": "I deny Medical Doctors in Hestia General Practitioners to access my medical record"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"period": {
|
||||
"start": "2016-05-04T08:18:03.203Z",
|
||||
"end": "2016-09-04T08:18:03.203Z"
|
||||
},
|
||||
"facilityType": {
|
||||
"coding": [
|
||||
{
|
||||
"system": "2.16.840.1.113883.5.10588",
|
||||
"code": "HOSP",
|
||||
"display": "Hospital"
|
||||
}
|
||||
]
|
||||
},
|
||||
"practiceSetting": {
|
||||
"coding": [
|
||||
{
|
||||
"system": "2.16.840.1.113883.2.1.6.8",
|
||||
"code": "300",
|
||||
"display": "General Medicine"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue