More work on hl7.org structs
This commit is contained in:
parent
cee02ea605
commit
26e60b1b85
|
@ -24,6 +24,8 @@ import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
|
||||||
|
import org.hl7.fhir.instance.model.Resource;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.ConfigurationException;
|
import ca.uhn.fhir.context.ConfigurationException;
|
||||||
import ca.uhn.fhir.model.api.Bundle;
|
import ca.uhn.fhir.model.api.Bundle;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
|
@ -150,4 +152,13 @@ public interface IParser {
|
||||||
*/
|
*/
|
||||||
IParser setSuppressNarratives(boolean theSuppressNarratives);
|
IParser setSuppressNarratives(boolean theSuppressNarratives);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a resource from the HL7.org structure library
|
||||||
|
*
|
||||||
|
* @param theClass The resource type
|
||||||
|
* @param theResourceBody The body of the resource to parse
|
||||||
|
* @return A parsed resource
|
||||||
|
*/
|
||||||
|
<T extends Resource> T parse(Class<T> theClass, String theResourceBody);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,8 @@ public class Reference extends Type {
|
||||||
@Description(shortDefinition="Text alternative for the resource", formalDefinition="Plain text narrative that identifies the resource in addition to the resource reference." )
|
@Description(shortDefinition="Text alternative for the resource", formalDefinition="Plain text narrative that identifies the resource in addition to the resource reference." )
|
||||||
protected StringType display;
|
protected StringType display;
|
||||||
|
|
||||||
|
private Resource resource;
|
||||||
|
|
||||||
private static final long serialVersionUID = 22777321L;
|
private static final long serialVersionUID = 22777321L;
|
||||||
|
|
||||||
public Reference() {
|
public Reference() {
|
||||||
|
@ -184,6 +186,14 @@ public class Reference extends Type {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setResource(Resource theResource) {
|
||||||
|
this.resource = theResource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Resource getResource() {
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,6 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
|
|
@ -30,6 +30,11 @@ import org.custommonkey.xmlunit.XMLUnit;
|
||||||
import org.hamcrest.core.IsNot;
|
import org.hamcrest.core.IsNot;
|
||||||
import org.hamcrest.core.StringContains;
|
import org.hamcrest.core.StringContains;
|
||||||
import org.hamcrest.text.StringContainsInOrder;
|
import org.hamcrest.text.StringContainsInOrder;
|
||||||
|
import org.hl7.fhir.instance.model.List_;
|
||||||
|
import org.hl7.fhir.instance.model.Organization;
|
||||||
|
import org.hl7.fhir.instance.model.Patient;
|
||||||
|
import org.hl7.fhir.instance.model.Profile;
|
||||||
|
import org.hl7.fhir.instance.model.Resource;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
@ -37,8 +42,6 @@ import org.xml.sax.SAXException;
|
||||||
import ca.uhn.fhir.context.ConfigurationException;
|
import ca.uhn.fhir.context.ConfigurationException;
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.context.ResourceWithExtensionsA;
|
import ca.uhn.fhir.context.ResourceWithExtensionsA;
|
||||||
import ca.uhn.fhir.model.api.Bundle;
|
|
||||||
import ca.uhn.fhir.model.api.BundleEntry;
|
|
||||||
import ca.uhn.fhir.model.api.ExtensionDt;
|
import ca.uhn.fhir.model.api.ExtensionDt;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
||||||
|
@ -80,17 +83,17 @@ public class XmlParserTest {
|
||||||
// Create an organization
|
// Create an organization
|
||||||
Organization org = new Organization();
|
Organization org = new Organization();
|
||||||
org.setId("Organization/65546");
|
org.setId("Organization/65546");
|
||||||
org.getName().setValue("Contained Test Organization");
|
org.getNameElement().setValue("Contained Test Organization");
|
||||||
|
|
||||||
// Create a patient
|
// Create a patient
|
||||||
Patient patient = new Patient();
|
Patient patient = new Patient();
|
||||||
patient.setId("Patient/1333");
|
patient.setId("Patient/1333");
|
||||||
patient.addIdentifier("urn:mrns", "253345");
|
patient.addIdentifier().setSystem("urn:mrns").setValue("253345");
|
||||||
patient.getManagingOrganization().setResource(org);
|
patient.getManagingOrganization().setResource(org);
|
||||||
|
|
||||||
// Create a list containing both resources. In a server method, you might just
|
// Create a list containing both resources. In a server method, you might just
|
||||||
// return this list, but here we will create a bundle to encode.
|
// return this list, but here we will create a bundle to encode.
|
||||||
List<IResource> resources = new ArrayList<IResource>();
|
List<Resource> resources = new ArrayList<Resource>();
|
||||||
resources.add(org);
|
resources.add(org);
|
||||||
resources.add(patient);
|
resources.add(patient);
|
||||||
|
|
||||||
|
@ -705,7 +708,7 @@ public class XmlParserTest {
|
||||||
+ "</Patient>";
|
+ "</Patient>";
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
|
|
||||||
Patient patient = ourCtx.newXmlParser().parseResource(Patient.class, msg);
|
Patient patient = ourCtx.newXmlParser().parse(Patient.class, msg);
|
||||||
|
|
||||||
assertEquals(NarrativeStatusEnum.GENERATED, patient.getText().getStatus().getValueAsEnum());
|
assertEquals(NarrativeStatusEnum.GENERATED, patient.getText().getStatus().getValueAsEnum());
|
||||||
assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">John Cardinal: 444333333 </div>", patient.getText().getDiv().getValueAsString());
|
assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\">John Cardinal: 444333333 </div>", patient.getText().getDiv().getValueAsString());
|
||||||
|
@ -846,7 +849,7 @@ public class XmlParserTest {
|
||||||
String string = IOUtils.toString(XmlParserTest.class.getResourceAsStream("/feed-with-list.xml"), Charset.forName("UTF-8"));
|
String string = IOUtils.toString(XmlParserTest.class.getResourceAsStream("/feed-with-list.xml"), Charset.forName("UTF-8"));
|
||||||
Bundle bundle = p.parseBundle(string);
|
Bundle bundle = p.parseBundle(string);
|
||||||
|
|
||||||
ListResource res = (ListResource) bundle.toListOfResources().get(2);
|
List_ res = (List_) bundle.toListOfResources().get(2);
|
||||||
assertEquals("cid:patient@bundle", res.getSubject().getReference().getValue());
|
assertEquals("cid:patient@bundle", res.getSubject().getReference().getValue());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue