Update STU3 definitions and being in STU2.1 defs too

This commit is contained in:
James 2016-12-10 19:51:25 -05:00
parent b0d656e5d9
commit 901a85880c
1739 changed files with 489772 additions and 108848 deletions

View File

@ -25,7 +25,7 @@ IGenericClient client = FhirContext.forDstu3().newRestfulGenericClient("http://f
//START SNIPPET: customTypeClientSimple
// Create an example patient
MyPatient custPatient = new MyPatient();
custPatient.addName().addFamily("Smith").addGiven("John");
custPatient.addName().setFamily("Smith").addGiven("John");
custPatient.setPetName(new StringType("Rover")); // populate the extension
// Create the resource like normal
@ -115,7 +115,7 @@ patient.addExtension(ext);
// Continuing the example from above, we will add a name to the patient, and then
// add an extension to part of that name
HumanName name = patient.addName();
name.addFamily("Shmoe");
name.setFamily("Shmoe");
// Add a new "given name", which is of type String
StringType given = name.addGivenElement();

View File

@ -31,7 +31,7 @@ FhirContext ctx = FhirContext.forDstu3();
// Working with RI structures is similar to how it works with the HAPI structures
org.hl7.fhir.dstu3.model.Patient patient = new org.hl7.fhir.dstu3.model.Patient();
patient.addName().addGiven("John").addFamily("Smith");
patient.addName().addGiven("John").setFamily("Smith");
patient.getBirthDateElement().setValueAsString("1998-02-22");
// Parsing and encoding works the same way too

View File

@ -885,4 +885,11 @@ public class FhirContext {
return retVal;
}
/**
* Creates and returns a new FhirContext with version {@link FhirVersionEnum#DSTU2 DSTU2} (2016 May DSTU3 Snapshot)
*/
public static FhirContext forDstu2_1() {
return new FhirContext(FhirVersionEnum.DSTU2_1);
}
}

View File

@ -40,7 +40,7 @@ public enum FhirVersionEnum {
DSTU2_HL7ORG("org.hl7.fhir.instance.FhirDstu2Hl7Org", DSTU2, true),
DSTU2_1("NONE", null, true),
DSTU2_1("org.hl7.fhir.dstu2016may.hapi.ctx.FhirDstu2_1", null, true),
DSTU3("org.hl7.fhir.dstu3.hapi.ctx.FhirDstu3", null, true);

View File

@ -159,6 +159,28 @@ public class HierarchicalTableGenerator {
pieces.add(piece);
return this;
}
private List<Piece> htmlToParagraphPieces(String html) {
List<Piece> myPieces = new ArrayList<Piece>();
String[] paragraphs = html.replace("<p>", "").split("<\\/p>|<br \\/>");
for (int i=0;i<paragraphs.length;i++) {
if (!paragraphs[i].isEmpty()) {
if (i!=0) {
myPieces.add(new Piece("br"));
myPieces.add(new Piece("br"));
}
myPieces.addAll(htmlFormattingToPieces(paragraphs[i]));
}
}
return myPieces;
}
private List<Piece> htmlFormattingToPieces(String html) {
List<Piece> myPieces = new ArrayList<Piece>();
//Todo: At least handle bold and italics and turn them into formatted spans. (Will need to handle nesting though)
myPieces.add(new Piece(null, html, null));
return myPieces;
}
public void addStyle(String style) {
for (Piece p : pieces)
p.addStyle(style);
@ -284,6 +306,10 @@ public class HierarchicalTableGenerator {
private boolean inLineGraphics;
public HierarchicalTableGenerator() {
super();
}
public HierarchicalTableGenerator(String dest, boolean inlineGraphics) {
super();
this.dest = dest;
@ -306,15 +332,25 @@ public class HierarchicalTableGenerator {
return model;
}
public XhtmlNode generate(TableModel model, String imagePath) throws IOException, FHIRException {
public TableModel initGridTable(String prefix) {
TableModel model = new TableModel();
model.getTitles().add(new Title(null, model.getDocoRef(), "Name", "The name of the element (Slice name in brackets). Mouse-over provides definition", null, 0));
model.getTitles().add(new Title(null, model.getDocoRef(), "Card.", "Minimum and Maximum # of times the the element can appear in the instance. Super-scripts indicate additional constraints on appearance", null, 0));
model.getTitles().add(new Title(null, model.getDocoRef(), "Type", "Reference to the type of the element", null, 100));
model.getTitles().add(new Title(null, model.getDocoRef(), "Constraints and Usage", "Fixed values, length limits, vocabulary bindings and other usage notes", null, 0));
return model;
}
public XhtmlNode generate(TableModel model, String imagePath, int border) throws IOException, FHIRException {
checkModel(model);
XhtmlNode table = new XhtmlNode(NodeType.Element, "table").setAttribute("border", "0").setAttribute("cellspacing", "0").setAttribute("cellpadding", "0");
table.setAttribute("style", "border: 0px; font-size: 11px; font-family: verdana; vertical-align: top;");
XhtmlNode table = new XhtmlNode(NodeType.Element, "table").setAttribute("border", Integer.toString(border)).setAttribute("cellspacing", "0").setAttribute("cellpadding", "0");
table.setAttribute("style", "border: " + border + "px #F0F0F0 solid; font-size: 11px; font-family: verdana; vertical-align: top;");
XhtmlNode tr = table.addTag("tr");
tr.setAttribute("style", "border: 1px #F0F0F0 solid; font-size: 11px; font-family: verdana; vertical-align: top;");
tr.setAttribute("style", "border: " + Integer.toString(1 + border) + "px #F0F0F0 solid; font-size: 11px; font-family: verdana; vertical-align: top;");
XhtmlNode tc = null;
for (Title t : model.getTitles()) {
tc = renderCell(tr, t, "th", null, null, null, false, null, "white", imagePath);
tc = renderCell(tr, t, "th", null, null, null, false, null, "white", imagePath, border);
if (t.width != 0)
tc.setAttribute("style", "width: "+Integer.toString(t.width)+"px");
}
@ -322,7 +358,7 @@ public class HierarchicalTableGenerator {
tc.addTag("span").setAttribute("style", "float: right").addTag("a").setAttribute("title", "Legend for this format").setAttribute("href", model.getDocoRef()).addTag("img").setAttribute("alt", "doco").setAttribute("style", "background-color: inherit").setAttribute("src", model.getDocoImg());
for (Row r : model.getRows()) {
renderRow(table, r, 0, new ArrayList<Boolean>(), imagePath);
renderRow(table, r, 0, new ArrayList<Boolean>(), imagePath, border);
}
if (model.getDocoRef() != null) {
tr = table.addTag("tr");
@ -339,15 +375,15 @@ public class HierarchicalTableGenerator {
}
private void renderRow(XhtmlNode table, Row r, int indent, List<Boolean> indents, String imagePath) throws IOException {
private void renderRow(XhtmlNode table, Row r, int indent, List<Boolean> indents, String imagePath, int border) throws IOException {
XhtmlNode tr = table.addTag("tr");
String color = "white";
if (r.getColor() != null)
color = r.getColor();
tr.setAttribute("style", "border: 0px; padding:0px; vertical-align: top; background-color: "+color+";");
tr.setAttribute("style", "border: " + border + "px #F0F0F0 solid; padding:0px; vertical-align: top; background-color: "+color+";");
boolean first = true;
for (Cell t : r.getCells()) {
renderCell(tr, t, "td", first ? r.getIcon() : null, first ? r.getHint() : null, first ? indents : null, !r.getSubRows().isEmpty(), first ? r.getAnchor() : null, color, imagePath);
renderCell(tr, t, "td", first ? r.getIcon() : null, first ? r.getHint() : null, first ? indents : null, !r.getSubRows().isEmpty(), first ? r.getAnchor() : null, color, imagePath, border);
first = false;
}
table.addText("\r\n");
@ -360,17 +396,17 @@ public class HierarchicalTableGenerator {
ind.add(true);
else
ind.add(false);
renderRow(table, c, indent+1, ind, imagePath);
renderRow(table, c, indent+1, ind, imagePath, border);
}
}
private XhtmlNode renderCell(XhtmlNode tr, Cell c, String name, String icon, String hint, List<Boolean> indents, boolean hasChildren, String anchor, String color, String imagePath) throws IOException {
private XhtmlNode renderCell(XhtmlNode tr, Cell c, String name, String icon, String hint, List<Boolean> indents, boolean hasChildren, String anchor, String color, String imagePath, int border) throws IOException {
XhtmlNode tc = tr.addTag(name);
tc.setAttribute("class", "hierarchy");
if (indents != null) {
tc.addTag("img").setAttribute("src", srcFor(imagePath, "tbl_spacer.png")).setAttribute("style", "background-color: inherit").setAttribute("class", "hierarchy").setAttribute("alt", ".");
tc.setAttribute("style", "vertical-align: top; text-align : left; background-color: "+color+"; padding:0px 4px 0px 4px; white-space: nowrap; background-image: url("+imagePath+checkExists(indents, hasChildren)+")");
tc.setAttribute("style", "vertical-align: top; text-align : left; background-color: "+color+"; border: "+ border +"px #F0F0F0 solid; padding:0px 4px 0px 4px; white-space: nowrap; background-image: url("+imagePath+checkExists(indents, hasChildren)+")");
for (int i = 0; i < indents.size()-1; i++) {
if (indents.get(i))
tc.addTag("img").setAttribute("src", srcFor(imagePath, "tbl_blank.png")).setAttribute("style", "background-color: inherit").setAttribute("class", "hierarchy").setAttribute("alt", ".");
@ -384,7 +420,7 @@ public class HierarchicalTableGenerator {
tc.addTag("img").setAttribute("src", srcFor(imagePath, "tbl_vjoin.png")).setAttribute("style", "background-color: inherit").setAttribute("class", "hierarchy").setAttribute("alt", ".");
}
else
tc.setAttribute("style", "vertical-align: top; text-align : left; background-color: "+color+"; padding:0px 4px 0px 4px");
tc.setAttribute("style", "vertical-align: top; text-align : left; background-color: "+color+"; border: "+ border +"px #F0F0F0 solid; padding:0px 4px 0px 4px");
if (!Utilities.noString(icon)) {
XhtmlNode img = tc.addTag("img").setAttribute("src", srcFor(imagePath, icon)).setAttribute("class", "hierarchy").setAttribute("style", "background-color: "+color+"; background-color: inherit").setAttribute("alt", ".");
if (hint != null)
@ -406,6 +442,7 @@ public class HierarchicalTableGenerator {
if (!Utilities.noString(p.getHint()))
a.setAttribute("title", p.getHint());
a.addText(p.getText());
addStyle(a, p);
} else {
if (!Utilities.noString(p.getHint())) {
XhtmlNode s = addStyle(tc.addTag("span"), p);
@ -442,7 +479,7 @@ public class HierarchicalTableGenerator {
b.append("data: image/png;base64,");
byte[] bytes;
File file = new File(Utilities.path(dest, filename));
if (!file.exists()) // because sometime this is called real early before the files exist. it will be uilt again later because of this
if (!file.exists()) // because sometime this is called real early before the files exist. it will be built again later because of this
bytes = new byte[0];
else
bytes = FileUtils.readFileToByteArray(file);

File diff suppressed because it is too large Load Diff

View File

@ -115,9 +115,6 @@ public class XMLWriterState {
return children;
}
/**
* @param children the children to set
*/
public void seeChild() {
this.children = true;
}

View File

@ -1,4 +1,23 @@
<th:block th:each="prefix : ${resource.prefix}" th:if="${!prefix.empty}" th:text="${prefix.value} + ' '">Dr</th:block>
<th:block th:each="givenName : ${resource.given}" th:if="${!givenName.empty}" th:text="${givenName.value} + ' '">John</th:block>
<b th:each="familyName : ${resource.family}" th:if="${!familyName.empty}" th:text="${#strings.toUpperCase(familyName.value)} + ' '">SMITH</b>
<th:block th:switch="${fhirVersion}">
<th:block th:case="'DSTU1'">
<b th:each="familyName : ${resource.family}" th:if="${!familyName.empty}" th:text="${#strings.toUpperCase(familyName.value)} + ' '">SMITH</b>
</th:block>
<th:block th:case="'DSTU2'">
<b th:each="familyName : ${resource.family}" th:if="${!familyName.empty}" th:text="${#strings.toUpperCase(familyName.value)} + ' '">SMITH</b>
</th:block>
<th:block th:case="'DSTU2_1'">
<b th:each="familyName : ${resource.family}" th:if="${!familyName.empty}" th:text="${#strings.toUpperCase(familyName.value)} + ' '">SMITH</b>
</th:block>
<th:block th:case="'DSTU2_HL7ORG'">
<b th:each="familyName : ${resource.family}" th:if="${!familyName.empty}" th:text="${#strings.toUpperCase(familyName.value)} + ' '">SMITH</b>
</th:block>
<th:block th:case="*">
<b th:if="${!resource.familyElement.empty}" th:text="${#strings.toUpperCase(resource.family)} + ' '">SMITH</b>
</th:block>
</th:block>
<th:block th:each="suffix : ${resource.suffix}" th:if="${!suffix.empty}" th:text="${suffix.value} + ' '">Jr</th:block>

View File

@ -161,7 +161,7 @@ public class GenericJaxRsClientDstu3Test {
conf.setCopyright("COPY");
final Patient patient = new Patient();
patient.addName().addFamily("FAMILY");
patient.addName().setFamily("FAMILY");
ourResponseContentType = Constants.CT_FHIR_XML + "; charset=UTF-8";
ourResponseBodies = new String[] { p.encodeResourceToString(conf), p.encodeResourceToString(conf), p.encodeResourceToString(patient) };
@ -170,7 +170,7 @@ public class GenericJaxRsClientDstu3Test {
IGenericClient client = ourCtx.newRestfulGenericClient("http://localhost:" + ourPort + "/fhir");
Patient resp = client.read(Patient.class, new IdType("123").getValue());
assertEquals("FAMILY", resp.getName().get(0).getFamily().get(0).getValue());
assertEquals("FAMILY", resp.getName().get(0).getFamily());
assertEquals("http://localhost:" + ourPort + "/fhir/metadata", ourRequestUriAll.get(0));
assertEquals("http://localhost:" + ourPort + "/fhir/metadata", ourRequestUriAll.get(1));
assertEquals(1, ourRequestHeadersAll.get(0).get("Accept").size());
@ -192,7 +192,7 @@ public class GenericJaxRsClientDstu3Test {
conf.setCopyright("COPY");
final Patient patient = new Patient();
patient.addName().addFamily("FAMILY");
patient.addName().setFamily("FAMILY");
ourResponseContentType = Constants.CT_FHIR_XML + "; charset=UTF-8";
ourResponseBodies = new String[] { p.encodeResourceToString(conf), p.encodeResourceToString(conf), p.encodeResourceToString(patient) };
@ -202,7 +202,7 @@ public class GenericJaxRsClientDstu3Test {
client.setEncoding(EncodingEnum.JSON);
Patient resp = client.read(Patient.class, new IdType("123").getValue());
assertEquals("FAMILY", resp.getName().get(0).getFamily().get(0).getValue());
assertEquals("FAMILY", resp.getName().get(0).getFamily());
assertEquals("http://localhost:" + ourPort + "/fhir/metadata?_format=json", ourRequestUriAll.get(0));
assertEquals("http://localhost:" + ourPort + "/fhir/metadata?_format=json", ourRequestUriAll.get(1));
assertEquals(1, ourRequestHeadersAll.get(0).get("Accept").size());
@ -264,7 +264,7 @@ public class GenericJaxRsClientDstu3Test {
Patient p = new Patient();
p.addName().addFamily("FOOFAMILY");
p.addName().setFamily("FOOFAMILY");
client.create().resource(p).execute();
@ -300,7 +300,7 @@ public class GenericJaxRsClientDstu3Test {
Patient p = new Patient();
p.addName().addFamily("FOOFAMILY");
p.addName().setFamily("FOOFAMILY");
client.create().resource(p).conditionalByUrl("Patient?name=foo").execute();
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_CONTENT_TYPE).size());
@ -341,7 +341,7 @@ public class GenericJaxRsClientDstu3Test {
Patient p = new Patient();
p.addName().addFamily("FOOFAMILY");
p.addName().setFamily("FOOFAMILY");
client.create(p);
@ -364,7 +364,7 @@ public class GenericJaxRsClientDstu3Test {
Patient p = new Patient();
p.addName().addFamily("FOOFAMILY");
p.addName().setFamily("FOOFAMILY");
client.create().resource(p).prefer(PreferReturnEnum.MINIMAL).execute();
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_PREFER).size());
@ -394,7 +394,7 @@ public class GenericJaxRsClientDstu3Test {
p = new Patient();
p.setId(new IdType("1"));
p.addName().addFamily("FOOFAMILY");
p.addName().setFamily("FOOFAMILY");
MethodOutcome output = client.create().resource(p).execute();
assertNotNull(output.getResource());
@ -1260,7 +1260,7 @@ public class GenericJaxRsClientDstu3Test {
public void testReadByUri() throws Exception {
Patient patient = new Patient();
patient.addName().addFamily("FAM");
patient.addName().setFamily("FAM");
final String respString = ourCtx.newXmlParser().encodeResourceToString(patient);
ourResponseContentType = Constants.CT_FHIR_XML + "; charset=UTF-8";
@ -1273,14 +1273,14 @@ public class GenericJaxRsClientDstu3Test {
response = (Patient) client.read(new UriDt("http://localhost:" + ourPort + "/fhir/Patient/123"));
assertEquals("http://localhost:" + ourPort + "/fhir/Patient/123", ourRequestUri);
assertEquals("FAM", response.getName().get(0).getFamily().get(0).getValue());
assertEquals("FAM", response.getName().get(0).getFamily());
}
@Test
public void testReadFluentByUri() throws Exception {
Patient patient = new Patient();
patient.addName().addFamily("FAM");
patient.addName().setFamily("FAM");
final String respString = ourCtx.newXmlParser().encodeResourceToString(patient);
ourResponseContentType = Constants.CT_FHIR_XML + "; charset=UTF-8";
@ -1292,7 +1292,7 @@ public class GenericJaxRsClientDstu3Test {
response = (Patient) client.read().resource(Patient.class).withUrl(new IdType("http://localhost:" + ourPort + "/AAA/Patient/123")).execute();
assertEquals("http://localhost:" + ourPort + "/AAA/Patient/123", ourRequestUri);
assertEquals("FAM", response.getName().get(0).getFamily().get(0).getValue());
assertEquals("FAM", response.getName().get(0).getFamily());
}
@Test
@ -1779,11 +1779,11 @@ public class GenericJaxRsClientDstu3Test {
List<IBaseResource> input = new ArrayList<IBaseResource>();
Patient p1 = new Patient(); // No ID
p1.addName().addFamily("PATIENT1");
p1.addName().setFamily("PATIENT1");
input.add(p1);
Patient p2 = new Patient(); // Yes ID
p2.addName().addFamily("PATIENT2");
p2.addName().setFamily("PATIENT2");
p2.setId("Patient/2");
input.add(p2);
@ -1818,7 +1818,7 @@ public class GenericJaxRsClientDstu3Test {
org.hl7.fhir.dstu3.model.Bundle req = new org.hl7.fhir.dstu3.model.Bundle();
Patient patient = new Patient();
patient.addName().addFamily("PAT_FAMILY");
patient.addName().setFamily("PAT_FAMILY");
req.addEntry().setResource(patient);
Observation observation = new Observation();
observation.getCode().setText("OBS_TEXT");
@ -1878,11 +1878,11 @@ public class GenericJaxRsClientDstu3Test {
org.hl7.fhir.dstu3.model.Bundle input = new org.hl7.fhir.dstu3.model.Bundle();
Patient p1 = new Patient(); // No ID
p1.addName().addFamily("PATIENT1");
p1.addName().setFamily("PATIENT1");
input.addEntry().setResource(p1);
Patient p2 = new Patient(); // Yes ID
p2.addName().addFamily("PATIENT2");
p2.addName().setFamily("PATIENT2");
p2.setId("Patient/2");
input.addEntry().setResource(p2);
@ -1911,7 +1911,7 @@ public class GenericJaxRsClientDstu3Test {
Patient p = new Patient();
p.addName().addFamily("FOOFAMILY");
p.addName().setFamily("FOOFAMILY");
client.update().resource(p).conditionalByUrl("Patient?name=foo").execute();
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_CONTENT_TYPE).size());
@ -1966,7 +1966,7 @@ public class GenericJaxRsClientDstu3Test {
Patient p = new Patient();
p.addName().addFamily("FOOFAMILY");
p.addName().setFamily("FOOFAMILY");
client.update(new IdType("Patient/123").getValue(), p);
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_CONTENT_TYPE).size());
@ -1997,7 +1997,7 @@ public class GenericJaxRsClientDstu3Test {
Patient p = new Patient();
p.setId(new IdType("1"));
p.addName().addFamily("FOOFAMILY");
p.addName().setFamily("FOOFAMILY");
client.update().resource(p).prefer(PreferReturnEnum.MINIMAL).execute();
assertEquals(1, ourRequestHeaders.get(Constants.HEADER_PREFER).size());
@ -2027,7 +2027,7 @@ public class GenericJaxRsClientDstu3Test {
p = new Patient();
p.setId(new IdType("1"));
p.addName().addFamily("FOOFAMILY");
p.addName().setFamily("FOOFAMILY");
MethodOutcome output = client.update().resource(p).execute();
assertNotNull(output.getResource());

View File

@ -200,7 +200,7 @@ public class JaxRsPatientRestProviderDstu3 extends AbstractJaxRsResourceProvider
for (final List<Patient> patientIterator : patients.values()) {
Patient single = null;
for (Patient patient : patientIterator) {
if (name == null || patient.getName().get(0).getFamily().get(0).getValueNotNull().equals(name.getValueNotNull())) {
if (name == null || patient.getName().get(0).getFamilyElement().getValueNotNull().equals(name.getValueNotNull())) {
single = patient;
}
}
@ -251,7 +251,7 @@ public class JaxRsPatientRestProviderDstu3 extends AbstractJaxRsResourceProvider
private static List<Patient> createPatient(final String name) {
final Patient patient = new Patient();
patient.getName().add(new HumanName().addFamily(name));
patient.getName().add(new HumanName().setFamily(name));
return createPatient(patient);
}

View File

@ -168,7 +168,7 @@ public class JaxRsPatientProviderDstu3Test {
public void testCreatePatient() {
final Patient existing = new Patient();
existing.setId((IdType) null);
existing.getName().add(new HumanName().addFamily("Created Patient 54"));
existing.getName().add(new HumanName().setFamily("Created Patient 54"));
client.setEncoding(EncodingEnum.JSON);
final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute();
System.out.println(results.getId());
@ -184,7 +184,7 @@ public class JaxRsPatientProviderDstu3Test {
public void testConditionalCreate() {
final Patient existing = new Patient();
existing.setId((IdType) null);
existing.getName().add(new HumanName().addFamily("Created Patient 54"));
existing.getName().add(new HumanName().setFamily("Created Patient 54"));
client.setEncoding(EncodingEnum.XML);
final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute();
System.out.println(results.getId());
@ -218,7 +218,7 @@ public class JaxRsPatientProviderDstu3Test {
@Test
public void testDeletePatient() {
final Patient existing = new Patient();
existing.getName().add(new HumanName().addFamily("Created Patient XYZ"));
existing.getName().add(new HumanName().setFamily("Created Patient XYZ"));
final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute();
System.out.println(results.getId());
final Patient patient = (Patient) results.getResource();
@ -239,7 +239,7 @@ public class JaxRsPatientProviderDstu3Test {
Bundle bundle = new Bundle();
BundleEntryComponent entry = bundle.addEntry();
final Patient existing = new Patient();
existing.getName().get(0).addFamily("Created with bundle");
existing.getName().get(0).setFamily("Created with bundle");
entry.setResource(existing);
// FIXME ?

View File

@ -23,7 +23,13 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.math.BigDecimal;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import javax.measure.unit.NonSI;
import javax.measure.unit.Unit;
@ -32,12 +38,31 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.hl7.fhir.dstu3.context.IWorkerContext;
import org.hl7.fhir.dstu3.hapi.validation.IValidationSupport;
import org.hl7.fhir.dstu3.model.*;
import org.hl7.fhir.dstu3.model.Address;
import org.hl7.fhir.dstu3.model.Base;
import org.hl7.fhir.dstu3.model.BaseDateTimeType;
import org.hl7.fhir.dstu3.model.CodeSystem;
import org.hl7.fhir.dstu3.model.CodeableConcept;
import org.hl7.fhir.dstu3.model.Coding;
import org.hl7.fhir.dstu3.model.Conformance.ConformanceRestSecurityComponent;
import org.hl7.fhir.dstu3.model.ContactPoint;
import org.hl7.fhir.dstu3.model.DateTimeType;
import org.hl7.fhir.dstu3.model.Duration;
import org.hl7.fhir.dstu3.model.Enumeration;
import org.hl7.fhir.dstu3.model.HumanName;
import org.hl7.fhir.dstu3.model.Identifier;
import org.hl7.fhir.dstu3.model.IntegerType;
import org.hl7.fhir.dstu3.model.Location.LocationPositionComponent;
import org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent;
import org.hl7.fhir.dstu3.utils.FluentPathEngine;
import org.hl7.fhir.dstu3.model.Period;
import org.hl7.fhir.dstu3.model.Quantity;
import org.hl7.fhir.dstu3.model.Questionnaire;
import org.hl7.fhir.dstu3.model.Range;
import org.hl7.fhir.dstu3.model.SimpleQuantity;
import org.hl7.fhir.dstu3.model.StringType;
import org.hl7.fhir.dstu3.model.Timing;
import org.hl7.fhir.dstu3.model.UriType;
import org.hl7.fhir.dstu3.utils.FHIRPathEngine;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.instance.model.api.IBase;
import org.hl7.fhir.instance.model.api.IBaseResource;
@ -54,7 +79,15 @@ import ca.uhn.fhir.jpa.dao.BaseHapiFhirDao;
import ca.uhn.fhir.jpa.dao.BaseSearchParamExtractor;
import ca.uhn.fhir.jpa.dao.ISearchParamExtractor;
import ca.uhn.fhir.jpa.dao.PathAndRef;
import ca.uhn.fhir.jpa.entity.*;
import ca.uhn.fhir.jpa.entity.BaseResourceIndexedSearchParam;
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamCoords;
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamDate;
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamNumber;
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamQuantity;
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamString;
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamToken;
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamUri;
import ca.uhn.fhir.jpa.entity.ResourceTable;
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
@ -390,7 +423,9 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
if (nextObject instanceof HumanName) {
ArrayList<StringType> allNames = new ArrayList<StringType>();
HumanName nextHumanName = (HumanName) nextObject;
allNames.addAll(nextHumanName.getFamily());
if (isNotBlank(nextHumanName.getFamily())) {
allNames.add(nextHumanName.getFamilyElement());
}
allNames.addAll(nextHumanName.getGiven());
for (StringType nextName : allNames) {
addSearchTerm(theEntity, retVal, resourceName, nextName.getValue());
@ -676,7 +711,7 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
@Override
protected List<Object> extractValues(String thePaths, IBaseResource theResource) {
IWorkerContext worker = new org.hl7.fhir.dstu3.hapi.validation.HapiWorkerContext(getContext(), myValidationSupport);
FluentPathEngine fp = new FluentPathEngine(worker);
FHIRPathEngine fp = new FHIRPathEngine(worker);
List<Object> values = new ArrayList<Object>();
try {

View File

@ -34,7 +34,7 @@ public class FhirResourceDaoDstu3ContainedTest extends BaseJpaDstu3Test {
public void testIndexContained() {
Patient p = new Patient();
p.setId("#some_patient");
p.addName().addFamily("MYFAMILY").addGiven("MYGIVEN");
p.addName().setFamily("MYFAMILY").addGiven("MYGIVEN");
Observation o1 = new Observation();
o1.getCode().setText("Some Observation");
@ -47,7 +47,7 @@ public class FhirResourceDaoDstu3ContainedTest extends BaseJpaDstu3Test {
IIdType oid2 = myObservationDao.create(o2, mySrd).getId().toUnqualifiedVersionless();
Patient p2 = new Patient();
p2.addName().addFamily("MYFAMILY").addGiven("MYGIVEN");
p2.addName().setFamily("MYFAMILY").addGiven("MYGIVEN");
IIdType pid2 = myPatientDao.create(p2, mySrd).getId().toUnqualifiedVersionless();
ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(o2));

View File

@ -57,7 +57,7 @@ public class FhirResourceDaoDstu3InterceptorTest extends BaseJpaDstu3Test {
@Test
public void testJpaCreate() {
Patient p = new Patient();
p.addName().addFamily("PATIENT");
p.addName().setFamily("PATIENT");
Long id = myPatientDao.create(p, mySrd).getId().getIdPartAsLong();
ArgumentCaptor<ActionRequestDetails> detailsCapt;
@ -77,7 +77,7 @@ public class FhirResourceDaoDstu3InterceptorTest extends BaseJpaDstu3Test {
* Not do a conditional create
*/
p = new Patient();
p.addName().addFamily("PATIENT1");
p.addName().setFamily("PATIENT1");
Long id2 = myPatientDao.create(p, "Patient?family=PATIENT", mySrd).getId().getIdPartAsLong();
assertEquals(id, id2);
@ -91,7 +91,7 @@ public class FhirResourceDaoDstu3InterceptorTest extends BaseJpaDstu3Test {
@Test
public void testJpaDelete() {
Patient p = new Patient();
p.addName().addFamily("PATIENT");
p.addName().setFamily("PATIENT");
Long id = myPatientDao.create(p, mySrd).getId().getIdPartAsLong();
myPatientDao.delete(new IdType("Patient", id), mySrd);
@ -111,12 +111,12 @@ public class FhirResourceDaoDstu3InterceptorTest extends BaseJpaDstu3Test {
@Test
public void testJpaUpdate() {
Patient p = new Patient();
p.addName().addFamily("PATIENT");
p.addName().setFamily("PATIENT");
Long id = myPatientDao.create(p, mySrd).getId().getIdPartAsLong();
p = new Patient();
p.setId(new IdType(id));
p.addName().addFamily("PATIENT1");
p.addName().setFamily("PATIENT1");
Long id2 = myPatientDao.update(p, mySrd).getId().getIdPartAsLong();
assertEquals(id, id2);
@ -135,7 +135,7 @@ public class FhirResourceDaoDstu3InterceptorTest extends BaseJpaDstu3Test {
p = new Patient();
p.setId(new IdType(id));
p.addName().addFamily("PATIENT2");
p.addName().setFamily("PATIENT2");
id2 = myPatientDao.update(p, "Patient?family=PATIENT1", mySrd).getId().getIdPartAsLong();
assertEquals(id, id2);
@ -150,7 +150,7 @@ public class FhirResourceDaoDstu3InterceptorTest extends BaseJpaDstu3Test {
*/
p = new Patient();
p.addName().addFamily("PATIENT3");
p.addName().setFamily("PATIENT3");
id2 = myPatientDao.update(p, "Patient?family=ZZZ", mySrd).getId().getIdPartAsLong();
assertNotEquals(id, id2);

View File

@ -146,7 +146,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
@Test
public void testSuggestIgnoresBase64Content() {
Patient patient = new Patient();
patient.addName().addFamily("testSuggest");
patient.addName().setFamily("testSuggest");
IIdType ptId = myPatientDao.create(patient, mockSrd()).getId().toUnqualifiedVersionless();
Media med = new Media();
@ -186,7 +186,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
@Test
public void testSuggest() {
Patient patient = new Patient();
patient.addName().addFamily("testSuggest");
patient.addName().setFamily("testSuggest");
IIdType ptId = myPatientDao.create(patient, mockSrd()).getId().toUnqualifiedVersionless();
Observation obs = new Observation();
@ -209,7 +209,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
* These shouldn't match since they're for another patient
*/
patient = new Patient();
patient.addName().addFamily("testSuggest2");
patient.addName().setFamily("testSuggest2");
IIdType ptId2 = myPatientDao.create(patient, mockSrd()).getId().toUnqualifiedVersionless();
Observation obs2 = new Observation();
@ -301,11 +301,11 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
@Test
public void testEverythingInstanceWithContentFilter() {
Patient pt1 = new Patient();
pt1.addName().addFamily("Everything").addGiven("Arthur");
pt1.addName().setFamily("Everything").addGiven("Arthur");
IIdType ptId1 = myPatientDao.create(pt1, mockSrd()).getId().toUnqualifiedVersionless();
Patient pt2 = new Patient();
pt2.addName().addFamily("Everything").addGiven("Arthur");
pt2.addName().setFamily("Everything").addGiven("Arthur");
IIdType ptId2 = myPatientDao.create(pt2, mockSrd()).getId().toUnqualifiedVersionless();
Device dev1 = new Device();
@ -394,11 +394,11 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
@Test
public void testEverythingTypeWithContentFilter() {
Patient pt1 = new Patient();
pt1.addName().addFamily("Everything").addGiven("Arthur");
pt1.addName().setFamily("Everything").addGiven("Arthur");
IIdType ptId1 = myPatientDao.create(pt1, mockSrd()).getId().toUnqualifiedVersionless();
Patient pt2 = new Patient();
pt2.addName().addFamily("Everything").addGiven("Arthur");
pt2.addName().setFamily("Everything").addGiven("Arthur");
IIdType ptId2 = myPatientDao.create(pt2, mockSrd()).getId().toUnqualifiedVersionless();
Device dev1 = new Device();

View File

@ -75,7 +75,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
@Override
public IIdType doInTransaction(TransactionStatus theStatus) {
org.hl7.fhir.dstu3.model.Patient p = new org.hl7.fhir.dstu3.model.Patient();
p.addName().addFamily(methodName);
p.addName().setFamily(methodName);
IIdType pid = myPatientDao.create(p).getId().toUnqualifiedVersionless();
org.hl7.fhir.dstu3.model.Condition c = new org.hl7.fhir.dstu3.model.Condition();
@ -291,11 +291,11 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
public void testIndexNoDuplicatesReference() {
Practitioner pract =new Practitioner();
pract.setId("Practitioner/somepract");
pract.addName().addFamily("SOME PRACT");
pract.addName().setFamily("SOME PRACT");
myPractitionerDao.update(pract, mySrd);
Practitioner pract2 =new Practitioner();
pract2.setId("Practitioner/somepract2");
pract2.addName().addFamily("SOME PRACT2");
pract2.addName().setFamily("SOME PRACT2");
myPractitionerDao.update(pract2, mySrd);
DiagnosticRequest res = new DiagnosticRequest();
@ -384,13 +384,13 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily("Tester").addGiven("Joe");
patient.addName().setFamily("Tester").addGiven("Joe");
myPatientDao.create(patient, mySrd);
}
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("002");
patient.addName().addFamily("Tester").addGiven("John");
patient.addName().setFamily("Tester").addGiven("John");
myPatientDao.create(patient, mySrd);
}
@ -406,13 +406,13 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily("Tester").addGiven("Joe");
patient.addName().setFamily("Tester").addGiven("Joe");
pid0 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily("Tester").addGiven("Joe");
patient.addName().setFamily("Tester").addGiven("Joe");
myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
{
@ -788,7 +788,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
Patient patient = new Patient();
patient.setId("TEST");
patient.setLanguageElement(new CodeType("TEST"));
patient.addName().addFamily("TEST");
patient.addName().setFamily("TEST");
patient.addIdentifier().setSystem("TEST").setValue("TEST");
myPatientDao.update(patient, mySrd);
}
@ -841,7 +841,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
Patient patient = new Patient();
patient.getLanguageElement().setValue("en_CA");
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily("testSearchLanguageParam").addGiven("Joe");
patient.addName().setFamily("testSearchLanguageParam").addGiven("Joe");
id1 = myPatientDao.create(patient, mySrd).getId();
}
IIdType id2;
@ -849,7 +849,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
Patient patient = new Patient();
patient.getLanguageElement().setValue("en_US");
patient.addIdentifier().setSystem("urn:system").setValue("002");
patient.addName().addFamily("testSearchLanguageParam").addGiven("John");
patient.addName().setFamily("testSearchLanguageParam").addGiven("John");
id2 = myPatientDao.create(patient, mySrd).getId();
}
{
@ -881,7 +881,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
Patient patient = new Patient();
patient.getLanguageElement().setValue("en_CA");
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily("testSearchLanguageParam").addGiven("Joe");
patient.addName().setFamily("testSearchLanguageParam").addGiven("Joe");
id1 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
@ -892,7 +892,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
Patient patient = new Patient();
patient.getLanguageElement().setValue("en_US");
patient.addIdentifier().setSystem("urn:system").setValue("002");
patient.addName().addFamily("testSearchLanguageParam").addGiven("John");
patient.addName().setFamily("testSearchLanguageParam").addGiven("John");
id2 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
{
@ -976,14 +976,14 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily(methodName).addGiven("Joe");
patient.addName().setFamily(methodName).addGiven("Joe");
id1a = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
IIdType id1b;
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("002");
patient.addName().addFamily(methodName + "XXXX").addGiven("Joe");
patient.addName().setFamily(methodName + "XXXX").addGiven("Joe");
id1b = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
@ -995,7 +995,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("002");
patient.addName().addFamily(methodName).addGiven("John");
patient.addName().setFamily(methodName).addGiven("John");
id2 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
@ -1102,13 +1102,13 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily("testSearchNameParam01Fam").addGiven("testSearchNameParam01Giv");
patient.addName().setFamily("testSearchNameParam01Fam").addGiven("testSearchNameParam01Giv");
id1 = myPatientDao.create(patient, mySrd).getId();
}
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("002");
patient.addName().addFamily("testSearchNameParam02Fam").addGiven("testSearchNameParam02Giv");
patient.addName().setFamily("testSearchNameParam02Fam").addGiven("testSearchNameParam02Giv");
myPatientDao.create(patient, mySrd);
}
@ -1188,7 +1188,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
IIdType id;
{
Patient patient = new Patient();
patient.addName().addFamily(name);
patient.addName().setFamily(name);
id = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
@ -1216,14 +1216,14 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
IIdType id1;
{
Practitioner patient = new Practitioner();
patient.addName().addFamily(methodName);
patient.addName().setFamily(methodName);
patient.addTelecom().setSystem(ContactPointSystem.PHONE).setValue("123");
id1 = myPractitionerDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
IIdType id2;
{
Practitioner patient = new Practitioner();
patient.addName().addFamily(methodName);
patient.addName().setFamily(methodName);
patient.addTelecom().setSystem(ContactPointSystem.EMAIL).setValue("abc");
id2 = myPractitionerDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
@ -1362,8 +1362,8 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
@Test
public void testSearchResourceLinkWithChainWithMultipleTypes() throws Exception {
Patient patient = new Patient();
patient.addName().addFamily("testSearchResourceLinkWithChainWithMultipleTypes01");
patient.addName().addFamily("testSearchResourceLinkWithChainWithMultipleTypesXX");
patient.addName().setFamily("testSearchResourceLinkWithChainWithMultipleTypes01");
patient.addName().setFamily("testSearchResourceLinkWithChainWithMultipleTypesXX");
IIdType patientId01 = myPatientDao.create(patient, mySrd).getId();
Location loc01 = new Location();
@ -1467,7 +1467,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily("Tester_testSearchStringParam").addGiven("Joe");
patient.addName().setFamily("Tester_testSearchStringParam").addGiven("Joe");
pid1 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
Date between = new Date();
@ -1475,7 +1475,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("002");
patient.addName().addFamily("Tester_testSearchStringParam").addGiven("John");
patient.addName().setFamily("Tester_testSearchStringParam").addGiven("John");
pid2 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
Thread.sleep(10);
@ -1519,14 +1519,14 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
IIdType pid2;
{
Patient patient = new Patient();
patient.addName().addFamily("EXPIRE");
patient.addName().setFamily("EXPIRE");
pid1 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
Date between = new Date();
Thread.sleep(10);
{
Patient patient = new Patient();
patient.addName().addFamily("EXPIRE");
patient.addName().setFamily("EXPIRE");
pid2 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
Thread.sleep(10);
@ -1551,13 +1551,13 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
IIdType pid2;
{
Patient patient = new Patient();
patient.addName().addFamily("EXPIRE");
patient.addName().setFamily("EXPIRE");
pid1 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
Thread.sleep(10);
{
Patient patient = new Patient();
patient.addName().addFamily("EXPIRE");
patient.addName().setFamily("EXPIRE");
pid2 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
Thread.sleep(10);
@ -1587,7 +1587,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily(value);
patient.addName().setFamily(value);
longId = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
{
@ -1638,13 +1638,13 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
public void testSearchTokenParam() {
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("testSearchTokenParam001");
patient.addName().addFamily("Tester").addGiven("testSearchTokenParam1");
patient.addName().setFamily("Tester").addGiven("testSearchTokenParam1");
patient.addCommunication().getLanguage().setText("testSearchTokenParamComText").addCoding().setCode("testSearchTokenParamCode").setSystem("testSearchTokenParamSystem").setDisplay("testSearchTokenParamDisplay");
myPatientDao.create(patient, mySrd);
patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("testSearchTokenParam002");
patient.addName().addFamily("Tester").addGiven("testSearchTokenParam2");
patient.addName().setFamily("Tester").addGiven("testSearchTokenParam2");
myPatientDao.create(patient, mySrd);
{
@ -1711,18 +1711,18 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
public void testSearchTokenParamNoValue() {
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("testSearchTokenParam001");
patient.addName().addFamily("Tester").addGiven("testSearchTokenParam1");
patient.addName().setFamily("Tester").addGiven("testSearchTokenParam1");
patient.addCommunication().getLanguage().setText("testSearchTokenParamComText").addCoding().setCode("testSearchTokenParamCode").setSystem("testSearchTokenParamSystem").setDisplay("testSearchTokenParamDisplay");
myPatientDao.create(patient, mySrd);
patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("testSearchTokenParam002");
patient.addName().addFamily("Tester").addGiven("testSearchTokenParam2");
patient.addName().setFamily("Tester").addGiven("testSearchTokenParam2");
myPatientDao.create(patient, mySrd);
patient = new Patient();
patient.addIdentifier().setSystem("urn:system2").setValue("testSearchTokenParam002");
patient.addName().addFamily("Tester").addGiven("testSearchTokenParam2");
patient.addName().setFamily("Tester").addGiven("testSearchTokenParam2");
myPatientDao.create(patient, mySrd);
{
@ -1829,14 +1829,14 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily("Tester_" + methodName + "_P1").addGiven("Joe");
patient.addName().setFamily("Tester_" + methodName + "_P1").addGiven("Joe");
patient.getManagingOrganization().setReferenceElement(orgId);
myPatientDao.create(patient, mySrd);
}
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("002");
patient.addName().addFamily("Tester_" + methodName + "_P2").addGiven("John");
patient.addName().setFamily("Tester_" + methodName + "_P2").addGiven("John");
myPatientDao.create(patient, mySrd);
}
@ -1946,7 +1946,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily("Tester_" + methodName + "_P1").addGiven("Joe");
patient.addName().setFamily("Tester_" + methodName + "_P1").addGiven("Joe");
patient.getManagingOrganization().setReferenceElement(orgId);
patientId = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
@ -1988,7 +1988,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily("Tester_" + methodName + "_P1").addGiven("Joe");
patient.addName().setFamily("Tester_" + methodName + "_P1").addGiven("Joe");
patient.getManagingOrganization().setReferenceElement(orgId);
patientId = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
@ -2030,7 +2030,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily("Tester_" + methodName + "_P1").addGiven("Joe");
patient.addName().setFamily("Tester_" + methodName + "_P1").addGiven("Joe");
patient.getManagingOrganization().setReferenceElement(orgId);
patientId = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
@ -2071,7 +2071,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily("Tester_" + methodName + "_P1").addGiven("Joe");
patient.addName().setFamily("Tester_" + methodName + "_P1").addGiven("Joe");
patient.getManagingOrganization().setReferenceElement(orgId);
patientId = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
@ -2099,14 +2099,14 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily("Tester_testSearchWithIncludesThatHaveTextId_P1").addGiven("Joe");
patient.addName().setFamily("Tester_testSearchWithIncludesThatHaveTextId_P1").addGiven("Joe");
patient.getManagingOrganization().setReferenceElement(orgId);
myPatientDao.create(patient, mySrd);
}
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("002");
patient.addName().addFamily("Tester_testSearchWithIncludesThatHaveTextId_P2").addGiven("John");
patient.addName().setFamily("Tester_testSearchWithIncludesThatHaveTextId_P2").addGiven("John");
myPatientDao.create(patient, mySrd);
}
@ -2139,7 +2139,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("002");
patient.addName().addFamily("Tester_testSearchStringParam").addGiven("John");
patient.addName().setFamily("Tester_testSearchStringParam").addGiven("John");
patient.setBirthDateElement(new DateType("2011-01-01"));
patient.getManagingOrganization().setReferenceElement(orgId);
notMissing = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
@ -2214,7 +2214,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("002");
patient.addName().addFamily("Tester_testSearchStringParam").addGiven("John");
patient.addName().setFamily("Tester_testSearchStringParam").addGiven("John");
patient.setBirthDateElement(new DateType("2011-01-01"));
patient.getManagingOrganization().setReferenceElement(orgId);
notMissing = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
@ -2254,7 +2254,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("002");
patient.addName().addFamily("Tester_testSearchStringParam").addGiven("John");
patient.addName().setFamily("Tester_testSearchStringParam").addGiven("John");
patient.setBirthDateElement(new DateType("2011-01-01"));
patient.getManagingOrganization().setReferenceElement(orgId);
notMissing = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();

View File

@ -222,7 +222,7 @@ public class FhirResourceDaoDstu3SubscriptionTest extends BaseJpaDstu3Test {
String methodName = "testDeleteSubscriptionWithFlaggedResources";
Patient p = new Patient();
p.addName().addFamily(methodName);
p.addName().setFamily(methodName);
IIdType pId = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
Subscription subs;
@ -310,7 +310,7 @@ public class FhirResourceDaoDstu3SubscriptionTest extends BaseJpaDstu3Test {
String methodName = "testSubscriptionResourcesAppear";
Patient p = new Patient();
p.addName().addFamily(methodName);
p.addName().setFamily(methodName);
IIdType pId = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
Observation obs = new Observation();
@ -418,7 +418,7 @@ public class FhirResourceDaoDstu3SubscriptionTest extends BaseJpaDstu3Test {
String methodName = "testSubscriptionResourcesAppear2";
Patient p = new Patient();
p.addName().addFamily(methodName);
p.addName().setFamily(methodName);
IIdType pId = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
Observation obs = new Observation();

View File

@ -12,13 +12,13 @@ import java.util.List;
import java.util.Set;
import org.hl7.fhir.dstu3.model.AllergyIntolerance;
import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceStatus;
import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory;
import org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus;
import org.hl7.fhir.dstu3.model.AuditEvent;
import org.hl7.fhir.dstu3.model.CodeSystem;
import org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemContentMode;
import org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent;
import org.hl7.fhir.dstu3.model.Observation;
import org.hl7.fhir.dstu3.model.Observation.ObservationStatus;
import org.hl7.fhir.dstu3.model.ValueSet;
import org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent;
import org.hl7.fhir.dstu3.model.ValueSet.FilterOperator;
@ -575,30 +575,30 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test {
@Test
public void testSearchCodeInBuiltInValueSet() {
AllergyIntolerance ai1 = new AllergyIntolerance();
ai1.setStatus(AllergyIntoleranceStatus.ACTIVE);
ai1.setClinicalStatus(AllergyIntoleranceClinicalStatus.ACTIVE);
String id1 = myAllergyIntoleranceDao.create(ai1, mySrd).getId().toUnqualifiedVersionless().getValue();
AllergyIntolerance ai2 = new AllergyIntolerance();
ai2.setStatus(AllergyIntoleranceStatus.ACTIVECONFIRMED);
ai2.setClinicalStatus(AllergyIntoleranceClinicalStatus.RESOLVED);
String id2 = myAllergyIntoleranceDao.create(ai2, mySrd).getId().toUnqualifiedVersionless().getValue();
AllergyIntolerance ai3 = new AllergyIntolerance();
ai3.setStatus(AllergyIntoleranceStatus.INACTIVE);
ai3.setClinicalStatus(AllergyIntoleranceClinicalStatus.INACTIVE);
String id3 = myAllergyIntoleranceDao.create(ai3, mySrd).getId().toUnqualifiedVersionless().getValue();
SearchParameterMap params;
params = new SearchParameterMap();
params.add(AllergyIntolerance.SP_STATUS, new TokenParam(null, "http://hl7.org/fhir/ValueSet/allergy-intolerance-status").setModifier(TokenParamModifier.IN));
params.add(AllergyIntolerance.SP_CLINICAL_STATUS, new TokenParam(null, "http://hl7.org/fhir/ValueSet/allergy-clinical-status").setModifier(TokenParamModifier.IN));
assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), containsInAnyOrder(id1, id2, id3));
// No codes in this one
params = new SearchParameterMap();
params.add(AllergyIntolerance.SP_STATUS, new TokenParam(null, "http://hl7.org/fhir/ValueSet/allergy-intolerance-criticality").setModifier(TokenParamModifier.IN));
params.add(AllergyIntolerance.SP_CLINICAL_STATUS, new TokenParam(null, "http://hl7.org/fhir/ValueSet/allergy-intolerance-criticality").setModifier(TokenParamModifier.IN));
assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), empty());
// Invalid VS
params = new SearchParameterMap();
params.add(AllergyIntolerance.SP_STATUS, new TokenParam(null, "http://hl7.org/fhir/ValueSet/FOO").setModifier(TokenParamModifier.IN));
params.add(AllergyIntolerance.SP_CLINICAL_STATUS, new TokenParam(null, "http://hl7.org/fhir/ValueSet/FOO").setModifier(TokenParamModifier.IN));
try {
myAllergyIntoleranceDao.search(params);
} catch (InvalidRequestException e) {
@ -615,30 +615,30 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test {
@Ignore
public void testSearchCodeNotInBuiltInValueSet() {
AllergyIntolerance ai1 = new AllergyIntolerance();
ai1.setStatus(AllergyIntoleranceStatus.ACTIVE);
ai1.setClinicalStatus(AllergyIntoleranceClinicalStatus.ACTIVE);
String id1 = myAllergyIntoleranceDao.create(ai1, mySrd).getId().toUnqualifiedVersionless().getValue();
AllergyIntolerance ai2 = new AllergyIntolerance();
ai2.setStatus(AllergyIntoleranceStatus.ACTIVECONFIRMED);
ai2.setClinicalStatus(AllergyIntoleranceClinicalStatus.RESOLVED);
String id2 = myAllergyIntoleranceDao.create(ai2, mySrd).getId().toUnqualifiedVersionless().getValue();
AllergyIntolerance ai3 = new AllergyIntolerance();
ai3.setStatus(AllergyIntoleranceStatus.INACTIVE);
ai3.setClinicalStatus(AllergyIntoleranceClinicalStatus.INACTIVE);
String id3 = myAllergyIntoleranceDao.create(ai3, mySrd).getId().toUnqualifiedVersionless().getValue();
SearchParameterMap params;
params = new SearchParameterMap();
params.add(AllergyIntolerance.SP_STATUS, new TokenParam(null, "http://hl7.org/fhir/ValueSet/allergy-intolerance-status").setModifier(TokenParamModifier.NOT_IN));
params.add(AllergyIntolerance.SP_CLINICAL_STATUS, new TokenParam(null, "http://hl7.org/fhir/ValueSet/allergy-intolerance-status").setModifier(TokenParamModifier.NOT_IN));
assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), empty());
// No codes in this one
params = new SearchParameterMap();
params.add(AllergyIntolerance.SP_STATUS, new TokenParam(null, "http://hl7.org/fhir/ValueSet/allergy-intolerance-criticality").setModifier(TokenParamModifier.NOT_IN));
params.add(AllergyIntolerance.SP_CLINICAL_STATUS, new TokenParam(null, "http://hl7.org/fhir/ValueSet/allergy-intolerance-criticality").setModifier(TokenParamModifier.NOT_IN));
assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), containsInAnyOrder(id1, id2, id3));
// Invalid VS
params = new SearchParameterMap();
params.add(AllergyIntolerance.SP_STATUS, new TokenParam(null, "http://hl7.org/fhir/ValueSet/FOO").setModifier(TokenParamModifier.NOT_IN));
params.add(AllergyIntolerance.SP_CLINICAL_STATUS, new TokenParam(null, "http://hl7.org/fhir/ValueSet/FOO").setModifier(TokenParamModifier.NOT_IN));
try {
myAllergyIntoleranceDao.search(params);
} catch (InvalidRequestException e) {
@ -650,46 +650,42 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test {
@Test
public void testSearchCodeBelowBuiltInCodesystem() {
AllergyIntolerance ai1 = new AllergyIntolerance();
ai1.setStatus(AllergyIntoleranceStatus.ACTIVE);
ai1.setClinicalStatus(AllergyIntoleranceClinicalStatus.ACTIVE);
String id1 = myAllergyIntoleranceDao.create(ai1, mySrd).getId().toUnqualifiedVersionless().getValue();
AllergyIntolerance ai2 = new AllergyIntolerance();
ai2.setStatus(AllergyIntoleranceStatus.ACTIVECONFIRMED);
ai2.setClinicalStatus(AllergyIntoleranceClinicalStatus.RESOLVED);
String id2 = myAllergyIntoleranceDao.create(ai2, mySrd).getId().toUnqualifiedVersionless().getValue();
AllergyIntolerance ai3 = new AllergyIntolerance();
ai3.setStatus(AllergyIntoleranceStatus.INACTIVE);
ai3.setClinicalStatus(AllergyIntoleranceClinicalStatus.INACTIVE);
String id3 = myAllergyIntoleranceDao.create(ai3, mySrd).getId().toUnqualifiedVersionless().getValue();
SearchParameterMap params;
params = new SearchParameterMap();
params.add(AllergyIntolerance.SP_STATUS, new TokenParam("http://hl7.org/fhir/allergy-intolerance-status", AllergyIntoleranceStatus.ACTIVE.toCode()));
params.add(AllergyIntolerance.SP_CLINICAL_STATUS, new TokenParam("http://hl7.org/fhir/allergy-clinical-status", AllergyIntoleranceClinicalStatus.ACTIVE.toCode()));
assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), containsInAnyOrder(id1));
params = new SearchParameterMap();
params.add(AllergyIntolerance.SP_STATUS, new TokenParam("http://hl7.org/fhir/allergy-intolerance-status", AllergyIntoleranceStatus.ACTIVE.toCode()).setModifier(TokenParamModifier.BELOW));
assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), containsInAnyOrder(id1, id2));
params.add(AllergyIntolerance.SP_CLINICAL_STATUS, new TokenParam("http://hl7.org/fhir/allergy-clinical-status", AllergyIntoleranceClinicalStatus.ACTIVE.toCode()).setModifier(TokenParamModifier.BELOW));
assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), containsInAnyOrder(id1));
params = new SearchParameterMap();
params.add(AllergyIntolerance.SP_STATUS, new TokenParam("http://hl7.org/fhir/allergy-intolerance-status", AllergyIntoleranceStatus.ACTIVECONFIRMED.toCode()).setModifier(TokenParamModifier.BELOW));
params.add(AllergyIntolerance.SP_CLINICAL_STATUS, new TokenParam("http://hl7.org/fhir/allergy-clinical-status", AllergyIntoleranceClinicalStatus.RESOLVED.toCode()).setModifier(TokenParamModifier.BELOW));
assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), containsInAnyOrder(id2));
params = new SearchParameterMap();
params.add(AllergyIntolerance.SP_STATUS, new TokenParam("http://hl7.org/fhir/allergy-intolerance-status", AllergyIntoleranceStatus.ACTIVECONFIRMED.toCode()));
params.add(AllergyIntolerance.SP_CLINICAL_STATUS, new TokenParam("http://hl7.org/fhir/allergy-clinical-status", AllergyIntoleranceClinicalStatus.RESOLVED.toCode()));
assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), containsInAnyOrder(id2));
params = new SearchParameterMap();
params.add(AllergyIntolerance.SP_STATUS, new TokenParam("http://hl7.org/fhir/allergy-intolerance-status", AllergyIntoleranceStatus.ENTEREDINERROR.toCode()));
assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), empty());
// Unknown code
params = new SearchParameterMap();
params.add(AllergyIntolerance.SP_STATUS, new TokenParam("http://hl7.org/fhir/allergy-intolerance-status", "fooooo"));
params.add(AllergyIntolerance.SP_CLINICAL_STATUS, new TokenParam("http://hl7.org/fhir/allergy-clinical-status", "fooooo"));
assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), empty());
// Unknown system
params = new SearchParameterMap();
params.add(AllergyIntolerance.SP_STATUS, new TokenParam("http://hl7.org/fhir/allergy-intolerance-status222222", "fooooo"));
params.add(AllergyIntolerance.SP_CLINICAL_STATUS, new TokenParam("http://hl7.org/fhir/allergy-clinical-status222222", "fooooo"));
assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), empty());
}
@ -697,36 +693,43 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test {
@Test
public void testSearchCodeBelowBuiltInCodesystemUnqualified() {
AllergyIntolerance ai1 = new AllergyIntolerance();
ai1.setStatus(AllergyIntoleranceStatus.ACTIVE);
ai1.setClinicalStatus(AllergyIntoleranceClinicalStatus.ACTIVE);
ai1.addCategoryElement().setValue(AllergyIntoleranceCategory.MEDICATION);
String id1 = myAllergyIntoleranceDao.create(ai1, mySrd).getId().toUnqualifiedVersionless().getValue();
AllergyIntolerance ai2 = new AllergyIntolerance();
ai2.setStatus(AllergyIntoleranceStatus.ACTIVECONFIRMED);
ai2.setClinicalStatus(AllergyIntoleranceClinicalStatus.RESOLVED);
ai2.addCategoryElement().setValue(AllergyIntoleranceCategory.BIOLOGIC);
String id2 = myAllergyIntoleranceDao.create(ai2, mySrd).getId().toUnqualifiedVersionless().getValue();
AllergyIntolerance ai3 = new AllergyIntolerance();
ai3.setStatus(AllergyIntoleranceStatus.INACTIVE);
ai3.setClinicalStatus(AllergyIntoleranceClinicalStatus.INACTIVE);
ai3.addCategoryElement().setValue(AllergyIntoleranceCategory.FOOD);
String id3 = myAllergyIntoleranceDao.create(ai3, mySrd).getId().toUnqualifiedVersionless().getValue();
SearchParameterMap params;
params = new SearchParameterMap();
params.add(AllergyIntolerance.SP_STATUS, new TokenParam(null, AllergyIntoleranceStatus.ACTIVE.toCode()));
params.add(AllergyIntolerance.SP_CLINICAL_STATUS, new TokenParam(null, AllergyIntoleranceClinicalStatus.ACTIVE.toCode()));
assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), containsInAnyOrder(id1));
params = new SearchParameterMap();
params.add(AllergyIntolerance.SP_STATUS, new TokenParam(null, AllergyIntoleranceStatus.ACTIVE.toCode()).setModifier(TokenParamModifier.BELOW));
params.add(AllergyIntolerance.SP_CLINICAL_STATUS, new TokenParam(null, AllergyIntoleranceClinicalStatus.ACTIVE.toCode()).setModifier(TokenParamModifier.BELOW));
assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), containsInAnyOrder(id1));
params = new SearchParameterMap();
params.add(AllergyIntolerance.SP_CATEGORY, new TokenParam(null, AllergyIntoleranceCategory.MEDICATION.toCode()).setModifier(TokenParamModifier.BELOW));
assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), containsInAnyOrder(id1, id2));
params = new SearchParameterMap();
params.add(AllergyIntolerance.SP_STATUS, new TokenParam(null, AllergyIntoleranceStatus.ACTIVECONFIRMED.toCode()).setModifier(TokenParamModifier.BELOW));
params.add(AllergyIntolerance.SP_CLINICAL_STATUS, new TokenParam(null, AllergyIntoleranceClinicalStatus.RESOLVED.toCode()).setModifier(TokenParamModifier.BELOW));
assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), containsInAnyOrder(id2));
params = new SearchParameterMap();
params.add(AllergyIntolerance.SP_STATUS, new TokenParam(null, AllergyIntoleranceStatus.ACTIVECONFIRMED.toCode()));
params.add(AllergyIntolerance.SP_CLINICAL_STATUS, new TokenParam(null, AllergyIntoleranceClinicalStatus.RESOLVED.toCode()));
assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), containsInAnyOrder(id2));
params = new SearchParameterMap();
params.add(AllergyIntolerance.SP_STATUS, new TokenParam(null, AllergyIntoleranceStatus.ENTEREDINERROR.toCode()));
params.add(AllergyIntolerance.SP_CLINICAL_STATUS, new TokenParam(null, "FOO"));
assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), empty());
}

View File

@ -551,7 +551,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
Patient pat = new Patient();
pat.setId(idName);
pat.addName().addFamily("FAM");
pat.addName().setFamily("FAM");
IIdType patId = myPatientDao.update(pat, mySrd).getId();
assertEquals("Patient/" + idName, patId.toUnqualifiedVersionless().getValue());
@ -632,7 +632,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
public void testCreateSummaryFails() {
Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue("testCreateTextIdFails");
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.getMeta().addTag().setSystem(Constants.TAG_SUBSETTED_SYSTEM).setCode(Constants.TAG_SUBSETTED_CODE);
@ -648,7 +648,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
public void testCreateTextIdDoesntFail() {
Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue("testCreateTextIdFails");
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.setId("Patient/ABC");
String id = myPatientDao.create(p, mySrd).getId().getIdPart();
assertNotEquals("ABC", id);
@ -676,7 +676,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
results = myPatientDao.create(p, "Patient?identifier=urn%3Asystem%7C" + methodName, mySrd);
assertEquals(id.getIdPart(), results.getId().getIdPart());
assertFalse(results.getCreated().booleanValue());
@ -687,7 +687,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
results = myPatientDao.create(p, mySrd);
assertNotEquals(id.getIdPart(), results.getId().getIdPart());
assertTrue(results.getCreated().booleanValue());
@ -696,7 +696,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
try {
myPatientDao.create(p, "Patient?identifier=urn%3Asystem%7C" + methodName, mySrd);
fail();
@ -718,7 +718,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
results = myPatientDao.create(p, "Patient?_id=" + id.toVersionless().getValue(), mySrd);
assertEquals(id.getIdPart(), results.getId().getIdPart());
assertEquals(id.getVersionIdPart(), results.getId().getVersionIdPart());
@ -794,7 +794,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
@Test
public void testCreateWithInvalidReferenceFailsGracefully() {
Patient patient = new Patient();
patient.addName().addFamily("testSearchResourceLinkWithChainWithMultipleTypes01");
patient.addName().setFamily("testSearchResourceLinkWithChainWithMultipleTypes01");
patient.setManagingOrganization(new Reference("Organization/99999999"));
try {
myPatientDao.create(patient, mySrd);
@ -808,7 +808,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
@Test
public void testCreateWithInvalidReferenceNoId() {
Patient p = new Patient();
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.getManagingOrganization().setReference("Organization/");
try {
@ -822,7 +822,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
@Test
public void testCreateWithReferenceBadType() {
Patient p = new Patient();
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.getManagingOrganization().setReference("Blah/123");
try {
@ -836,7 +836,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
@Test
public void testCreateWithReferenceNoType() {
Patient p = new Patient();
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.getManagingOrganization().setReference("123");
try {
@ -855,7 +855,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
IFhirResourceDao dao = myNamingSystemDao;
Patient resource = new Patient();
resource.addName().addFamily("My Name");
resource.addName().setFamily("My Name");
try {
dao.create(resource, mySrd);
fail();
@ -1010,7 +1010,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
IIdType orgId = myOrganizationDao.create(org, mySrd).getId().toUnqualifiedVersionless();
Patient patient = new Patient();
patient.addName().addFamily(methodName);
patient.addName().setFamily(methodName);
patient.getManagingOrganization().setReferenceElement(orgId);
IIdType patId = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
@ -1055,13 +1055,13 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily("Tester_testDeleteResource").addGiven("Joe");
patient.addName().setFamily("Tester_testDeleteResource").addGiven("Joe");
id1 = myPatientDao.create(patient, mySrd).getId();
}
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("002");
patient.addName().addFamily("Tester_testDeleteResource").addGiven("John");
patient.addName().setFamily("Tester_testDeleteResource").addGiven("John");
id2 = myPatientDao.create(patient, mySrd).getId();
}
{
@ -1112,7 +1112,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
public void testDeleteThenUndelete() {
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily("Tester_testDeleteThenUndelete").addGiven("Joe");
patient.addName().setFamily("Tester_testDeleteThenUndelete").addGiven("Joe");
IIdType id = myPatientDao.create(patient, mySrd).getId();
assertThat(id.getValue(), Matchers.endsWith("/_history/1"));
@ -1131,7 +1131,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily("Tester_testDeleteThenUndelete").addGiven("Joe");
patient.addName().setFamily("Tester_testDeleteThenUndelete").addGiven("Joe");
patient.setId(id.toUnqualifiedVersionless());
IIdType id2 = myPatientDao.update(patient, mySrd).getId();
@ -1411,11 +1411,11 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("testHistoryByForcedId");
patient.addName().addFamily("Tester").addGiven("testHistoryByForcedId");
patient.addName().setFamily("Tester").addGiven("testHistoryByForcedId");
patient.setId("Patient/testHistoryByForcedId");
idv1 = myPatientDao.update(patient, mySrd).getId();
patient.addName().addFamily("Tester").addGiven("testHistoryByForcedIdName2");
patient.addName().setFamily("Tester").addGiven("testHistoryByForcedIdName2");
patient.setId(patient.getIdElement().toUnqualifiedVersionless());
idv2 = myPatientDao.update(patient, mySrd).getId();
}
@ -1433,7 +1433,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
String methodName = "testHistoryOverMultiplePages";
Patient patient = new Patient();
patient.addName().addFamily(methodName);
patient.addName().setFamily(methodName);
IIdType id = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
Date middleDate = null;
@ -1447,7 +1447,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
Thread.sleep(fullSize);
}
patient.setId(id);
patient.getName().get(0).getFamily().get(0).setValue(methodName + "_i");
patient.getName().get(0).getFamilyElement().setValue(methodName + "_i");
myPatientDao.update(patient, mySrd);
}
@ -1581,14 +1581,14 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
@Test
public void testHistoryReflectsMetaOperations() throws Exception {
Patient inPatient = new Patient();
inPatient.addName().addFamily("version1");
inPatient.addName().setFamily("version1");
inPatient.getMeta().addProfile("http://example.com/1");
IIdType id = myPatientDao.create(inPatient, mySrd).getId().toUnqualifiedVersionless();
IBundleProvider history = myPatientDao.history((Date)null, null, mySrd);
assertEquals(1, history.size());
Patient outPatient = (Patient) history.getResources(0, 1).get(0);
assertEquals("version1", inPatient.getName().get(0).getFamilyAsSingleString());
assertEquals("version1", inPatient.getName().get(0).getFamily());
List<String> profiles = toStringList(outPatient.getMeta().getProfile());
assertThat(profiles, contains("http://example.com/1"));
@ -1602,7 +1602,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
history = myPatientDao.history((Date)null, null, mySrd);
assertEquals(1, history.size());
outPatient = (Patient) history.getResources(0, 1).get(0);
assertEquals("version1", inPatient.getName().get(0).getFamilyAsSingleString());
assertEquals("version1", inPatient.getName().get(0).getFamily());
profiles = toStringList(outPatient.getMeta().getProfile());
assertThat(profiles, containsInAnyOrder("http://example.com/1", "http://example.com/2"));
@ -1612,19 +1612,19 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
inPatient.setId(id);
inPatient.getMeta().addProfile("http://example.com/3");
inPatient.getName().get(0).addFamily("version2");
inPatient.getName().get(0).setFamily("version2");
myPatientDao.update(inPatient, mySrd);
history = myPatientDao.history((Date)null, null, mySrd);
assertEquals(2, history.size());
outPatient = (Patient) history.getResources(0, 2).get(0);
assertEquals("version1 version2", outPatient.getName().get(0).getFamilyAsSingleString());
assertEquals("version2", outPatient.getName().get(0).getFamily());
profiles = toStringList(outPatient.getMeta().getProfile());
ourLog.info(profiles.toString());
assertThat(profiles, containsInAnyOrder("http://example.com/1", "http://example.com/2", "http://example.com/3"));
outPatient = (Patient) history.getResources(0, 2).get(1);
assertEquals("version1", outPatient.getName().get(0).getFamilyAsSingleString());
assertEquals("version1", outPatient.getName().get(0).getFamily());
profiles = toStringList(outPatient.getMeta().getProfile());
assertThat(profiles, containsInAnyOrder("http://example.com/1", "http://example.com/2"));
}
@ -1634,7 +1634,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
String methodName = "testHistoryWithDeletedResource";
Patient patient = new Patient();
patient.addName().addFamily(methodName);
patient.addName().setFamily(methodName);
IIdType id = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
myPatientDao.delete(id, mySrd);
@ -1667,7 +1667,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
String methodName = "testHistoryWithFromAndTo";
Patient patient = new Patient();
patient.addName().addFamily(methodName);
patient.addName().setFamily(methodName);
IIdType id = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
List<Date> preDates = Lists.newArrayList();
@ -1677,7 +1677,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
preDates.add(new Date());
Thread.sleep(100);
patient.setId(id);
patient.getName().get(0).getFamily().get(0).setValue(methodName + "_i");
patient.getName().get(0).getFamilyElement().setValue(methodName + "_i");
ids.add(myPatientDao.update(patient, mySrd).getId().toUnqualified().getValue());
}
@ -1700,7 +1700,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
Thread.sleep(10);
Patient inPatient = new Patient();
inPatient.addName().addFamily("version1");
inPatient.addName().setFamily("version1");
inPatient.getMeta().addProfile("http://example.com/1");
myPatientDao.create(inPatient, mySrd).getId().toUnqualifiedVersionless();
@ -1712,7 +1712,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
IBundleProvider history = myPatientDao.history((Date)null, null, mySrd);
assertEquals(1, history.size());
Patient outPatient = (Patient) history.getResources(0, 1).get(0);
assertEquals("version1", inPatient.getName().get(0).getFamilyAsSingleString());
assertEquals("version1", inPatient.getName().get(0).getFamily());
List<String> profiles = toStringList(outPatient.getMeta().getProfile());
assertThat(profiles, contains("http://example.com/1"));
@ -1721,7 +1721,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
history = myPatientDao.history(before, null, mySrd);
assertEquals(1, history.size());
outPatient = (Patient) history.getResources(0, 1).get(0);
assertEquals("version1", inPatient.getName().get(0).getFamilyAsSingleString());
assertEquals("version1", inPatient.getName().get(0).getFamily());
profiles = toStringList(outPatient.getMeta().getProfile());
assertThat(profiles, contains("http://example.com/1"));
@ -1746,7 +1746,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
public void testIdParam() {
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily("Tester").addGiven("Joe");
patient.addName().setFamily("Tester").addGiven("Joe");
MethodOutcome outcome = myPatientDao.create(patient, mySrd);
assertNotNull(outcome.getId());
@ -1783,7 +1783,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
List<Patient> ret = toList(myPatientDao.search(paramMap));
assertEquals(1, ret.size());
Patient p = ret.get(0);
assertEquals("Tester", p.getName().get(0).getFamilyAsSingleString());
assertEquals("Tester", p.getName().get(0).getFamily());
}
{
SearchParameterMap paramMap = new SearchParameterMap();
@ -1792,7 +1792,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
List<Patient> ret = toList(myPatientDao.search(paramMap));
assertEquals(1, ret.size());
Patient p = ret.get(0);
assertEquals("Tester", p.getName().get(0).getFamilyAsSingleString());
assertEquals("Tester", p.getName().get(0).getFamily());
}
{
SearchParameterMap paramMap = new SearchParameterMap();
@ -1801,7 +1801,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
List<Patient> ret = toList(myPatientDao.search(paramMap));
assertEquals(1, ret.size());
Patient p = ret.get(0);
assertEquals("Tester", p.getName().get(0).getFamilyAsSingleString());
assertEquals("Tester", p.getName().get(0).getFamily());
}
{
SearchParameterMap paramMap = new SearchParameterMap();
@ -1863,7 +1863,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
*/
Patient pt = myPatientDao.read(id, mySrd);
pt.addName().addFamily("anotherName");
pt.addName().setFamily("anotherName");
myPatientDao.update(pt, mySrd);
/*
@ -2172,7 +2172,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001testPersistSearchParams");
patient.getGenderElement().setValue(AdministrativeGender.MALE);
patient.addName().addFamily("Tester").addGiven("JoetestPersistSearchParams");
patient.addName().setFamily("Tester").addGiven("JoetestPersistSearchParams");
MethodOutcome outcome = myPatientDao.create(patient, mySrd);
assertNotNull(outcome.getId());
@ -2337,7 +2337,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
String methodName = "testReadWithDeletedResource";
Patient patient = new Patient();
patient.addName().addFamily(methodName);
patient.addName().setFamily(methodName);
IIdType id = myPatientDao.create(patient, mySrd).getId().toVersionless();
myPatientDao.delete(id, mySrd);
@ -2374,7 +2374,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue(methodName);
patient.addName().addFamily("Tester").addGiven("Joe");
patient.addName().setFamily("Tester").addGiven("Joe");
id1 = myPatientDao.create(patient, mySrd).getId();
Meta metaAdd = new Meta();
@ -2386,7 +2386,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue(methodName);
patient.addName().addFamily("Tester").addGiven("Joe");
patient.addName().setFamily("Tester").addGiven("Joe");
patient.getMeta().addTag("http://foo", "Cat", "Kittens");
patient.getMeta().addSecurity().setSystem("seclabel:sys:2").setCode("seclabel:code:2").setDisplay("seclabel:dis:2");
@ -2479,7 +2479,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue(methodName);
patient.addName().addFamily("Tester").addGiven("Joe");
patient.addName().setFamily("Tester").addGiven("Joe");
patient.getMeta().addTag(null, "Dog", "Puppies");
patient.getMeta().addSecurity().setSystem("seclabel:sys:1").setCode("seclabel:code:1").setDisplay("seclabel:dis:1");
@ -2491,7 +2491,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue(methodName);
patient.addName().addFamily("Tester").addGiven("Joe");
patient.addName().setFamily("Tester").addGiven("Joe");
patient.getMeta().addTag("http://foo", "Cat", "Kittens");
patient.getMeta().addSecurity().setSystem("seclabel:sys:2").setCode("seclabel:code:2").setDisplay("seclabel:dis:2");
@ -2576,7 +2576,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
IIdType orgId = myOrganizationDao.create(org, mySrd).getId();
Patient pat = new Patient();
pat.addName().addFamily("X" + methodName + "X");
pat.addName().setFamily("X" + methodName + "X");
pat.getManagingOrganization().setReferenceElement(orgId.toUnqualifiedVersionless());
myPatientDao.create(pat, mySrd);
@ -2614,20 +2614,20 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
public void testSortByDate() {
Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue("testtestSortByDate");
p.addName().addFamily("testSortF1").addGiven("testSortG1");
p.addName().setFamily("testSortF1").addGiven("testSortG1");
p.setBirthDateElement(new DateType("2001-01-01"));
IIdType id1 = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
// Create out of order
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue("testtestSortByDate");
p.addName().addFamily("testSortF2").addGiven("testSortG2");
p.addName().setFamily("testSortF2").addGiven("testSortG2");
p.setBirthDateElement(new DateType("2001-01-03"));
IIdType id3 = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue("testtestSortByDate");
p.addName().addFamily("testSortF3").addGiven("testSortG3");
p.addName().setFamily("testSortF3").addGiven("testSortG3");
p.setBirthDateElement(new DateType("2001-01-02"));
IIdType id2 = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
@ -2718,22 +2718,22 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
Patient p = new Patient();
p.addIdentifier().setSystem("urn:system1").setValue(methodName);
p.addName().addFamily(methodName);
p.addName().setFamily(methodName);
IIdType id1 = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
p = new Patient();
p.addIdentifier().setSystem("urn:system2").setValue(methodName);
p.addName().addFamily(methodName);
p.addName().setFamily(methodName);
IIdType id2 = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
p = new Patient();
p.addIdentifier().setSystem("urn:system3").setValue(methodName);
p.addName().addFamily(methodName);
p.addName().setFamily(methodName);
IIdType id3 = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
p = new Patient();
p.addIdentifier().setSystem("urn:system4").setValue(methodName);
p.addName().addFamily(methodName);
p.addName().setFamily(methodName);
IIdType id4 = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
SearchParameterMap pm;
@ -2845,19 +2845,19 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("testSortF1").addGiven("testSortG1");
p.addName().setFamily("testSortF1").addGiven("testSortG1");
p.getManagingOrganization().setReferenceElement(oid1);
IIdType id1 = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("testSortF2").addGiven("testSortG2");
p.addName().setFamily("testSortF2").addGiven("testSortG2");
p.getManagingOrganization().setReferenceElement(oid2);
IIdType id2 = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("testSortF3").addGiven("testSortG3");
p.addName().setFamily("testSortF3").addGiven("testSortG3");
p.getManagingOrganization().setReferenceElement(oid1);
IIdType id3 = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
@ -2899,18 +2899,18 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
Patient p = new Patient();
String string = "testSortByString01";
p.addIdentifier().setSystem("urn:system").setValue(string);
p.addName().addFamily("testSortF1").addGiven("testSortG1");
p.addName().setFamily("testSortF1").addGiven("testSortG1");
IIdType id1 = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
// Create out of order
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(string);
p.addName().addFamily("testSortF3").addGiven("testSortG3");
p.addName().setFamily("testSortF3").addGiven("testSortG3");
IIdType id3 = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(string);
p.addName().addFamily("testSortF2").addGiven("testSortG2");
p.addName().setFamily("testSortF2").addGiven("testSortG2");
IIdType id2 = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
p = new Patient();
@ -2952,22 +2952,22 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(string);
p.addName().addFamily("Fam1").addGiven("Giv1");
p.addName().setFamily("Fam1").addGiven("Giv1");
myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(string);
p.addName().addFamily("Fam2").addGiven("Giv1");
p.addName().setFamily("Fam2").addGiven("Giv1");
myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(string);
p.addName().addFamily("Fam2").addGiven("Giv2");
p.addName().setFamily("Fam2").addGiven("Giv2");
myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(string);
p.addName().addFamily("Fam1").addGiven("Giv2");
p.addName().setFamily("Fam1").addGiven("Giv2");
myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
SearchParameterMap pm;
@ -3120,7 +3120,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
assertTrue(o1id.hasVersionIdPart());
Patient p1 = new Patient();
p1.addName().addFamily("AAAA");
p1.addName().setFamily("AAAA");
p1.getManagingOrganization().setReferenceElement(o1id);
IIdType p1id = myPatientDao.create(p1, mySrd).getId();
@ -3180,7 +3180,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
public void testTagsAndProfilesAndSecurityLabelsWithCreateAndReadAndSearch() {
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("testTagsWithCreateAndReadAndSearch");
patient.addName().addFamily("Tester").addGiven("Joe");
patient.addName().setFamily("Tester").addGiven("Joe");
List<Coding> tagList = new ArrayList<Coding>();
tagList.add(new Coding().setSystem(null).setCode("Dog").setDisplay("Puppies"));
// Add this twice

View File

@ -62,7 +62,7 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
public void testUpdateAndGetHistoryResource() throws InterruptedException {
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily("Tester").addGiven("Joe");
patient.addName().setFamily("Tester").addGiven("Joe");
MethodOutcome outcome = myPatientDao.create(patient, mySrd);
assertNotNull(outcome.getId());
@ -139,7 +139,7 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.setId("Patient/" + methodName);
myPatientDao.update(p, "Patient?identifier=urn%3Asystem%7C" + methodName, mySrd);
@ -213,7 +213,7 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.setId("Patient/" + methodName);
String matchUrl = "Patient?_lastUpdated=gt" + start.getValueAsString();
@ -251,7 +251,7 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.setId("Patient/" + methodName);
myPatientDao.update(p, "Patient?_lastUpdated=gt" + start.getValueAsString(), mySrd);
@ -271,7 +271,7 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
Patient p = new Patient();
String methodName = "testUpdateCreatesTextualIdIfItDoesntAlreadyExist";
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.setId("Patient/" + methodName);
IIdType id = myPatientDao.update(p, mySrd).getId();
@ -286,7 +286,7 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
String methodName = "testUpdateFailsForUnknownIdWithNumberThenText";
Patient p = new Patient();
p.setId("0" + methodName);
p.addName().addFamily(methodName);
p.addName().setFamily(methodName);
myPatientDao.update(p, mySrd);
}
@ -301,7 +301,7 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
IIdType p1id;
{
Patient p1 = new Patient();
p1.addName().addFamily(methodName);
p1.addName().setFamily(methodName);
p1.getMeta().addTag("tag_scheme1", "tag_term1",null);
p1.getMeta().addSecurity("sec_scheme1", "sec_term1",null);
@ -312,7 +312,7 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
{
Patient p1 = new Patient();
p1.setId(p1id);
p1.addName().addFamily(methodName);
p1.addName().setFamily(methodName);
p1.getMeta().addTag("tag_scheme2", "tag_term2", null);
p1.getMeta().addSecurity("sec_scheme2", "sec_term2", null);
@ -344,12 +344,12 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
public void testUpdateMaintainsSearchParams() throws InterruptedException {
Patient p1 = new Patient();
p1.addIdentifier().setSystem("urn:system").setValue("testUpdateMaintainsSearchParamsDstu2AAA");
p1.addName().addFamily("Tester").addGiven("testUpdateMaintainsSearchParamsDstu2AAA");
p1.addName().setFamily("Tester").addGiven("testUpdateMaintainsSearchParamsDstu2AAA");
IIdType p1id = myPatientDao.create(p1, mySrd).getId();
Patient p2 = new Patient();
p2.addIdentifier().setSystem("urn:system").setValue("testUpdateMaintainsSearchParamsDstu2BBB");
p2.addName().addFamily("Tester").addGiven("testUpdateMaintainsSearchParamsDstu2BBB");
p2.addName().setFamily("Tester").addGiven("testUpdateMaintainsSearchParamsDstu2BBB");
myPatientDao.create(p2, mySrd).getId();
Set<Long> ids = myPatientDao.searchForIds(Patient.SP_GIVEN, new StringParam("testUpdateMaintainsSearchParamsDstu2AAA"));
@ -380,7 +380,7 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
public void testUpdateRejectsInvalidTypes() throws InterruptedException {
Patient p1 = new Patient();
p1.addIdentifier().setSystem("urn:system").setValue("testUpdateRejectsInvalidTypes");
p1.addName().addFamily("Tester").addGiven("testUpdateRejectsInvalidTypes");
p1.addName().setFamily("Tester").addGiven("testUpdateRejectsInvalidTypes");
IIdType p1id = myPatientDao.create(p1, mySrd).getId();
Organization p2 = new Organization();
@ -410,7 +410,7 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
Patient p1 = new Patient();
p1.addIdentifier().setSystem("urn:system").setValue(methodName);
p1.addName().addFamily("Tester").addGiven(methodName);
p1.addName().setFamily("Tester").addGiven(methodName);
IIdType p1id = myPatientDao.create(p1, mySrd).getId();
IIdType p1id2 = myPatientDao.update(p1, mySrd).getId();
@ -428,7 +428,7 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
IIdType id;
{
Patient patient = new Patient();
patient.addName().addFamily(name);
patient.addName().setFamily(name);
List<IdType> tl = new ArrayList<IdType>();
tl.add(new IdType("http://foo/bar"));
@ -455,7 +455,7 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
IIdType id;
{
Patient patient = new Patient();
patient.addName().addFamily(name);
patient.addName().setFamily(name);
List<IdType> tl = new ArrayList<IdType>();
tl.add(new IdType("http://foo/bar"));
@ -476,7 +476,7 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
{
Patient patient = new Patient();
patient.setId(id);
patient.addName().addFamily(name);
patient.addName().setFamily(name);
List<IdType> tl = new ArrayList<IdType>();
tl.add(new IdType("http://foo/baz"));
@ -500,7 +500,7 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
public void testUpdateUnknownNumericIdFails() {
Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue("testCreateNumericIdFails");
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.setId("Patient/9999999999999999");
try {
myPatientDao.update(p, mySrd);
@ -514,7 +514,7 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
public void testUpdateWithInvalidIdFails() {
Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue("testCreateNumericIdFails");
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.setId("Patient/123:456");
try {
myPatientDao.update(p, mySrd);
@ -528,7 +528,7 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
public void testUpdateWithNumericIdFails() {
Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue("testCreateNumericIdFails");
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.setId("Patient/123");
try {
myPatientDao.update(p, mySrd);
@ -542,7 +542,7 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
public void testUpdateWithNumericThenTextIdSucceeds() {
Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue("testCreateNumericIdFails");
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.setId("Patient/123abc");
IIdType id = myPatientDao.update(p, mySrd).getId();
assertEquals("123abc", id.getIdPart());
@ -550,7 +550,7 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
p = myPatientDao.read(id.toUnqualifiedVersionless(), mySrd);
assertEquals("Patient/123abc", p.getIdElement().toUnqualifiedVersionless().getValue());
assertEquals("Hello", p.getName().get(0).getFamily().get(0).getValue());
assertEquals("Hello", p.getName().get(0).getFamily());
}

View File

@ -181,7 +181,7 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test {
Patient pat = new Patient();
pat.setId("Patient/123");
pat.addName().addFamily(methodName);
pat.addName().setFamily(methodName);
try {
myPatientDao.validate(pat, null, null, null, ValidationModeEnum.CREATE, null, mySrd);
@ -201,7 +201,7 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test {
Patient pat = new Patient();
pat.setId("Patient/123");
pat.addName().addFamily(methodName);
pat.addName().setFamily(methodName);
myPatientDao.validate(pat, null, null, null, ValidationModeEnum.UPDATE, null, mySrd);
pat.setId("");
@ -224,7 +224,7 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test {
Patient pat = new Patient();
pat.setId("Patient/123");
pat.addName().addFamily(methodName);
pat.addName().setFamily(methodName);
myPatientDao.validate(pat, null, null, null, ValidationModeEnum.UPDATE, null, mySrd);
pat.setId("");
@ -247,7 +247,7 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test {
IIdType orgId = myOrganizationDao.create(org, mySrd).getId().toUnqualifiedVersionless();
Patient pat = new Patient();
pat.addName().addFamily(methodName);
pat.addName().setFamily(methodName);
pat.getManagingOrganization().setReference(orgId.getValue());
IIdType patId = myPatientDao.create(pat, mySrd).getId().toUnqualifiedVersionless();

View File

@ -39,8 +39,8 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addGiven("testSearchStringParamWithNonNormalized_h\u00F6ra");
patient.addName().addFamily("AAAS");
patient.addName().addFamily("CCC");
patient.addName().addGiven("AAAS");
patient.addName().addGiven("CCC");
id1 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless().getIdPartAsLong();
}
Long id2;
@ -48,8 +48,8 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("002");
patient.addName().addGiven("testSearchStringParamWithNonNormalized_HORA");
patient.addName().addFamily("AAAB");
patient.addName().addFamily("CCC");
patient.addName().addGiven("AAAB");
patient.addName().addGiven("CCC");
id2 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless().getIdPartAsLong();
}
Long id3;

View File

@ -168,7 +168,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
@Test
public void testReindexing() {
Patient p = new Patient();
p.addName().addFamily("family");
p.addName().setFamily("family");
final IIdType id = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
ValueSet vs = new ValueSet();
@ -250,7 +250,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue(methodName);
patient.addName().addFamily("Tester").addGiven("Joe");
patient.addName().setFamily("Tester").addGiven("Joe");
patient.getMeta().addTag(null, "Dog", "Puppies");
patient.getMeta().getSecurity().add(new Coding().setSystem("seclabel:sys:1").setCode("seclabel:code:1").setDisplay("seclabel:dis:1"));
@ -261,7 +261,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue(methodName);
patient.addName().addFamily("Tester").addGiven("Joe");
patient.addName().setFamily("Tester").addGiven("Joe");
patient.getMeta().addTag("http://foo", "Cat", "Kittens");
patient.getMeta().getSecurity().add(new Coding().setSystem("seclabel:sys:2").setCode("seclabel:code:2").setDisplay("seclabel:dis:2"));
@ -320,7 +320,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
request.setType(BundleType.BATCH);
Patient p = new Patient();
p.addName().addFamily(methodName);
p.addName().setFamily(methodName);
request.addEntry().setResource(p).getRequest().setMethod(HTTPVerb.POST);
request.addEntry().getRequest().setMethod(HTTPVerb.GET).setUrl("Patient/THIS_ID_DOESNT_EXIST");
@ -525,7 +525,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.setId("Patient/" + methodName);
request.addEntry().setResource(p).getRequest().setMethod(HTTPVerb.POST).setIfNoneExist("Patient?identifier=urn%3Asystem%7C" + methodName);
@ -571,7 +571,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
Bundle request = new Bundle();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.setId("Patient/" + methodName);
request.addEntry().setResource(p).getRequest().setMethod(HTTPVerb.POST).setIfNoneExist("Patient?identifier=urn%3Asystem%7C" + methodName);
@ -595,7 +595,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.setId("Patient/" + methodName);
request.addEntry().setResource(p).getRequest().setMethod(HTTPVerb.POST).setIfNoneExist("Patient?identifier=urn%3Asystem%7C" + methodName);
@ -636,7 +636,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.setId("Patient/" + methodName);
request.addEntry().setResource(p).getRequest().setMethod(HTTPVerb.POST);
@ -775,7 +775,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.getManagingOrganization().setReference("Organization/9999999999999999");
request.addEntry().setResource(p).getRequest().setMethod(HTTPVerb.POST);
@ -794,7 +794,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.getManagingOrganization().setReference("Organization/" + methodName);
request.addEntry().setResource(p).getRequest().setMethod(HTTPVerb.POST);
@ -1070,7 +1070,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.setId("Patient/" + methodName);
Bundle request = new Bundle();
@ -1295,7 +1295,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
Patient pat = new Patient();
pat.addIdentifier().setValue(methodName);
pat.addName().addFamily(methodName + pass);
pat.addName().setFamily(methodName + pass);
req.addEntry().setResource(pat).setFullUrl(patientPlaceholderId.getValue()).getRequest().setMethod(HTTPVerb.POST).setUrl("Patient");
req.addEntry().getRequest().setMethod(HTTPVerb.DELETE).setUrl("Patient?identifier=" + methodName);
@ -1326,7 +1326,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
Bundle respGetBundle = (Bundle) resp.getEntry().get(0).getResource();
assertEquals(1, respGetBundle.getEntry().size());
assertEquals("testTransactionOrdering" + pass, ((Patient)respGetBundle.getEntry().get(0).getResource()).getName().get(0).getFamily().get(0).getValue());
assertEquals("testTransactionOrdering" + pass, ((Patient)respGetBundle.getEntry().get(0).getResource()).getName().get(0).getFamily());
assertThat(respGetBundle.getLink("self").getUrl(), endsWith("/Patient?identifier=testTransactionOrdering"));
}
@ -1342,7 +1342,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Family Name");
p.addName().setFamily("Family Name");
p.setId("Patient/" + methodName);
IIdType idv2 = myPatientDao.update(p, mySrd).getId();
ourLog.info("Updated patient, got id: {}", idv2);
@ -1412,7 +1412,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Family Name");
p.addName().setFamily("Family Name");
p.setId("Patient/" + methodName);
IIdType idv2 = myPatientDao.update(p, mySrd).getId();
ourLog.info("Updated patient, got id: {}", idv2);
@ -1457,7 +1457,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Family Name");
p.addName().setFamily("Family Name");
p.setId("Patient/" + methodName);
IIdType idv2 = myPatientDao.update(p, mySrd).getId();
ourLog.info("Updated patient, got id: {}", idv2);
@ -1520,7 +1520,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.setId("Patient/" + methodName);
request.addEntry().setResource(p).getRequest().setMethod(HTTPVerb.PUT).setUrl("Patient?identifier=urn%3Asystem%7C" + methodName);
@ -1566,7 +1566,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.setId("Patient/" + methodName);
request.addEntry().setResource(p).getRequest().setMethod(HTTPVerb.PUT).setUrl("Patient?identifier=urn%3Asystem%7C" + methodName);
@ -1589,12 +1589,12 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
Bundle request = new Bundle();
Patient p = new Patient();
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
IIdType id = myPatientDao.create(p, mySrd).getId();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.setId(methodName);
request.addEntry().setResource(p).getRequest().setMethod(HTTPVerb.PUT).setUrl("Patient?identifier=urn%3Asystem%7C" + methodName);
@ -1634,7 +1634,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("Hello");
p.addName().setFamily("Hello");
p.setId("Patient/" + methodName);
request.addEntry().setResource(p).getRequest().setMethod(HTTPVerb.PUT).setUrl("Patient/" + id.getIdPart());
@ -1778,14 +1778,14 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
@Test
public void testTransactionWithNullReference() {
Patient p = new Patient();
p.addName().addFamily("family");
p.addName().setFamily("family");
final IIdType id = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
Bundle inputBundle = new Bundle();
//@formatter:off
Patient app0 = new Patient();
app0.addName().addFamily("NEW PATIENT");
app0.addName().setFamily("NEW PATIENT");
String placeholderId0 = IdDt.newRandomUuid().getValue();
inputBundle
.addEntry()

View File

@ -61,7 +61,7 @@ public class AuthorizationInterceptorResourceProviderDstu3Test extends BaseResou
Patient patient = new Patient();
patient.addIdentifier().setSystem("http://uhn.ca/mrns").setValue("100");
patient.addName().addFamily("Tester").addGiven("Raghad");
patient.addName().setFamily("Tester").addGiven("Raghad");
final MethodOutcome output1 = ourClient.update().resource(patient).conditionalByUrl("Patient?identifier=http://uhn.ca/mrns|100").execute();
ourRestServer.registerInterceptor(new AuthorizationInterceptor(PolicyEnum.DENY) {
@ -79,14 +79,14 @@ public class AuthorizationInterceptorResourceProviderDstu3Test extends BaseResou
patient = new Patient();
patient.setId(output1.getId().toUnqualifiedVersionless());
patient.addIdentifier().setSystem("http://uhn.ca/mrns").setValue("100");
patient.addName().addFamily("Tester").addGiven("Raghad");
patient.addName().setFamily("Tester").addGiven("Raghad");
MethodOutcome output2 = ourClient.update().resource(patient).conditionalByUrl("Patient?identifier=http://uhn.ca/mrns|100").execute();
assertEquals(output1.getId().getIdPart(), output2.getId().getIdPart());
patient = new Patient();
patient.addIdentifier().setSystem("http://uhn.ca/mrns").setValue("100");
patient.addName().addFamily("Tester").addGiven("Raghad");
patient.addName().setFamily("Tester").addGiven("Raghad");
try {
ourClient.update().resource(patient).conditionalByUrl("Patient?identifier=http://uhn.ca/mrns|101").execute();
fail();
@ -97,7 +97,7 @@ public class AuthorizationInterceptorResourceProviderDstu3Test extends BaseResou
patient = new Patient();
patient.setId("999");
patient.addIdentifier().setSystem("http://uhn.ca/mrns").setValue("100");
patient.addName().addFamily("Tester").addGiven("Raghad");
patient.addName().setFamily("Tester").addGiven("Raghad");
try {
ourClient.update().resource(patient).execute();
fail();
@ -112,7 +112,7 @@ public class AuthorizationInterceptorResourceProviderDstu3Test extends BaseResou
String methodName = "testDeleteResourceConditional";
Patient pt = new Patient();
pt.addName().addFamily(methodName);
pt.addName().setFamily(methodName);
String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt);
HttpPost post = new HttpPost(ourServerBase + "/Patient");
@ -129,7 +129,7 @@ public class AuthorizationInterceptorResourceProviderDstu3Test extends BaseResou
}
pt = new Patient();
pt.addName().addFamily("FOOFOOFOO");
pt.addName().setFamily("FOOFOOFOO");
resource = myFhirCtx.newXmlParser().encodeResourceToString(pt);
post = new HttpPost(ourServerBase + "/Patient");

View File

@ -152,7 +152,7 @@ public abstract class BaseResourceProviderDstu3Test extends BaseJpaDstu3Test {
List<String> names = new ArrayList<String>();
for (BundleEntryComponent next : resp.getEntry()) {
Patient nextPt = (Patient) next.getResource();
String nextStr = nextPt.getName().size() > 0 ? nextPt.getName().get(0).getGivenAsSingleString() + " " + nextPt.getName().get(0).getFamilyAsSingleString() : "";
String nextStr = nextPt.getName().size() > 0 ? nextPt.getName().get(0).getGivenAsSingleString() + " " + nextPt.getName().get(0).getFamily() : "";
if (isNotBlank(nextStr)) {
names.add(nextStr);
}

View File

@ -407,13 +407,13 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
public void testCreateConditional() {
Patient patient = new Patient();
patient.addIdentifier().setSystem("http://uhn.ca/mrns").setValue("100");
patient.addName().addFamily("Tester").addGiven("Raghad");
patient.addName().setFamily("Tester").addGiven("Raghad");
MethodOutcome output1 = ourClient.update().resource(patient).conditionalByUrl("Patient?identifier=http://uhn.ca/mrns|100").execute();
patient = new Patient();
patient.addIdentifier().setSystem("http://uhn.ca/mrns").setValue("100");
patient.addName().addFamily("Tester").addGiven("Raghad");
patient.addName().setFamily("Tester").addGiven("Raghad");
MethodOutcome output2 = ourClient.update().resource(patient).conditionalByUrl("Patient?identifier=http://uhn.ca/mrns|100").execute();
@ -463,7 +463,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
String methodName = "testCreateResourceConditional";
Patient pt = new Patient();
pt.addName().addFamily(methodName);
pt.addName().setFamily(methodName);
String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt);
HttpPost post = new HttpPost(ourServerBase + "/Patient");
@ -584,7 +584,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
String methodName = "testCreateWithForcedId";
Patient p = new Patient();
p.addName().addFamily(methodName);
p.addName().setFamily(methodName);
p.setId(methodName);
IIdType optId = ourClient.update().resource(p).execute().getId();
@ -635,12 +635,12 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("FAM1");
p.addName().setFamily("FAM1");
IIdType id1 = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addFamily("FAM2");
p.addName().setFamily("FAM2");
IIdType id2 = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
try {
@ -728,7 +728,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
@Test
public void testDeleteNormal() throws IOException {
Patient p = new Patient();
p.addName().addFamily("FAM");
p.addName().setFamily("FAM");
IIdType id = ourClient.create().resource(p).execute().getId().toUnqualifiedVersionless();
ourClient.read().resource(Patient.class).withId(id).execute();
@ -748,7 +748,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
String methodName = "testDeleteResourceConditional1";
Patient pt = new Patient();
pt.addName().addFamily(methodName);
pt.addName().setFamily(methodName);
String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt);
HttpPost post = new HttpPost(ourServerBase + "/Patient");
@ -791,7 +791,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
String methodName = "testDeleteResourceConditional2";
Patient pt = new Patient();
pt.addName().addFamily(methodName);
pt.addName().setFamily(methodName);
pt.addIdentifier().setSystem("http://ghh.org/patient").setValue(methodName);
String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt);
@ -938,7 +938,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
IIdType orgId1 = ourClient.create().resource(org1).execute().getId().toUnqualifiedVersionless();
Patient p = new Patient();
p.addName().addFamily(methodName);
p.addName().setFamily(methodName);
p.getManagingOrganization().setReferenceElement(orgId1);
IIdType patientId = ourClient.create().resource(p).execute().getId().toUnqualifiedVersionless();
@ -1002,7 +1002,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
IIdType orgId1 = ourClient.create().resource(org1).execute().getId().toUnqualifiedVersionless();
Patient p = new Patient();
p.addName().addFamily(methodName);
p.addName().setFamily(methodName);
p.getManagingOrganization().setReferenceElement(orgId1);
IIdType patientId = ourClient.create().resource(p).execute().getId().toUnqualifiedVersionless();
@ -1050,11 +1050,11 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
@Test
public void testEverythingInstanceWithContentFilter() {
Patient pt1 = new Patient();
pt1.addName().addFamily("Everything").addGiven("Arthur");
pt1.addName().setFamily("Everything").addGiven("Arthur");
IIdType ptId1 = myPatientDao.create(pt1, mySrd).getId().toUnqualifiedVersionless();
Patient pt2 = new Patient();
pt2.addName().addFamily("Everything").addGiven("Arthur");
pt2.addName().setFamily("Everything").addGiven("Arthur");
IIdType ptId2 = myPatientDao.create(pt2, mySrd).getId().toUnqualifiedVersionless();
Device dev1 = new Device();
@ -1270,7 +1270,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
IIdType orgId1 = ourClient.create().resource(org1).execute().getId().toUnqualifiedVersionless();
Patient p = new Patient();
p.addName().addFamily(methodName);
p.addName().setFamily(methodName);
p.getManagingOrganization().setReferenceElement(orgId1);
IIdType patientId = ourClient.create().resource(p).execute().getId().toUnqualifiedVersionless();
@ -1312,11 +1312,11 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
IIdType o2Id = ourClient.create().resource(o2).execute().getId().toUnqualifiedVersionless();
Patient p1 = new Patient();
p1.addName().addFamily(methodName + "1");
p1.addName().setFamily(methodName + "1");
p1.getManagingOrganization().setReferenceElement(o1Id);
IIdType p1Id = ourClient.create().resource(p1).execute().getId().toUnqualifiedVersionless();
Patient p2 = new Patient();
p2.addName().addFamily(methodName + "2");
p2.addName().setFamily(methodName + "2");
p2.getManagingOrganization().setReferenceElement(o2Id);
IIdType p2Id = ourClient.create().resource(p2).execute().getId().toUnqualifiedVersionless();
@ -1354,7 +1354,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
Thread.sleep(10);
Patient p = new Patient();
p.addName().addFamily(methodName);
p.addName().setFamily(methodName);
p.getManagingOrganization().setReferenceElement(oId);
IIdType pId = ourClient.create().resource(p).execute().getId().toUnqualifiedVersionless();
@ -1559,7 +1559,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
String methodName = "testMetaOperations";
Patient pt = new Patient();
pt.addName().addFamily(methodName);
pt.addName().setFamily(methodName);
ourClient.create().resource(pt).execute().getId().toUnqualifiedVersionless();
HttpGet get = new HttpGet(ourServerBase + "/$get-resource-counts");
@ -1581,13 +1581,13 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily("Tester").addGiven("Joe");
patient.addName().setFamily("Tester").addGiven("Joe");
pid0 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily("Tester").addGiven("Joe");
patient.addName().setFamily("Tester").addGiven("Joe");
myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
{
@ -1632,7 +1632,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
String methodName = "testHistoryWithFromAndTo";
Patient patient = new Patient();
patient.addName().addFamily(methodName);
patient.addName().setFamily(methodName);
IIdType id = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
List<Date> preDates = Lists.newArrayList();
@ -1642,7 +1642,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
preDates.add(new Date());
Thread.sleep(100);
patient.setId(id);
patient.getName().get(0).getFamily().get(0).setValue(methodName + "_i");
patient.getName().get(0).getFamilyElement().setValue(methodName + "_i");
ids.add(myPatientDao.update(patient, mySrd).getId().toUnqualified().getValue());
}
@ -1675,7 +1675,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
String methodName = "testHistoryWithDeletedResource";
Patient patient = new Patient();
patient.addName().addFamily(methodName);
patient.addName().setFamily(methodName);
IIdType id = ourClient.create().resource(patient).execute().getId().toVersionless();
ourClient.delete().resourceById(id).execute();
patient.setId(id);
@ -1708,7 +1708,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
Patient pt = new Patient();
pt.setId("Patient/AAA/_history/4");
pt.addName().addFamily(methodName);
pt.addName().setFamily(methodName);
String resource = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(pt);
ourLog.info("Input: {}", resource);
@ -1750,7 +1750,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
Patient pt = new Patient();
pt.setId("Patient/AAA/_history/4");
pt.addName().addFamily(methodName);
pt.addName().setFamily(methodName);
String resource = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(pt);
ourLog.info("Input: {}", resource);
@ -1857,7 +1857,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
String methodName = "testMetaOperations";
Patient pt = new Patient();
pt.addName().addFamily(methodName);
pt.addName().setFamily(methodName);
IIdType id = ourClient.create().resource(pt).execute().getId().toUnqualifiedVersionless();
Meta meta = ourClient.meta().get(Meta.class).fromResource(id).execute();
@ -1878,7 +1878,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
@Test
public void testMetaOperationWithNoMetaParameter() throws Exception {
Patient p = new Patient();
p.addName().addFamily("testMetaAddInvalid");
p.addName().setFamily("testMetaAddInvalid");
IIdType id = ourClient.create().resource(p).execute().getId().toUnqualifiedVersionless();
//@formatter:off
@ -1927,7 +1927,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
Patient patient = new Patient();
patient.setActive(true);
patient.addIdentifier().setSystem("urn:system").setValue("0");
patient.addName().addFamily(methodName).addGiven("Joe");
patient.addName().setFamily(methodName).addGiven("Joe");
pid1 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
@ -1957,7 +1957,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
Patient patient = new Patient();
patient.setActive(true);
patient.addIdentifier().setSystem("urn:system").setValue("0");
patient.addName().addFamily(methodName).addGiven("Joe");
patient.addName().setFamily(methodName).addGiven("Joe");
pid1 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
@ -1988,7 +1988,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
Patient patient = new Patient();
patient.setActive(true);
patient.addIdentifier().setSystem("urn:system").setValue("0");
patient.addName().addFamily(methodName).addGiven("Joe");
patient.addName().setFamily(methodName).addGiven("Joe");
pid1 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
@ -2019,7 +2019,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
Patient patient = new Patient();
patient.setActive(true);
patient.addIdentifier().setSystem("urn:system").setValue("0");
patient.addName().addFamily(methodName).addGiven("Joe");
patient.addName().setFamily(methodName).addGiven("Joe");
pid1 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
@ -2190,7 +2190,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
public void testSearchByExtendedChars() throws Exception {
for (int i = 0; i < 10; i++) {
Patient p = new Patient();
p.addName().addFamily("Jernelöv");
p.addName().setFamily("Jernelöv");
p.addIdentifier().setValue("ID" + i);
myPatientDao.create(p, mySrd);
}
@ -2209,7 +2209,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
assertEquals("http://localhost:" + ourPort + "/fhir/context/Patient?_count=5&_pretty=true&name=Jernel%C3%B6v", b.getLink("self").getUrl());
Patient p = (Patient) b.getEntry().get(0).getResource();
assertEquals("Jernelöv", p.getName().get(0).getFamily().get(0).getValue());
assertEquals("Jernelöv", p.getName().get(0).getFamily());
} finally {
IOUtils.closeQuietly(resp.getEntity().getContent());
@ -2221,12 +2221,12 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
public void testSearchByIdentifier() {
Patient p1 = new Patient();
p1.addIdentifier().setSystem("urn:system").setValue("testSearchByIdentifier01");
p1.addName().addFamily("testSearchByIdentifierFamily01").addGiven("testSearchByIdentifierGiven01");
p1.addName().setFamily("testSearchByIdentifierFamily01").addGiven("testSearchByIdentifierGiven01");
IdType p1Id = (IdType) ourClient.create().resource(p1).execute().getId();
Patient p2 = new Patient();
p2.addIdentifier().setSystem("urn:system").setValue("testSearchByIdentifier02");
p2.addName().addFamily("testSearchByIdentifierFamily01").addGiven("testSearchByIdentifierGiven02");
p2.addName().setFamily("testSearchByIdentifierFamily01").addGiven("testSearchByIdentifierGiven02");
ourClient.create().resource(p2).execute().getId();
//@formatter:off
@ -2307,13 +2307,13 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
Patient p1 = new Patient();
p1.addIdentifier().setSystem("urn:system").setValue("testSearchByReferenceIds01");
p1.addName().addFamily("testSearchByReferenceIdsFamily01").addGiven("testSearchByReferenceIdsGiven01");
p1.addName().setFamily("testSearchByReferenceIdsFamily01").addGiven("testSearchByReferenceIdsGiven01");
p1.setManagingOrganization(new Reference(o1id.toUnqualifiedVersionless()));
IIdType p1Id = ourClient.create().resource(p1).execute().getId();
Patient p2 = new Patient();
p2.addIdentifier().setSystem("urn:system").setValue("testSearchByReferenceIds02");
p2.addName().addFamily("testSearchByReferenceIdsFamily02").addGiven("testSearchByReferenceIdsGiven02");
p2.addName().setFamily("testSearchByReferenceIdsFamily02").addGiven("testSearchByReferenceIdsGiven02");
p2.setManagingOrganization(new Reference(o2id.toUnqualifiedVersionless()));
IIdType p2Id = ourClient.create().resource(p2).execute().getId();
@ -2342,7 +2342,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
Patient p1 = new Patient();
p1.addIdentifier().setSystem("urn:system").setValue("testSearchByResourceChain01");
p1.addName().addFamily("testSearchByResourceChainFamily01").addGiven("testSearchByResourceChainGiven01");
p1.addName().setFamily("testSearchByResourceChainFamily01").addGiven("testSearchByResourceChainGiven01");
p1.setManagingOrganization(new Reference(o1id.toUnqualifiedVersionless()));
IdType p1Id = (IdType) ourClient.create().resource(p1).execute().getId();
@ -2378,14 +2378,14 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("001");
patient.addName().addFamily(methodName).addGiven("Joe");
patient.addName().setFamily(methodName).addGiven("Joe");
id1a = (IdType) ourClient.create().resource(patient).execute().getId().toUnqualifiedVersionless();
}
IIdType id1b;
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("002");
patient.addName().addFamily(methodName + "XXXX").addGiven("Joe");
patient.addName().setFamily(methodName + "XXXX").addGiven("Joe");
id1b = (IdType) ourClient.create().resource(patient).execute().getId().toUnqualifiedVersionless();
}
@ -2397,7 +2397,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("002");
patient.addName().addFamily(methodName).addGiven("John");
patient.addName().setFamily(methodName).addGiven("John");
id2 = (IdType) ourClient.create().resource(patient).execute().getId().toUnqualifiedVersionless();
}
@ -2498,14 +2498,14 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
{
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("0");
patient.addName().addFamily(methodName).addGiven("Joe");
patient.addName().setFamily(methodName).addGiven("Joe");
pid1 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
for (int i = 1; i <= 20; i++) {
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue(Integer.toString(i));
patient.addName().addFamily(methodName).addGiven("Joe");
patient.addName().setFamily(methodName).addGiven("Joe");
myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
}
@ -2572,7 +2572,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
public void testSearchThenTagThenSearch() {
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system2").setValue("testSearchTokenParam002");
patient.addName().addFamily("Tester").addGiven("testSearchTokenParam2");
patient.addName().setFamily("Tester").addGiven("testSearchTokenParam2");
ourClient.create().resource(patient).execute();
//@formatter:off
@ -2610,19 +2610,19 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
public void testSearchTokenParamNoValue() {
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("testSearchTokenParam001");
patient.addName().addFamily("Tester").addGiven("testSearchTokenParam1");
patient.addName().setFamily("Tester").addGiven("testSearchTokenParam1");
patient.addCommunication().getLanguage().setText("testSearchTokenParamComText").addCoding().setCode("testSearchTokenParamCode").setSystem("testSearchTokenParamSystem")
.setDisplay("testSearchTokenParamDisplay");
myPatientDao.create(patient, mySrd);
patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("testSearchTokenParam002");
patient.addName().addFamily("Tester").addGiven("testSearchTokenParam2");
patient.addName().setFamily("Tester").addGiven("testSearchTokenParam2");
myPatientDao.create(patient, mySrd);
patient = new Patient();
patient.addIdentifier().setSystem("urn:system2").setValue("testSearchTokenParam002");
patient.addName().addFamily("Tester").addGiven("testSearchTokenParam2");
patient.addName().setFamily("Tester").addGiven("testSearchTokenParam2");
myPatientDao.create(patient, mySrd);
//@formatter:off
@ -2809,7 +2809,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
public void testSearchWithMixedParams() throws Exception {
Patient patient = new Patient();
patient.addIdentifier().setSystem("urn:system").setValue("0");
patient.addName().addFamily("testSearchWithMixedParams").addGiven("Joe");
patient.addName().setFamily("testSearchWithMixedParams").addGiven("Joe");
myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
HttpPost httpPost = new HttpPost(ourServerBase + "/Patient/_search?_format=application/xml");
@ -2859,82 +2859,82 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addGiven("Daniel").addFamily("Adams");
p.addName().addGiven("Daniel").setFamily("Adams");
ourClient.create().resource(p).execute();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addGiven("Aaron").addFamily("Alexis");
p.addName().addGiven("Aaron").setFamily("Alexis");
ourClient.create().resource(p).execute();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addGiven("Carol").addFamily("Allen");
p.addName().addGiven("Carol").setFamily("Allen");
ourClient.create().resource(p).execute();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addGiven("Ruth").addFamily("Black");
p.addName().addGiven("Ruth").setFamily("Black");
ourClient.create().resource(p).execute();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addGiven("Brian").addFamily("Brooks");
p.addName().addGiven("Brian").setFamily("Brooks");
ourClient.create().resource(p).execute();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addGiven("Susan").addFamily("Clark");
p.addName().addGiven("Susan").setFamily("Clark");
ourClient.create().resource(p).execute();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addGiven("Amy").addFamily("Clark");
p.addName().addGiven("Amy").setFamily("Clark");
ourClient.create().resource(p).execute();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addGiven("Anthony").addFamily("Coleman");
p.addName().addGiven("Anthony").setFamily("Coleman");
ourClient.create().resource(p).execute();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addGiven("Steven").addFamily("Coleman");
p.addName().addGiven("Steven").setFamily("Coleman");
ourClient.create().resource(p).execute();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addGiven("Lisa").addFamily("Coleman");
p.addName().addGiven("Lisa").setFamily("Coleman");
ourClient.create().resource(p).execute();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addGiven("Ruth").addFamily("Cook");
p.addName().addGiven("Ruth").setFamily("Cook");
ourClient.create().resource(p).execute();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addGiven("Betty").addFamily("Davis");
p.addName().addGiven("Betty").setFamily("Davis");
ourClient.create().resource(p).execute();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addGiven("Joshua").addFamily("Diaz");
p.addName().addGiven("Joshua").setFamily("Diaz");
ourClient.create().resource(p).execute();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addGiven("Brian").addFamily("Gracia");
p.addName().addGiven("Brian").setFamily("Gracia");
ourClient.create().resource(p).execute();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addGiven("Stephan").addFamily("Graham");
p.addName().addGiven("Stephan").setFamily("Graham");
ourClient.create().resource(p).execute();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.addName().addGiven("Sarah").addFamily("Graham");
p.addName().addGiven("Sarah").setFamily("Graham");
ourClient.create().resource(p).execute();
//@formatter:off
@ -3020,7 +3020,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
public void testTryToCreateResourceWithReferenceThatDoesntExist() {
Patient p1 = new Patient();
p1.addIdentifier().setSystem("urn:system").setValue("testTryToCreateResourceWithReferenceThatDoesntExist01");
p1.addName().addFamily("testTryToCreateResourceWithReferenceThatDoesntExistFamily01").addGiven("testTryToCreateResourceWithReferenceThatDoesntExistGiven01");
p1.addName().setFamily("testTryToCreateResourceWithReferenceThatDoesntExistFamily01").addGiven("testTryToCreateResourceWithReferenceThatDoesntExistGiven01");
p1.setManagingOrganization(new Reference("Organization/99999999999"));
try {
@ -3037,7 +3037,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
String methodName = "testUpdateInvalidReference";
Patient pt = new Patient();
pt.addName().addFamily(methodName);
pt.addName().setFamily(methodName);
String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt);
HttpPut post = new HttpPut(ourServerBase + "/Patient");
@ -3060,7 +3060,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
Patient pt = new Patient();
pt.setId("2");
pt.addName().addFamily(methodName);
pt.addName().setFamily(methodName);
String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt);
HttpPut post = new HttpPut(ourServerBase + "/Patient");
@ -3086,7 +3086,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
String methodName = "testUpdateNoIdInBody";
Patient pt = new Patient();
pt.addName().addFamily(methodName);
pt.addName().setFamily(methodName);
String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt);
HttpPut post = new HttpPut(ourServerBase + "/Patient/FOO");
@ -3108,7 +3108,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
Patient p1 = new Patient();
p1.addIdentifier().setSystem("urn:system").setValue("testUpdateRejectsInvalidTypes");
p1.addName().addFamily("Tester").addGiven("testUpdateRejectsInvalidTypes");
p1.addName().setFamily("Tester").addGiven("testUpdateRejectsInvalidTypes");
IdType p1id = (IdType) ourClient.create().resource(p1).execute().getId();
// Try to update with the wrong ID in the resource body
@ -3167,7 +3167,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
Patient p1 = new Patient();
p1.addIdentifier().setSystem("urn:system").setValue("testUpdateRejectsInvalidTypes");
p1.addName().addFamily("Tester").addGiven("testUpdateRejectsInvalidTypes");
p1.addName().setFamily("Tester").addGiven("testUpdateRejectsInvalidTypes");
IdType p1id = (IdType) ourClient.create().resource(p1).execute().getId();
Organization p2 = new Organization();
@ -3194,7 +3194,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
String methodName = "testUpdateResourceConditional";
Patient pt = new Patient();
pt.addName().addFamily(methodName);
pt.addName().setFamily(methodName);
String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt);
HttpPost post = new HttpPost(ourServerBase + "/Patient?name=" + methodName);
@ -3245,7 +3245,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
response.close();
}
pt.addName().addFamily("FOO");
pt.addName().setFamily("FOO");
resource = myFhirCtx.newXmlParser().encodeResourceToString(pt);
HttpPut put = new HttpPut(ourServerBase + "/Patient?identifier=" + ("http://general-hospital.co.uk/Identifiers|09832345234543876876".replace("|", UrlUtil.escape("|"))));
put.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
@ -3271,7 +3271,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
String methodName = "testUpdateResourceWithPrefer";
Patient pt = new Patient();
pt.addName().addFamily(methodName);
pt.addName().setFamily(methodName);
String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt);
HttpPost post = new HttpPost(ourServerBase + "/Patient");
@ -3347,10 +3347,10 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
String methodName = "testUpdateWithETag";
Patient pt = new Patient();
pt.addName().addFamily(methodName);
pt.addName().setFamily(methodName);
IIdType id = ourClient.create().resource(pt).execute().getId().toUnqualifiedVersionless();
pt.addName().addFamily("FAM2");
pt.addName().setFamily("FAM2");
pt.setId(id.toUnqualifiedVersionless());
String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt);
@ -3389,7 +3389,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
Patient pt = new Patient();
pt.setId("333");
pt.addName().addFamily(methodName);
pt.addName().setFamily(methodName);
String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt);
HttpPut post = new HttpPut(ourServerBase + "/Patient/A2");

View File

@ -68,7 +68,7 @@ public class ResourceProviderQuestionnaireResponseDstu3Test extends BaseResource
@Test
public void testCreateWithLocalReference() {
Patient pt1 = new Patient();
pt1.addName().addFamily("Everything").addGiven("Arthur");
pt1.addName().setFamily("Everything").addGiven("Arthur");
IIdType ptId1 = myPatientDao.create(pt1, mySrd).getId().toUnqualifiedVersionless();
Questionnaire q1 = new Questionnaire();
@ -91,7 +91,7 @@ public class ResourceProviderQuestionnaireResponseDstu3Test extends BaseResource
@Test
public void testCreateWithAbsoluteReference() {
Patient pt1 = new Patient();
pt1.addName().addFamily("Everything").addGiven("Arthur");
pt1.addName().setFamily("Everything").addGiven("Arthur");
IIdType ptId1 = myPatientDao.create(pt1, mySrd).getId().toUnqualifiedVersionless();
Questionnaire q1 = new Questionnaire();

View File

@ -43,7 +43,7 @@ public class StaleSearchDeletingSvcDstu3Test extends BaseResourceProviderDstu3Te
for (int i = 0; i < 20; i++) {
Patient pt1 = new Patient();
pt1.addName().addFamily("Everything").addGiven("Arthur");
pt1.addName().setFamily("Everything").addGiven("Arthur");
myPatientDao.create(pt1, mySrd).getId().toUnqualifiedVersionless();
}

View File

@ -168,7 +168,7 @@ public class SubscriptionsDstu3Test extends BaseResourceProviderDstu3Test {
String methodName = "testSubscriptionDynamic";
Patient p = new Patient();
p.addName().addFamily(methodName);
p.addName().setFamily(methodName);
IIdType pId = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
String criteria = "Observation?subject=Patient/" + pId.getIdPart();
@ -233,7 +233,7 @@ public class SubscriptionsDstu3Test extends BaseResourceProviderDstu3Test {
String methodName = "testSubscriptionDynamic";
Patient p = new Patient();
p.addName().addFamily(methodName);
p.addName().setFamily(methodName);
IIdType pId = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
String criteria = "Observation?subject=Patient/" + pId.getIdPart() + "&_format=xml";
@ -298,7 +298,7 @@ public class SubscriptionsDstu3Test extends BaseResourceProviderDstu3Test {
String methodName = "testSubscriptionResourcesAppear";
Patient p = new Patient();
p.addName().addFamily(methodName);
p.addName().setFamily(methodName);
IIdType pId = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
Subscription subs = new Subscription();

View File

@ -85,7 +85,7 @@ public class SystemProviderDstu3Test extends BaseJpaDstu3Test {
myDaoConfig.setAllowInlineMatchUrlReferences(true);
Patient p = new Patient();
p.addName().addFamily("van de Heuvelcx85ioqWJbI").addGiven("Pietercx85ioqWJbI");
p.addName().setFamily("van de Heuvelcx85ioqWJbI").addGiven("Pietercx85ioqWJbI");
myPatientDao.create(p, mySrd);
Organization o = new Organization();
@ -144,7 +144,7 @@ public class SystemProviderDstu3Test extends BaseJpaDstu3Test {
myDaoConfig.setAllowInlineMatchUrlReferences(true);
Patient p = new Patient();
p.addName().addFamily("van de Heuvelcx85ioqWJbI").addGiven("Pietercx85ioqWJbI");
p.addName().setFamily("van de Heuvelcx85ioqWJbI").addGiven("Pietercx85ioqWJbI");
IIdType id = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
ourClient.read().resource(Patient.class).withId(id);
@ -304,7 +304,7 @@ public class SystemProviderDstu3Test extends BaseJpaDstu3Test {
for (int i = 0; i < 11; i++) {
Patient p = new Patient();
p.addName().addFamily("Name" + i);
p.addName().setFamily("Name" + i);
ourClient.create().resource(p).execute();
}
@ -333,7 +333,7 @@ public class SystemProviderDstu3Test extends BaseJpaDstu3Test {
for (int i = 0; i < 11; i++) {
Patient p = new Patient();
p.addName().addFamily("Name" + i);
p.addName().setFamily("Name" + i);
ourClient.create().resource(p).execute();
}
@ -385,7 +385,7 @@ public class SystemProviderDstu3Test extends BaseJpaDstu3Test {
public void testSuggestKeywords() throws Exception {
Patient patient = new Patient();
patient.addName().addFamily("testSuggest");
patient.addName().setFamily("testSuggest");
IIdType ptId = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
Observation obs = new Observation();
@ -421,7 +421,7 @@ public class SystemProviderDstu3Test extends BaseJpaDstu3Test {
@Test
public void testSuggestKeywordsInvalid() throws Exception {
Patient patient = new Patient();
patient.addName().addFamily("testSuggest");
patient.addName().setFamily("testSuggest");
IIdType ptId = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
Observation obs = new Observation();
@ -591,7 +591,7 @@ public class SystemProviderDstu3Test extends BaseJpaDstu3Test {
public void testTransactionSearch() throws Exception {
for (int i = 0; i < 20; i++) {
Patient p = new Patient();
p.addName().addFamily("PATIENT_" + i);
p.addName().setFamily("PATIENT_" + i);
myPatientDao.create(p, mySrd);
}
@ -615,7 +615,7 @@ public class SystemProviderDstu3Test extends BaseJpaDstu3Test {
public void testTransactionCount() throws Exception {
for (int i = 0; i < 20; i++) {
Patient p = new Patient();
p.addName().addFamily("PATIENT_" + i);
p.addName().setFamily("PATIENT_" + i);
myPatientDao.create(p, mySrd);
}

View File

@ -107,21 +107,21 @@ public class TerminologySvcImplTest extends BaseJpaDstu3Test {
List<VersionIndependentConcept> concepts;
Set<String> codes;
concepts = myTermSvc.findCodesBelow("http://hl7.org/fhir/allergy-intolerance-status", "active");
concepts = myTermSvc.findCodesBelow("http://hl7.org/fhir/allergy-clinical-status", "inactive");
codes = toCodes(concepts);
assertThat(codes, containsInAnyOrder("active", "active-confirmed"));
assertThat(codes, containsInAnyOrder("inactive", "resolved"));
concepts = myTermSvc.findCodesBelow("http://hl7.org/fhir/allergy-intolerance-status", "active-confirmed");
concepts = myTermSvc.findCodesBelow("http://hl7.org/fhir/allergy-clinical-status", "resolved");
codes = toCodes(concepts);
assertThat(codes, containsInAnyOrder("active-confirmed"));
assertThat(codes, containsInAnyOrder("resolved"));
// Unknown code
concepts = myTermSvc.findCodesBelow("http://hl7.org/fhir/allergy-intolerance-status", "FOO");
concepts = myTermSvc.findCodesBelow("http://hl7.org/fhir/allergy-clinical-status", "FOO");
codes = toCodes(concepts);
assertThat(codes, empty());
// Unknown system
concepts = myTermSvc.findCodesBelow("http://hl7.org/fhir/allergy-intolerance-status2222", "FOO");
concepts = myTermSvc.findCodesBelow("http://hl7.org/fhir/allergy-clinical-status2222", "active");
codes = toCodes(concepts);
assertThat(codes, empty());
}
@ -131,21 +131,21 @@ public class TerminologySvcImplTest extends BaseJpaDstu3Test {
List<VersionIndependentConcept> concepts;
Set<String> codes;
concepts = myTermSvc.findCodesAbove("http://hl7.org/fhir/allergy-intolerance-status", "active");
concepts = myTermSvc.findCodesAbove("http://hl7.org/fhir/allergy-clinical-status", "active");
codes = toCodes(concepts);
assertThat(codes, containsInAnyOrder("active"));
concepts = myTermSvc.findCodesAbove("http://hl7.org/fhir/allergy-intolerance-status", "active-confirmed");
concepts = myTermSvc.findCodesAbove("http://hl7.org/fhir/allergy-clinical-status", "resolved");
codes = toCodes(concepts);
assertThat(codes, containsInAnyOrder("active", "active-confirmed"));
assertThat(codes, containsInAnyOrder("inactive", "resolved"));
// Unknown code
concepts = myTermSvc.findCodesAbove("http://hl7.org/fhir/allergy-intolerance-status", "FOO");
concepts = myTermSvc.findCodesAbove("http://hl7.org/fhir/allergy-clinical-status", "FOO");
codes = toCodes(concepts);
assertThat(codes, empty());
// Unknown system
concepts = myTermSvc.findCodesAbove("http://hl7.org/fhir/allergy-intolerance-status2222", "FOO");
concepts = myTermSvc.findCodesAbove("http://hl7.org/fhir/allergy-clinical-status2222", "active");
codes = toCodes(concepts);
assertThat(codes, empty());
}

View File

@ -75,7 +75,7 @@ public class UhnFhirTestApp {
Patient p1 = new Patient();
p1.getMeta().addTag("http://hl7.org/fhir/tag", "urn:happytag", "This is a happy resource");
p1.addIdentifier().setSystem("foo:bar").setValue("12345");
p1.addName().addFamily("Smith").addGiven("John");
p1.addName().setFamily("Smith").addGiven("John");
p1.getManagingOrganization().setReferenceElement(orgId.toUnqualifiedVersionless());
Subscription subs = new Subscription();

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="src" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/hapi-fhir-base"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -0,0 +1 @@
/build/

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>hapi-fhir-structures-dstu2.1</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View File

@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

View File

@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="java" version="1.8"/>
</faceted-project>

View File

@ -0,0 +1,227 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>2.2-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
<artifactId>hapi-fhir-structures-dstu2.1</artifactId>
<packaging>jar</packaging>
<name>HAPI FHIR Structures - DSTU2.1 (2016May)</name>
<dependencies>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
</dependency>
<!--
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu2.1</artifactId>
<version>2.2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
-->
<!--
The JPA project uses a newer API but we'll try to hold to this version
as much as possible. See #283.
-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>xpp3</groupId>
<artifactId>xpp3_min</artifactId>
<version>1.1.4c</version>
</dependency>
<!--
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId>
<version>9.6.0-4</version>
</dependency>
-->
<!-- Testing -->
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlets</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<optional>true</optional>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.phloc</groupId>
<artifactId>phloc-schematron</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.phloc</groupId>
<artifactId>phloc-commons</artifactId>
<scope>test</scope>
</dependency>
<!-- UNIT TEST DEPENDENCIES -->
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<classifier>jdk15</classifier>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<classifier>jdk15-sources</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>directory-naming</groupId>
<artifactId>naming-java</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<show>public</show>
</configuration>
</plugin>
</plugins>
</reporting>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<classFolders>
<classFolder>${basedir}/target/classes</classFolder>
<classFolder>${basedir}/../hapi-fhir-base/target/classes</classFolder>
</classFolders>
<sourceFolders>
<sourceFolder>${basedir}/src/main/java</sourceFolder>
<sourceFolder>${basedir}/../hapi-fhir-base/src/main/java</sourceFolder>
</sourceFolders>
<dumpOnExit>true</dumpOnExit>
</configuration>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>${argLine} -Dfile.encoding=UTF-8 -Xmx712m</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<configuration>
<!-- Don't add UHN licenses to RI structures -->
<skipUpdateLicense>true</skipUpdateLicense>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,152 @@
package org.hl7.fhir.dstu2016may.hapi.ctx;
/*
* #%L
* HAPI FHIR Structures - DSTU2 (FHIR v1.0.0)
* %%
* Copyright (C) 2014 - 2015 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.io.InputStream;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.dstu2016may.hapi.rest.server.Dstu2_1BundleFactory;
import org.hl7.fhir.dstu2016may.hapi.rest.server.ServerConformanceProvider;
import org.hl7.fhir.dstu2016may.hapi.rest.server.ServerProfileProvider;
import org.hl7.fhir.dstu2016may.model.Coding;
import org.hl7.fhir.dstu2016may.model.Constants;
import org.hl7.fhir.dstu2016may.model.IdType;
import org.hl7.fhir.dstu2016may.model.Reference;
import org.hl7.fhir.dstu2016may.model.Resource;
import org.hl7.fhir.dstu2016may.model.StructureDefinition;
import org.hl7.fhir.instance.model.api.IBaseCoding;
import org.hl7.fhir.instance.model.api.IBaseReference;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.instance.model.api.IPrimitiveType;
import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.context.support.IContextValidationSupport;
import ca.uhn.fhir.fluentpath.IFluentPath;
import ca.uhn.fhir.model.api.IFhirVersion;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.IVersionSpecificBundleFactory;
import ca.uhn.fhir.rest.server.RestfulServer;
public class FhirDstu2_1 implements IFhirVersion {
private String myId;
@Override
public IFluentPath createFluentPathExecutor(FhirContext theFhirContext) {
throw new UnsupportedOperationException("FluentPath is not supported in DSTU2 contexts");
}
@Override
public ServerConformanceProvider createServerConformanceProvider(RestfulServer theServer) {
return new ServerConformanceProvider(theServer);
}
@Override
public IResourceProvider createServerProfilesProvider(RestfulServer theRestfulServer) {
return new ServerProfileProvider(theRestfulServer);
}
@Override
public IContextValidationSupport<?, ?, ?, ?, ?, ?> createValidationSupport() {
throw new UnsupportedOperationException("Validation is not supported in DSTU2.1 contexts");
}
@Override
public IBaseResource generateProfile(RuntimeResourceDefinition theRuntimeResourceDefinition, String theServerBase) {
StructureDefinition retVal = new StructureDefinition();
RuntimeResourceDefinition def = theRuntimeResourceDefinition;
myId = def.getId();
if (StringUtils.isBlank(myId)) {
myId = theRuntimeResourceDefinition.getName().toLowerCase();
}
retVal.setId(new IdDt(myId));
return retVal;
}
@SuppressWarnings("rawtypes")
@Override
public Class<List> getContainedType() {
return List.class;
}
@Override
public InputStream getFhirVersionPropertiesFile() {
InputStream str = FhirDstu2_1.class.getResourceAsStream("/org/hl7/fhir/dstu2016may/model/fhirversion.properties");
if (str == null) {
str = FhirDstu2_1.class.getResourceAsStream("/org/hl7/fhir/dstu2016may/model/fhirversion.properties");
}
if (str == null) {
throw new ConfigurationException("Can not find model property file on classpath: " + "/ca/uhn/fhir/model/dstu2016may/fhirversion.properties");
}
return str;
}
@Override
public IPrimitiveType<Date> getLastUpdated(IBaseResource theResource) {
return ((Resource) theResource).getMeta().getLastUpdatedElement();
}
@Override
public String getPathToSchemaDefinitions() {
return "/org/hl7/fhir/instance/model/dstu3/schema";
}
@Override
public Class<? extends IBaseReference> getResourceReferenceType() {
return Reference.class;
}
@Override
public FhirVersionEnum getVersion() {
return FhirVersionEnum.DSTU2_1;
}
@Override
public String getVersionString() {
return Constants.VERSION;
}
@Override
public IVersionSpecificBundleFactory newBundleFactory(FhirContext theContext) {
return new Dstu2_1BundleFactory(theContext);
}
@Override
public IBaseCoding newCodingDt() {
return new Coding();
}
@Override
public IIdType newIdType() {
return new IdType();
}
}

View File

@ -0,0 +1,449 @@
package org.hl7.fhir.dstu2016may.hapi.rest.server;
/*
* #%L
* HAPI FHIR Structures - DSTU2 (FHIR v1.0.0)
* %%
* Copyright (C) 2014 - 2015 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.apache.commons.lang3.Validate;
import org.hl7.fhir.dstu2016may.model.Bundle;
import org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.dstu2016may.model.Bundle.BundleLinkComponent;
import org.hl7.fhir.dstu2016may.model.Bundle.HTTPVerb;
import org.hl7.fhir.dstu2016may.model.Bundle.SearchEntryMode;
import org.hl7.fhir.dstu2016may.model.DomainResource;
import org.hl7.fhir.dstu2016may.model.IdType;
import org.hl7.fhir.dstu2016may.model.Resource;
import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.instance.model.api.IBaseReference;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.instance.model.api.IPrimitiveType;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.Include;
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
import ca.uhn.fhir.rest.server.BundleInclusionRule;
import ca.uhn.fhir.rest.server.Constants;
import ca.uhn.fhir.rest.server.EncodingEnum;
import ca.uhn.fhir.rest.server.IBundleProvider;
import ca.uhn.fhir.rest.server.IPagingProvider;
import ca.uhn.fhir.rest.server.IRestfulServer;
import ca.uhn.fhir.rest.server.IVersionSpecificBundleFactory;
import ca.uhn.fhir.rest.server.RestfulServerUtils;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.util.ResourceReferenceInfo;
public class Dstu2_1BundleFactory implements IVersionSpecificBundleFactory {
private Bundle myBundle;
private FhirContext myContext;
private String myBase;
public Dstu2_1BundleFactory(FhirContext theContext) {
myContext = theContext;
}
private void addResourcesForSearch(List<? extends IBaseResource> theResult) {
List<IBaseResource> includedResources = new ArrayList<IBaseResource>();
Set<IIdType> addedResourceIds = new HashSet<IIdType>();
for (IBaseResource next : theResult) {
if (next.getIdElement().isEmpty() == false) {
addedResourceIds.add(next.getIdElement());
}
}
for (IBaseResource nextBaseRes : theResult) {
Resource next = (Resource) nextBaseRes;
Set<String> containedIds = new HashSet<String>();
if (next instanceof DomainResource) {
for (Resource nextContained : ((DomainResource)next).getContained()) {
if (nextContained.getIdElement().isEmpty() == false) {
containedIds.add(nextContained.getIdElement().getValue());
}
}
}
List<IBaseReference> references = myContext.newTerser().getAllPopulatedChildElementsOfType(next, IBaseReference.class);
do {
List<IAnyResource> addedResourcesThisPass = new ArrayList<IAnyResource>();
for (IBaseReference nextRef : references) {
IAnyResource nextRes = (IAnyResource) nextRef.getResource();
if (nextRes != null) {
if (nextRes.getIdElement().hasIdPart()) {
if (containedIds.contains(nextRes.getIdElement().getValue())) {
// Don't add contained IDs as top level resources
continue;
}
IIdType id = nextRes.getIdElement();
if (id.hasResourceType() == false) {
String resName = myContext.getResourceDefinition(nextRes).getName();
id = id.withResourceType(resName);
}
if (!addedResourceIds.contains(id)) {
addedResourceIds.add(id);
addedResourcesThisPass.add(nextRes);
}
}
}
}
// Linked resources may themselves have linked resources
references = new ArrayList<IBaseReference>();
for (IAnyResource iResource : addedResourcesThisPass) {
List<IBaseReference> newReferences = myContext.newTerser().getAllPopulatedChildElementsOfType(iResource, IBaseReference.class);
references.addAll(newReferences);
}
includedResources.addAll(addedResourcesThisPass);
} while (references.isEmpty() == false);
BundleEntryComponent entry = myBundle.addEntry().setResource(next);
if (next.getIdElement().hasBaseUrl()) {
entry.setFullUrl(next.getId());
}
String httpVerb = ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.get(next);
if (httpVerb != null) {
entry.getRequest().getMethodElement().setValueAsString(httpVerb);
entry.getRequest().getUrlElement().setValue(next.getId());
}
}
/*
* Actually add the resources to the bundle
*/
for (IBaseResource next : includedResources) {
BundleEntryComponent entry = myBundle.addEntry();
entry.setResource((Resource) next).getSearch().setMode(SearchEntryMode.INCLUDE);
if (next.getIdElement().hasBaseUrl()) {
entry.setFullUrl(next.getIdElement().getValue());
}
}
}
@Override
public void addResourcesToBundle(List<IBaseResource> theResult, BundleTypeEnum theBundleType, String theServerBase, BundleInclusionRule theBundleInclusionRule, Set<Include> theIncludes) {
if (myBundle == null) {
myBundle = new Bundle();
}
List<IAnyResource> includedResources = new ArrayList<IAnyResource>();
Set<IIdType> addedResourceIds = new HashSet<IIdType>();
for (IBaseResource next : theResult) {
if (next.getIdElement().isEmpty() == false) {
addedResourceIds.add(next.getIdElement());
}
}
for (IBaseResource next : theResult) {
Set<String> containedIds = new HashSet<String>();
if (next instanceof DomainResource) {
for (Resource nextContained : ((DomainResource)next).getContained()) {
if (isNotBlank(nextContained.getId())) {
containedIds.add(nextContained.getId());
}
}
}
List<ResourceReferenceInfo> references = myContext.newTerser().getAllResourceReferences(next);
do {
List<IAnyResource> addedResourcesThisPass = new ArrayList<IAnyResource>();
for (ResourceReferenceInfo nextRefInfo : references) {
if (!theBundleInclusionRule.shouldIncludeReferencedResource(nextRefInfo, theIncludes)) {
continue;
}
IAnyResource nextRes = (IAnyResource) nextRefInfo.getResourceReference().getResource();
if (nextRes != null) {
if (nextRes.getIdElement().hasIdPart()) {
if (containedIds.contains(nextRes.getIdElement().getValue())) {
// Don't add contained IDs as top level resources
continue;
}
IIdType id = nextRes.getIdElement();
if (id.hasResourceType() == false) {
String resName = myContext.getResourceDefinition(nextRes).getName();
id = id.withResourceType(resName);
}
if (!addedResourceIds.contains(id)) {
addedResourceIds.add(id);
addedResourcesThisPass.add(nextRes);
}
}
}
}
includedResources.addAll(addedResourcesThisPass);
// Linked resources may themselves have linked resources
references = new ArrayList<ResourceReferenceInfo>();
for (IAnyResource iResource : addedResourcesThisPass) {
List<ResourceReferenceInfo> newReferences = myContext.newTerser().getAllResourceReferences(iResource);
references.addAll(newReferences);
}
} while (references.isEmpty() == false);
BundleEntryComponent entry = myBundle.addEntry().setResource((Resource) next);
Resource nextAsResource = (Resource)next;
IIdType id = populateBundleEntryFullUrl(next, entry);
String httpVerb = ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.get(nextAsResource);
if (httpVerb != null) {
entry.getRequest().getMethodElement().setValueAsString(httpVerb);
if (id != null) {
entry.getRequest().setUrl(id.getValue());
}
}
String searchMode = ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.get(nextAsResource);
if (searchMode != null) {
entry.getSearch().getModeElement().setValueAsString(searchMode);
}
}
/*
* Actually add the resources to the bundle
*/
for (IAnyResource next : includedResources) {
BundleEntryComponent entry = myBundle.addEntry();
entry.setResource((Resource) next).getSearch().setMode(SearchEntryMode.INCLUDE);
populateBundleEntryFullUrl(next, entry);
}
}
private IIdType populateBundleEntryFullUrl(IBaseResource next, BundleEntryComponent entry) {
IIdType idElement = null;
if (next.getIdElement().hasBaseUrl()) {
idElement = next.getIdElement();
entry.setFullUrl(idElement.toVersionless().getValue());
} else {
if (isNotBlank(myBase) && next.getIdElement().hasIdPart()) {
idElement = next.getIdElement();
idElement = idElement.withServerBase(myBase, myContext.getResourceDefinition(next).getName());
entry.setFullUrl(idElement.toVersionless().getValue());
}
}
return idElement;
}
@Override
public void addRootPropertiesToBundle(String theAuthor, String theServerBase, String theCompleteUrl, Integer theTotalResults, BundleTypeEnum theBundleType, IPrimitiveType<Date> theLastUpdated) {
myBase = theServerBase;
if (myBundle.getIdElement().isEmpty()) {
myBundle.setId(UUID.randomUUID().toString());
}
if (myBundle.getMeta().getLastUpdated() == null && theLastUpdated != null) {
myBundle.getMeta().getLastUpdatedElement().setValueAsString(theLastUpdated.getValueAsString());
}
if (!hasLink(Constants.LINK_SELF, myBundle) && isNotBlank(theCompleteUrl)) {
myBundle.addLink().setRelation("self").setUrl(theCompleteUrl);
}
if (myBundle.getTypeElement().isEmpty() && theBundleType != null) {
myBundle.getTypeElement().setValueAsString(theBundleType.getCode());
}
if (myBundle.getTotalElement().isEmpty() && theTotalResults != null) {
myBundle.getTotalElement().setValue(theTotalResults);
}
}
@Override
public ca.uhn.fhir.model.api.Bundle getDstu1Bundle() {
return null;
}
@Override
public IBaseResource getResourceBundle() {
return myBundle;
}
private boolean hasLink(String theLinkType, Bundle theBundle) {
for (BundleLinkComponent next : theBundle.getLink()) {
if (theLinkType.equals(next.getRelation())) {
return true;
}
}
return false;
}
@Override
public void initializeBundleFromBundleProvider(IRestfulServer<?> theServer, IBundleProvider theResult, EncodingEnum theResponseEncoding, String theServerBase, String theCompleteUrl,
boolean thePrettyPrint, int theOffset, Integer theLimit, String theSearchId, BundleTypeEnum theBundleType, Set<Include> theIncludes) {
myBase = theServerBase;
int numToReturn;
String searchId = null;
List<IBaseResource> resourceList;
if (theServer.getPagingProvider() == null) {
numToReturn = theResult.size();
if (numToReturn > 0) {
resourceList = theResult.getResources(0, numToReturn);
} else {
resourceList = Collections.emptyList();
}
RestfulServerUtils.validateResourceListNotNull(resourceList);
} else {
IPagingProvider pagingProvider = theServer.getPagingProvider();
if (theLimit == null) {
numToReturn = pagingProvider.getDefaultPageSize();
} else {
numToReturn = Math.min(pagingProvider.getMaximumPageSize(), theLimit);
}
numToReturn = Math.min(numToReturn, theResult.size() - theOffset);
if (numToReturn > 0) {
resourceList = theResult.getResources(theOffset, numToReturn + theOffset);
} else {
resourceList = Collections.emptyList();
}
RestfulServerUtils.validateResourceListNotNull(resourceList);
if (theSearchId != null) {
searchId = theSearchId;
} else {
if (theResult.size() > numToReturn) {
searchId = pagingProvider.storeResultList(theResult);
Validate.notNull(searchId, "Paging provider returned null searchId");
}
}
}
for (IBaseResource next : resourceList) {
if (next.getIdElement() == null || next.getIdElement().isEmpty()) {
if (!(next instanceof BaseOperationOutcome)) {
throw new InternalErrorException("Server method returned resource of type[" + next.getClass().getSimpleName() + "] with no ID specified (IResource#setId(IdDt) must be called)");
}
}
}
addResourcesToBundle(new ArrayList<IBaseResource>(resourceList), theBundleType, theServerBase, theServer.getBundleInclusionRule(), theIncludes);
addRootPropertiesToBundle(null, theServerBase, theCompleteUrl, theResult.size(), theBundleType, theResult.getPublished());
if (theServer.getPagingProvider() != null) {
int limit;
limit = theLimit != null ? theLimit : theServer.getPagingProvider().getDefaultPageSize();
limit = Math.min(limit, theServer.getPagingProvider().getMaximumPageSize());
if (searchId != null) {
if (theOffset + numToReturn < theResult.size()) {
myBundle.addLink().setRelation(Constants.LINK_NEXT)
.setUrl(RestfulServerUtils.createPagingLink(theIncludes, theServerBase, searchId, theOffset + numToReturn, numToReturn, theResponseEncoding, thePrettyPrint, theBundleType));
}
if (theOffset > 0) {
int start = Math.max(0, theOffset - limit);
myBundle.addLink().setRelation(Constants.LINK_PREVIOUS)
.setUrl(RestfulServerUtils.createPagingLink(theIncludes, theServerBase, searchId, start, limit, theResponseEncoding, thePrettyPrint, theBundleType));
}
}
}
}
@Override
public void initializeBundleFromResourceList(String theAuthor, List<? extends IBaseResource> theResources, String theServerBase, String theCompleteUrl, int theTotalResults,
BundleTypeEnum theBundleType) {
myBundle = new Bundle();
myBundle.setId(UUID.randomUUID().toString());
myBundle.getMeta().setLastUpdated(new Date());
myBundle.addLink().setRelation(Constants.LINK_FHIR_BASE).setUrl(theServerBase);
myBundle.addLink().setRelation(Constants.LINK_SELF).setUrl(theCompleteUrl);
myBundle.getTypeElement().setValueAsString(theBundleType.getCode());
if (theBundleType.equals(BundleTypeEnum.TRANSACTION)) {
for (IBaseResource nextBaseRes : theResources) {
Resource next = (Resource) nextBaseRes;
BundleEntryComponent nextEntry = myBundle.addEntry();
nextEntry.setResource(next);
if (next.getIdElement().isEmpty()) {
nextEntry.getRequest().setMethod(HTTPVerb.POST);
} else {
nextEntry.getRequest().setMethod(HTTPVerb.PUT);
if (next.getIdElement().isAbsolute()) {
nextEntry.getRequest().setUrl(next.getId());
} else {
String resourceType = myContext.getResourceDefinition(next).getName();
nextEntry.getRequest().setUrl(new IdType(theServerBase, resourceType, next.getIdElement().getIdPart(), next.getIdElement().getVersionIdPart()).getValue());
}
}
}
} else {
addResourcesForSearch(theResources);
}
myBundle.getTotalElement().setValue(theTotalResults);
}
@Override
public void initializeWithBundleResource(IBaseResource theBundle) {
myBundle = (Bundle) theBundle;
}
@Override
public List<IBaseResource> toListOfResources() {
ArrayList<IBaseResource> retVal = new ArrayList<IBaseResource>();
for (BundleEntryComponent next : myBundle.getEntry()) {
if (next.getResource() != null) {
retVal.add(next.getResource());
} else if (next.getResponse().getLocationElement().isEmpty() == false) {
IdType id = new IdType(next.getResponse().getLocation());
String resourceType = id.getResourceType();
if (isNotBlank(resourceType)) {
IAnyResource res = (IAnyResource) myContext.getResourceDefinition(resourceType).newInstance();
res.setId(id);
retVal.add(res);
}
}
}
return retVal;
}
}

View File

@ -0,0 +1,661 @@
package org.hl7.fhir.dstu2016may.hapi.rest.server;
import static org.apache.commons.lang3.StringUtils.isBlank;
/*
* #%L
* HAPI FHIR Structures - DSTU2 (FHIR v1.0.0)
* %%
* Copyright (C) 2014 - 2015 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.dstu2016may.model.Conformance;
import org.hl7.fhir.dstu2016may.model.Conformance.ConditionalDeleteStatus;
import org.hl7.fhir.dstu2016may.model.Conformance.ConformanceRestComponent;
import org.hl7.fhir.dstu2016may.model.Conformance.ConformanceRestResourceComponent;
import org.hl7.fhir.dstu2016may.model.Conformance.ConformanceRestResourceSearchParamComponent;
import org.hl7.fhir.dstu2016may.model.Conformance.ConformanceStatementKind;
import org.hl7.fhir.dstu2016may.model.Conformance.ResourceInteractionComponent;
import org.hl7.fhir.dstu2016may.model.Conformance.RestfulConformanceMode;
import org.hl7.fhir.dstu2016may.model.Conformance.SystemRestfulInteraction;
import org.hl7.fhir.dstu2016may.model.Conformance.TypeRestfulInteraction;
import org.hl7.fhir.dstu2016may.model.Conformance.UnknownContentCode;
import org.hl7.fhir.dstu2016may.model.DateTimeType;
import org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatus;
import org.hl7.fhir.dstu2016may.model.Enumerations.ResourceType;
import org.hl7.fhir.dstu2016may.model.IdType;
import org.hl7.fhir.dstu2016may.model.OperationDefinition;
import org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationDefinitionParameterComponent;
import org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationKind;
import org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationParameterUse;
import org.hl7.fhir.dstu2016may.model.Reference;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.instance.model.api.IBaseResource;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.context.RuntimeSearchParam;
import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.Initialize;
import ca.uhn.fhir.rest.annotation.Metadata;
import ca.uhn.fhir.rest.annotation.Read;
import ca.uhn.fhir.rest.method.BaseMethodBinding;
import ca.uhn.fhir.rest.method.DynamicSearchMethodBinding;
import ca.uhn.fhir.rest.method.IParameter;
import ca.uhn.fhir.rest.method.OperationMethodBinding;
import ca.uhn.fhir.rest.method.OperationMethodBinding.ReturnType;
import ca.uhn.fhir.rest.method.OperationParameter;
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
import ca.uhn.fhir.rest.method.SearchMethodBinding;
import ca.uhn.fhir.rest.method.SearchParameter;
import ca.uhn.fhir.rest.server.Constants;
import ca.uhn.fhir.rest.server.IServerConformanceProvider;
import ca.uhn.fhir.rest.server.ResourceBinding;
import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.rest.server.RestulfulServerConfiguration;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
/**
* Server FHIR Provider which serves the conformance statement for a RESTful server implementation
*
* <p>
* Note: This class is safe to extend, but it is important to note that the same instance of {@link Conformance} is always returned unless {@link #setCache(boolean)} is called with a value of
* <code>false</code>. This means that if you are adding anything to the returned conformance instance on each call you should call <code>setCache(false)</code> in your provider constructor.
* </p>
*/
public class ServerConformanceProvider implements IServerConformanceProvider<Conformance> {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ServerConformanceProvider.class);
private boolean myCache = true;
private volatile Conformance myConformance;
private IdentityHashMap<OperationMethodBinding, String> myOperationBindingToName;
private HashMap<String, List<OperationMethodBinding>> myOperationNameToBindings;
private String myPublisher = "Not provided";
private RestulfulServerConfiguration myServerConfiguration;
/*
* Add a no-arg constructor and seetter so that the ServerConfirmanceProvider can be Spring-wired with the RestfulService avoiding the potential reference cycle that would happen.
*/
public ServerConformanceProvider() {
super();
}
public ServerConformanceProvider(RestfulServer theRestfulServer) {
this.myServerConfiguration = theRestfulServer.createConfiguration();
}
public ServerConformanceProvider(RestulfulServerConfiguration theServerConfiguration) {
this.myServerConfiguration = theServerConfiguration;
}
private void checkBindingForSystemOps(ConformanceRestComponent rest, Set<SystemRestfulInteraction> systemOps, BaseMethodBinding<?> nextMethodBinding) {
if (nextMethodBinding.getRestOperationType() != null) {
String sysOpCode = nextMethodBinding.getRestOperationType().getCode();
if (sysOpCode != null) {
SystemRestfulInteraction sysOp;
try {
sysOp = SystemRestfulInteraction.fromCode(sysOpCode);
} catch (FHIRException e) {
return;
}
if (sysOp == null) {
return;
}
if (systemOps.contains(sysOp) == false) {
systemOps.add(sysOp);
rest.addInteraction().setCode(sysOp);
}
}
}
}
private Map<String, List<BaseMethodBinding<?>>> collectMethodBindings() {
Map<String, List<BaseMethodBinding<?>>> resourceToMethods = new TreeMap<String, List<BaseMethodBinding<?>>>();
for (ResourceBinding next : myServerConfiguration.getResourceBindings()) {
String resourceName = next.getResourceName();
for (BaseMethodBinding<?> nextMethodBinding : next.getMethodBindings()) {
if (resourceToMethods.containsKey(resourceName) == false) {
resourceToMethods.put(resourceName, new ArrayList<BaseMethodBinding<?>>());
}
resourceToMethods.get(resourceName).add(nextMethodBinding);
}
}
for (BaseMethodBinding<?> nextMethodBinding : myServerConfiguration.getServerBindings()) {
String resourceName = "";
if (resourceToMethods.containsKey(resourceName) == false) {
resourceToMethods.put(resourceName, new ArrayList<BaseMethodBinding<?>>());
}
resourceToMethods.get(resourceName).add(nextMethodBinding);
}
return resourceToMethods;
}
private DateTimeType conformanceDate() {
String buildDate = myServerConfiguration.getConformanceDate();
if (buildDate != null) {
try {
return new DateTimeType(buildDate);
} catch (DataFormatException e) {
// fall through
}
}
return DateTimeType.now();
}
private String createOperationName(OperationMethodBinding theMethodBinding) {
StringBuilder retVal = new StringBuilder();
if (theMethodBinding.getResourceName() != null) {
retVal.append(theMethodBinding.getResourceName());
}
retVal.append('-');
if (theMethodBinding.isCanOperateAtInstanceLevel()) {
retVal.append('i');
}
if (theMethodBinding.isCanOperateAtServerLevel()) {
retVal.append('s');
}
retVal.append('-');
// Exclude the leading $
retVal.append(theMethodBinding.getName(), 1, theMethodBinding.getName().length());
return retVal.toString();
}
/**
* Gets the value of the "publisher" that will be placed in the generated conformance statement. As this is a mandatory element, the value should not be null (although this is not enforced). The
* value defaults to "Not provided" but may be set to null, which will cause this element to be omitted.
*/
public String getPublisher() {
return myPublisher;
}
@Override
@Metadata
public Conformance getServerConformance(HttpServletRequest theRequest) {
if (myConformance != null && myCache) {
return myConformance;
}
Conformance retVal = new Conformance();
retVal.setPublisher(myPublisher);
retVal.setDateElement(conformanceDate());
retVal.setFhirVersion(FhirVersionEnum.DSTU2_1.getVersionImplementation().getVersionString());
retVal.setAcceptUnknown(UnknownContentCode.EXTENSIONS); // TODO: make this configurable - this is a fairly big
// effort since the parser
// needs to be modified to actually allow it
retVal.getImplementation().setDescription(myServerConfiguration.getImplementationDescription());
retVal.setKind(ConformanceStatementKind.INSTANCE);
retVal.getSoftware().setName(myServerConfiguration.getServerName());
retVal.getSoftware().setVersion(myServerConfiguration.getServerVersion());
retVal.addFormat(Constants.CT_FHIR_XML_NEW);
retVal.addFormat(Constants.CT_FHIR_JSON_NEW);
retVal.setStatus(ConformanceResourceStatus.ACTIVE);
ConformanceRestComponent rest = retVal.addRest();
rest.setMode(RestfulConformanceMode.SERVER);
Set<SystemRestfulInteraction> systemOps = new HashSet<SystemRestfulInteraction>();
Set<String> operationNames = new HashSet<String>();
Map<String, List<BaseMethodBinding<?>>> resourceToMethods = collectMethodBindings();
for (Entry<String, List<BaseMethodBinding<?>>> nextEntry : resourceToMethods.entrySet()) {
if (nextEntry.getKey().isEmpty() == false) {
Set<TypeRestfulInteraction> resourceOps = new HashSet<TypeRestfulInteraction>();
ConformanceRestResourceComponent resource = rest.addResource();
String resourceName = nextEntry.getKey();
RuntimeResourceDefinition def = myServerConfiguration.getFhirContext().getResourceDefinition(resourceName);
resource.getTypeElement().setValue(def.getName());
ServletContext servletContext = (ServletContext) (theRequest == null ? null : theRequest.getAttribute(RestfulServer.SERVLET_CONTEXT_ATTRIBUTE));
String serverBase = myServerConfiguration.getServerAddressStrategy().determineServerBase(servletContext, theRequest);
resource.getProfile().setReference((def.getResourceProfile(serverBase)));
TreeSet<String> includes = new TreeSet<String>();
// Map<String, Conformance.RestResourceSearchParam> nameToSearchParam = new HashMap<String,
// Conformance.RestResourceSearchParam>();
for (BaseMethodBinding<?> nextMethodBinding : nextEntry.getValue()) {
if (nextMethodBinding.getRestOperationType() != null) {
String resOpCode = nextMethodBinding.getRestOperationType().getCode();
if (resOpCode != null) {
TypeRestfulInteraction resOp;
try {
resOp = TypeRestfulInteraction.fromCode(resOpCode);
} catch (Exception e) {
resOp = null;
}
if (resOp != null) {
if (resourceOps.contains(resOp) == false) {
resourceOps.add(resOp);
resource.addInteraction().setCode(resOp);
}
if ("vread".equals(resOpCode)) {
// vread implies read
resOp = TypeRestfulInteraction.READ;
if (resourceOps.contains(resOp) == false) {
resourceOps.add(resOp);
resource.addInteraction().setCode(resOp);
}
}
if (nextMethodBinding.isSupportsConditional()) {
switch (resOp) {
case CREATE:
resource.setConditionalCreate(true);
break;
case DELETE:
if (nextMethodBinding.isSupportsConditionalMultiple()) {
resource.setConditionalDelete(ConditionalDeleteStatus.MULTIPLE);
} else {
resource.setConditionalDelete(ConditionalDeleteStatus.SINGLE);
}
break;
case UPDATE:
resource.setConditionalUpdate(true);
break;
default:
break;
}
}
}
}
}
checkBindingForSystemOps(rest, systemOps, nextMethodBinding);
if (nextMethodBinding instanceof SearchMethodBinding) {
handleSearchMethodBinding(rest, resource, resourceName, def, includes, (SearchMethodBinding) nextMethodBinding);
} else if (nextMethodBinding instanceof DynamicSearchMethodBinding) {
handleDynamicSearchMethodBinding(resource, def, includes, (DynamicSearchMethodBinding) nextMethodBinding);
} else if (nextMethodBinding instanceof OperationMethodBinding) {
OperationMethodBinding methodBinding = (OperationMethodBinding) nextMethodBinding;
String opName = myOperationBindingToName.get(methodBinding);
if (operationNames.add(opName)) {
// Only add each operation (by name) once
rest.addOperation().setName(methodBinding.getName().substring(1)).setDefinition(new Reference("OperationDefinition/" + opName));
}
}
Collections.sort(resource.getInteraction(), new Comparator<ResourceInteractionComponent>() {
@Override
public int compare(ResourceInteractionComponent theO1, ResourceInteractionComponent theO2) {
TypeRestfulInteraction o1 = theO1.getCode();
TypeRestfulInteraction o2 = theO2.getCode();
if (o1 == null && o2 == null) {
return 0;
}
if (o1 == null) {
return 1;
}
if (o2 == null) {
return -1;
}
return o1.ordinal() - o2.ordinal();
}
});
}
for (String nextInclude : includes) {
resource.addSearchInclude(nextInclude);
}
} else {
for (BaseMethodBinding<?> nextMethodBinding : nextEntry.getValue()) {
checkBindingForSystemOps(rest, systemOps, nextMethodBinding);
if (nextMethodBinding instanceof OperationMethodBinding) {
OperationMethodBinding methodBinding = (OperationMethodBinding) nextMethodBinding;
String opName = myOperationBindingToName.get(methodBinding);
if (operationNames.add(opName)) {
ourLog.debug("Found bound operation: {}", opName);
rest.addOperation().setName(methodBinding.getName().substring(1)).setDefinition(new Reference("OperationDefinition/" + opName));
}
}
}
}
}
myConformance = retVal;
return retVal;
}
private void handleDynamicSearchMethodBinding(ConformanceRestResourceComponent resource, RuntimeResourceDefinition def, TreeSet<String> includes, DynamicSearchMethodBinding searchMethodBinding) {
includes.addAll(searchMethodBinding.getIncludes());
List<RuntimeSearchParam> searchParameters = new ArrayList<RuntimeSearchParam>();
searchParameters.addAll(searchMethodBinding.getSearchParams());
sortRuntimeSearchParameters(searchParameters);
if (!searchParameters.isEmpty()) {
for (RuntimeSearchParam nextParameter : searchParameters) {
String nextParamName = nextParameter.getName();
// String chain = null;
String nextParamUnchainedName = nextParamName;
if (nextParamName.contains(".")) {
// chain = nextParamName.substring(nextParamName.indexOf('.') + 1);
nextParamUnchainedName = nextParamName.substring(0, nextParamName.indexOf('.'));
}
String nextParamDescription = nextParameter.getDescription();
/*
* If the parameter has no description, default to the one from the resource
*/
if (StringUtils.isBlank(nextParamDescription)) {
RuntimeSearchParam paramDef = def.getSearchParam(nextParamUnchainedName);
if (paramDef != null) {
nextParamDescription = paramDef.getDescription();
}
}
ConformanceRestResourceSearchParamComponent param = resource.addSearchParam();
param.setName(nextParamName);
// if (StringUtils.isNotBlank(chain)) {
// param.addChain(chain);
// }
param.setDocumentation(nextParamDescription);
// param.setType(nextParameter.getParamType());
}
}
}
private void handleSearchMethodBinding(ConformanceRestComponent rest, ConformanceRestResourceComponent resource, String resourceName, RuntimeResourceDefinition def, TreeSet<String> includes,
SearchMethodBinding searchMethodBinding) {
includes.addAll(searchMethodBinding.getIncludes());
List<IParameter> params = searchMethodBinding.getParameters();
List<SearchParameter> searchParameters = new ArrayList<SearchParameter>();
for (IParameter nextParameter : params) {
if ((nextParameter instanceof SearchParameter)) {
searchParameters.add((SearchParameter) nextParameter);
}
}
sortSearchParameters(searchParameters);
if (!searchParameters.isEmpty()) {
// boolean allOptional = searchParameters.get(0).isRequired() == false;
//
// OperationDefinition query = null;
// if (!allOptional) {
// RestOperation operation = rest.addOperation();
// query = new OperationDefinition();
// operation.setDefinition(new ResourceReferenceDt(query));
// query.getDescriptionElement().setValue(searchMethodBinding.getDescription());
// query.addUndeclaredExtension(false, ExtensionConstants.QUERY_RETURN_TYPE, new CodeDt(resourceName));
// for (String nextInclude : searchMethodBinding.getIncludes()) {
// query.addUndeclaredExtension(false, ExtensionConstants.QUERY_ALLOWED_INCLUDE, new StringDt(nextInclude));
// }
// }
for (SearchParameter nextParameter : searchParameters) {
String nextParamName = nextParameter.getName();
String chain = null;
String nextParamUnchainedName = nextParamName;
if (nextParamName.contains(".")) {
chain = nextParamName.substring(nextParamName.indexOf('.') + 1);
nextParamUnchainedName = nextParamName.substring(0, nextParamName.indexOf('.'));
}
String nextParamDescription = nextParameter.getDescription();
/*
* If the parameter has no description, default to the one from the resource
*/
if (StringUtils.isBlank(nextParamDescription)) {
RuntimeSearchParam paramDef = def.getSearchParam(nextParamUnchainedName);
if (paramDef != null) {
nextParamDescription = paramDef.getDescription();
}
}
ConformanceRestResourceSearchParamComponent param = resource.addSearchParam();
param.setName(nextParamUnchainedName);
if (StringUtils.isNotBlank(chain)) {
param.addChain(chain);
}
if (nextParameter.getParamType() == RestSearchParameterTypeEnum.REFERENCE) {
for (String nextWhitelist : new TreeSet<String>(nextParameter.getQualifierWhitelist())) {
if (nextWhitelist.startsWith(".")) {
param.addChain(nextWhitelist.substring(1));
}
}
}
param.setDocumentation(nextParamDescription);
if (nextParameter.getParamType() != null) {
param.getTypeElement().setValueAsString(nextParameter.getParamType().getCode());
}
for (Class<? extends IBaseResource> nextTarget : nextParameter.getDeclaredTypes()) {
RuntimeResourceDefinition targetDef = myServerConfiguration.getFhirContext().getResourceDefinition(nextTarget);
if (targetDef != null) {
ResourceType code;
try {
code = ResourceType.fromCode(targetDef.getName());
} catch (FHIRException e) {
code = null;
}
if (code != null) {
param.addTarget(targetDef.getName());
}
}
}
}
}
}
@Initialize
public void initializeOperations() {
myOperationBindingToName = new IdentityHashMap<OperationMethodBinding, String>();
myOperationNameToBindings = new HashMap<String, List<OperationMethodBinding>>();
Map<String, List<BaseMethodBinding<?>>> resourceToMethods = collectMethodBindings();
for (Entry<String, List<BaseMethodBinding<?>>> nextEntry : resourceToMethods.entrySet()) {
List<BaseMethodBinding<?>> nextMethodBindings = nextEntry.getValue();
for (BaseMethodBinding<?> nextMethodBinding : nextMethodBindings) {
if (nextMethodBinding instanceof OperationMethodBinding) {
OperationMethodBinding methodBinding = (OperationMethodBinding) nextMethodBinding;
if (myOperationBindingToName.containsKey(methodBinding)) {
continue;
}
String name = createOperationName(methodBinding);
ourLog.debug("Detected operation: {}", name);
myOperationBindingToName.put(methodBinding, name);
if (myOperationNameToBindings.containsKey(name) == false) {
myOperationNameToBindings.put(name, new ArrayList<OperationMethodBinding>());
}
myOperationNameToBindings.get(name).add(methodBinding);
}
}
}
}
@Read(type = OperationDefinition.class)
public OperationDefinition readOperationDefinition(@IdParam IdType theId) {
if (theId == null || theId.hasIdPart() == false) {
throw new ResourceNotFoundException(theId);
}
List<OperationMethodBinding> sharedDescriptions = myOperationNameToBindings.get(theId.getIdPart());
if (sharedDescriptions == null || sharedDescriptions.isEmpty()) {
throw new ResourceNotFoundException(theId);
}
OperationDefinition op = new OperationDefinition();
op.setStatus(ConformanceResourceStatus.ACTIVE);
op.setKind(OperationKind.OPERATION);
op.setIdempotent(true);
op.setInstance(false);
op.setSystem(false);
Set<String> inParams = new HashSet<String>();
Set<String> outParams = new HashSet<String>();
for (OperationMethodBinding sharedDescription : sharedDescriptions) {
if (isNotBlank(sharedDescription.getDescription())) {
op.setDescription(sharedDescription.getDescription());
}
if (sharedDescription.isCanOperateAtInstanceLevel()) {
op.setInstance(true);
}
if (sharedDescription.isCanOperateAtServerLevel()) {
op.setSystem(true);
}
if (!sharedDescription.isIdempotent()) {
op.setIdempotent(sharedDescription.isIdempotent());
}
op.setCode(sharedDescription.getName().substring(1));
if (sharedDescription.isCanOperateAtInstanceLevel()) {
op.setInstance(sharedDescription.isCanOperateAtInstanceLevel());
}
if (sharedDescription.isCanOperateAtServerLevel()) {
op.setSystem(sharedDescription.isCanOperateAtServerLevel());
}
if (isNotBlank(sharedDescription.getResourceName())) {
op.addType(sharedDescription.getResourceName());
}
for (IParameter nextParamUntyped : sharedDescription.getParameters()) {
if (nextParamUntyped instanceof OperationParameter) {
OperationParameter nextParam = (OperationParameter) nextParamUntyped;
OperationDefinitionParameterComponent param = op.addParameter();
if (!inParams.add(nextParam.getName())) {
continue;
}
param.setUse(OperationParameterUse.IN);
if (nextParam.getParamType() != null) {
param.setType(nextParam.getParamType());
}
if (nextParam.getSearchParamType() != null) {
param.getSearchTypeElement().setValueAsString(nextParam.getSearchParamType());
}
param.setMin(nextParam.getMin());
param.setMax(nextParam.getMax() == -1 ? "*" : Integer.toString(nextParam.getMax()));
param.setName(nextParam.getName());
}
}
for (ReturnType nextParam : sharedDescription.getReturnParams()) {
if (!outParams.add(nextParam.getName())) {
continue;
}
OperationDefinitionParameterComponent param = op.addParameter();
param.setUse(OperationParameterUse.OUT);
if (nextParam.getType() != null) {
param.setType(nextParam.getType());
}
param.setMin(nextParam.getMin());
param.setMax(nextParam.getMax() == -1 ? "*" : Integer.toString(nextParam.getMax()));
param.setName(nextParam.getName());
}
}
if (isBlank(op.getName())) {
if (isNotBlank(op.getDescription())) {
op.setName(op.getDescription());
} else {
op.setName(op.getCode());
}
}
if (op.hasSystem() == false) {
op.setSystem(false);
}
if (op.hasInstance() == false) {
op.setInstance(false);
}
return op;
}
/**
* Sets the cache property (default is true). If set to true, the same response will be returned for each invocation.
* <p>
* See the class documentation for an important note if you are extending this class
* </p>
*/
public void setCache(boolean theCache) {
myCache = theCache;
}
/**
* Sets the value of the "publisher" that will be placed in the generated conformance statement. As this is a mandatory element, the value should not be null (although this is not enforced). The
* value defaults to "Not provided" but may be set to null, which will cause this element to be omitted.
*/
public void setPublisher(String thePublisher) {
myPublisher = thePublisher;
}
@Override
public void setRestfulServer(RestfulServer theRestfulServer) {
myServerConfiguration = theRestfulServer.createConfiguration();
}
RestulfulServerConfiguration getServerConfiguration() {
return myServerConfiguration;
}
private void sortRuntimeSearchParameters(List<RuntimeSearchParam> searchParameters) {
Collections.sort(searchParameters, new Comparator<RuntimeSearchParam>() {
@Override
public int compare(RuntimeSearchParam theO1, RuntimeSearchParam theO2) {
return theO1.getName().compareTo(theO2.getName());
}
});
}
private void sortSearchParameters(List<SearchParameter> searchParameters) {
Collections.sort(searchParameters, new Comparator<SearchParameter>() {
@Override
public int compare(SearchParameter theO1, SearchParameter theO2) {
if (theO1.isRequired() == theO2.isRequired()) {
return theO1.getName().compareTo(theO2.getName());
}
if (theO1.isRequired()) {
return -1;
}
return 1;
}
});
}
}

View File

@ -0,0 +1,90 @@
package org.hl7.fhir.dstu2016may.hapi.rest.server;
/*
* #%L
* HAPI FHIR Structures - DSTU2 (FHIR v1.0.0)
* %%
* Copyright (C) 2014 - 2015 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.hl7.fhir.dstu2016may.model.IdType;
import org.hl7.fhir.dstu2016may.model.StructureDefinition;
import org.hl7.fhir.instance.model.api.IBaseResource;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.Read;
import ca.uhn.fhir.rest.annotation.Search;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.RestfulServer;
public class ServerProfileProvider implements IResourceProvider {
private final FhirContext myContext;
private final RestfulServer myRestfulServer;
public ServerProfileProvider(RestfulServer theServer) {
myContext = theServer.getFhirContext();
myRestfulServer = theServer;
}
@Override
public Class<? extends IBaseResource> getResourceType() {
return StructureDefinition.class;
}
@Read()
public StructureDefinition getProfileById(HttpServletRequest theRequest, @IdParam IdType theId) {
RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart());
if (retVal==null) {
return null;
}
String serverBase = getServerBase(theRequest);
return (StructureDefinition) retVal.toProfile(serverBase);
}
@Search()
public List<StructureDefinition> getAllProfiles(HttpServletRequest theRequest) {
final String serverBase = getServerBase(theRequest);
List<RuntimeResourceDefinition> defs = new ArrayList<RuntimeResourceDefinition>(myContext.getResourceDefinitionsWithExplicitId());
Collections.sort(defs, new Comparator<RuntimeResourceDefinition>() {
@Override
public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) {
int cmp = theO1.getName().compareTo(theO2.getName());
if (cmp==0) {
cmp=theO1.getResourceProfile(serverBase).compareTo(theO2.getResourceProfile(serverBase));
}
return cmp;
}});
ArrayList<StructureDefinition> retVal = new ArrayList<StructureDefinition>();
for (RuntimeResourceDefinition next : defs) {
retVal.add((StructureDefinition) next.toProfile(serverBase));
}
return retVal;
}
private String getServerBase(HttpServletRequest theHttpRequest) {
return myRestfulServer.getServerBaseForRequest(theHttpRequest);
}
}

View File

@ -0,0 +1,88 @@
package org.hl7.fhir.dstu2016may.model;
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
/**
* A measured amount (or an amount that can potentially be measured). Note that measured amounts include amounts that are not precisely quantified, including amounts involving arbitrary units and floating currencies.
*/
@DatatypeDef(name="Age", profileOf=Quantity.class)
public class Age extends Quantity {
private static final long serialVersionUID = 1069574054L;
public Age copy() {
Age dst = new Age();
copyValues(dst);
dst.value = value == null ? null : value.copy();
dst.comparator = comparator == null ? null : comparator.copy();
dst.unit = unit == null ? null : unit.copy();
dst.system = system == null ? null : system.copy();
dst.code = code == null ? null : code.copy();
return dst;
}
protected Age typedCopy() {
return copy();
}
@Override
public boolean equalsDeep(Base other) {
if (!super.equalsDeep(other))
return false;
if (!(other instanceof Age))
return false;
Age o = (Age) other;
return compareDeep(value, o.value, true) && compareDeep(comparator, o.comparator, true) && compareDeep(unit, o.unit, true)
&& compareDeep(system, o.system, true) && compareDeep(code, o.code, true);
}
@Override
public boolean equalsShallow(Base other) {
if (!super.equalsShallow(other))
return false;
if (!(other instanceof Age))
return false;
Age o = (Age) other;
return compareValues(value, o.value, true) && compareValues(comparator, o.comparator, true) && compareValues(unit, o.unit, true)
&& compareValues(system, o.system, true) && compareValues(code, o.code, true);
}
public boolean isEmpty() {
return super.isEmpty() && (value == null || value.isEmpty()) && (comparator == null || comparator.isEmpty())
&& (unit == null || unit.isEmpty()) && (system == null || system.isEmpty()) && (code == null || code.isEmpty())
;
}
}

View File

@ -0,0 +1,349 @@
package org.hl7.fhir.dstu2016may.model;
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
import java.util.Date;
import java.util.List;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.instance.model.api.ICompositeType;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
import ca.uhn.fhir.model.api.annotation.Description;
/**
* A text note which also contains information about who made the statement and when.
*/
@DatatypeDef(name="Annotation")
public class Annotation extends Type implements ICompositeType {
/**
* The individual responsible for making the annotation.
*/
@Child(name = "author", type = {Practitioner.class, Patient.class, RelatedPerson.class, StringType.class}, order=0, min=0, max=1, modifier=false, summary=true)
@Description(shortDefinition="Individual responsible for the annotation", formalDefinition="The individual responsible for making the annotation." )
protected Type author;
/**
* Indicates when this particular annotation was made.
*/
@Child(name = "time", type = {DateTimeType.class}, order=1, min=0, max=1, modifier=false, summary=true)
@Description(shortDefinition="When the annotation was made", formalDefinition="Indicates when this particular annotation was made." )
protected DateTimeType time;
/**
* The text of the annotation.
*/
@Child(name = "text", type = {StringType.class}, order=2, min=1, max=1, modifier=false, summary=false)
@Description(shortDefinition="The annotation - text content", formalDefinition="The text of the annotation." )
protected StringType text;
private static final long serialVersionUID = -575590381L;
/**
* Constructor
*/
public Annotation() {
super();
}
/**
* Constructor
*/
public Annotation(StringType text) {
super();
this.text = text;
}
/**
* @return {@link #author} (The individual responsible for making the annotation.)
*/
public Type getAuthor() {
return this.author;
}
/**
* @return {@link #author} (The individual responsible for making the annotation.)
*/
public Reference getAuthorReference() throws FHIRException {
if (!(this.author instanceof Reference))
throw new FHIRException("Type mismatch: the type Reference was expected, but "+this.author.getClass().getName()+" was encountered");
return (Reference) this.author;
}
public boolean hasAuthorReference() {
return this.author instanceof Reference;
}
/**
* @return {@link #author} (The individual responsible for making the annotation.)
*/
public StringType getAuthorStringType() throws FHIRException {
if (!(this.author instanceof StringType))
throw new FHIRException("Type mismatch: the type StringType was expected, but "+this.author.getClass().getName()+" was encountered");
return (StringType) this.author;
}
public boolean hasAuthorStringType() {
return this.author instanceof StringType;
}
public boolean hasAuthor() {
return this.author != null && !this.author.isEmpty();
}
/**
* @param value {@link #author} (The individual responsible for making the annotation.)
*/
public Annotation setAuthor(Type value) {
this.author = value;
return this;
}
/**
* @return {@link #time} (Indicates when this particular annotation was made.). This is the underlying object with id, value and extensions. The accessor "getTime" gives direct access to the value
*/
public DateTimeType getTimeElement() {
if (this.time == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create Annotation.time");
else if (Configuration.doAutoCreate())
this.time = new DateTimeType(); // bb
return this.time;
}
public boolean hasTimeElement() {
return this.time != null && !this.time.isEmpty();
}
public boolean hasTime() {
return this.time != null && !this.time.isEmpty();
}
/**
* @param value {@link #time} (Indicates when this particular annotation was made.). This is the underlying object with id, value and extensions. The accessor "getTime" gives direct access to the value
*/
public Annotation setTimeElement(DateTimeType value) {
this.time = value;
return this;
}
/**
* @return Indicates when this particular annotation was made.
*/
public Date getTime() {
return this.time == null ? null : this.time.getValue();
}
/**
* @param value Indicates when this particular annotation was made.
*/
public Annotation setTime(Date value) {
if (value == null)
this.time = null;
else {
if (this.time == null)
this.time = new DateTimeType();
this.time.setValue(value);
}
return this;
}
/**
* @return {@link #text} (The text of the annotation.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value
*/
public StringType getTextElement() {
if (this.text == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create Annotation.text");
else if (Configuration.doAutoCreate())
this.text = new StringType(); // bb
return this.text;
}
public boolean hasTextElement() {
return this.text != null && !this.text.isEmpty();
}
public boolean hasText() {
return this.text != null && !this.text.isEmpty();
}
/**
* @param value {@link #text} (The text of the annotation.). This is the underlying object with id, value and extensions. The accessor "getText" gives direct access to the value
*/
public Annotation setTextElement(StringType value) {
this.text = value;
return this;
}
/**
* @return The text of the annotation.
*/
public String getText() {
return this.text == null ? null : this.text.getValue();
}
/**
* @param value The text of the annotation.
*/
public Annotation setText(String value) {
if (this.text == null)
this.text = new StringType();
this.text.setValue(value);
return this;
}
protected void listChildren(List<Property> childrenList) {
super.listChildren(childrenList);
childrenList.add(new Property("author[x]", "Reference(Practitioner|Patient|RelatedPerson)|string", "The individual responsible for making the annotation.", 0, java.lang.Integer.MAX_VALUE, author));
childrenList.add(new Property("time", "dateTime", "Indicates when this particular annotation was made.", 0, java.lang.Integer.MAX_VALUE, time));
childrenList.add(new Property("text", "string", "The text of the annotation.", 0, java.lang.Integer.MAX_VALUE, text));
}
@Override
public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
switch (hash) {
case -1406328437: /*author*/ return this.author == null ? new Base[0] : new Base[] {this.author}; // Type
case 3560141: /*time*/ return this.time == null ? new Base[0] : new Base[] {this.time}; // DateTimeType
case 3556653: /*text*/ return this.text == null ? new Base[0] : new Base[] {this.text}; // StringType
default: return super.getProperty(hash, name, checkValid);
}
}
@Override
public void setProperty(int hash, String name, Base value) throws FHIRException {
switch (hash) {
case -1406328437: // author
this.author = (Type) value; // Type
break;
case 3560141: // time
this.time = castToDateTime(value); // DateTimeType
break;
case 3556653: // text
this.text = castToString(value); // StringType
break;
default: super.setProperty(hash, name, value);
}
}
@Override
public void setProperty(String name, Base value) throws FHIRException {
if (name.equals("author[x]"))
this.author = (Type) value; // Type
else if (name.equals("time"))
this.time = castToDateTime(value); // DateTimeType
else if (name.equals("text"))
this.text = castToString(value); // StringType
else
super.setProperty(name, value);
}
@Override
public Base makeProperty(int hash, String name) throws FHIRException {
switch (hash) {
case 1475597077: return getAuthor(); // Type
case 3560141: throw new FHIRException("Cannot make property time as it is not a complex type"); // DateTimeType
case 3556653: throw new FHIRException("Cannot make property text as it is not a complex type"); // StringType
default: return super.makeProperty(hash, name);
}
}
@Override
public Base addChild(String name) throws FHIRException {
if (name.equals("authorReference")) {
this.author = new Reference();
return this.author;
}
else if (name.equals("authorString")) {
this.author = new StringType();
return this.author;
}
else if (name.equals("time")) {
throw new FHIRException("Cannot call addChild on a primitive type Annotation.time");
}
else if (name.equals("text")) {
throw new FHIRException("Cannot call addChild on a primitive type Annotation.text");
}
else
return super.addChild(name);
}
public String fhirType() {
return "Annotation";
}
public Annotation copy() {
Annotation dst = new Annotation();
copyValues(dst);
dst.author = author == null ? null : author.copy();
dst.time = time == null ? null : time.copy();
dst.text = text == null ? null : text.copy();
return dst;
}
protected Annotation typedCopy() {
return copy();
}
@Override
public boolean equalsDeep(Base other) {
if (!super.equalsDeep(other))
return false;
if (!(other instanceof Annotation))
return false;
Annotation o = (Annotation) other;
return compareDeep(author, o.author, true) && compareDeep(time, o.time, true) && compareDeep(text, o.text, true)
;
}
@Override
public boolean equalsShallow(Base other) {
if (!super.equalsShallow(other))
return false;
if (!(other instanceof Annotation))
return false;
Annotation o = (Annotation) other;
return compareValues(time, o.time, true) && compareValues(text, o.text, true);
}
public boolean isEmpty() {
return super.isEmpty() && (author == null || author.isEmpty()) && (time == null || time.isEmpty())
&& (text == null || text.isEmpty());
}
}

View File

@ -0,0 +1,858 @@
package org.hl7.fhir.dstu2016may.model;
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.utilities.Utilities;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
/**
* A reply to an appointment request for a patient and/or practitioner(s), such as a confirmation or rejection.
*/
@ResourceDef(name="AppointmentResponse", profile="http://hl7.org/fhir/Profile/AppointmentResponse")
public class AppointmentResponse extends DomainResource {
/**
* This records identifiers associated with this appointment response concern that are defined by business processes and/ or used to refer to it when a direct URL reference to the resource itself is not appropriate.
*/
@Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
@Description(shortDefinition="External Ids for this item", formalDefinition="This records identifiers associated with this appointment response concern that are defined by business processes and/ or used to refer to it when a direct URL reference to the resource itself is not appropriate." )
protected List<Identifier> identifier;
/**
* Appointment that this response is replying to.
*/
@Child(name = "appointment", type = {Appointment.class}, order=1, min=1, max=1, modifier=false, summary=true)
@Description(shortDefinition="Appointment this response relates to", formalDefinition="Appointment that this response is replying to." )
protected Reference appointment;
/**
* The actual object that is the target of the reference (Appointment that this response is replying to.)
*/
protected Appointment appointmentTarget;
/**
* Date/Time that the appointment is to take place, or requested new start time.
*/
@Child(name = "start", type = {InstantType.class}, order=2, min=0, max=1, modifier=false, summary=false)
@Description(shortDefinition="Time from appointment, or requested new start time", formalDefinition="Date/Time that the appointment is to take place, or requested new start time." )
protected InstantType start;
/**
* This may be either the same as the appointment request to confirm the details of the appointment, or alternately a new time to request a re-negotiation of the end time.
*/
@Child(name = "end", type = {InstantType.class}, order=3, min=0, max=1, modifier=false, summary=false)
@Description(shortDefinition="Time from appointment, or requested new end time", formalDefinition="This may be either the same as the appointment request to confirm the details of the appointment, or alternately a new time to request a re-negotiation of the end time." )
protected InstantType end;
/**
* Role of participant in the appointment.
*/
@Child(name = "participantType", type = {CodeableConcept.class}, order=4, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
@Description(shortDefinition="Role of participant in the appointment", formalDefinition="Role of participant in the appointment." )
protected List<CodeableConcept> participantType;
/**
* A Person, Location/HealthcareService or Device that is participating in the appointment.
*/
@Child(name = "actor", type = {Patient.class, Practitioner.class, RelatedPerson.class, Device.class, HealthcareService.class, Location.class}, order=5, min=0, max=1, modifier=false, summary=true)
@Description(shortDefinition="Person, Location/HealthcareService or Device", formalDefinition="A Person, Location/HealthcareService or Device that is participating in the appointment." )
protected Reference actor;
/**
* The actual object that is the target of the reference (A Person, Location/HealthcareService or Device that is participating in the appointment.)
*/
protected Resource actorTarget;
/**
* Participation status of the participant. When the status is declined or tentative if the start/end times are different to the appointment, then these times should be interpreted as a requested time change. When the status is accepted, the times can either be the time of the appointment (as a confirmation of the time) or can be empty.
*/
@Child(name = "participantStatus", type = {CodeType.class}, order=6, min=1, max=1, modifier=true, summary=true)
@Description(shortDefinition="accepted | declined | tentative | in-process | completed | needs-action", formalDefinition="Participation status of the participant. When the status is declined or tentative if the start/end times are different to the appointment, then these times should be interpreted as a requested time change. When the status is accepted, the times can either be the time of the appointment (as a confirmation of the time) or can be empty." )
protected CodeType participantStatus;
/**
* Additional comments about the appointment.
*/
@Child(name = "comment", type = {StringType.class}, order=7, min=0, max=1, modifier=false, summary=false)
@Description(shortDefinition="Additional comments", formalDefinition="Additional comments about the appointment." )
protected StringType comment;
private static final long serialVersionUID = -1645343660L;
/**
* Constructor
*/
public AppointmentResponse() {
super();
}
/**
* Constructor
*/
public AppointmentResponse(Reference appointment, CodeType participantStatus) {
super();
this.appointment = appointment;
this.participantStatus = participantStatus;
}
/**
* @return {@link #identifier} (This records identifiers associated with this appointment response concern that are defined by business processes and/ or used to refer to it when a direct URL reference to the resource itself is not appropriate.)
*/
public List<Identifier> getIdentifier() {
if (this.identifier == null)
this.identifier = new ArrayList<Identifier>();
return this.identifier;
}
public boolean hasIdentifier() {
if (this.identifier == null)
return false;
for (Identifier item : this.identifier)
if (!item.isEmpty())
return true;
return false;
}
/**
* @return {@link #identifier} (This records identifiers associated with this appointment response concern that are defined by business processes and/ or used to refer to it when a direct URL reference to the resource itself is not appropriate.)
*/
// syntactic sugar
public Identifier addIdentifier() { //3
Identifier t = new Identifier();
if (this.identifier == null)
this.identifier = new ArrayList<Identifier>();
this.identifier.add(t);
return t;
}
// syntactic sugar
public AppointmentResponse addIdentifier(Identifier t) { //3
if (t == null)
return this;
if (this.identifier == null)
this.identifier = new ArrayList<Identifier>();
this.identifier.add(t);
return this;
}
/**
* @return {@link #appointment} (Appointment that this response is replying to.)
*/
public Reference getAppointment() {
if (this.appointment == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create AppointmentResponse.appointment");
else if (Configuration.doAutoCreate())
this.appointment = new Reference(); // cc
return this.appointment;
}
public boolean hasAppointment() {
return this.appointment != null && !this.appointment.isEmpty();
}
/**
* @param value {@link #appointment} (Appointment that this response is replying to.)
*/
public AppointmentResponse setAppointment(Reference value) {
this.appointment = value;
return this;
}
/**
* @return {@link #appointment} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Appointment that this response is replying to.)
*/
public Appointment getAppointmentTarget() {
if (this.appointmentTarget == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create AppointmentResponse.appointment");
else if (Configuration.doAutoCreate())
this.appointmentTarget = new Appointment(); // aa
return this.appointmentTarget;
}
/**
* @param value {@link #appointment} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Appointment that this response is replying to.)
*/
public AppointmentResponse setAppointmentTarget(Appointment value) {
this.appointmentTarget = value;
return this;
}
/**
* @return {@link #start} (Date/Time that the appointment is to take place, or requested new start time.). This is the underlying object with id, value and extensions. The accessor "getStart" gives direct access to the value
*/
public InstantType getStartElement() {
if (this.start == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create AppointmentResponse.start");
else if (Configuration.doAutoCreate())
this.start = new InstantType(); // bb
return this.start;
}
public boolean hasStartElement() {
return this.start != null && !this.start.isEmpty();
}
public boolean hasStart() {
return this.start != null && !this.start.isEmpty();
}
/**
* @param value {@link #start} (Date/Time that the appointment is to take place, or requested new start time.). This is the underlying object with id, value and extensions. The accessor "getStart" gives direct access to the value
*/
public AppointmentResponse setStartElement(InstantType value) {
this.start = value;
return this;
}
/**
* @return Date/Time that the appointment is to take place, or requested new start time.
*/
public Date getStart() {
return this.start == null ? null : this.start.getValue();
}
/**
* @param value Date/Time that the appointment is to take place, or requested new start time.
*/
public AppointmentResponse setStart(Date value) {
if (value == null)
this.start = null;
else {
if (this.start == null)
this.start = new InstantType();
this.start.setValue(value);
}
return this;
}
/**
* @return {@link #end} (This may be either the same as the appointment request to confirm the details of the appointment, or alternately a new time to request a re-negotiation of the end time.). This is the underlying object with id, value and extensions. The accessor "getEnd" gives direct access to the value
*/
public InstantType getEndElement() {
if (this.end == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create AppointmentResponse.end");
else if (Configuration.doAutoCreate())
this.end = new InstantType(); // bb
return this.end;
}
public boolean hasEndElement() {
return this.end != null && !this.end.isEmpty();
}
public boolean hasEnd() {
return this.end != null && !this.end.isEmpty();
}
/**
* @param value {@link #end} (This may be either the same as the appointment request to confirm the details of the appointment, or alternately a new time to request a re-negotiation of the end time.). This is the underlying object with id, value and extensions. The accessor "getEnd" gives direct access to the value
*/
public AppointmentResponse setEndElement(InstantType value) {
this.end = value;
return this;
}
/**
* @return This may be either the same as the appointment request to confirm the details of the appointment, or alternately a new time to request a re-negotiation of the end time.
*/
public Date getEnd() {
return this.end == null ? null : this.end.getValue();
}
/**
* @param value This may be either the same as the appointment request to confirm the details of the appointment, or alternately a new time to request a re-negotiation of the end time.
*/
public AppointmentResponse setEnd(Date value) {
if (value == null)
this.end = null;
else {
if (this.end == null)
this.end = new InstantType();
this.end.setValue(value);
}
return this;
}
/**
* @return {@link #participantType} (Role of participant in the appointment.)
*/
public List<CodeableConcept> getParticipantType() {
if (this.participantType == null)
this.participantType = new ArrayList<CodeableConcept>();
return this.participantType;
}
public boolean hasParticipantType() {
if (this.participantType == null)
return false;
for (CodeableConcept item : this.participantType)
if (!item.isEmpty())
return true;
return false;
}
/**
* @return {@link #participantType} (Role of participant in the appointment.)
*/
// syntactic sugar
public CodeableConcept addParticipantType() { //3
CodeableConcept t = new CodeableConcept();
if (this.participantType == null)
this.participantType = new ArrayList<CodeableConcept>();
this.participantType.add(t);
return t;
}
// syntactic sugar
public AppointmentResponse addParticipantType(CodeableConcept t) { //3
if (t == null)
return this;
if (this.participantType == null)
this.participantType = new ArrayList<CodeableConcept>();
this.participantType.add(t);
return this;
}
/**
* @return {@link #actor} (A Person, Location/HealthcareService or Device that is participating in the appointment.)
*/
public Reference getActor() {
if (this.actor == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create AppointmentResponse.actor");
else if (Configuration.doAutoCreate())
this.actor = new Reference(); // cc
return this.actor;
}
public boolean hasActor() {
return this.actor != null && !this.actor.isEmpty();
}
/**
* @param value {@link #actor} (A Person, Location/HealthcareService or Device that is participating in the appointment.)
*/
public AppointmentResponse setActor(Reference value) {
this.actor = value;
return this;
}
/**
* @return {@link #actor} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (A Person, Location/HealthcareService or Device that is participating in the appointment.)
*/
public Resource getActorTarget() {
return this.actorTarget;
}
/**
* @param value {@link #actor} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (A Person, Location/HealthcareService or Device that is participating in the appointment.)
*/
public AppointmentResponse setActorTarget(Resource value) {
this.actorTarget = value;
return this;
}
/**
* @return {@link #participantStatus} (Participation status of the participant. When the status is declined or tentative if the start/end times are different to the appointment, then these times should be interpreted as a requested time change. When the status is accepted, the times can either be the time of the appointment (as a confirmation of the time) or can be empty.). This is the underlying object with id, value and extensions. The accessor "getParticipantStatus" gives direct access to the value
*/
public CodeType getParticipantStatusElement() {
if (this.participantStatus == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create AppointmentResponse.participantStatus");
else if (Configuration.doAutoCreate())
this.participantStatus = new CodeType(); // bb
return this.participantStatus;
}
public boolean hasParticipantStatusElement() {
return this.participantStatus != null && !this.participantStatus.isEmpty();
}
public boolean hasParticipantStatus() {
return this.participantStatus != null && !this.participantStatus.isEmpty();
}
/**
* @param value {@link #participantStatus} (Participation status of the participant. When the status is declined or tentative if the start/end times are different to the appointment, then these times should be interpreted as a requested time change. When the status is accepted, the times can either be the time of the appointment (as a confirmation of the time) or can be empty.). This is the underlying object with id, value and extensions. The accessor "getParticipantStatus" gives direct access to the value
*/
public AppointmentResponse setParticipantStatusElement(CodeType value) {
this.participantStatus = value;
return this;
}
/**
* @return Participation status of the participant. When the status is declined or tentative if the start/end times are different to the appointment, then these times should be interpreted as a requested time change. When the status is accepted, the times can either be the time of the appointment (as a confirmation of the time) or can be empty.
*/
public String getParticipantStatus() {
return this.participantStatus == null ? null : this.participantStatus.getValue();
}
/**
* @param value Participation status of the participant. When the status is declined or tentative if the start/end times are different to the appointment, then these times should be interpreted as a requested time change. When the status is accepted, the times can either be the time of the appointment (as a confirmation of the time) or can be empty.
*/
public AppointmentResponse setParticipantStatus(String value) {
if (this.participantStatus == null)
this.participantStatus = new CodeType();
this.participantStatus.setValue(value);
return this;
}
/**
* @return {@link #comment} (Additional comments about the appointment.). This is the underlying object with id, value and extensions. The accessor "getComment" gives direct access to the value
*/
public StringType getCommentElement() {
if (this.comment == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create AppointmentResponse.comment");
else if (Configuration.doAutoCreate())
this.comment = new StringType(); // bb
return this.comment;
}
public boolean hasCommentElement() {
return this.comment != null && !this.comment.isEmpty();
}
public boolean hasComment() {
return this.comment != null && !this.comment.isEmpty();
}
/**
* @param value {@link #comment} (Additional comments about the appointment.). This is the underlying object with id, value and extensions. The accessor "getComment" gives direct access to the value
*/
public AppointmentResponse setCommentElement(StringType value) {
this.comment = value;
return this;
}
/**
* @return Additional comments about the appointment.
*/
public String getComment() {
return this.comment == null ? null : this.comment.getValue();
}
/**
* @param value Additional comments about the appointment.
*/
public AppointmentResponse setComment(String value) {
if (Utilities.noString(value))
this.comment = null;
else {
if (this.comment == null)
this.comment = new StringType();
this.comment.setValue(value);
}
return this;
}
protected void listChildren(List<Property> childrenList) {
super.listChildren(childrenList);
childrenList.add(new Property("identifier", "Identifier", "This records identifiers associated with this appointment response concern that are defined by business processes and/ or used to refer to it when a direct URL reference to the resource itself is not appropriate.", 0, java.lang.Integer.MAX_VALUE, identifier));
childrenList.add(new Property("appointment", "Reference(Appointment)", "Appointment that this response is replying to.", 0, java.lang.Integer.MAX_VALUE, appointment));
childrenList.add(new Property("start", "instant", "Date/Time that the appointment is to take place, or requested new start time.", 0, java.lang.Integer.MAX_VALUE, start));
childrenList.add(new Property("end", "instant", "This may be either the same as the appointment request to confirm the details of the appointment, or alternately a new time to request a re-negotiation of the end time.", 0, java.lang.Integer.MAX_VALUE, end));
childrenList.add(new Property("participantType", "CodeableConcept", "Role of participant in the appointment.", 0, java.lang.Integer.MAX_VALUE, participantType));
childrenList.add(new Property("actor", "Reference(Patient|Practitioner|RelatedPerson|Device|HealthcareService|Location)", "A Person, Location/HealthcareService or Device that is participating in the appointment.", 0, java.lang.Integer.MAX_VALUE, actor));
childrenList.add(new Property("participantStatus", "code", "Participation status of the participant. When the status is declined or tentative if the start/end times are different to the appointment, then these times should be interpreted as a requested time change. When the status is accepted, the times can either be the time of the appointment (as a confirmation of the time) or can be empty.", 0, java.lang.Integer.MAX_VALUE, participantStatus));
childrenList.add(new Property("comment", "string", "Additional comments about the appointment.", 0, java.lang.Integer.MAX_VALUE, comment));
}
@Override
public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
switch (hash) {
case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
case -1474995297: /*appointment*/ return this.appointment == null ? new Base[0] : new Base[] {this.appointment}; // Reference
case 109757538: /*start*/ return this.start == null ? new Base[0] : new Base[] {this.start}; // InstantType
case 100571: /*end*/ return this.end == null ? new Base[0] : new Base[] {this.end}; // InstantType
case 841294093: /*participantType*/ return this.participantType == null ? new Base[0] : this.participantType.toArray(new Base[this.participantType.size()]); // CodeableConcept
case 92645877: /*actor*/ return this.actor == null ? new Base[0] : new Base[] {this.actor}; // Reference
case 996096261: /*participantStatus*/ return this.participantStatus == null ? new Base[0] : new Base[] {this.participantStatus}; // CodeType
case 950398559: /*comment*/ return this.comment == null ? new Base[0] : new Base[] {this.comment}; // StringType
default: return super.getProperty(hash, name, checkValid);
}
}
@Override
public void setProperty(int hash, String name, Base value) throws FHIRException {
switch (hash) {
case -1618432855: // identifier
this.getIdentifier().add(castToIdentifier(value)); // Identifier
break;
case -1474995297: // appointment
this.appointment = castToReference(value); // Reference
break;
case 109757538: // start
this.start = castToInstant(value); // InstantType
break;
case 100571: // end
this.end = castToInstant(value); // InstantType
break;
case 841294093: // participantType
this.getParticipantType().add(castToCodeableConcept(value)); // CodeableConcept
break;
case 92645877: // actor
this.actor = castToReference(value); // Reference
break;
case 996096261: // participantStatus
this.participantStatus = castToCode(value); // CodeType
break;
case 950398559: // comment
this.comment = castToString(value); // StringType
break;
default: super.setProperty(hash, name, value);
}
}
@Override
public void setProperty(String name, Base value) throws FHIRException {
if (name.equals("identifier"))
this.getIdentifier().add(castToIdentifier(value));
else if (name.equals("appointment"))
this.appointment = castToReference(value); // Reference
else if (name.equals("start"))
this.start = castToInstant(value); // InstantType
else if (name.equals("end"))
this.end = castToInstant(value); // InstantType
else if (name.equals("participantType"))
this.getParticipantType().add(castToCodeableConcept(value));
else if (name.equals("actor"))
this.actor = castToReference(value); // Reference
else if (name.equals("participantStatus"))
this.participantStatus = castToCode(value); // CodeType
else if (name.equals("comment"))
this.comment = castToString(value); // StringType
else
super.setProperty(name, value);
}
@Override
public Base makeProperty(int hash, String name) throws FHIRException {
switch (hash) {
case -1618432855: return addIdentifier(); // Identifier
case -1474995297: return getAppointment(); // Reference
case 109757538: throw new FHIRException("Cannot make property start as it is not a complex type"); // InstantType
case 100571: throw new FHIRException("Cannot make property end as it is not a complex type"); // InstantType
case 841294093: return addParticipantType(); // CodeableConcept
case 92645877: return getActor(); // Reference
case 996096261: throw new FHIRException("Cannot make property participantStatus as it is not a complex type"); // CodeType
case 950398559: throw new FHIRException("Cannot make property comment as it is not a complex type"); // StringType
default: return super.makeProperty(hash, name);
}
}
@Override
public Base addChild(String name) throws FHIRException {
if (name.equals("identifier")) {
return addIdentifier();
}
else if (name.equals("appointment")) {
this.appointment = new Reference();
return this.appointment;
}
else if (name.equals("start")) {
throw new FHIRException("Cannot call addChild on a primitive type AppointmentResponse.start");
}
else if (name.equals("end")) {
throw new FHIRException("Cannot call addChild on a primitive type AppointmentResponse.end");
}
else if (name.equals("participantType")) {
return addParticipantType();
}
else if (name.equals("actor")) {
this.actor = new Reference();
return this.actor;
}
else if (name.equals("participantStatus")) {
throw new FHIRException("Cannot call addChild on a primitive type AppointmentResponse.participantStatus");
}
else if (name.equals("comment")) {
throw new FHIRException("Cannot call addChild on a primitive type AppointmentResponse.comment");
}
else
return super.addChild(name);
}
public String fhirType() {
return "AppointmentResponse";
}
public AppointmentResponse copy() {
AppointmentResponse dst = new AppointmentResponse();
copyValues(dst);
if (identifier != null) {
dst.identifier = new ArrayList<Identifier>();
for (Identifier i : identifier)
dst.identifier.add(i.copy());
};
dst.appointment = appointment == null ? null : appointment.copy();
dst.start = start == null ? null : start.copy();
dst.end = end == null ? null : end.copy();
if (participantType != null) {
dst.participantType = new ArrayList<CodeableConcept>();
for (CodeableConcept i : participantType)
dst.participantType.add(i.copy());
};
dst.actor = actor == null ? null : actor.copy();
dst.participantStatus = participantStatus == null ? null : participantStatus.copy();
dst.comment = comment == null ? null : comment.copy();
return dst;
}
protected AppointmentResponse typedCopy() {
return copy();
}
@Override
public boolean equalsDeep(Base other) {
if (!super.equalsDeep(other))
return false;
if (!(other instanceof AppointmentResponse))
return false;
AppointmentResponse o = (AppointmentResponse) other;
return compareDeep(identifier, o.identifier, true) && compareDeep(appointment, o.appointment, true)
&& compareDeep(start, o.start, true) && compareDeep(end, o.end, true) && compareDeep(participantType, o.participantType, true)
&& compareDeep(actor, o.actor, true) && compareDeep(participantStatus, o.participantStatus, true)
&& compareDeep(comment, o.comment, true);
}
@Override
public boolean equalsShallow(Base other) {
if (!super.equalsShallow(other))
return false;
if (!(other instanceof AppointmentResponse))
return false;
AppointmentResponse o = (AppointmentResponse) other;
return compareValues(start, o.start, true) && compareValues(end, o.end, true) && compareValues(participantStatus, o.participantStatus, true)
&& compareValues(comment, o.comment, true);
}
public boolean isEmpty() {
return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (appointment == null || appointment.isEmpty())
&& (start == null || start.isEmpty()) && (end == null || end.isEmpty()) && (participantType == null || participantType.isEmpty())
&& (actor == null || actor.isEmpty()) && (participantStatus == null || participantStatus.isEmpty())
&& (comment == null || comment.isEmpty());
}
@Override
public ResourceType getResourceType() {
return ResourceType.AppointmentResponse;
}
/**
* Search parameter: <b>patient</b>
* <p>
* Description: <b>This Response is for this Patient</b><br>
* Type: <b>reference</b><br>
* Path: <b>AppointmentResponse.actor</b><br>
* </p>
*/
@SearchParamDefinition(name="patient", path="AppointmentResponse.actor", description="This Response is for this Patient", type="reference" )
public static final String SP_PATIENT = "patient";
/**
* <b>Fluent Client</b> search parameter constant for <b>patient</b>
* <p>
* Description: <b>This Response is for this Patient</b><br>
* Type: <b>reference</b><br>
* Path: <b>AppointmentResponse.actor</b><br>
* </p>
*/
public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
/**
* Constant for fluent queries to be used to add include statements. Specifies
* the path value of "<b>AppointmentResponse:patient</b>".
*/
public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("AppointmentResponse:patient").toLocked();
/**
* Search parameter: <b>practitioner</b>
* <p>
* Description: <b>This Response is for this Practitioner</b><br>
* Type: <b>reference</b><br>
* Path: <b>AppointmentResponse.actor</b><br>
* </p>
*/
@SearchParamDefinition(name="practitioner", path="AppointmentResponse.actor", description="This Response is for this Practitioner", type="reference" )
public static final String SP_PRACTITIONER = "practitioner";
/**
* <b>Fluent Client</b> search parameter constant for <b>practitioner</b>
* <p>
* Description: <b>This Response is for this Practitioner</b><br>
* Type: <b>reference</b><br>
* Path: <b>AppointmentResponse.actor</b><br>
* </p>
*/
public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PRACTITIONER = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PRACTITIONER);
/**
* Constant for fluent queries to be used to add include statements. Specifies
* the path value of "<b>AppointmentResponse:practitioner</b>".
*/
public static final ca.uhn.fhir.model.api.Include INCLUDE_PRACTITIONER = new ca.uhn.fhir.model.api.Include("AppointmentResponse:practitioner").toLocked();
/**
* Search parameter: <b>location</b>
* <p>
* Description: <b>This Response is for this Location</b><br>
* Type: <b>reference</b><br>
* Path: <b>AppointmentResponse.actor</b><br>
* </p>
*/
@SearchParamDefinition(name="location", path="AppointmentResponse.actor", description="This Response is for this Location", type="reference" )
public static final String SP_LOCATION = "location";
/**
* <b>Fluent Client</b> search parameter constant for <b>location</b>
* <p>
* Description: <b>This Response is for this Location</b><br>
* Type: <b>reference</b><br>
* Path: <b>AppointmentResponse.actor</b><br>
* </p>
*/
public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam LOCATION = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_LOCATION);
/**
* Constant for fluent queries to be used to add include statements. Specifies
* the path value of "<b>AppointmentResponse:location</b>".
*/
public static final ca.uhn.fhir.model.api.Include INCLUDE_LOCATION = new ca.uhn.fhir.model.api.Include("AppointmentResponse:location").toLocked();
/**
* Search parameter: <b>part-status</b>
* <p>
* Description: <b>The participants acceptance status for this appointment</b><br>
* Type: <b>token</b><br>
* Path: <b>AppointmentResponse.participantStatus</b><br>
* </p>
*/
@SearchParamDefinition(name="part-status", path="AppointmentResponse.participantStatus", description="The participants acceptance status for this appointment", type="token" )
public static final String SP_PART_STATUS = "part-status";
/**
* <b>Fluent Client</b> search parameter constant for <b>part-status</b>
* <p>
* Description: <b>The participants acceptance status for this appointment</b><br>
* Type: <b>token</b><br>
* Path: <b>AppointmentResponse.participantStatus</b><br>
* </p>
*/
public static final ca.uhn.fhir.rest.gclient.TokenClientParam PART_STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_PART_STATUS);
/**
* Search parameter: <b>actor</b>
* <p>
* Description: <b>The Person, Location/HealthcareService or Device that this appointment response replies for</b><br>
* Type: <b>reference</b><br>
* Path: <b>AppointmentResponse.actor</b><br>
* </p>
*/
@SearchParamDefinition(name="actor", path="AppointmentResponse.actor", description="The Person, Location/HealthcareService or Device that this appointment response replies for", type="reference" )
public static final String SP_ACTOR = "actor";
/**
* <b>Fluent Client</b> search parameter constant for <b>actor</b>
* <p>
* Description: <b>The Person, Location/HealthcareService or Device that this appointment response replies for</b><br>
* Type: <b>reference</b><br>
* Path: <b>AppointmentResponse.actor</b><br>
* </p>
*/
public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam ACTOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_ACTOR);
/**
* Constant for fluent queries to be used to add include statements. Specifies
* the path value of "<b>AppointmentResponse:actor</b>".
*/
public static final ca.uhn.fhir.model.api.Include INCLUDE_ACTOR = new ca.uhn.fhir.model.api.Include("AppointmentResponse:actor").toLocked();
/**
* Search parameter: <b>identifier</b>
* <p>
* Description: <b>An Identifier in this appointment response</b><br>
* Type: <b>token</b><br>
* Path: <b>AppointmentResponse.identifier</b><br>
* </p>
*/
@SearchParamDefinition(name="identifier", path="AppointmentResponse.identifier", description="An Identifier in this appointment response", type="token" )
public static final String SP_IDENTIFIER = "identifier";
/**
* <b>Fluent Client</b> search parameter constant for <b>identifier</b>
* <p>
* Description: <b>An Identifier in this appointment response</b><br>
* Type: <b>token</b><br>
* Path: <b>AppointmentResponse.identifier</b><br>
* </p>
*/
public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
/**
* Search parameter: <b>appointment</b>
* <p>
* Description: <b>The appointment that the response is attached to</b><br>
* Type: <b>reference</b><br>
* Path: <b>AppointmentResponse.appointment</b><br>
* </p>
*/
@SearchParamDefinition(name="appointment", path="AppointmentResponse.appointment", description="The appointment that the response is attached to", type="reference" )
public static final String SP_APPOINTMENT = "appointment";
/**
* <b>Fluent Client</b> search parameter constant for <b>appointment</b>
* <p>
* Description: <b>The appointment that the response is attached to</b><br>
* Type: <b>reference</b><br>
* Path: <b>AppointmentResponse.appointment</b><br>
* </p>
*/
public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam APPOINTMENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_APPOINTMENT);
/**
* Constant for fluent queries to be used to add include statements. Specifies
* the path value of "<b>AppointmentResponse:appointment</b>".
*/
public static final ca.uhn.fhir.model.api.Include INCLUDE_APPOINTMENT = new ca.uhn.fhir.model.api.Include("AppointmentResponse:appointment").toLocked();
}

View File

@ -0,0 +1,688 @@
package org.hl7.fhir.dstu2016may.model;
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
import java.util.Date;
import java.util.List;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.instance.model.api.ICompositeType;
import org.hl7.fhir.utilities.Utilities;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
import ca.uhn.fhir.model.api.annotation.Description;
/**
* For referring to data content defined in other formats.
*/
@DatatypeDef(name="Attachment")
public class Attachment extends Type implements ICompositeType {
/**
* Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.
*/
@Child(name = "contentType", type = {CodeType.class}, order=0, min=0, max=1, modifier=false, summary=true)
@Description(shortDefinition="Mime type of the content, with charset etc.", formalDefinition="Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate." )
protected CodeType contentType;
/**
* The human language of the content. The value can be any valid value according to BCP 47.
*/
@Child(name = "language", type = {CodeType.class}, order=1, min=0, max=1, modifier=false, summary=true)
@Description(shortDefinition="Human language of the content (BCP-47)", formalDefinition="The human language of the content. The value can be any valid value according to BCP 47." )
protected CodeType language;
/**
* The actual data of the attachment - a sequence of bytes. In XML, represented using base64.
*/
@Child(name = "data", type = {Base64BinaryType.class}, order=2, min=0, max=1, modifier=false, summary=false)
@Description(shortDefinition="Data inline, base64ed", formalDefinition="The actual data of the attachment - a sequence of bytes. In XML, represented using base64." )
protected Base64BinaryType data;
/**
* An alternative location where the data can be accessed.
*/
@Child(name = "url", type = {UriType.class}, order=3, min=0, max=1, modifier=false, summary=true)
@Description(shortDefinition="Uri where the data can be found", formalDefinition="An alternative location where the data can be accessed." )
protected UriType url;
/**
* The number of bytes of data that make up this attachment.
*/
@Child(name = "size", type = {UnsignedIntType.class}, order=4, min=0, max=1, modifier=false, summary=true)
@Description(shortDefinition="Number of bytes of content (if url provided)", formalDefinition="The number of bytes of data that make up this attachment." )
protected UnsignedIntType size;
/**
* The calculated hash of the data using SHA-1. Represented using base64.
*/
@Child(name = "hash", type = {Base64BinaryType.class}, order=5, min=0, max=1, modifier=false, summary=true)
@Description(shortDefinition="Hash of the data (sha-1, base64ed)", formalDefinition="The calculated hash of the data using SHA-1. Represented using base64." )
protected Base64BinaryType hash;
/**
* A label or set of text to display in place of the data.
*/
@Child(name = "title", type = {StringType.class}, order=6, min=0, max=1, modifier=false, summary=true)
@Description(shortDefinition="Label to display in place of the data", formalDefinition="A label or set of text to display in place of the data." )
protected StringType title;
/**
* The date that the attachment was first created.
*/
@Child(name = "creation", type = {DateTimeType.class}, order=7, min=0, max=1, modifier=false, summary=true)
@Description(shortDefinition="Date attachment was first created", formalDefinition="The date that the attachment was first created." )
protected DateTimeType creation;
private static final long serialVersionUID = 581007080L;
/**
* Constructor
*/
public Attachment() {
super();
}
/**
* @return {@link #contentType} (Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.). This is the underlying object with id, value and extensions. The accessor "getContentType" gives direct access to the value
*/
public CodeType getContentTypeElement() {
if (this.contentType == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create Attachment.contentType");
else if (Configuration.doAutoCreate())
this.contentType = new CodeType(); // bb
return this.contentType;
}
public boolean hasContentTypeElement() {
return this.contentType != null && !this.contentType.isEmpty();
}
public boolean hasContentType() {
return this.contentType != null && !this.contentType.isEmpty();
}
/**
* @param value {@link #contentType} (Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.). This is the underlying object with id, value and extensions. The accessor "getContentType" gives direct access to the value
*/
public Attachment setContentTypeElement(CodeType value) {
this.contentType = value;
return this;
}
/**
* @return Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.
*/
public String getContentType() {
return this.contentType == null ? null : this.contentType.getValue();
}
/**
* @param value Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.
*/
public Attachment setContentType(String value) {
if (Utilities.noString(value))
this.contentType = null;
else {
if (this.contentType == null)
this.contentType = new CodeType();
this.contentType.setValue(value);
}
return this;
}
/**
* @return {@link #language} (The human language of the content. The value can be any valid value according to BCP 47.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value
*/
public CodeType getLanguageElement() {
if (this.language == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create Attachment.language");
else if (Configuration.doAutoCreate())
this.language = new CodeType(); // bb
return this.language;
}
public boolean hasLanguageElement() {
return this.language != null && !this.language.isEmpty();
}
public boolean hasLanguage() {
return this.language != null && !this.language.isEmpty();
}
/**
* @param value {@link #language} (The human language of the content. The value can be any valid value according to BCP 47.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value
*/
public Attachment setLanguageElement(CodeType value) {
this.language = value;
return this;
}
/**
* @return The human language of the content. The value can be any valid value according to BCP 47.
*/
public String getLanguage() {
return this.language == null ? null : this.language.getValue();
}
/**
* @param value The human language of the content. The value can be any valid value according to BCP 47.
*/
public Attachment setLanguage(String value) {
if (Utilities.noString(value))
this.language = null;
else {
if (this.language == null)
this.language = new CodeType();
this.language.setValue(value);
}
return this;
}
/**
* @return {@link #data} (The actual data of the attachment - a sequence of bytes. In XML, represented using base64.). This is the underlying object with id, value and extensions. The accessor "getData" gives direct access to the value
*/
public Base64BinaryType getDataElement() {
if (this.data == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create Attachment.data");
else if (Configuration.doAutoCreate())
this.data = new Base64BinaryType(); // bb
return this.data;
}
public boolean hasDataElement() {
return this.data != null && !this.data.isEmpty();
}
public boolean hasData() {
return this.data != null && !this.data.isEmpty();
}
/**
* @param value {@link #data} (The actual data of the attachment - a sequence of bytes. In XML, represented using base64.). This is the underlying object with id, value and extensions. The accessor "getData" gives direct access to the value
*/
public Attachment setDataElement(Base64BinaryType value) {
this.data = value;
return this;
}
/**
* @return The actual data of the attachment - a sequence of bytes. In XML, represented using base64.
*/
public byte[] getData() {
return this.data == null ? null : this.data.getValue();
}
/**
* @param value The actual data of the attachment - a sequence of bytes. In XML, represented using base64.
*/
public Attachment setData(byte[] value) {
if (value == null)
this.data = null;
else {
if (this.data == null)
this.data = new Base64BinaryType();
this.data.setValue(value);
}
return this;
}
/**
* @return {@link #url} (An alternative location where the data can be accessed.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
*/
public UriType getUrlElement() {
if (this.url == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create Attachment.url");
else if (Configuration.doAutoCreate())
this.url = new UriType(); // bb
return this.url;
}
public boolean hasUrlElement() {
return this.url != null && !this.url.isEmpty();
}
public boolean hasUrl() {
return this.url != null && !this.url.isEmpty();
}
/**
* @param value {@link #url} (An alternative location where the data can be accessed.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value
*/
public Attachment setUrlElement(UriType value) {
this.url = value;
return this;
}
/**
* @return An alternative location where the data can be accessed.
*/
public String getUrl() {
return this.url == null ? null : this.url.getValue();
}
/**
* @param value An alternative location where the data can be accessed.
*/
public Attachment setUrl(String value) {
if (Utilities.noString(value))
this.url = null;
else {
if (this.url == null)
this.url = new UriType();
this.url.setValue(value);
}
return this;
}
/**
* @return {@link #size} (The number of bytes of data that make up this attachment.). This is the underlying object with id, value and extensions. The accessor "getSize" gives direct access to the value
*/
public UnsignedIntType getSizeElement() {
if (this.size == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create Attachment.size");
else if (Configuration.doAutoCreate())
this.size = new UnsignedIntType(); // bb
return this.size;
}
public boolean hasSizeElement() {
return this.size != null && !this.size.isEmpty();
}
public boolean hasSize() {
return this.size != null && !this.size.isEmpty();
}
/**
* @param value {@link #size} (The number of bytes of data that make up this attachment.). This is the underlying object with id, value and extensions. The accessor "getSize" gives direct access to the value
*/
public Attachment setSizeElement(UnsignedIntType value) {
this.size = value;
return this;
}
/**
* @return The number of bytes of data that make up this attachment.
*/
public int getSize() {
return this.size == null || this.size.isEmpty() ? 0 : this.size.getValue();
}
/**
* @param value The number of bytes of data that make up this attachment.
*/
public Attachment setSize(int value) {
if (this.size == null)
this.size = new UnsignedIntType();
this.size.setValue(value);
return this;
}
/**
* @return {@link #hash} (The calculated hash of the data using SHA-1. Represented using base64.). This is the underlying object with id, value and extensions. The accessor "getHash" gives direct access to the value
*/
public Base64BinaryType getHashElement() {
if (this.hash == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create Attachment.hash");
else if (Configuration.doAutoCreate())
this.hash = new Base64BinaryType(); // bb
return this.hash;
}
public boolean hasHashElement() {
return this.hash != null && !this.hash.isEmpty();
}
public boolean hasHash() {
return this.hash != null && !this.hash.isEmpty();
}
/**
* @param value {@link #hash} (The calculated hash of the data using SHA-1. Represented using base64.). This is the underlying object with id, value and extensions. The accessor "getHash" gives direct access to the value
*/
public Attachment setHashElement(Base64BinaryType value) {
this.hash = value;
return this;
}
/**
* @return The calculated hash of the data using SHA-1. Represented using base64.
*/
public byte[] getHash() {
return this.hash == null ? null : this.hash.getValue();
}
/**
* @param value The calculated hash of the data using SHA-1. Represented using base64.
*/
public Attachment setHash(byte[] value) {
if (value == null)
this.hash = null;
else {
if (this.hash == null)
this.hash = new Base64BinaryType();
this.hash.setValue(value);
}
return this;
}
/**
* @return {@link #title} (A label or set of text to display in place of the data.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
*/
public StringType getTitleElement() {
if (this.title == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create Attachment.title");
else if (Configuration.doAutoCreate())
this.title = new StringType(); // bb
return this.title;
}
public boolean hasTitleElement() {
return this.title != null && !this.title.isEmpty();
}
public boolean hasTitle() {
return this.title != null && !this.title.isEmpty();
}
/**
* @param value {@link #title} (A label or set of text to display in place of the data.). This is the underlying object with id, value and extensions. The accessor "getTitle" gives direct access to the value
*/
public Attachment setTitleElement(StringType value) {
this.title = value;
return this;
}
/**
* @return A label or set of text to display in place of the data.
*/
public String getTitle() {
return this.title == null ? null : this.title.getValue();
}
/**
* @param value A label or set of text to display in place of the data.
*/
public Attachment setTitle(String value) {
if (Utilities.noString(value))
this.title = null;
else {
if (this.title == null)
this.title = new StringType();
this.title.setValue(value);
}
return this;
}
/**
* @return {@link #creation} (The date that the attachment was first created.). This is the underlying object with id, value and extensions. The accessor "getCreation" gives direct access to the value
*/
public DateTimeType getCreationElement() {
if (this.creation == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create Attachment.creation");
else if (Configuration.doAutoCreate())
this.creation = new DateTimeType(); // bb
return this.creation;
}
public boolean hasCreationElement() {
return this.creation != null && !this.creation.isEmpty();
}
public boolean hasCreation() {
return this.creation != null && !this.creation.isEmpty();
}
/**
* @param value {@link #creation} (The date that the attachment was first created.). This is the underlying object with id, value and extensions. The accessor "getCreation" gives direct access to the value
*/
public Attachment setCreationElement(DateTimeType value) {
this.creation = value;
return this;
}
/**
* @return The date that the attachment was first created.
*/
public Date getCreation() {
return this.creation == null ? null : this.creation.getValue();
}
/**
* @param value The date that the attachment was first created.
*/
public Attachment setCreation(Date value) {
if (value == null)
this.creation = null;
else {
if (this.creation == null)
this.creation = new DateTimeType();
this.creation.setValue(value);
}
return this;
}
protected void listChildren(List<Property> childrenList) {
super.listChildren(childrenList);
childrenList.add(new Property("contentType", "code", "Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate.", 0, java.lang.Integer.MAX_VALUE, contentType));
childrenList.add(new Property("language", "code", "The human language of the content. The value can be any valid value according to BCP 47.", 0, java.lang.Integer.MAX_VALUE, language));
childrenList.add(new Property("data", "base64Binary", "The actual data of the attachment - a sequence of bytes. In XML, represented using base64.", 0, java.lang.Integer.MAX_VALUE, data));
childrenList.add(new Property("url", "uri", "An alternative location where the data can be accessed.", 0, java.lang.Integer.MAX_VALUE, url));
childrenList.add(new Property("size", "unsignedInt", "The number of bytes of data that make up this attachment.", 0, java.lang.Integer.MAX_VALUE, size));
childrenList.add(new Property("hash", "base64Binary", "The calculated hash of the data using SHA-1. Represented using base64.", 0, java.lang.Integer.MAX_VALUE, hash));
childrenList.add(new Property("title", "string", "A label or set of text to display in place of the data.", 0, java.lang.Integer.MAX_VALUE, title));
childrenList.add(new Property("creation", "dateTime", "The date that the attachment was first created.", 0, java.lang.Integer.MAX_VALUE, creation));
}
@Override
public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
switch (hash) {
case -389131437: /*contentType*/ return this.contentType == null ? new Base[0] : new Base[] {this.contentType}; // CodeType
case -1613589672: /*language*/ return this.language == null ? new Base[0] : new Base[] {this.language}; // CodeType
case 3076010: /*data*/ return this.data == null ? new Base[0] : new Base[] {this.data}; // Base64BinaryType
case 116079: /*url*/ return this.url == null ? new Base[0] : new Base[] {this.url}; // UriType
case 3530753: /*size*/ return this.size == null ? new Base[0] : new Base[] {this.size}; // UnsignedIntType
case 3195150: /*hash*/ return this.hash == null ? new Base[0] : new Base[] {this.hash}; // Base64BinaryType
case 110371416: /*title*/ return this.title == null ? new Base[0] : new Base[] {this.title}; // StringType
case 1820421855: /*creation*/ return this.creation == null ? new Base[0] : new Base[] {this.creation}; // DateTimeType
default: return super.getProperty(hash, name, checkValid);
}
}
@Override
public void setProperty(int hash, String name, Base value) throws FHIRException {
switch (hash) {
case -389131437: // contentType
this.contentType = castToCode(value); // CodeType
break;
case -1613589672: // language
this.language = castToCode(value); // CodeType
break;
case 3076010: // data
this.data = castToBase64Binary(value); // Base64BinaryType
break;
case 116079: // url
this.url = castToUri(value); // UriType
break;
case 3530753: // size
this.size = castToUnsignedInt(value); // UnsignedIntType
break;
case 3195150: // hash
this.hash = castToBase64Binary(value); // Base64BinaryType
break;
case 110371416: // title
this.title = castToString(value); // StringType
break;
case 1820421855: // creation
this.creation = castToDateTime(value); // DateTimeType
break;
default: super.setProperty(hash, name, value);
}
}
@Override
public void setProperty(String name, Base value) throws FHIRException {
if (name.equals("contentType"))
this.contentType = castToCode(value); // CodeType
else if (name.equals("language"))
this.language = castToCode(value); // CodeType
else if (name.equals("data"))
this.data = castToBase64Binary(value); // Base64BinaryType
else if (name.equals("url"))
this.url = castToUri(value); // UriType
else if (name.equals("size"))
this.size = castToUnsignedInt(value); // UnsignedIntType
else if (name.equals("hash"))
this.hash = castToBase64Binary(value); // Base64BinaryType
else if (name.equals("title"))
this.title = castToString(value); // StringType
else if (name.equals("creation"))
this.creation = castToDateTime(value); // DateTimeType
else
super.setProperty(name, value);
}
@Override
public Base makeProperty(int hash, String name) throws FHIRException {
switch (hash) {
case -389131437: throw new FHIRException("Cannot make property contentType as it is not a complex type"); // CodeType
case -1613589672: throw new FHIRException("Cannot make property language as it is not a complex type"); // CodeType
case 3076010: throw new FHIRException("Cannot make property data as it is not a complex type"); // Base64BinaryType
case 116079: throw new FHIRException("Cannot make property url as it is not a complex type"); // UriType
case 3530753: throw new FHIRException("Cannot make property size as it is not a complex type"); // UnsignedIntType
case 3195150: throw new FHIRException("Cannot make property hash as it is not a complex type"); // Base64BinaryType
case 110371416: throw new FHIRException("Cannot make property title as it is not a complex type"); // StringType
case 1820421855: throw new FHIRException("Cannot make property creation as it is not a complex type"); // DateTimeType
default: return super.makeProperty(hash, name);
}
}
@Override
public Base addChild(String name) throws FHIRException {
if (name.equals("contentType")) {
throw new FHIRException("Cannot call addChild on a primitive type Attachment.contentType");
}
else if (name.equals("language")) {
throw new FHIRException("Cannot call addChild on a primitive type Attachment.language");
}
else if (name.equals("data")) {
throw new FHIRException("Cannot call addChild on a primitive type Attachment.data");
}
else if (name.equals("url")) {
throw new FHIRException("Cannot call addChild on a primitive type Attachment.url");
}
else if (name.equals("size")) {
throw new FHIRException("Cannot call addChild on a primitive type Attachment.size");
}
else if (name.equals("hash")) {
throw new FHIRException("Cannot call addChild on a primitive type Attachment.hash");
}
else if (name.equals("title")) {
throw new FHIRException("Cannot call addChild on a primitive type Attachment.title");
}
else if (name.equals("creation")) {
throw new FHIRException("Cannot call addChild on a primitive type Attachment.creation");
}
else
return super.addChild(name);
}
public String fhirType() {
return "Attachment";
}
public Attachment copy() {
Attachment dst = new Attachment();
copyValues(dst);
dst.contentType = contentType == null ? null : contentType.copy();
dst.language = language == null ? null : language.copy();
dst.data = data == null ? null : data.copy();
dst.url = url == null ? null : url.copy();
dst.size = size == null ? null : size.copy();
dst.hash = hash == null ? null : hash.copy();
dst.title = title == null ? null : title.copy();
dst.creation = creation == null ? null : creation.copy();
return dst;
}
protected Attachment typedCopy() {
return copy();
}
@Override
public boolean equalsDeep(Base other) {
if (!super.equalsDeep(other))
return false;
if (!(other instanceof Attachment))
return false;
Attachment o = (Attachment) other;
return compareDeep(contentType, o.contentType, true) && compareDeep(language, o.language, true)
&& compareDeep(data, o.data, true) && compareDeep(url, o.url, true) && compareDeep(size, o.size, true)
&& compareDeep(hash, o.hash, true) && compareDeep(title, o.title, true) && compareDeep(creation, o.creation, true)
;
}
@Override
public boolean equalsShallow(Base other) {
if (!super.equalsShallow(other))
return false;
if (!(other instanceof Attachment))
return false;
Attachment o = (Attachment) other;
return compareValues(contentType, o.contentType, true) && compareValues(language, o.language, true)
&& compareValues(data, o.data, true) && compareValues(url, o.url, true) && compareValues(size, o.size, true)
&& compareValues(hash, o.hash, true) && compareValues(title, o.title, true) && compareValues(creation, o.creation, true)
;
}
public boolean isEmpty() {
return super.isEmpty() && (contentType == null || contentType.isEmpty()) && (language == null || language.isEmpty())
&& (data == null || data.isEmpty()) && (url == null || url.isEmpty()) && (size == null || size.isEmpty())
&& (hash == null || hash.isEmpty()) && (title == null || title.isEmpty()) && (creation == null || creation.isEmpty())
;
}
}

View File

@ -0,0 +1,195 @@
package org.hl7.fhir.dstu2016may.model;
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
import java.util.ArrayList;
import java.util.List;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
import ca.uhn.fhir.model.api.annotation.Description;
/**
* Base definition for all elements that are defined inside a resource - but not those in a data type.
*/
@DatatypeDef(name="BackboneElement")
public abstract class BackboneElement extends Element implements IBaseBackboneElement {
/**
* May be used to represent additional information that is not part of the basic definition of the element, and that modifies the understanding of the element that contains it. Usually modifier elements provide negation or qualification. In order to make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.
*/
@Child(name = "modifierExtension", type = {Extension.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=true, summary=true)
@Description(shortDefinition="Extensions that cannot be ignored", formalDefinition="May be used to represent additional information that is not part of the basic definition of the element, and that modifies the understanding of the element that contains it. Usually modifier elements provide negation or qualification. In order to make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions." )
protected List<Extension> modifierExtension;
private static final long serialVersionUID = -1431673179L;
/**
* Constructor
*/
public BackboneElement() {
super();
}
/**
* @return {@link #modifierExtension} (May be used to represent additional information that is not part of the basic definition of the element, and that modifies the understanding of the element that contains it. Usually modifier elements provide negation or qualification. In order to make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.)
*/
public List<Extension> getModifierExtension() {
if (this.modifierExtension == null)
this.modifierExtension = new ArrayList<Extension>();
return this.modifierExtension;
}
public boolean hasModifierExtension() {
if (this.modifierExtension == null)
return false;
for (Extension item : this.modifierExtension)
if (!item.isEmpty())
return true;
return false;
}
/**
* @return {@link #modifierExtension} (May be used to represent additional information that is not part of the basic definition of the element, and that modifies the understanding of the element that contains it. Usually modifier elements provide negation or qualification. In order to make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.)
*/
// syntactic sugar
public Extension addModifierExtension() { //3
Extension t = new Extension();
if (this.modifierExtension == null)
this.modifierExtension = new ArrayList<Extension>();
this.modifierExtension.add(t);
return t;
}
// syntactic sugar
public BackboneElement addModifierExtension(Extension t) { //3
if (t == null)
return this;
if (this.modifierExtension == null)
this.modifierExtension = new ArrayList<Extension>();
this.modifierExtension.add(t);
return this;
}
protected void listChildren(List<Property> childrenList) {
childrenList.add(new Property("modifierExtension", "Extension", "May be used to represent additional information that is not part of the basic definition of the element, and that modifies the understanding of the element that contains it. Usually modifier elements provide negation or qualification. In order to make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.", 0, java.lang.Integer.MAX_VALUE, modifierExtension));
}
@Override
public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
switch (hash) {
case -298878168: /*modifierExtension*/ return this.modifierExtension == null ? new Base[0] : this.modifierExtension.toArray(new Base[this.modifierExtension.size()]); // Extension
default: return super.getProperty(hash, name, checkValid);
}
}
@Override
public void setProperty(int hash, String name, Base value) throws FHIRException {
switch (hash) {
case -298878168: // modifierExtension
this.getModifierExtension().add(castToExtension(value)); // Extension
break;
default: super.setProperty(hash, name, value);
}
}
@Override
public void setProperty(String name, Base value) throws FHIRException {
if (name.equals("modifierExtension"))
this.getModifierExtension().add(castToExtension(value));
else
super.setProperty(name, value);
}
@Override
public Base makeProperty(int hash, String name) throws FHIRException {
switch (hash) {
case -298878168: return addModifierExtension(); // Extension
default: return super.makeProperty(hash, name);
}
}
@Override
public Base addChild(String name) throws FHIRException {
if (name.equals("modifierExtension")) {
return addModifierExtension();
}
else
return super.addChild(name);
}
public String fhirType() {
return "BackboneElement";
}
public abstract BackboneElement copy();
public void copyValues(BackboneElement dst) {
if (modifierExtension != null) {
dst.modifierExtension = new ArrayList<Extension>();
for (Extension i : modifierExtension)
dst.modifierExtension.add(i.copy());
};
}
@Override
public boolean equalsDeep(Base other) {
if (!super.equalsDeep(other))
return false;
if (!(other instanceof BackboneElement))
return false;
BackboneElement o = (BackboneElement) other;
return compareDeep(modifierExtension, o.modifierExtension, true);
}
@Override
public boolean equalsShallow(Base other) {
if (!super.equalsShallow(other))
return false;
if (!(other instanceof BackboneElement))
return false;
BackboneElement o = (BackboneElement) other;
return true;
}
public boolean isEmpty() {
return super.isEmpty() && (modifierExtension == null || modifierExtension.isEmpty());
}
}

View File

@ -0,0 +1,609 @@
package org.hl7.fhir.dstu2016may.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.instance.model.api.IBase;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
import ca.uhn.fhir.model.api.IElement;
public abstract class Base implements Serializable, IBase, IElement {
/**
* User appended data items - allow users to add extra information to the class
*/
private Map<String, Object> userData;
/**
* Round tracking xml comments for testing convenience
*/
private List<String> formatCommentsPre;
/**
* Round tracking xml comments for testing convenience
*/
private List<String> formatCommentsPost;
public Object getUserData(String name) {
if (userData == null)
return null;
return userData.get(name);
}
public void setUserData(String name, Object value) {
if (userData == null)
userData = new HashMap<String, Object>();
userData.put(name, value);
}
public void setUserDataINN(String name, Object value) {
if (value == null)
return;
if (userData == null)
userData = new HashMap<String, Object>();
userData.put(name, value);
}
public boolean hasUserData(String name) {
if (userData == null)
return false;
else
return userData.containsKey(name);
}
public String getUserString(String name) {
return (String) getUserData(name);
}
public int getUserInt(String name) {
if (!hasUserData(name))
return 0;
return (Integer) getUserData(name);
}
public boolean hasFormatComment() {
return (formatCommentsPre != null && !formatCommentsPre.isEmpty()) || (formatCommentsPost != null && !formatCommentsPost.isEmpty());
}
public List<String> getFormatCommentsPre() {
if (formatCommentsPre == null)
formatCommentsPre = new ArrayList<String>();
return formatCommentsPre;
}
public List<String> getFormatCommentsPost() {
if (formatCommentsPost == null)
formatCommentsPost = new ArrayList<String>();
return formatCommentsPost;
}
// these 3 allow evaluation engines to get access to primitive values
public boolean isPrimitive() {
return false;
}
public boolean hasPrimitiveValue() {
return isPrimitive();
}
public String primitiveValue() {
return null;
}
public abstract String fhirType() ;
public boolean hasType(String... name) {
String t = fhirType();
for (String n : name)
if (n.equals(t))
return true;
return false;
}
protected abstract void listChildren(List<Property> result) ;
public void setProperty(String name, Base value) throws FHIRException {
throw new FHIRException("Attempt to set unknown property "+name);
}
public Base addChild(String name) throws FHIRException {
throw new FHIRException("Attempt to add child with unknown name "+name);
}
/**
* Supports iterating the children elements in some generic processor or browser
* All defined children will be listed, even if they have no value on this instance
*
* Note that the actual content of primitive or xhtml elements is not iterated explicitly.
* To find these, the processing code must recognise the element as a primitive, typecast
* the value to a {@link Type}, and examine the value
*
* @return a list of all the children defined for this element
*/
public List<Property> children() {
List<Property> result = new ArrayList<Property>();
listChildren(result);
return result;
}
public Property getChildByName(String name) {
List<Property> children = new ArrayList<Property>();
listChildren(children);
for (Property c : children)
if (c.getName().equals(name))
return c;
return null;
}
public List<Base> listChildrenByName(String name) throws FHIRException {
List<Base> result = new ArrayList<Base>();
for (Base b : listChildrenByName(name, true))
if (b != null)
result.add(b);
return result;
}
public Base[] listChildrenByName(String name, boolean checkValid) throws FHIRException {
if (name.equals("*")) {
List<Property> children = new ArrayList<Property>();
listChildren(children);
List<Base> result = new ArrayList<Base>();
for (Property c : children)
if (name.equals("*") || c.getName().equals(name) || (c.getName().endsWith("[x]") && c.getName().startsWith(name)))
result.addAll(c.getValues());
return result.toArray(new Base[result.size()]);
}
else
return getProperty(name.hashCode(), name, checkValid);
}
public boolean isEmpty() {
return true; // userData does not count
}
public boolean equalsDeep(Base other) {
return other == this;
}
public boolean equalsShallow(Base other) {
return other == this;
}
public static boolean compareDeep(List<? extends Base> e1, List<? extends Base> e2, boolean allowNull) {
if (noList(e1) && noList(e2) && allowNull)
return true;
if (noList(e1) || noList(e2))
return false;
if (e1.size() != e2.size())
return false;
for (int i = 0; i < e1.size(); i++) {
if (!compareDeep(e1.get(i), e2.get(i), allowNull))
return false;
}
return true;
}
private static boolean noList(List<? extends Base> list) {
return list == null || list.isEmpty();
}
public static boolean compareDeep(Base e1, Base e2, boolean allowNull) {
if (e1 == null && e2 == null && allowNull)
return true;
if (e1 == null || e2 == null)
return false;
if (e2.isMetadataBased() && !e1.isMetadataBased()) // respect existing order for debugging consistency; outcome must be the same either way
return e2.equalsDeep(e1);
else
return e1.equalsDeep(e2);
}
public static boolean compareDeep(XhtmlNode div1, XhtmlNode div2, boolean allowNull) {
if (div1 == null && div2 == null && allowNull)
return true;
if (div1 == null || div2 == null)
return false;
return div1.equalsDeep(div2);
}
public static boolean compareValues(List<? extends PrimitiveType> e1, List<? extends PrimitiveType> e2, boolean allowNull) {
if (e1 == null && e2 == null && allowNull)
return true;
if (e1 == null || e2 == null)
return false;
if (e1.size() != e2.size())
return false;
for (int i = 0; i < e1.size(); i++) {
if (!compareValues(e1.get(i), e2.get(i), allowNull))
return false;
}
return true;
}
public static boolean compareValues(PrimitiveType e1, PrimitiveType e2, boolean allowNull) {
if (e1 == null && e2 == null && allowNull)
return true;
if (e1 == null || e2 == null)
return false;
return e1.equalsShallow(e2);
}
// -- converters for property setters
public BooleanType castToBoolean(Base b) throws FHIRException {
if (b instanceof BooleanType)
return (BooleanType) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Boolean");
}
public IntegerType castToInteger(Base b) throws FHIRException {
if (b instanceof IntegerType)
return (IntegerType) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Integer");
}
public DecimalType castToDecimal(Base b) throws FHIRException {
if (b instanceof DecimalType)
return (DecimalType) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Decimal");
}
public Base64BinaryType castToBase64Binary(Base b) throws FHIRException {
if (b instanceof Base64BinaryType)
return (Base64BinaryType) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Base64Binary");
}
public InstantType castToInstant(Base b) throws FHIRException {
if (b instanceof InstantType)
return (InstantType) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Instant");
}
public StringType castToString(Base b) throws FHIRException {
if (b instanceof StringType)
return (StringType) b;
else if (b.hasPrimitiveValue())
return new StringType(b.primitiveValue());
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a String");
}
public UriType castToUri(Base b) throws FHIRException {
if (b instanceof UriType)
return (UriType) b;
else if (b.hasPrimitiveValue())
return new UriType(b.primitiveValue());
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Uri");
}
public DateType castToDate(Base b) throws FHIRException {
if (b instanceof DateType)
return (DateType) b;
else if (b.hasPrimitiveValue())
return new DateType(b.primitiveValue());
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Date");
}
public DateTimeType castToDateTime(Base b) throws FHIRException {
if (b instanceof DateTimeType)
return (DateTimeType) b;
else if (b.fhirType().equals("dateTime"))
return new DateTimeType(b.primitiveValue());
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a DateTime");
}
public TimeType castToTime(Base b) throws FHIRException {
if (b instanceof TimeType)
return (TimeType) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Time");
}
public CodeType castToCode(Base b) throws FHIRException {
if (b instanceof CodeType)
return (CodeType) b;
else if (b.isPrimitive())
return new CodeType(b.primitiveValue());
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Code");
}
public OidType castToOid(Base b) throws FHIRException {
if (b instanceof OidType)
return (OidType) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Oid");
}
public IdType castToId(Base b) throws FHIRException {
if (b instanceof IdType)
return (IdType) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Id");
}
public UnsignedIntType castToUnsignedInt(Base b) throws FHIRException {
if (b instanceof UnsignedIntType)
return (UnsignedIntType) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a UnsignedInt");
}
public PositiveIntType castToPositiveInt(Base b) throws FHIRException {
if (b instanceof PositiveIntType)
return (PositiveIntType) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a PositiveInt");
}
public MarkdownType castToMarkdown(Base b) throws FHIRException {
if (b instanceof MarkdownType)
return (MarkdownType) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Markdown");
}
public Annotation castToAnnotation(Base b) throws FHIRException {
if (b instanceof Annotation)
return (Annotation) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an Annotation");
}
public Attachment castToAttachment(Base b) throws FHIRException {
if (b instanceof Attachment)
return (Attachment) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an Attachment");
}
public Identifier castToIdentifier(Base b) throws FHIRException {
if (b instanceof Identifier)
return (Identifier) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an Identifier");
}
public CodeableConcept castToCodeableConcept(Base b) throws FHIRException {
if (b instanceof CodeableConcept)
return (CodeableConcept) b;
else if (b instanceof CodeType) {
CodeableConcept cc = new CodeableConcept();
cc.addCoding().setCode(((CodeType) b).asStringValue());
return cc;
} else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a CodeableConcept");
}
public Coding castToCoding(Base b) throws FHIRException {
if (b instanceof Coding)
return (Coding) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Coding");
}
public Quantity castToQuantity(Base b) throws FHIRException {
if (b instanceof Quantity)
return (Quantity) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an Quantity");
}
public Money castToMoney(Base b) throws FHIRException {
if (b instanceof Money)
return (Money) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an Money");
}
public Duration castToDuration(Base b) throws FHIRException {
if (b instanceof Duration)
return (Duration) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an Duration");
}
public SimpleQuantity castToSimpleQuantity(Base b) throws FHIRException {
if (b instanceof SimpleQuantity)
return (SimpleQuantity) b;
else if (b instanceof Quantity) {
Quantity q = (Quantity) b;
SimpleQuantity sq = new SimpleQuantity();
sq.setValueElement(q.getValueElement());
sq.setComparatorElement(q.getComparatorElement());
sq.setUnitElement(q.getUnitElement());
sq.setSystemElement(q.getSystemElement());
sq.setCodeElement(q.getCodeElement());
return sq;
} else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an SimpleQuantity");
}
public Range castToRange(Base b) throws FHIRException {
if (b instanceof Range)
return (Range) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Range");
}
public Period castToPeriod(Base b) throws FHIRException {
if (b instanceof Period)
return (Period) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Period");
}
public Ratio castToRatio(Base b) throws FHIRException {
if (b instanceof Ratio)
return (Ratio) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Ratio");
}
public SampledData castToSampledData(Base b) throws FHIRException {
if (b instanceof SampledData)
return (SampledData) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a SampledData");
}
public Signature castToSignature(Base b) throws FHIRException {
if (b instanceof Signature)
return (Signature) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Signature");
}
public HumanName castToHumanName(Base b) throws FHIRException {
if (b instanceof HumanName)
return (HumanName) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a HumanName");
}
public Address castToAddress(Base b) throws FHIRException {
if (b instanceof Address)
return (Address) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Address");
}
public ContactPoint castToContactPoint(Base b) throws FHIRException {
if (b instanceof ContactPoint)
return (ContactPoint) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a ContactPoint");
}
public Timing castToTiming(Base b) throws FHIRException {
if (b instanceof Timing)
return (Timing) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Timing");
}
public Reference castToReference(Base b) throws FHIRException {
if (b instanceof Reference)
return (Reference) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Reference");
}
public Meta castToMeta(Base b) throws FHIRException {
if (b instanceof Meta)
return (Meta) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Meta");
}
public Extension castToExtension(Base b) throws FHIRException {
if (b instanceof Extension)
return (Extension) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Extension");
}
public Resource castToResource(Base b) throws FHIRException {
if (b instanceof Resource)
return (Resource) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Resource");
}
public Narrative castToNarrative(Base b) throws FHIRException {
if (b instanceof Narrative)
return (Narrative) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Narrative");
}
public ElementDefinition castToElementDefinition(Base b) throws FHIRException {
if (b instanceof ElementDefinition)
return (ElementDefinition) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a ElementDefinition");
}
public ModuleMetadata castToModuleMetadata(Base b) throws FHIRException {
if (b instanceof ModuleMetadata)
return (ModuleMetadata) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a ModuleMetadata");
}
public ActionDefinition castToActionDefinition(Base b) throws FHIRException {
if (b instanceof ActionDefinition)
return (ActionDefinition) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a ActionDefinition");
}
public DataRequirement castToDataRequirement(Base b) throws FHIRException {
if (b instanceof DataRequirement)
return (DataRequirement) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a DataRequirement");
}
public ParameterDefinition castToParameterDefinition(Base b) throws FHIRException {
if (b instanceof ParameterDefinition)
return (ParameterDefinition) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a ParameterDefinition");
}
public TriggerDefinition castToTriggerDefinition(Base b) throws FHIRException {
if (b instanceof TriggerDefinition)
return (TriggerDefinition) b;
else
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a TriggerDefinition");
}
protected boolean isMetadataBased() {
return false;
}
public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
if (checkValid)
throw new FHIRException("Attempt to read invalid property '"+name+"' on type "+fhirType());
return null;
}
public void setProperty(int hash, String name, Base value) throws FHIRException {
throw new FHIRException("Attempt to write to invalid property '"+name+"' on type "+fhirType());
}
public Base makeProperty(int hash, String name) throws FHIRException {
throw new FHIRException("Attempt to make an invalid property '"+name+"' on type "+fhirType());
}
public static boolean equals(String v1, String v2) {
if (v1 == null && v2 == null)
return true;
else if (v1 == null || v2 == null)
return false;
else
return v1.equals(v2);
}
}

View File

@ -0,0 +1,76 @@
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
package org.hl7.fhir.dstu2016may.model;
import org.apache.commons.codec.binary.Base64;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
/**
* Primitive type "base64Binary" in FHIR: a sequence of bytes represented in base64
*/
@DatatypeDef(name="base64binary")
public class Base64BinaryType extends PrimitiveType<byte[]> {
private static final long serialVersionUID = 3L;
/**
* Constructor
*/
public Base64BinaryType() {
super();
}
public Base64BinaryType(byte[] theBytes) {
super();
setValue(theBytes);
}
public Base64BinaryType(String theValue) {
super();
setValueAsString(theValue);
}
protected byte[] parse(String theValue) {
return Base64.decodeBase64(theValue);
}
protected String encode(byte[] theValue) {
return Base64.encodeBase64String(theValue);
}
@Override
public Base64BinaryType copy() {
return new Base64BinaryType(getValue());
}
public String fhirType() {
return "base64Binary";
}
}

View File

@ -0,0 +1,26 @@
package org.hl7.fhir.dstu2016may.model;
import org.hl7.fhir.instance.model.api.IBaseBinary;
public abstract class BaseBinary extends Resource implements IBaseBinary {
private static final long serialVersionUID = 1L;
@Override
public String getContentAsBase64() {
return getContentElement().getValueAsString();
}
@Override
public BaseBinary setContentAsBase64(String theContent) {
if (theContent != null) {
getContentElement().setValueAsString(theContent);
} else {
setContent(null);
}
return this;
}
abstract Base64BinaryType getContentElement();
}

View File

@ -0,0 +1,743 @@
package org.hl7.fhir.dstu2016may.model;
import static org.apache.commons.lang3.StringUtils.isBlank;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.lang3.time.FastDateFormat;
import ca.uhn.fhir.parser.DataFormatException;
public abstract class BaseDateTimeType extends PrimitiveType<Date> {
private static final long serialVersionUID = 1L;
static final long NANOS_PER_MILLIS = 1000000L;
static final long NANOS_PER_SECOND = 1000000000L;
private static final FastDateFormat ourHumanDateFormat = FastDateFormat.getDateInstance(FastDateFormat.MEDIUM);
private static final FastDateFormat ourHumanDateTimeFormat = FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM);
private String myFractionalSeconds;
private TemporalPrecisionEnum myPrecision = null;
private TimeZone myTimeZone;
private boolean myTimeZoneZulu = false;
/**
* Constructor
*/
public BaseDateTimeType() {
// nothing
}
/**
* Constructor
*
* @throws DataFormatException
* If the specified precision is not allowed for this type
*/
public BaseDateTimeType(Date theDate, TemporalPrecisionEnum thePrecision) {
setValue(theDate, thePrecision);
if (isPrecisionAllowed(thePrecision) == false) {
throw new DataFormatException("Invalid date/time string (datatype " + getClass().getSimpleName() + " does not support " + thePrecision + " precision): " + theDate);
}
}
/**
* Constructor
*/
public BaseDateTimeType(Date theDate, TemporalPrecisionEnum thePrecision, TimeZone theTimeZone) {
this(theDate, thePrecision);
setTimeZone(theTimeZone);
}
/**
* Constructor
*
* @throws DataFormatException
* If the specified precision is not allowed for this type
*/
public BaseDateTimeType(String theString) {
setValueAsString(theString);
if (isPrecisionAllowed(getPrecision()) == false) {
throw new DataFormatException("Invalid date/time string (datatype " + getClass().getSimpleName() + " does not support " + getPrecision() + " precision): " + theString);
}
}
private void clearTimeZone() {
myTimeZone = null;
myTimeZoneZulu = false;
}
@Override
protected String encode(Date theValue) {
if (theValue == null) {
return null;
} else {
GregorianCalendar cal;
if (myTimeZoneZulu) {
cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
} else if (myTimeZone != null) {
cal = new GregorianCalendar(myTimeZone);
} else {
cal = new GregorianCalendar();
}
cal.setTime(theValue);
StringBuilder b = new StringBuilder();
leftPadWithZeros(cal.get(Calendar.YEAR), 4, b);
if (myPrecision.ordinal() > TemporalPrecisionEnum.YEAR.ordinal()) {
b.append('-');
leftPadWithZeros(cal.get(Calendar.MONTH) + 1, 2, b);
if (myPrecision.ordinal() > TemporalPrecisionEnum.MONTH.ordinal()) {
b.append('-');
leftPadWithZeros(cal.get(Calendar.DATE), 2, b);
if (myPrecision.ordinal() > TemporalPrecisionEnum.DAY.ordinal()) {
b.append('T');
leftPadWithZeros(cal.get(Calendar.HOUR_OF_DAY), 2, b);
b.append(':');
leftPadWithZeros(cal.get(Calendar.MINUTE), 2, b);
if (myPrecision.ordinal() > TemporalPrecisionEnum.MINUTE.ordinal()) {
b.append(':');
leftPadWithZeros(cal.get(Calendar.SECOND), 2, b);
if (myPrecision.ordinal() > TemporalPrecisionEnum.SECOND.ordinal()) {
b.append('.');
b.append(myFractionalSeconds);
for (int i = myFractionalSeconds.length(); i < 3; i++) {
b.append('0');
}
}
}
if (myTimeZoneZulu) {
b.append('Z');
} else if (myTimeZone != null) {
int offset = myTimeZone.getOffset(theValue.getTime());
if (offset >= 0) {
b.append('+');
} else {
b.append('-');
offset = Math.abs(offset);
}
int hoursOffset = (int) (offset / DateUtils.MILLIS_PER_HOUR);
leftPadWithZeros(hoursOffset, 2, b);
b.append(':');
int minutesOffset = (int) (offset % DateUtils.MILLIS_PER_HOUR);
minutesOffset = (int) (minutesOffset / DateUtils.MILLIS_PER_MINUTE);
leftPadWithZeros(minutesOffset, 2, b);
}
}
}
}
return b.toString();
}
}
/**
* Returns the default precision for the given datatype
*/
protected abstract TemporalPrecisionEnum getDefaultPrecisionForDatatype();
private int getOffsetIndex(String theValueString) {
int plusIndex = theValueString.indexOf('+', 16);
int minusIndex = theValueString.indexOf('-', 16);
int zIndex = theValueString.indexOf('Z', 16);
int retVal = Math.max(Math.max(plusIndex, minusIndex), zIndex);
if (retVal == -1) {
return -1;
}
if ((retVal - 2) != (plusIndex + minusIndex + zIndex)) {
throwBadDateFormat(theValueString);
}
return retVal;
}
/**
* Gets the precision for this datatype (using the default for the given type if not set)
*
* @see #setPrecision(TemporalPrecisionEnum)
*/
public TemporalPrecisionEnum getPrecision() {
if (myPrecision == null) {
return getDefaultPrecisionForDatatype();
}
return myPrecision;
}
/**
* Returns the TimeZone associated with this dateTime's value. May return <code>null</code> if no timezone was
* supplied.
*/
public TimeZone getTimeZone() {
if (myTimeZoneZulu) {
return TimeZone.getTimeZone("Z");
}
return myTimeZone;
}
/**
* Returns the value of this object as a {@link GregorianCalendar}
*/
public GregorianCalendar getValueAsCalendar() {
if (getValue() == null) {
return null;
}
GregorianCalendar cal;
if (getTimeZone() != null) {
cal = new GregorianCalendar(getTimeZone());
} else {
cal = new GregorianCalendar();
}
cal.setTime(getValue());
return cal;
}
/**
* To be implemented by subclasses to indicate whether the given precision is allowed by this type
*/
abstract boolean isPrecisionAllowed(TemporalPrecisionEnum thePrecision);
/**
* Returns true if the timezone is set to GMT-0:00 (Z)
*/
public boolean isTimeZoneZulu() {
return myTimeZoneZulu;
}
/**
* Returns <code>true</code> if this object represents a date that is today's date
*
* @throws NullPointerException
* if {@link #getValue()} returns <code>null</code>
*/
public boolean isToday() {
Validate.notNull(getValue(), getClass().getSimpleName() + " contains null value");
return DateUtils.isSameDay(new Date(), getValue());
}
private void leftPadWithZeros(int theInteger, int theLength, StringBuilder theTarget) {
String string = Integer.toString(theInteger);
for (int i = string.length(); i < theLength; i++) {
theTarget.append('0');
}
theTarget.append(string);
}
@Override
protected Date parse(String theValue) throws DataFormatException {
Calendar cal = new GregorianCalendar(0, 0, 0);
cal.setTimeZone(TimeZone.getDefault());
String value = theValue;
boolean fractionalSecondsSet = false;
if (value.length() > 0 && (value.charAt(0) == ' ' || value.charAt(value.length() - 1) == ' ')) {
value = value.trim();
}
int length = value.length();
if (length == 0) {
return null;
}
if (length < 4) {
throwBadDateFormat(value);
}
TemporalPrecisionEnum precision = null;
cal.set(Calendar.YEAR, parseInt(value, value.substring(0, 4), 0, 9999));
precision = TemporalPrecisionEnum.YEAR;
if (length > 4) {
validateCharAtIndexIs(value, 4, '-');
validateLengthIsAtLeast(value, 7);
int monthVal = parseInt(value, value.substring(5, 7), 1, 12) - 1;
cal.set(Calendar.MONTH, monthVal);
precision = TemporalPrecisionEnum.MONTH;
if (length > 7) {
validateCharAtIndexIs(value, 7, '-');
validateLengthIsAtLeast(value, 10);
cal.set(Calendar.DATE, 1); // for some reason getActualMaximum works incorrectly if date isn't set
int actualMaximum = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
cal.set(Calendar.DAY_OF_MONTH, parseInt(value, value.substring(8, 10), 1, actualMaximum));
precision = TemporalPrecisionEnum.DAY;
if (length > 10) {
validateLengthIsAtLeast(value, 17);
validateCharAtIndexIs(value, 10, 'T'); // yyyy-mm-ddThh:mm:ss
int offsetIdx = getOffsetIndex(value);
String time;
if (offsetIdx == -1) {
//throwBadDateFormat(theValue);
// No offset - should this be an error?
time = value.substring(11);
} else {
time = value.substring(11, offsetIdx);
String offsetString = value.substring(offsetIdx);
setTimeZone(value, offsetString);
cal.setTimeZone(getTimeZone());
}
int timeLength = time.length();
validateCharAtIndexIs(value, 13, ':');
cal.set(Calendar.HOUR_OF_DAY, parseInt(value, value.substring(11, 13), 0, 23));
cal.set(Calendar.MINUTE, parseInt(value, value.substring(14, 16), 0, 59));
precision = TemporalPrecisionEnum.MINUTE;
if (timeLength > 5) {
validateLengthIsAtLeast(value, 19);
validateCharAtIndexIs(value, 16, ':'); // yyyy-mm-ddThh:mm:ss
cal.set(Calendar.SECOND, parseInt(value, value.substring(17, 19), 0, 59));
precision = TemporalPrecisionEnum.SECOND;
if (timeLength > 8) {
validateCharAtIndexIs(value, 19, '.'); // yyyy-mm-ddThh:mm:ss.SSSS
validateLengthIsAtLeast(value, 20);
int endIndex = getOffsetIndex(value);
if (endIndex == -1) {
endIndex = value.length();
}
int millis;
String millisString;
if (endIndex > 23) {
myFractionalSeconds = value.substring(20, endIndex);
fractionalSecondsSet = true;
endIndex = 23;
millisString = value.substring(20, endIndex);
millis = parseInt(value, millisString, 0, 999);
} else {
millisString = value.substring(20, endIndex);
millis = parseInt(value, millisString, 0, 999);
myFractionalSeconds = millisString;
fractionalSecondsSet = true;
}
if (millisString.length() == 1) {
millis = millis * 100;
} else if (millisString.length() == 2) {
millis = millis * 10;
}
cal.set(Calendar.MILLISECOND, millis);
precision = TemporalPrecisionEnum.MILLI;
}
}
}
} else {
cal.set(Calendar.DATE, 1);
}
} else {
cal.set(Calendar.DATE, 1);
}
if (fractionalSecondsSet == false) {
myFractionalSeconds = "";
}
myPrecision = precision;
return cal.getTime();
}
private int parseInt(String theValue, String theSubstring, int theLowerBound, int theUpperBound) {
int retVal = 0;
try {
retVal = Integer.parseInt(theSubstring);
} catch (NumberFormatException e) {
throwBadDateFormat(theValue);
}
if (retVal < theLowerBound || retVal > theUpperBound) {
throwBadDateFormat(theValue);
}
return retVal;
}
/**
* Sets the precision for this datatype
*
* @throws DataFormatException
*/
public void setPrecision(TemporalPrecisionEnum thePrecision) throws DataFormatException {
if (thePrecision == null) {
throw new NullPointerException("Precision may not be null");
}
myPrecision = thePrecision;
updateStringValue();
}
private BaseDateTimeType setTimeZone(String theWholeValue, String theValue) {
if (isBlank(theValue)) {
throwBadDateFormat(theWholeValue);
} else if (theValue.charAt(0) == 'Z') {
myTimeZone = null;
myTimeZoneZulu = true;
} else if (theValue.length() != 6) {
throwBadDateFormat(theWholeValue, "Timezone offset must be in the form \"Z\", \"-HH:mm\", or \"+HH:mm\"");
} else if (theValue.charAt(3) != ':' || !(theValue.charAt(0) == '+' || theValue.charAt(0) == '-')) {
throwBadDateFormat(theWholeValue, "Timezone offset must be in the form \"Z\", \"-HH:mm\", or \"+HH:mm\"");
} else {
parseInt(theWholeValue, theValue.substring(1, 3), 0, 23);
parseInt(theWholeValue, theValue.substring(4, 6), 0, 59);
myTimeZoneZulu = false;
myTimeZone = TimeZone.getTimeZone("GMT" + theValue);
}
return this;
}
public BaseDateTimeType setTimeZone(TimeZone theTimeZone) {
myTimeZone = theTimeZone;
myTimeZoneZulu = false;
updateStringValue();
return this;
}
public BaseDateTimeType setTimeZoneZulu(boolean theTimeZoneZulu) {
myTimeZoneZulu = theTimeZoneZulu;
myTimeZone = null;
updateStringValue();
return this;
}
/**
* Sets the value for this type using the given Java Date object as the time, and using the default precision for
* this datatype (unless the precision is already set), as well as the local timezone as determined by the local operating
* system. Both of these properties may be modified in subsequent calls if neccesary.
*/
@Override
public BaseDateTimeType setValue(Date theValue) {
setValue(theValue, getPrecision());
return this;
}
/**
* Sets the value for this type using the given Java Date object as the time, and using the specified precision, as
* well as the local timezone as determined by the local operating system. Both of
* these properties may be modified in subsequent calls if neccesary.
*
* @param theValue
* The date value
* @param thePrecision
* The precision
* @throws DataFormatException
*/
public void setValue(Date theValue, TemporalPrecisionEnum thePrecision) throws DataFormatException {
if (getTimeZone() == null) {
setTimeZone(TimeZone.getDefault());
}
myPrecision = thePrecision;
myFractionalSeconds = "";
if (theValue != null) {
long millis = theValue.getTime() % 1000;
if (millis < 0) {
// This is for times before 1970 (see bug #444)
millis = 1000 + millis;
}
String fractionalSeconds = Integer.toString((int) millis);
myFractionalSeconds = StringUtils.leftPad(fractionalSeconds, 3, '0');
}
super.setValue(theValue);
}
@Override
public void setValueAsString(String theValue) throws DataFormatException {
clearTimeZone();
super.setValueAsString(theValue);
}
private void throwBadDateFormat(String theValue) {
throw new DataFormatException("Invalid date/time format: \"" + theValue + "\"");
}
private void throwBadDateFormat(String theValue, String theMesssage) {
throw new DataFormatException("Invalid date/time format: \"" + theValue + "\": " + theMesssage);
}
/**
* Returns a human readable version of this date/time using the system local format.
* <p>
* <b>Note on time zones:</b> This method renders the value using the time zone that is contained within the value.
* For example, if this date object contains the value "2012-01-05T12:00:00-08:00",
* the human display will be rendered as "12:00:00" even if the application is being executed on a system in a
* different time zone. If this behaviour is not what you want, use
* {@link #toHumanDisplayLocalTimezone()} instead.
* </p>
*/
public String toHumanDisplay() {
TimeZone tz = getTimeZone();
Calendar value = tz != null ? Calendar.getInstance(tz) : Calendar.getInstance();
value.setTime(getValue());
switch (getPrecision()) {
case YEAR:
case MONTH:
case DAY:
return ourHumanDateFormat.format(value);
case MILLI:
case SECOND:
default:
return ourHumanDateTimeFormat.format(value);
}
}
/**
* Returns a human readable version of this date/time using the system local format, converted to the local timezone
* if neccesary.
*
* @see #toHumanDisplay() for a method which does not convert the time to the local timezone before rendering it.
*/
public String toHumanDisplayLocalTimezone() {
switch (getPrecision()) {
case YEAR:
case MONTH:
case DAY:
return ourHumanDateFormat.format(getValue());
case MILLI:
case SECOND:
default:
return ourHumanDateTimeFormat.format(getValue());
}
}
private void validateCharAtIndexIs(String theValue, int theIndex, char theChar) {
if (theValue.charAt(theIndex) != theChar) {
throwBadDateFormat(theValue, "Expected character '" + theChar + "' at index " + theIndex + " but found " + theValue.charAt(theIndex));
}
}
private void validateLengthIsAtLeast(String theValue, int theLength) {
if (theValue.length() < theLength) {
throwBadDateFormat(theValue);
}
}
/**
* Returns the year, e.g. 2015
*/
public Integer getYear() {
return getFieldValue(Calendar.YEAR);
}
/**
* Returns the month with 0-index, e.g. 0=January
*/
public Integer getMonth() {
return getFieldValue(Calendar.MONTH);
}
/**
* Returns the month with 1-index, e.g. 1=the first day of the month
*/
public Integer getDay() {
return getFieldValue(Calendar.DAY_OF_MONTH);
}
/**
* Returns the hour of the day in a 24h clock, e.g. 13=1pm
*/
public Integer getHour() {
return getFieldValue(Calendar.HOUR_OF_DAY);
}
/**
* Returns the minute of the hour in the range 0-59
*/
public Integer getMinute() {
return getFieldValue(Calendar.MINUTE);
}
/**
* Returns the second of the minute in the range 0-59
*/
public Integer getSecond() {
return getFieldValue(Calendar.SECOND);
}
/**
* Returns the milliseconds within the current second.
* <p>
* Note that this method returns the
* same value as {@link #getNanos()} but with less precision.
* </p>
*/
public Integer getMillis() {
return getFieldValue(Calendar.MILLISECOND);
}
/**
* Returns the nanoseconds within the current second
* <p>
* Note that this method returns the
* same value as {@link #getMillis()} but with more precision.
* </p>
*/
public Long getNanos() {
if (isBlank(myFractionalSeconds)) {
return null;
}
String retVal = StringUtils.rightPad(myFractionalSeconds, 9, '0');
retVal = retVal.substring(0, 9);
return Long.parseLong(retVal);
}
/**
* Sets the year, e.g. 2015
*/
public BaseDateTimeType setYear(int theYear) {
setFieldValue(Calendar.YEAR, theYear, null, 0, 9999);
return this;
}
/**
* Sets the month with 0-index, e.g. 0=January
*/
public BaseDateTimeType setMonth(int theMonth) {
setFieldValue(Calendar.MONTH, theMonth, null, 0, 11);
return this;
}
/**
* Sets the month with 1-index, e.g. 1=the first day of the month
*/
public BaseDateTimeType setDay(int theDay) {
setFieldValue(Calendar.DAY_OF_MONTH, theDay, null, 0, 31);
return this;
}
/**
* Sets the hour of the day in a 24h clock, e.g. 13=1pm
*/
public BaseDateTimeType setHour(int theHour) {
setFieldValue(Calendar.HOUR_OF_DAY, theHour, null, 0, 23);
return this;
}
/**
* Sets the minute of the hour in the range 0-59
*/
public BaseDateTimeType setMinute(int theMinute) {
setFieldValue(Calendar.MINUTE, theMinute, null, 0, 59);
return this;
}
/**
* Sets the second of the minute in the range 0-59
*/
public BaseDateTimeType setSecond(int theSecond) {
setFieldValue(Calendar.SECOND, theSecond, null, 0, 59);
return this;
}
/**
* Sets the milliseconds within the current second.
* <p>
* Note that this method sets the
* same value as {@link #setNanos(long)} but with less precision.
* </p>
*/
public BaseDateTimeType setMillis(int theMillis) {
setFieldValue(Calendar.MILLISECOND, theMillis, null, 0, 999);
return this;
}
/**
* Sets the nanoseconds within the current second
* <p>
* Note that this method sets the
* same value as {@link #setMillis(int)} but with more precision.
* </p>
*/
public BaseDateTimeType setNanos(long theNanos) {
validateValueInRange(theNanos, 0, NANOS_PER_SECOND-1);
String fractionalSeconds = StringUtils.leftPad(Long.toString(theNanos), 9, '0');
// Strip trailing 0s
for (int i = fractionalSeconds.length(); i > 0; i--) {
if (fractionalSeconds.charAt(i-1) != '0') {
fractionalSeconds = fractionalSeconds.substring(0, i);
break;
}
}
int millis = (int)(theNanos / NANOS_PER_MILLIS);
setFieldValue(Calendar.MILLISECOND, millis, fractionalSeconds, 0, 999);
return this;
}
private void setFieldValue(int theField, int theValue, String theFractionalSeconds, int theMinimum, int theMaximum) {
validateValueInRange(theValue, theMinimum, theMaximum);
Calendar cal;
if (getValue() == null) {
cal = new GregorianCalendar(0, 0, 0);
} else {
cal = getValueAsCalendar();
}
if (theField != -1) {
cal.set(theField, theValue);
}
if (theFractionalSeconds != null) {
myFractionalSeconds = theFractionalSeconds;
} else if (theField == Calendar.MILLISECOND) {
myFractionalSeconds = StringUtils.leftPad(Integer.toString(theValue), 3, '0');
}
super.setValue(cal.getTime());
}
private void validateValueInRange(long theValue, long theMinimum, long theMaximum) {
if (theValue < theMinimum || theValue > theMaximum) {
throw new IllegalArgumentException("Value " + theValue + " is not between allowable range: " + theMinimum + " - " + theMaximum);
}
}
private Integer getFieldValue(int theField) {
if (getValue() == null) {
return null;
}
Calendar cal = getValueAsCalendar();
return cal.get(theField);
}
protected void setValueAsV3String(String theV3String) {
if (StringUtils.isBlank(theV3String)) {
setValue(null);
} else {
StringBuilder b = new StringBuilder();
String timeZone = null;
for (int i = 0; i < theV3String.length(); i++) {
char nextChar = theV3String.charAt(i);
if (nextChar == '+' || nextChar == '-' || nextChar == 'Z') {
timeZone = (theV3String.substring(i));
break;
}
// assertEquals("2013-02-02T20:13:03-05:00", DateAndTime.parseV3("20130202201303-0500").toString());
if (i == 4 || i == 6) {
b.append('-');
} else if (i == 8) {
b.append('T');
} else if (i == 10 || i == 12) {
b.append(':');
}
b.append(nextChar);
}
if (b.length() == 16)
b.append(":00"); // schema rule, must have seconds
if (timeZone != null && b.length() > 10) {
if (timeZone.length() ==5) {
b.append(timeZone.substring(0, 3));
b.append(':');
b.append(timeZone.substring(3));
}else {
b.append(timeZone);
}
}
setValueAsString(b.toString());
}
}
}

View File

@ -0,0 +1,17 @@
package org.hl7.fhir.dstu2016may.model;
import org.hl7.fhir.instance.model.api.IBaseDatatype;
import org.hl7.fhir.instance.model.api.IBaseExtension;
import org.hl7.fhir.instance.model.api.IBaseHasExtensions;
public abstract class BaseExtension extends Type implements IBaseExtension<Extension, Type>, IBaseHasExtensions {
@Override
public Extension setValue(IBaseDatatype theValue) {
setValue((Type)theValue);
return (Extension) this;
}
public abstract Extension setValue(Type theValue);
}

View File

@ -0,0 +1,50 @@
package org.hl7.fhir.dstu2016may.model;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.instance.model.api.INarrative;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
public abstract class BaseNarrative extends Type implements INarrative {
/**
* Sets the value of
*
* @param theString
* @throws Exception
*/
public void setDivAsString(String theString) {
XhtmlNode div;
if (StringUtils.isNotBlank(theString)) {
div = new XhtmlNode();
div.setValueAsString(theString);
} else {
div = null;
}
setDiv(div);
}
protected abstract BaseNarrative setDiv(XhtmlNode theDiv);
public String getDivAsString() {
XhtmlNode div = getDiv();
if (div != null && !div.isEmpty()) {
return div.getValueAsString();
} else {
return null;
}
}
protected abstract XhtmlNode getDiv();
public abstract Enumeration<?> getStatusElement();
public INarrative setStatusAsString(String theString) {
getStatusElement().setValueAsString(theString);
return this;
}
public String getStatusAsString() {
return getStatusElement().getValueAsString();
}
}

View File

@ -0,0 +1,65 @@
package org.hl7.fhir.dstu2016may.model;
import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.instance.model.api.IBaseReference;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.ICompositeType;
import org.hl7.fhir.instance.model.api.IIdType;
public abstract class BaseReference extends Type implements IBaseReference, ICompositeType {
/**
* This is not a part of the "wire format" resource, but can be changed/accessed by parsers
*/
private transient IBaseResource resource;
public BaseReference(String theReference) {
setReference(theReference);
}
public BaseReference(IIdType theReference) {
if (theReference != null) {
setReference(theReference.getValue());
} else {
setReference(null);
}
}
public BaseReference(IAnyResource theResource) {
resource = theResource;
}
public BaseReference() {
}
/**
* Retrieves the actual resource referenced by this reference. Note that the resource itself is not
* a part of the FHIR "wire format" and is never transmitted or receieved inline, but this property
* may be changed/accessed by parsers.
*/
public IBaseResource getResource() {
return resource;
}
@Override
public IIdType getReferenceElement() {
return new IdType(getReference());
}
abstract String getReference();
/**
* Sets the actual resource referenced by this reference. Note that the resource itself is not
* a part of the FHIR "wire format" and is never transmitted or receieved inline, but this property
* may be changed/accessed by parsers.
*/
public void setResource(IBaseResource theResource) {
resource = theResource;
}
@Override
public boolean isEmpty() {
return resource == null && super.isEmpty();
}
}

View File

@ -0,0 +1,33 @@
package org.hl7.fhir.dstu2016may.model;
import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.instance.model.api.IIdType;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.model.api.IElement;
public abstract class BaseResource extends Base implements IAnyResource, IElement {
private static final long serialVersionUID = 1L;
/**
* @param value The logical id of the resource, as used in the url for the resoure. Once assigned, this value never changes.
*/
public BaseResource setId(IIdType value) {
if (value == null) {
setIdElement((IdType)null);
} else if (value instanceof IdType) {
setIdElement((IdType) value);
} else {
setIdElement(new IdType(value.getValue()));
}
return this;
}
public abstract BaseResource setIdElement(IdType theIdType);
@Override
public FhirVersionEnum getStructureFhirVersionEnum() {
return FhirVersionEnum.DSTU2_1;
}
}

View File

@ -0,0 +1,596 @@
package org.hl7.fhir.dstu2016may.model;
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.hl7.fhir.exceptions.FHIRException;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
/**
* Basic is used for handling concepts not yet defined in FHIR, narrative-only resources that don't map to an existing resource, and custom resources not appropriate for inclusion in the FHIR specification.
*/
@ResourceDef(name="Basic", profile="http://hl7.org/fhir/Profile/Basic")
public class Basic extends DomainResource {
/**
* Identifier assigned to the resource for business purposes, outside the context of FHIR.
*/
@Child(name = "identifier", type = {Identifier.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
@Description(shortDefinition="Business identifier", formalDefinition="Identifier assigned to the resource for business purposes, outside the context of FHIR." )
protected List<Identifier> identifier;
/**
* Identifies the 'type' of resource - equivalent to the resource name for other resources.
*/
@Child(name = "code", type = {CodeableConcept.class}, order=1, min=1, max=1, modifier=true, summary=true)
@Description(shortDefinition="Kind of Resource", formalDefinition="Identifies the 'type' of resource - equivalent to the resource name for other resources." )
protected CodeableConcept code;
/**
* Identifies the patient, practitioner, device or any other resource that is the "focus" of this resource.
*/
@Child(name = "subject", type = {}, order=2, min=0, max=1, modifier=false, summary=true)
@Description(shortDefinition="Identifies the focus of this resource", formalDefinition="Identifies the patient, practitioner, device or any other resource that is the \"focus\" of this resource." )
protected Reference subject;
/**
* The actual object that is the target of the reference (Identifies the patient, practitioner, device or any other resource that is the "focus" of this resource.)
*/
protected Resource subjectTarget;
/**
* Identifies when the resource was first created.
*/
@Child(name = "created", type = {DateType.class}, order=3, min=0, max=1, modifier=false, summary=true)
@Description(shortDefinition="When created", formalDefinition="Identifies when the resource was first created." )
protected DateType created;
/**
* Indicates who was responsible for creating the resource instance.
*/
@Child(name = "author", type = {Practitioner.class, Patient.class, RelatedPerson.class}, order=4, min=0, max=1, modifier=false, summary=true)
@Description(shortDefinition="Who created", formalDefinition="Indicates who was responsible for creating the resource instance." )
protected Reference author;
/**
* The actual object that is the target of the reference (Indicates who was responsible for creating the resource instance.)
*/
protected Resource authorTarget;
private static final long serialVersionUID = 650756402L;
/**
* Constructor
*/
public Basic() {
super();
}
/**
* Constructor
*/
public Basic(CodeableConcept code) {
super();
this.code = code;
}
/**
* @return {@link #identifier} (Identifier assigned to the resource for business purposes, outside the context of FHIR.)
*/
public List<Identifier> getIdentifier() {
if (this.identifier == null)
this.identifier = new ArrayList<Identifier>();
return this.identifier;
}
public boolean hasIdentifier() {
if (this.identifier == null)
return false;
for (Identifier item : this.identifier)
if (!item.isEmpty())
return true;
return false;
}
/**
* @return {@link #identifier} (Identifier assigned to the resource for business purposes, outside the context of FHIR.)
*/
// syntactic sugar
public Identifier addIdentifier() { //3
Identifier t = new Identifier();
if (this.identifier == null)
this.identifier = new ArrayList<Identifier>();
this.identifier.add(t);
return t;
}
// syntactic sugar
public Basic addIdentifier(Identifier t) { //3
if (t == null)
return this;
if (this.identifier == null)
this.identifier = new ArrayList<Identifier>();
this.identifier.add(t);
return this;
}
/**
* @return {@link #code} (Identifies the 'type' of resource - equivalent to the resource name for other resources.)
*/
public CodeableConcept getCode() {
if (this.code == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create Basic.code");
else if (Configuration.doAutoCreate())
this.code = new CodeableConcept(); // cc
return this.code;
}
public boolean hasCode() {
return this.code != null && !this.code.isEmpty();
}
/**
* @param value {@link #code} (Identifies the 'type' of resource - equivalent to the resource name for other resources.)
*/
public Basic setCode(CodeableConcept value) {
this.code = value;
return this;
}
/**
* @return {@link #subject} (Identifies the patient, practitioner, device or any other resource that is the "focus" of this resource.)
*/
public Reference getSubject() {
if (this.subject == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create Basic.subject");
else if (Configuration.doAutoCreate())
this.subject = new Reference(); // cc
return this.subject;
}
public boolean hasSubject() {
return this.subject != null && !this.subject.isEmpty();
}
/**
* @param value {@link #subject} (Identifies the patient, practitioner, device or any other resource that is the "focus" of this resource.)
*/
public Basic setSubject(Reference value) {
this.subject = value;
return this;
}
/**
* @return {@link #subject} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Identifies the patient, practitioner, device or any other resource that is the "focus" of this resource.)
*/
public Resource getSubjectTarget() {
return this.subjectTarget;
}
/**
* @param value {@link #subject} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Identifies the patient, practitioner, device or any other resource that is the "focus" of this resource.)
*/
public Basic setSubjectTarget(Resource value) {
this.subjectTarget = value;
return this;
}
/**
* @return {@link #created} (Identifies when the resource was first created.). This is the underlying object with id, value and extensions. The accessor "getCreated" gives direct access to the value
*/
public DateType getCreatedElement() {
if (this.created == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create Basic.created");
else if (Configuration.doAutoCreate())
this.created = new DateType(); // bb
return this.created;
}
public boolean hasCreatedElement() {
return this.created != null && !this.created.isEmpty();
}
public boolean hasCreated() {
return this.created != null && !this.created.isEmpty();
}
/**
* @param value {@link #created} (Identifies when the resource was first created.). This is the underlying object with id, value and extensions. The accessor "getCreated" gives direct access to the value
*/
public Basic setCreatedElement(DateType value) {
this.created = value;
return this;
}
/**
* @return Identifies when the resource was first created.
*/
public Date getCreated() {
return this.created == null ? null : this.created.getValue();
}
/**
* @param value Identifies when the resource was first created.
*/
public Basic setCreated(Date value) {
if (value == null)
this.created = null;
else {
if (this.created == null)
this.created = new DateType();
this.created.setValue(value);
}
return this;
}
/**
* @return {@link #author} (Indicates who was responsible for creating the resource instance.)
*/
public Reference getAuthor() {
if (this.author == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create Basic.author");
else if (Configuration.doAutoCreate())
this.author = new Reference(); // cc
return this.author;
}
public boolean hasAuthor() {
return this.author != null && !this.author.isEmpty();
}
/**
* @param value {@link #author} (Indicates who was responsible for creating the resource instance.)
*/
public Basic setAuthor(Reference value) {
this.author = value;
return this;
}
/**
* @return {@link #author} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Indicates who was responsible for creating the resource instance.)
*/
public Resource getAuthorTarget() {
return this.authorTarget;
}
/**
* @param value {@link #author} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Indicates who was responsible for creating the resource instance.)
*/
public Basic setAuthorTarget(Resource value) {
this.authorTarget = value;
return this;
}
protected void listChildren(List<Property> childrenList) {
super.listChildren(childrenList);
childrenList.add(new Property("identifier", "Identifier", "Identifier assigned to the resource for business purposes, outside the context of FHIR.", 0, java.lang.Integer.MAX_VALUE, identifier));
childrenList.add(new Property("code", "CodeableConcept", "Identifies the 'type' of resource - equivalent to the resource name for other resources.", 0, java.lang.Integer.MAX_VALUE, code));
childrenList.add(new Property("subject", "Reference(Any)", "Identifies the patient, practitioner, device or any other resource that is the \"focus\" of this resource.", 0, java.lang.Integer.MAX_VALUE, subject));
childrenList.add(new Property("created", "date", "Identifies when the resource was first created.", 0, java.lang.Integer.MAX_VALUE, created));
childrenList.add(new Property("author", "Reference(Practitioner|Patient|RelatedPerson)", "Indicates who was responsible for creating the resource instance.", 0, java.lang.Integer.MAX_VALUE, author));
}
@Override
public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
switch (hash) {
case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
case -1867885268: /*subject*/ return this.subject == null ? new Base[0] : new Base[] {this.subject}; // Reference
case 1028554472: /*created*/ return this.created == null ? new Base[0] : new Base[] {this.created}; // DateType
case -1406328437: /*author*/ return this.author == null ? new Base[0] : new Base[] {this.author}; // Reference
default: return super.getProperty(hash, name, checkValid);
}
}
@Override
public void setProperty(int hash, String name, Base value) throws FHIRException {
switch (hash) {
case -1618432855: // identifier
this.getIdentifier().add(castToIdentifier(value)); // Identifier
break;
case 3059181: // code
this.code = castToCodeableConcept(value); // CodeableConcept
break;
case -1867885268: // subject
this.subject = castToReference(value); // Reference
break;
case 1028554472: // created
this.created = castToDate(value); // DateType
break;
case -1406328437: // author
this.author = castToReference(value); // Reference
break;
default: super.setProperty(hash, name, value);
}
}
@Override
public void setProperty(String name, Base value) throws FHIRException {
if (name.equals("identifier"))
this.getIdentifier().add(castToIdentifier(value));
else if (name.equals("code"))
this.code = castToCodeableConcept(value); // CodeableConcept
else if (name.equals("subject"))
this.subject = castToReference(value); // Reference
else if (name.equals("created"))
this.created = castToDate(value); // DateType
else if (name.equals("author"))
this.author = castToReference(value); // Reference
else
super.setProperty(name, value);
}
@Override
public Base makeProperty(int hash, String name) throws FHIRException {
switch (hash) {
case -1618432855: return addIdentifier(); // Identifier
case 3059181: return getCode(); // CodeableConcept
case -1867885268: return getSubject(); // Reference
case 1028554472: throw new FHIRException("Cannot make property created as it is not a complex type"); // DateType
case -1406328437: return getAuthor(); // Reference
default: return super.makeProperty(hash, name);
}
}
@Override
public Base addChild(String name) throws FHIRException {
if (name.equals("identifier")) {
return addIdentifier();
}
else if (name.equals("code")) {
this.code = new CodeableConcept();
return this.code;
}
else if (name.equals("subject")) {
this.subject = new Reference();
return this.subject;
}
else if (name.equals("created")) {
throw new FHIRException("Cannot call addChild on a primitive type Basic.created");
}
else if (name.equals("author")) {
this.author = new Reference();
return this.author;
}
else
return super.addChild(name);
}
public String fhirType() {
return "Basic";
}
public Basic copy() {
Basic dst = new Basic();
copyValues(dst);
if (identifier != null) {
dst.identifier = new ArrayList<Identifier>();
for (Identifier i : identifier)
dst.identifier.add(i.copy());
};
dst.code = code == null ? null : code.copy();
dst.subject = subject == null ? null : subject.copy();
dst.created = created == null ? null : created.copy();
dst.author = author == null ? null : author.copy();
return dst;
}
protected Basic typedCopy() {
return copy();
}
@Override
public boolean equalsDeep(Base other) {
if (!super.equalsDeep(other))
return false;
if (!(other instanceof Basic))
return false;
Basic o = (Basic) other;
return compareDeep(identifier, o.identifier, true) && compareDeep(code, o.code, true) && compareDeep(subject, o.subject, true)
&& compareDeep(created, o.created, true) && compareDeep(author, o.author, true);
}
@Override
public boolean equalsShallow(Base other) {
if (!super.equalsShallow(other))
return false;
if (!(other instanceof Basic))
return false;
Basic o = (Basic) other;
return compareValues(created, o.created, true);
}
public boolean isEmpty() {
return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (code == null || code.isEmpty())
&& (subject == null || subject.isEmpty()) && (created == null || created.isEmpty()) && (author == null || author.isEmpty())
;
}
@Override
public ResourceType getResourceType() {
return ResourceType.Basic;
}
/**
* Search parameter: <b>author</b>
* <p>
* Description: <b>Who created</b><br>
* Type: <b>reference</b><br>
* Path: <b>Basic.author</b><br>
* </p>
*/
@SearchParamDefinition(name="author", path="Basic.author", description="Who created", type="reference" )
public static final String SP_AUTHOR = "author";
/**
* <b>Fluent Client</b> search parameter constant for <b>author</b>
* <p>
* Description: <b>Who created</b><br>
* Type: <b>reference</b><br>
* Path: <b>Basic.author</b><br>
* </p>
*/
public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam AUTHOR = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_AUTHOR);
/**
* Constant for fluent queries to be used to add include statements. Specifies
* the path value of "<b>Basic:author</b>".
*/
public static final ca.uhn.fhir.model.api.Include INCLUDE_AUTHOR = new ca.uhn.fhir.model.api.Include("Basic:author").toLocked();
/**
* Search parameter: <b>patient</b>
* <p>
* Description: <b>Identifies the focus of this resource</b><br>
* Type: <b>reference</b><br>
* Path: <b>Basic.subject</b><br>
* </p>
*/
@SearchParamDefinition(name="patient", path="Basic.subject", description="Identifies the focus of this resource", type="reference" )
public static final String SP_PATIENT = "patient";
/**
* <b>Fluent Client</b> search parameter constant for <b>patient</b>
* <p>
* Description: <b>Identifies the focus of this resource</b><br>
* Type: <b>reference</b><br>
* Path: <b>Basic.subject</b><br>
* </p>
*/
public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
/**
* Constant for fluent queries to be used to add include statements. Specifies
* the path value of "<b>Basic:patient</b>".
*/
public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("Basic:patient").toLocked();
/**
* Search parameter: <b>created</b>
* <p>
* Description: <b>When created</b><br>
* Type: <b>date</b><br>
* Path: <b>Basic.created</b><br>
* </p>
*/
@SearchParamDefinition(name="created", path="Basic.created", description="When created", type="date" )
public static final String SP_CREATED = "created";
/**
* <b>Fluent Client</b> search parameter constant for <b>created</b>
* <p>
* Description: <b>When created</b><br>
* Type: <b>date</b><br>
* Path: <b>Basic.created</b><br>
* </p>
*/
public static final ca.uhn.fhir.rest.gclient.DateClientParam CREATED = new ca.uhn.fhir.rest.gclient.DateClientParam(SP_CREATED);
/**
* Search parameter: <b>subject</b>
* <p>
* Description: <b>Identifies the focus of this resource</b><br>
* Type: <b>reference</b><br>
* Path: <b>Basic.subject</b><br>
* </p>
*/
@SearchParamDefinition(name="subject", path="Basic.subject", description="Identifies the focus of this resource", type="reference" )
public static final String SP_SUBJECT = "subject";
/**
* <b>Fluent Client</b> search parameter constant for <b>subject</b>
* <p>
* Description: <b>Identifies the focus of this resource</b><br>
* Type: <b>reference</b><br>
* Path: <b>Basic.subject</b><br>
* </p>
*/
public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam SUBJECT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_SUBJECT);
/**
* Constant for fluent queries to be used to add include statements. Specifies
* the path value of "<b>Basic:subject</b>".
*/
public static final ca.uhn.fhir.model.api.Include INCLUDE_SUBJECT = new ca.uhn.fhir.model.api.Include("Basic:subject").toLocked();
/**
* Search parameter: <b>code</b>
* <p>
* Description: <b>Kind of Resource</b><br>
* Type: <b>token</b><br>
* Path: <b>Basic.code</b><br>
* </p>
*/
@SearchParamDefinition(name="code", path="Basic.code", description="Kind of Resource", type="token" )
public static final String SP_CODE = "code";
/**
* <b>Fluent Client</b> search parameter constant for <b>code</b>
* <p>
* Description: <b>Kind of Resource</b><br>
* Type: <b>token</b><br>
* Path: <b>Basic.code</b><br>
* </p>
*/
public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
/**
* Search parameter: <b>identifier</b>
* <p>
* Description: <b>Business identifier</b><br>
* Type: <b>token</b><br>
* Path: <b>Basic.identifier</b><br>
* </p>
*/
@SearchParamDefinition(name="identifier", path="Basic.identifier", description="Business identifier", type="token" )
public static final String SP_IDENTIFIER = "identifier";
/**
* <b>Fluent Client</b> search parameter constant for <b>identifier</b>
* <p>
* Description: <b>Business identifier</b><br>
* Type: <b>token</b><br>
* Path: <b>Basic.identifier</b><br>
* </p>
*/
public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
}

View File

@ -0,0 +1,301 @@
package org.hl7.fhir.dstu2016may.model;
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
import java.util.List;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.instance.model.api.IBaseBinary;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
/**
* A binary resource can contain any content, whether text, image, pdf, zip archive, etc.
*/
@ResourceDef(name="Binary", profile="http://hl7.org/fhir/Profile/Binary")
public class Binary extends BaseBinary implements IBaseBinary {
/**
* MimeType of the binary content represented as a standard MimeType (BCP 13).
*/
@Child(name = "contentType", type = {CodeType.class}, order=0, min=1, max=1, modifier=false, summary=true)
@Description(shortDefinition="MimeType of the binary content", formalDefinition="MimeType of the binary content represented as a standard MimeType (BCP 13)." )
protected CodeType contentType;
/**
* The actual content, base64 encoded.
*/
@Child(name = "content", type = {Base64BinaryType.class}, order=1, min=1, max=1, modifier=false, summary=true)
@Description(shortDefinition="The actual content", formalDefinition="The actual content, base64 encoded." )
protected Base64BinaryType content;
private static final long serialVersionUID = 974764407L;
/**
* Constructor
*/
public Binary() {
super();
}
/**
* Constructor
*/
public Binary(CodeType contentType, Base64BinaryType content) {
super();
this.contentType = contentType;
this.content = content;
}
/**
* @return {@link #contentType} (MimeType of the binary content represented as a standard MimeType (BCP 13).). This is the underlying object with id, value and extensions. The accessor "getContentType" gives direct access to the value
*/
public CodeType getContentTypeElement() {
if (this.contentType == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create Binary.contentType");
else if (Configuration.doAutoCreate())
this.contentType = new CodeType(); // bb
return this.contentType;
}
public boolean hasContentTypeElement() {
return this.contentType != null && !this.contentType.isEmpty();
}
public boolean hasContentType() {
return this.contentType != null && !this.contentType.isEmpty();
}
/**
* @param value {@link #contentType} (MimeType of the binary content represented as a standard MimeType (BCP 13).). This is the underlying object with id, value and extensions. The accessor "getContentType" gives direct access to the value
*/
public Binary setContentTypeElement(CodeType value) {
this.contentType = value;
return this;
}
/**
* @return MimeType of the binary content represented as a standard MimeType (BCP 13).
*/
public String getContentType() {
return this.contentType == null ? null : this.contentType.getValue();
}
/**
* @param value MimeType of the binary content represented as a standard MimeType (BCP 13).
*/
public Binary setContentType(String value) {
if (this.contentType == null)
this.contentType = new CodeType();
this.contentType.setValue(value);
return this;
}
/**
* @return {@link #content} (The actual content, base64 encoded.). This is the underlying object with id, value and extensions. The accessor "getContent" gives direct access to the value
*/
public Base64BinaryType getContentElement() {
if (this.content == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create Binary.content");
else if (Configuration.doAutoCreate())
this.content = new Base64BinaryType(); // bb
return this.content;
}
public boolean hasContentElement() {
return this.content != null && !this.content.isEmpty();
}
public boolean hasContent() {
return this.content != null && !this.content.isEmpty();
}
/**
* @param value {@link #content} (The actual content, base64 encoded.). This is the underlying object with id, value and extensions. The accessor "getContent" gives direct access to the value
*/
public Binary setContentElement(Base64BinaryType value) {
this.content = value;
return this;
}
/**
* @return The actual content, base64 encoded.
*/
public byte[] getContent() {
return this.content == null ? null : this.content.getValue();
}
/**
* @param value The actual content, base64 encoded.
*/
public Binary setContent(byte[] value) {
if (this.content == null)
this.content = new Base64BinaryType();
this.content.setValue(value);
return this;
}
protected void listChildren(List<Property> childrenList) {
super.listChildren(childrenList);
childrenList.add(new Property("contentType", "code", "MimeType of the binary content represented as a standard MimeType (BCP 13).", 0, java.lang.Integer.MAX_VALUE, contentType));
childrenList.add(new Property("content", "base64Binary", "The actual content, base64 encoded.", 0, java.lang.Integer.MAX_VALUE, content));
}
@Override
public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
switch (hash) {
case -389131437: /*contentType*/ return this.contentType == null ? new Base[0] : new Base[] {this.contentType}; // CodeType
case 951530617: /*content*/ return this.content == null ? new Base[0] : new Base[] {this.content}; // Base64BinaryType
default: return super.getProperty(hash, name, checkValid);
}
}
@Override
public void setProperty(int hash, String name, Base value) throws FHIRException {
switch (hash) {
case -389131437: // contentType
this.contentType = castToCode(value); // CodeType
break;
case 951530617: // content
this.content = castToBase64Binary(value); // Base64BinaryType
break;
default: super.setProperty(hash, name, value);
}
}
@Override
public void setProperty(String name, Base value) throws FHIRException {
if (name.equals("contentType"))
this.contentType = castToCode(value); // CodeType
else if (name.equals("content"))
this.content = castToBase64Binary(value); // Base64BinaryType
else
super.setProperty(name, value);
}
@Override
public Base makeProperty(int hash, String name) throws FHIRException {
switch (hash) {
case -389131437: throw new FHIRException("Cannot make property contentType as it is not a complex type"); // CodeType
case 951530617: throw new FHIRException("Cannot make property content as it is not a complex type"); // Base64BinaryType
default: return super.makeProperty(hash, name);
}
}
@Override
public Base addChild(String name) throws FHIRException {
if (name.equals("contentType")) {
throw new FHIRException("Cannot call addChild on a primitive type Binary.contentType");
}
else if (name.equals("content")) {
throw new FHIRException("Cannot call addChild on a primitive type Binary.content");
}
else
return super.addChild(name);
}
public String fhirType() {
return "Binary";
}
public Binary copy() {
Binary dst = new Binary();
copyValues(dst);
dst.contentType = contentType == null ? null : contentType.copy();
dst.content = content == null ? null : content.copy();
return dst;
}
protected Binary typedCopy() {
return copy();
}
@Override
public boolean equalsDeep(Base other) {
if (!super.equalsDeep(other))
return false;
if (!(other instanceof Binary))
return false;
Binary o = (Binary) other;
return compareDeep(contentType, o.contentType, true) && compareDeep(content, o.content, true);
}
@Override
public boolean equalsShallow(Base other) {
if (!super.equalsShallow(other))
return false;
if (!(other instanceof Binary))
return false;
Binary o = (Binary) other;
return compareValues(contentType, o.contentType, true) && compareValues(content, o.content, true);
}
public boolean isEmpty() {
return super.isEmpty() && (contentType == null || contentType.isEmpty()) && (content == null || content.isEmpty())
;
}
@Override
public ResourceType getResourceType() {
return ResourceType.Binary;
}
/**
* Search parameter: <b>contenttype</b>
* <p>
* Description: <b>MimeType of the binary content</b><br>
* Type: <b>token</b><br>
* Path: <b>Binary.contentType</b><br>
* </p>
*/
@SearchParamDefinition(name="contenttype", path="Binary.contentType", description="MimeType of the binary content", type="token" )
public static final String SP_CONTENTTYPE = "contenttype";
/**
* <b>Fluent Client</b> search parameter constant for <b>contenttype</b>
* <p>
* Description: <b>MimeType of the binary content</b><br>
* Type: <b>token</b><br>
* Path: <b>Binary.contentType</b><br>
* </p>
*/
public static final ca.uhn.fhir.rest.gclient.TokenClientParam CONTENTTYPE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CONTENTTYPE);
}

View File

@ -0,0 +1,592 @@
package org.hl7.fhir.dstu2016may.model;
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
import java.util.ArrayList;
import java.util.List;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.utilities.Utilities;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
/**
* Record details about the anatomical location of a specimen or body part. This resource may be used when a coded concept does not provide the necessary detail needed for the use case.
*/
@ResourceDef(name="BodySite", profile="http://hl7.org/fhir/Profile/BodySite")
public class BodySite extends DomainResource {
/**
* The person to which the body site belongs.
*/
@Child(name = "patient", type = {Patient.class}, order=0, min=1, max=1, modifier=false, summary=true)
@Description(shortDefinition="Patient", formalDefinition="The person to which the body site belongs." )
protected Reference patient;
/**
* The actual object that is the target of the reference (The person to which the body site belongs.)
*/
protected Patient patientTarget;
/**
* Identifier for this instance of the anatomical location.
*/
@Child(name = "identifier", type = {Identifier.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
@Description(shortDefinition="Bodysite identifier", formalDefinition="Identifier for this instance of the anatomical location." )
protected List<Identifier> identifier;
/**
* Named anatomical location - ideally coded where possible.
*/
@Child(name = "code", type = {CodeableConcept.class}, order=2, min=0, max=1, modifier=false, summary=true)
@Description(shortDefinition="Named anatomical location", formalDefinition="Named anatomical location - ideally coded where possible." )
protected CodeableConcept code;
/**
* Modifier to refine the anatomical location. These include modifiers for laterality, relative location, directionality, number, and plane.
*/
@Child(name = "modifier", type = {CodeableConcept.class}, order=3, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
@Description(shortDefinition="Modification to location code", formalDefinition="Modifier to refine the anatomical location. These include modifiers for laterality, relative location, directionality, number, and plane." )
protected List<CodeableConcept> modifier;
/**
* Description of anatomical location.
*/
@Child(name = "description", type = {StringType.class}, order=4, min=0, max=1, modifier=false, summary=true)
@Description(shortDefinition="The Description of anatomical location", formalDefinition="Description of anatomical location." )
protected StringType description;
/**
* Image or images used to identify a location.
*/
@Child(name = "image", type = {Attachment.class}, order=5, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false)
@Description(shortDefinition="Attached images", formalDefinition="Image or images used to identify a location." )
protected List<Attachment> image;
private static final long serialVersionUID = 1568109920L;
/**
* Constructor
*/
public BodySite() {
super();
}
/**
* Constructor
*/
public BodySite(Reference patient) {
super();
this.patient = patient;
}
/**
* @return {@link #patient} (The person to which the body site belongs.)
*/
public Reference getPatient() {
if (this.patient == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create BodySite.patient");
else if (Configuration.doAutoCreate())
this.patient = new Reference(); // cc
return this.patient;
}
public boolean hasPatient() {
return this.patient != null && !this.patient.isEmpty();
}
/**
* @param value {@link #patient} (The person to which the body site belongs.)
*/
public BodySite setPatient(Reference value) {
this.patient = value;
return this;
}
/**
* @return {@link #patient} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The person to which the body site belongs.)
*/
public Patient getPatientTarget() {
if (this.patientTarget == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create BodySite.patient");
else if (Configuration.doAutoCreate())
this.patientTarget = new Patient(); // aa
return this.patientTarget;
}
/**
* @param value {@link #patient} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The person to which the body site belongs.)
*/
public BodySite setPatientTarget(Patient value) {
this.patientTarget = value;
return this;
}
/**
* @return {@link #identifier} (Identifier for this instance of the anatomical location.)
*/
public List<Identifier> getIdentifier() {
if (this.identifier == null)
this.identifier = new ArrayList<Identifier>();
return this.identifier;
}
public boolean hasIdentifier() {
if (this.identifier == null)
return false;
for (Identifier item : this.identifier)
if (!item.isEmpty())
return true;
return false;
}
/**
* @return {@link #identifier} (Identifier for this instance of the anatomical location.)
*/
// syntactic sugar
public Identifier addIdentifier() { //3
Identifier t = new Identifier();
if (this.identifier == null)
this.identifier = new ArrayList<Identifier>();
this.identifier.add(t);
return t;
}
// syntactic sugar
public BodySite addIdentifier(Identifier t) { //3
if (t == null)
return this;
if (this.identifier == null)
this.identifier = new ArrayList<Identifier>();
this.identifier.add(t);
return this;
}
/**
* @return {@link #code} (Named anatomical location - ideally coded where possible.)
*/
public CodeableConcept getCode() {
if (this.code == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create BodySite.code");
else if (Configuration.doAutoCreate())
this.code = new CodeableConcept(); // cc
return this.code;
}
public boolean hasCode() {
return this.code != null && !this.code.isEmpty();
}
/**
* @param value {@link #code} (Named anatomical location - ideally coded where possible.)
*/
public BodySite setCode(CodeableConcept value) {
this.code = value;
return this;
}
/**
* @return {@link #modifier} (Modifier to refine the anatomical location. These include modifiers for laterality, relative location, directionality, number, and plane.)
*/
public List<CodeableConcept> getModifier() {
if (this.modifier == null)
this.modifier = new ArrayList<CodeableConcept>();
return this.modifier;
}
public boolean hasModifier() {
if (this.modifier == null)
return false;
for (CodeableConcept item : this.modifier)
if (!item.isEmpty())
return true;
return false;
}
/**
* @return {@link #modifier} (Modifier to refine the anatomical location. These include modifiers for laterality, relative location, directionality, number, and plane.)
*/
// syntactic sugar
public CodeableConcept addModifier() { //3
CodeableConcept t = new CodeableConcept();
if (this.modifier == null)
this.modifier = new ArrayList<CodeableConcept>();
this.modifier.add(t);
return t;
}
// syntactic sugar
public BodySite addModifier(CodeableConcept t) { //3
if (t == null)
return this;
if (this.modifier == null)
this.modifier = new ArrayList<CodeableConcept>();
this.modifier.add(t);
return this;
}
/**
* @return {@link #description} (Description of anatomical location.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
*/
public StringType getDescriptionElement() {
if (this.description == null)
if (Configuration.errorOnAutoCreate())
throw new Error("Attempt to auto-create BodySite.description");
else if (Configuration.doAutoCreate())
this.description = new StringType(); // bb
return this.description;
}
public boolean hasDescriptionElement() {
return this.description != null && !this.description.isEmpty();
}
public boolean hasDescription() {
return this.description != null && !this.description.isEmpty();
}
/**
* @param value {@link #description} (Description of anatomical location.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
*/
public BodySite setDescriptionElement(StringType value) {
this.description = value;
return this;
}
/**
* @return Description of anatomical location.
*/
public String getDescription() {
return this.description == null ? null : this.description.getValue();
}
/**
* @param value Description of anatomical location.
*/
public BodySite setDescription(String value) {
if (Utilities.noString(value))
this.description = null;
else {
if (this.description == null)
this.description = new StringType();
this.description.setValue(value);
}
return this;
}
/**
* @return {@link #image} (Image or images used to identify a location.)
*/
public List<Attachment> getImage() {
if (this.image == null)
this.image = new ArrayList<Attachment>();
return this.image;
}
public boolean hasImage() {
if (this.image == null)
return false;
for (Attachment item : this.image)
if (!item.isEmpty())
return true;
return false;
}
/**
* @return {@link #image} (Image or images used to identify a location.)
*/
// syntactic sugar
public Attachment addImage() { //3
Attachment t = new Attachment();
if (this.image == null)
this.image = new ArrayList<Attachment>();
this.image.add(t);
return t;
}
// syntactic sugar
public BodySite addImage(Attachment t) { //3
if (t == null)
return this;
if (this.image == null)
this.image = new ArrayList<Attachment>();
this.image.add(t);
return this;
}
protected void listChildren(List<Property> childrenList) {
super.listChildren(childrenList);
childrenList.add(new Property("patient", "Reference(Patient)", "The person to which the body site belongs.", 0, java.lang.Integer.MAX_VALUE, patient));
childrenList.add(new Property("identifier", "Identifier", "Identifier for this instance of the anatomical location.", 0, java.lang.Integer.MAX_VALUE, identifier));
childrenList.add(new Property("code", "CodeableConcept", "Named anatomical location - ideally coded where possible.", 0, java.lang.Integer.MAX_VALUE, code));
childrenList.add(new Property("modifier", "CodeableConcept", "Modifier to refine the anatomical location. These include modifiers for laterality, relative location, directionality, number, and plane.", 0, java.lang.Integer.MAX_VALUE, modifier));
childrenList.add(new Property("description", "string", "Description of anatomical location.", 0, java.lang.Integer.MAX_VALUE, description));
childrenList.add(new Property("image", "Attachment", "Image or images used to identify a location.", 0, java.lang.Integer.MAX_VALUE, image));
}
@Override
public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
switch (hash) {
case -791418107: /*patient*/ return this.patient == null ? new Base[0] : new Base[] {this.patient}; // Reference
case -1618432855: /*identifier*/ return this.identifier == null ? new Base[0] : this.identifier.toArray(new Base[this.identifier.size()]); // Identifier
case 3059181: /*code*/ return this.code == null ? new Base[0] : new Base[] {this.code}; // CodeableConcept
case -615513385: /*modifier*/ return this.modifier == null ? new Base[0] : this.modifier.toArray(new Base[this.modifier.size()]); // CodeableConcept
case -1724546052: /*description*/ return this.description == null ? new Base[0] : new Base[] {this.description}; // StringType
case 100313435: /*image*/ return this.image == null ? new Base[0] : this.image.toArray(new Base[this.image.size()]); // Attachment
default: return super.getProperty(hash, name, checkValid);
}
}
@Override
public void setProperty(int hash, String name, Base value) throws FHIRException {
switch (hash) {
case -791418107: // patient
this.patient = castToReference(value); // Reference
break;
case -1618432855: // identifier
this.getIdentifier().add(castToIdentifier(value)); // Identifier
break;
case 3059181: // code
this.code = castToCodeableConcept(value); // CodeableConcept
break;
case -615513385: // modifier
this.getModifier().add(castToCodeableConcept(value)); // CodeableConcept
break;
case -1724546052: // description
this.description = castToString(value); // StringType
break;
case 100313435: // image
this.getImage().add(castToAttachment(value)); // Attachment
break;
default: super.setProperty(hash, name, value);
}
}
@Override
public void setProperty(String name, Base value) throws FHIRException {
if (name.equals("patient"))
this.patient = castToReference(value); // Reference
else if (name.equals("identifier"))
this.getIdentifier().add(castToIdentifier(value));
else if (name.equals("code"))
this.code = castToCodeableConcept(value); // CodeableConcept
else if (name.equals("modifier"))
this.getModifier().add(castToCodeableConcept(value));
else if (name.equals("description"))
this.description = castToString(value); // StringType
else if (name.equals("image"))
this.getImage().add(castToAttachment(value));
else
super.setProperty(name, value);
}
@Override
public Base makeProperty(int hash, String name) throws FHIRException {
switch (hash) {
case -791418107: return getPatient(); // Reference
case -1618432855: return addIdentifier(); // Identifier
case 3059181: return getCode(); // CodeableConcept
case -615513385: return addModifier(); // CodeableConcept
case -1724546052: throw new FHIRException("Cannot make property description as it is not a complex type"); // StringType
case 100313435: return addImage(); // Attachment
default: return super.makeProperty(hash, name);
}
}
@Override
public Base addChild(String name) throws FHIRException {
if (name.equals("patient")) {
this.patient = new Reference();
return this.patient;
}
else if (name.equals("identifier")) {
return addIdentifier();
}
else if (name.equals("code")) {
this.code = new CodeableConcept();
return this.code;
}
else if (name.equals("modifier")) {
return addModifier();
}
else if (name.equals("description")) {
throw new FHIRException("Cannot call addChild on a primitive type BodySite.description");
}
else if (name.equals("image")) {
return addImage();
}
else
return super.addChild(name);
}
public String fhirType() {
return "BodySite";
}
public BodySite copy() {
BodySite dst = new BodySite();
copyValues(dst);
dst.patient = patient == null ? null : patient.copy();
if (identifier != null) {
dst.identifier = new ArrayList<Identifier>();
for (Identifier i : identifier)
dst.identifier.add(i.copy());
};
dst.code = code == null ? null : code.copy();
if (modifier != null) {
dst.modifier = new ArrayList<CodeableConcept>();
for (CodeableConcept i : modifier)
dst.modifier.add(i.copy());
};
dst.description = description == null ? null : description.copy();
if (image != null) {
dst.image = new ArrayList<Attachment>();
for (Attachment i : image)
dst.image.add(i.copy());
};
return dst;
}
protected BodySite typedCopy() {
return copy();
}
@Override
public boolean equalsDeep(Base other) {
if (!super.equalsDeep(other))
return false;
if (!(other instanceof BodySite))
return false;
BodySite o = (BodySite) other;
return compareDeep(patient, o.patient, true) && compareDeep(identifier, o.identifier, true) && compareDeep(code, o.code, true)
&& compareDeep(modifier, o.modifier, true) && compareDeep(description, o.description, true) && compareDeep(image, o.image, true)
;
}
@Override
public boolean equalsShallow(Base other) {
if (!super.equalsShallow(other))
return false;
if (!(other instanceof BodySite))
return false;
BodySite o = (BodySite) other;
return compareValues(description, o.description, true);
}
public boolean isEmpty() {
return super.isEmpty() && (patient == null || patient.isEmpty()) && (identifier == null || identifier.isEmpty())
&& (code == null || code.isEmpty()) && (modifier == null || modifier.isEmpty()) && (description == null || description.isEmpty())
&& (image == null || image.isEmpty());
}
@Override
public ResourceType getResourceType() {
return ResourceType.BodySite;
}
/**
* Search parameter: <b>patient</b>
* <p>
* Description: <b>Patient to whom bodysite belongs</b><br>
* Type: <b>reference</b><br>
* Path: <b>BodySite.patient</b><br>
* </p>
*/
@SearchParamDefinition(name="patient", path="BodySite.patient", description="Patient to whom bodysite belongs", type="reference" )
public static final String SP_PATIENT = "patient";
/**
* <b>Fluent Client</b> search parameter constant for <b>patient</b>
* <p>
* Description: <b>Patient to whom bodysite belongs</b><br>
* Type: <b>reference</b><br>
* Path: <b>BodySite.patient</b><br>
* </p>
*/
public static final ca.uhn.fhir.rest.gclient.ReferenceClientParam PATIENT = new ca.uhn.fhir.rest.gclient.ReferenceClientParam(SP_PATIENT);
/**
* Constant for fluent queries to be used to add include statements. Specifies
* the path value of "<b>BodySite:patient</b>".
*/
public static final ca.uhn.fhir.model.api.Include INCLUDE_PATIENT = new ca.uhn.fhir.model.api.Include("BodySite:patient").toLocked();
/**
* Search parameter: <b>code</b>
* <p>
* Description: <b>Named anatomical location</b><br>
* Type: <b>token</b><br>
* Path: <b>BodySite.code</b><br>
* </p>
*/
@SearchParamDefinition(name="code", path="BodySite.code", description="Named anatomical location", type="token" )
public static final String SP_CODE = "code";
/**
* <b>Fluent Client</b> search parameter constant for <b>code</b>
* <p>
* Description: <b>Named anatomical location</b><br>
* Type: <b>token</b><br>
* Path: <b>BodySite.code</b><br>
* </p>
*/
public static final ca.uhn.fhir.rest.gclient.TokenClientParam CODE = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_CODE);
/**
* Search parameter: <b>identifier</b>
* <p>
* Description: <b>Identifier for this instance of the anatomical location</b><br>
* Type: <b>token</b><br>
* Path: <b>BodySite.identifier</b><br>
* </p>
*/
@SearchParamDefinition(name="identifier", path="BodySite.identifier", description="Identifier for this instance of the anatomical location", type="token" )
public static final String SP_IDENTIFIER = "identifier";
/**
* <b>Fluent Client</b> search parameter constant for <b>identifier</b>
* <p>
* Description: <b>Identifier for this instance of the anatomical location</b><br>
* Type: <b>token</b><br>
* Path: <b>BodySite.identifier</b><br>
* </p>
*/
public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
}

View File

@ -0,0 +1,102 @@
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/**
*
*/
package org.hl7.fhir.dstu2016may.model;
import org.hl7.fhir.instance.model.api.IBaseBooleanDatatype;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
/**
* Primitive type "boolean" in FHIR "true" or "false"
*/
@DatatypeDef(name = "boolean")
public class BooleanType extends PrimitiveType<Boolean> implements IBaseBooleanDatatype {
private static final long serialVersionUID = 3L;
public BooleanType() {
super();
}
public BooleanType(boolean theBoolean) {
super();
setValue(theBoolean);
}
public BooleanType(Boolean theBoolean) {
super();
setValue(theBoolean);
}
public BooleanType(String value) {
super();
setValueAsString(value);
}
/**
* Returns the value of this type as a primitive boolean.
*
* @return Returns the value of this type as a primitive boolean.
* @throws NullPointerException
* If the value is not set
*/
public boolean booleanValue() {
return getValue().booleanValue();
}
public BooleanType copy() {
return new BooleanType(getValue());
}
protected String encode(Boolean theValue) {
if (Boolean.TRUE.equals(theValue)) {
return "true";
} else {
return "false";
}
}
public String fhirType() {
return "boolean";
}
protected Boolean parse(String theValue) {
String value = theValue.trim();
if ("true".equals(value)) {
return Boolean.TRUE;
} else if ("false".equals(value)) {
return Boolean.FALSE;
} else {
throw new IllegalArgumentException("Invalid boolean string: '" + theValue + "'");
}
}
}

Some files were not shown because too many files have changed in this diff Show More