Merge branch 'master' of https://github.com/jamesagnew/hapi-fhir.git
This commit is contained in:
commit
0c0a014454
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="hapi-fhir-structures-dstu/target/generated-sources/tinder"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>0.8-SNAPSHOT</version>
|
||||
<version>0.9-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -17,12 +17,12 @@
|
|||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-base</artifactId>
|
||||
<version>0.8-SNAPSHOT</version>
|
||||
<version>0.9-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu</artifactId>
|
||||
<version>0.8-SNAPSHOT</version>
|
||||
<artifactId>hapi-fhir-structures-dstu2</artifactId>
|
||||
<version>0.9-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
<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-fhir</artifactId>
|
||||
<version>0.8-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>hapi-fhir-base-examples</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HAPI FHIR - Examples (for site)</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-base</artifactId>
|
||||
<version>0.8-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu</artifactId>
|
||||
<version>0.8-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit_version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -1,61 +0,0 @@
|
|||
<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-fhir</artifactId>
|
||||
<version>0.8-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>hapi-fhir-base-examples</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HAPI FHIR - Examples (for site)</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-base</artifactId>
|
||||
<version>0.8-SNAPSHOT</version>
|
||||
<<<<<<< HEAD:hapi-fhir-base/examples/pom.xml
|
||||
=======
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
>>>>>>> d22a35788f57e9f7ce64bc8afc2ee7eaf29d94f2:examples/pom.xml.orig
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu</artifactId>
|
||||
<version>0.8-SNAPSHOT</version>
|
||||
<<<<<<< HEAD:hapi-fhir-base/examples/pom.xml
|
||||
=======
|
||||
>>>>>>> versions
|
||||
>>>>>>> d22a35788f57e9f7ce64bc8afc2ee7eaf29d94f2:examples/pom.xml.orig
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit_version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -5,10 +5,10 @@ import java.io.IOException;
|
|||
import java.util.List;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
|
||||
import ca.uhn.fhir.model.dstu.resource.Organization;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.composite.IdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Organization;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.rest.annotation.RequiredParam;
|
||||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.rest.client.api.IRestfulClient;
|
||||
|
@ -57,7 +57,7 @@ public class CompleteExampleClient {
|
|||
Organization org = (Organization) managingRef.loadResource(client);
|
||||
|
||||
// Print organization name
|
||||
System.out.println(org.getName().getValue());
|
||||
System.out.println(org.getName());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package example;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.parser.IParser;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class Dstu2Examples {
|
||||
private Collection<IResourceProvider> resourceProviderList;
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Dstu2Examples().getResourceTags();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void getResourceTags() {
|
||||
// START SNIPPET: context
|
||||
// Create a "dev" context, which supports DSTU2
|
||||
FhirContext ctx = FhirContext.forDev();
|
||||
|
||||
// This parser supports DSTU2
|
||||
IParser parser = ctx.newJsonParser();
|
||||
|
||||
// This client supports DSTU2
|
||||
IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu2");
|
||||
// END SNIPPET: context
|
||||
}
|
||||
|
||||
|
||||
// START SNIPPET: server
|
||||
public class MyServer extends RestfulServer
|
||||
{
|
||||
|
||||
@Override
|
||||
protected void initialize() throws ServletException {
|
||||
|
||||
// In your initialize method, assign a DEV FhirContext. This
|
||||
// is all that is required in order to put the server
|
||||
// into DSTU2 mode
|
||||
setFhirContext(FhirContext.forDev());
|
||||
|
||||
// Then set resource providers as normal, and do any other
|
||||
// configuration you need to do.
|
||||
setResourceProviders(resourceProviderList);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// END SNIPPET: server
|
||||
|
||||
}
|
|
@ -1,18 +1,17 @@
|
|||
package example;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.rest.annotation.RequiredParam;
|
||||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
|
||||
@SuppressWarnings(value= {"serial","unused"})
|
||||
@SuppressWarnings(value= {"serial"})
|
||||
public class ExampleProviders {
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package example;
|
|||
import java.util.List;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
|
|
@ -5,9 +5,9 @@ import java.util.List;
|
|||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.ExtensionDt;
|
||||
import ca.uhn.fhir.model.dstu.composite.HumanNameDt;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu.valueset.IdentifierUseEnum;
|
||||
import ca.uhn.fhir.model.dstu2.composite.HumanNameDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.IdentifierUseEnum;
|
||||
import ca.uhn.fhir.model.primitive.DateTimeDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
|
@ -21,7 +21,7 @@ public static void main(String[] args) throws DataFormatException, IOException {
|
|||
// START SNIPPET: resourceExtension
|
||||
// Create an example patient
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier(IdentifierUseEnum.OFFICIAL, "urn:example", "7000135", null);
|
||||
patient.addIdentifier().setUse(IdentifierUseEnum.OFFICIAL).setSystem("urn:example").setValue("7000135");
|
||||
|
||||
// Create an extension
|
||||
ExtensionDt ext = new ExtensionDt();
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
package example;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu.composite.HumanNameDt;
|
||||
import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu.resource.Observation;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu.valueset.NameUseEnum;
|
||||
import ca.uhn.fhir.model.primitive.CodeDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.dstu2.composite.HumanNameDt;
|
||||
import ca.uhn.fhir.model.dstu2.composite.IdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Observation;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.NameUseEnum;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import ca.uhn.fhir.parser.IParser;
|
||||
|
||||
|
@ -16,7 +14,7 @@ public class FhirContextIntro {
|
|||
@SuppressWarnings("unused")
|
||||
public static void creatingContext() {
|
||||
// START SNIPPET: creatingContext
|
||||
FhirContext ctx = new FhirContext();
|
||||
FhirContext ctx = FhirContext.forDstu1();
|
||||
// END SNIPPET: creatingContext
|
||||
|
||||
}
|
||||
|
@ -84,7 +82,7 @@ System.out.println(encoded);
|
|||
|
||||
|
||||
public static void parseMsg() {
|
||||
FhirContext ctx = new FhirContext(Patient.class, Observation.class);
|
||||
FhirContext ctx = FhirContext.forDstu1();
|
||||
|
||||
//START SNIPPET: parseMsg
|
||||
// The following is an example Patient resource
|
||||
|
@ -103,16 +101,14 @@ IParser parser = ctx.newXmlParser();
|
|||
Patient patient = parser.parseResource(Patient.class, msgString);
|
||||
|
||||
// The patient object has accessor methods to retrieve all of the
|
||||
// data which has been parsed into the instance. All of the
|
||||
// FHIR datatypes are represented by classes which end in "Dt".
|
||||
StringDt patientId = patient.getIdentifier().get(0).getValue();
|
||||
StringDt familyName = patient.getName().get(0).getFamily().get(0);
|
||||
CodeDt gender = patient.getGender().getCoding().get(0).getCode();
|
||||
// data which has been parsed into the instance.
|
||||
String patientId = patient.getIdentifier().get(0).getValue();
|
||||
String familyName = patient.getName().get(0).getFamily().get(0).getValue();
|
||||
String gender = patient.getGender();
|
||||
|
||||
// The various datatype classes have accessors called getValue()
|
||||
System.out.println(patientId.getValue()); // PRP1660
|
||||
System.out.println(familyName.getValue()); // Cardinal
|
||||
System.out.println(gender.getValue()); // M
|
||||
System.out.println(patientId); // PRP1660
|
||||
System.out.println(familyName); // Cardinal
|
||||
System.out.println(gender); // M
|
||||
//END SNIPPET: parseMsg
|
||||
|
||||
}
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
package example;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
||||
import ca.uhn.fhir.model.dstu.composite.CodingDt;
|
||||
import ca.uhn.fhir.model.dstu.composite.HumanNameDt;
|
||||
import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu.composite.PeriodDt;
|
||||
import ca.uhn.fhir.model.dstu.composite.QuantityDt;
|
||||
import ca.uhn.fhir.model.dstu.resource.Observation;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu.valueset.AdministrativeGenderCodesEnum;
|
||||
import ca.uhn.fhir.model.dstu2.composite.CodingDt;
|
||||
import ca.uhn.fhir.model.dstu2.composite.HumanNameDt;
|
||||
import ca.uhn.fhir.model.dstu2.composite.IdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu2.composite.PeriodDt;
|
||||
import ca.uhn.fhir.model.dstu2.composite.QuantityDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Observation;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.AdministrativeGenderEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.MaritalStatusCodesEnum;
|
||||
import ca.uhn.fhir.model.primitive.DateTimeDt;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
|
@ -28,8 +30,8 @@ public class FhirDataModel {
|
|||
|
||||
// The InstantDt also lets you work with the instant as a Java Date
|
||||
// object or as a FHIR String.
|
||||
Date date = obs.getIssued().getValue(); // A date object
|
||||
String dateString = obs.getIssued().getValueAsString(); // "2014-03-08T12:59:58.068-05:00"
|
||||
Date date = obs.getIssuedElement().getValue(); // A date object
|
||||
String dateString = obs.getIssuedElement().getValueAsString(); // "2014-03-08T12:59:58.068-05:00"
|
||||
// END SNIPPET: datatypes
|
||||
|
||||
System.out.println(date);
|
||||
|
@ -47,31 +49,108 @@ public class FhirDataModel {
|
|||
// child elements.
|
||||
IdentifierDt identifierDt = observation.getIdentifier();
|
||||
PeriodDt periodDt = observation.getIdentifier().getPeriod();
|
||||
DateTimeDt activeDt = observation.getIdentifier().getPeriod().getStart();
|
||||
DateTimeDt activeDt = observation.getIdentifier().getPeriod().getStartElement();
|
||||
|
||||
// DateTimeDt is a FHIR primitive however, so the following will return
|
||||
// null
|
||||
// unless a value has been placed there.
|
||||
Date active = observation.getIdentifier().getPeriod().getStart().getValue();
|
||||
Date active = observation.getIdentifier().getPeriod().getStartElement().getValue();
|
||||
// END SNIPPET: nonNull
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static void codes() {
|
||||
// START SNIPPET: codes
|
||||
Patient patient = new Patient();
|
||||
|
||||
// Coded types can naturally be set using plain Strings
|
||||
CodingDt genderCoding = patient.getGender().addCoding();
|
||||
genderCoding.setSystem("http://hl7.org/fhir/v3/AdministrativeGender");
|
||||
genderCoding.setCode("M");
|
||||
|
||||
// This is equivalent to the three statements above
|
||||
patient.setGender(AdministrativeGenderCodesEnum.M);
|
||||
// You can set this code using a String if you want. Note that
|
||||
// for "closed" valuesets (such as the one used for Patient.gender)
|
||||
// you must use one of the strings defined by the FHIR specification.
|
||||
// You must not define your own.
|
||||
patient.getGenderElement().setValue("male");
|
||||
|
||||
// HAPI also provides Java enumerated types which make it easier to
|
||||
// deal with coded values. This code achieves the exact same result
|
||||
// as the code above.
|
||||
patient.setGender(AdministrativeGenderEnum.MALE);
|
||||
|
||||
// You can also retrieve coded values the same way
|
||||
String genderString = patient.getGenderElement().getValueAsString();
|
||||
AdministrativeGenderEnum genderEnum = patient.getGenderElement().getValueAsEnum();
|
||||
|
||||
// The following is a shortcut to create
|
||||
patient.setMaritalStatus(MaritalStatusCodesEnum.M);
|
||||
// END SNIPPET: codes
|
||||
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static void codeableConcepts() {
|
||||
// START SNIPPET: codeableConcepts
|
||||
Patient patient = new Patient();
|
||||
|
||||
// Coded types can naturally be set using plain strings
|
||||
CodingDt statusCoding = patient.getMaritalStatus().addCoding();
|
||||
statusCoding.setSystem("http://hl7.org/fhir/v3/MaritalStatus");
|
||||
statusCoding.setCode("M");
|
||||
statusCoding.setDisplay("Married");
|
||||
|
||||
// You could add a second coding to the field if needed too. This
|
||||
// can be useful if you want to convey the concept using different
|
||||
// codesystems.
|
||||
CodingDt secondStatus = patient.getMaritalStatus().addCoding();
|
||||
secondStatus.setCode("H");
|
||||
secondStatus.setSystem("http://example.com#maritalStatus");
|
||||
secondStatus.setDisplay("Happily Married");
|
||||
|
||||
// CodeableConcept also has a text field meant to convey
|
||||
// a user readable version of the concepts it conveys.
|
||||
patient.getMaritalStatus().setText("Happily Married");
|
||||
|
||||
// There are also accessors for retrieving values
|
||||
String firstCode = patient.getMaritalStatus().getCoding().get(0).getCode();
|
||||
String secondCode = patient.getMaritalStatus().getCoding().get(1).getCode();
|
||||
// END SNIPPET: codeableConcepts
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static void codeableConceptEnums() {
|
||||
// START SNIPPET: codeableConceptEnums
|
||||
Patient patient = new Patient();
|
||||
|
||||
// Set the CodeableConcept's first coding to use the code
|
||||
// and codesystem associated with the M value.
|
||||
patient.setMaritalStatus(MaritalStatusCodesEnum.M);
|
||||
|
||||
// If you need to set other fields (such as the display name) after
|
||||
// using the Enum type, you may still do so.
|
||||
patient.getMaritalStatus().getCodingFirstRep().setDisplay("Married");
|
||||
patient.getMaritalStatus().getCodingFirstRep().setPrimary(true);
|
||||
patient.getMaritalStatus().getCodingFirstRep().setVersion("1.0");
|
||||
|
||||
// You can use accessors to retrieve values from CodeableConcept fields
|
||||
|
||||
// Returns "M"
|
||||
String code = patient.getMaritalStatus().getCodingFirstRep().getCode();
|
||||
|
||||
// Returns "http://hl7.org/fhir/v3/MaritalStatus". This value was also
|
||||
// populated via the enum above.
|
||||
String codeSystem = patient.getMaritalStatus().getCodingFirstRep().getCode();
|
||||
|
||||
// In many cases, Enum types can be used to retrieve values as well. Note that
|
||||
// the setter takes a single type, but the getter returns a Set, because the
|
||||
// field can technicaly contain more than one code and codesystem. BE CAREFUL
|
||||
// when using this method however, as no Enum will be returned in the case
|
||||
// that the field contains only a code other than the ones defined by the Enum.
|
||||
Set<MaritalStatusCodesEnum> status = patient.getMaritalStatus().getValueAsEnum();
|
||||
// END SNIPPET: codeableConceptEnums
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
datatypes();
|
||||
|
||||
|
@ -88,8 +167,8 @@ public class FhirDataModel {
|
|||
observation.setValue(q);
|
||||
|
||||
// Set the reference range
|
||||
observation.getReferenceRangeFirstRep().setLow(100);
|
||||
observation.getReferenceRangeFirstRep().setHigh(200);
|
||||
observation.getReferenceRangeFirstRep().setLow(new QuantityDt(100));
|
||||
observation.getReferenceRangeFirstRep().setHigh(new QuantityDt(200));
|
||||
|
||||
// END SNIPPET: observation
|
||||
|
||||
|
|
|
@ -8,19 +8,24 @@ import ca.uhn.fhir.model.api.Bundle;
|
|||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.base.resource.BaseConformance;
|
||||
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
|
||||
import ca.uhn.fhir.model.dstu.resource.Observation;
|
||||
import ca.uhn.fhir.model.dstu.resource.Organization;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.AdministrativeGenderEnum;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Observation;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Organization;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.rest.method.SearchStyleEnum;
|
||||
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
|
||||
|
||||
public class GenericClientExample {
|
||||
|
||||
public static void simpleExample() {
|
||||
// START SNIPPET: simple
|
||||
FhirContext ctx = new FhirContext();
|
||||
String serverBase = "http://fhirtest.uhn.ca/base";
|
||||
// We're connecting to a DSTU1 compliant server in this example
|
||||
FhirContext ctx = FhirContext.forDstu1();
|
||||
String serverBase = "http://fhirtest.uhn.ca/baseDstu1";
|
||||
|
||||
IGenericClient client = ctx.newRestfulGenericClient(serverBase);
|
||||
|
||||
// Perform a search
|
||||
|
@ -42,25 +47,32 @@ public class GenericClientExample {
|
|||
// START SNIPPET: create
|
||||
Patient patient = new Patient();
|
||||
// ..populate the patient object..
|
||||
patient.addIdentifier("urn:system", "12345");
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("12345");
|
||||
patient.addName().addFamily("Smith").addGiven("John");
|
||||
|
||||
// Invoke the server create method (and send pretty-printed JSON
|
||||
// encoding to the server
|
||||
// instead of the default which is non-pretty printed XML)
|
||||
client
|
||||
.create()
|
||||
MethodOutcome outcome = client.create()
|
||||
.resource(patient)
|
||||
.prettyPrint()
|
||||
.encodedJson()
|
||||
.execute();
|
||||
|
||||
// The MethodOutcome object will contain information about the
|
||||
// response from the server, including the ID of the created
|
||||
// resource, the OperationOutcome response, etc. (assuming that
|
||||
// any of these things were provided by the server! They may not
|
||||
// always be)
|
||||
IdDt id = outcome.getId();
|
||||
System.out.println("Got ID: " + id.getValue());
|
||||
// END SNIPPET: create
|
||||
}
|
||||
{
|
||||
// START SNIPPET: update
|
||||
Patient patient = new Patient();
|
||||
// ..populate the patient object..
|
||||
patient.addIdentifier("urn:system", "12345");
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("12345");
|
||||
patient.addName().addFamily("Smith").addGiven("John");
|
||||
|
||||
// To update a resource, it should have an ID set (if the resource
|
||||
|
@ -69,15 +81,47 @@ public class GenericClientExample {
|
|||
// have one though)
|
||||
patient.setId("Patient/123");
|
||||
|
||||
// Invoke the server create method (and send pretty-printed JSON
|
||||
// encoding to the server
|
||||
// instead of the default which is non-pretty printed XML)
|
||||
client
|
||||
.update()
|
||||
// Invoke the server update method
|
||||
MethodOutcome outcome = client.update()
|
||||
.resource(patient)
|
||||
.execute();
|
||||
|
||||
// The MethodOutcome object will contain information about the
|
||||
// response from the server, including the ID of the created
|
||||
// resource, the OperationOutcome response, etc. (assuming that
|
||||
// any of these things were provided by the server! They may not
|
||||
// always be)
|
||||
IdDt id = outcome.getId();
|
||||
System.out.println("Got ID: " + id.getValue());
|
||||
// END SNIPPET: update
|
||||
}
|
||||
{
|
||||
// START SNIPPET: etagupdate
|
||||
// First, let's retrive the latest version of a resource
|
||||
// from the server
|
||||
Patient patient = client.read().resource(Patient.class).withId("123").execute();
|
||||
|
||||
// If the server is a version aware server, we should now know the latest version
|
||||
// of the resource
|
||||
System.out.println("Version ID: " + patient.getId().getVersionIdPart());
|
||||
|
||||
// Now let's make a change to the resource
|
||||
patient.setGender(AdministrativeGenderEnum.FEMALE);
|
||||
|
||||
// Invoke the server update method - Because the resource has
|
||||
// a version, it will be included in the request sent to
|
||||
// the server
|
||||
try {
|
||||
MethodOutcome outcome = client
|
||||
.update()
|
||||
.resource(patient)
|
||||
.execute();
|
||||
} catch (PreconditionFailedException e) {
|
||||
// If we get here, the latest version has changed
|
||||
// on the server so our update failed.
|
||||
}
|
||||
// END SNIPPET: etagupdate
|
||||
}
|
||||
{
|
||||
// START SNIPPET: conformance
|
||||
// Retrieve the server's conformance statement and print its
|
||||
|
@ -103,7 +147,7 @@ public class GenericClientExample {
|
|||
Bundle response = client.search()
|
||||
.forResource(Patient.class)
|
||||
.where(Patient.BIRTHDATE.beforeOrEquals().day("2011-01-01"))
|
||||
.and(Patient.PROVIDER.hasChainedProperty(Organization.NAME.matches().value("Health")))
|
||||
.and(Patient.CAREPROVIDER.hasChainedProperty(Organization.NAME.matches().value("Health")))
|
||||
.execute();
|
||||
// END SNIPPET: search
|
||||
|
||||
|
@ -180,23 +224,46 @@ public class GenericClientExample {
|
|||
|
||||
{
|
||||
// START SNIPPET: read
|
||||
IdDt id = new IdDt("Patient", "123");
|
||||
Patient patient = client.read(Patient.class, id); // search for patient 123
|
||||
// search for patient 123
|
||||
Patient patient = client.read()
|
||||
.resource(Patient.class)
|
||||
.withId("123")
|
||||
.execute();
|
||||
// END SNIPPET: read
|
||||
}
|
||||
{
|
||||
// START SNIPPET: vread
|
||||
IdDt id = new IdDt("Patient", "123", "888");
|
||||
Patient patient = client.vread(Patient.class, id); // search for version 888 of patient 123
|
||||
// search for patient 123 (specific version 888)
|
||||
Patient patient = client.read()
|
||||
.resource(Patient.class)
|
||||
.withIdAndVersion("123", "888")
|
||||
.execute();
|
||||
// END SNIPPET: vread
|
||||
}
|
||||
{
|
||||
// START SNIPPET: readabsolute
|
||||
IdDt id = new IdDt("http://example.com/fhir/Patient/123");
|
||||
Patient patient = client.read(Patient.class, id); // search for patient 123 on example.com
|
||||
// search for patient 123 on example.com
|
||||
String url = "http://example.com/fhir/Patient/123";
|
||||
Patient patient = client.read()
|
||||
.resource(Patient.class)
|
||||
.withUrl(url)
|
||||
.execute();
|
||||
// END SNIPPET: readabsolute
|
||||
}
|
||||
|
||||
{
|
||||
// START SNIPPET: etagread
|
||||
// search for patient 123
|
||||
Patient patient = client.read()
|
||||
.resource(Patient.class)
|
||||
.withId("123")
|
||||
.ifVersionMatches("001").returnNull()
|
||||
.execute();
|
||||
if (patient == null) {
|
||||
// resource has not changed
|
||||
}
|
||||
// END SNIPPET: etagread
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package example;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
|
|
|
@ -8,7 +8,7 @@ import ca.uhn.fhir.model.api.annotation.Child;
|
|||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import ca.uhn.fhir.model.api.annotation.Extension;
|
||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.DateTimeDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.util.ElementUtil;
|
||||
|
|
|
@ -10,7 +10,7 @@ import ca.uhn.fhir.model.api.annotation.Child;
|
|||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import ca.uhn.fhir.model.api.annotation.Extension;
|
||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.DateTimeDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
|
|
|
@ -3,8 +3,8 @@ package example;
|
|||
import java.io.IOException;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu.valueset.NarrativeStatusEnum;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
|
||||
|
@ -14,7 +14,7 @@ public static void main(String[] args) throws DataFormatException, IOException {
|
|||
|
||||
//START SNIPPET: example1
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier("urn:foo", "7000135");
|
||||
patient.addIdentifier().setSystem("urn:foo").setValue("7000135");
|
||||
patient.addName().addFamily("Smith").addGiven("John").addGiven("Edward");
|
||||
patient.addAddress().addLine("742 Evergreen Terrace").setCity("Springfield").setState("ZZ");
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package example;
|
|||
import java.util.List;
|
||||
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.rest.annotation.RequiredParam;
|
||||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
|
@ -11,7 +11,7 @@ import ca.uhn.fhir.rest.param.StringParam;
|
|||
import ca.uhn.fhir.rest.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
||||
//START SNIPPET: provider
|
||||
public class PagingPatientProvider implements IResourceProvider {
|
||||
|
||||
|
|
|
@ -1,17 +1,6 @@
|
|||
package example;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.rest.annotation.RequiredParam;
|
||||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.server.FifoMemoryPagingProvider;
|
||||
import ca.uhn.fhir.rest.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.server.IPagingProvider;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
|
||||
@SuppressWarnings({ "unused", "serial" })
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
package example;
|
||||
|
||||
import static ca.uhn.fhir.model.dstu.valueset.IdentifierUseEnum.OFFICIAL;
|
||||
import static ca.uhn.fhir.model.dstu.valueset.IdentifierUseEnum.SECONDARY;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu.valueset.AdministrativeGenderCodesEnum;
|
||||
import ca.uhn.fhir.model.dstu2.composite.IdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.AdministrativeGenderEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.IdentifierUseEnum;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import ca.uhn.fhir.rest.annotation.Create;
|
||||
import ca.uhn.fhir.rest.annotation.RequiredParam;
|
||||
|
@ -24,12 +23,12 @@ public class QuickUsage {
|
|||
public static void main(String[] args) throws DataFormatException, IOException {
|
||||
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setUse(OFFICIAL).setSystem("urn:fake:mrns").setValue("7000135");
|
||||
patient.addIdentifier().setUse(SECONDARY).setSystem("urn:fake:otherids").setValue("3287486");
|
||||
patient.addIdentifier().setUse(IdentifierUseEnum.OFFICIAL).setSystem("urn:fake:mrns").setValue("7000135");
|
||||
patient.addIdentifier().setUse(IdentifierUseEnum.SECONDARY).setSystem("urn:fake:otherids").setValue("3287486");
|
||||
|
||||
patient.addName().addFamily("Smith").addGiven("John").addGiven("Q").addSuffix("Junior");
|
||||
|
||||
patient.setGender(AdministrativeGenderCodesEnum.M);
|
||||
patient.setGender(AdministrativeGenderEnum.MALE);
|
||||
|
||||
|
||||
FhirContext ctx = new FhirContext();
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package example;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu.resource.Organization;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Organization;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
|
||||
public class ResourceRefs {
|
||||
|
||||
|
@ -17,12 +17,12 @@ public class ResourceRefs {
|
|||
// Create an organization, and give it a local ID
|
||||
Organization org = new Organization();
|
||||
org.setId("#localOrganization");
|
||||
org.getName().setValue("Contained Test Organization");
|
||||
org.getNameElement().setValue("Contained Test Organization");
|
||||
|
||||
// Create a patient
|
||||
Patient patient = new Patient();
|
||||
patient.setId("Patient/1333");
|
||||
patient.addIdentifier("urn:mrns", "253345");
|
||||
patient.addIdentifier().setSystem("urn:mrns").setValue("253345");
|
||||
|
||||
// Set the reference, and manually add the contained resource
|
||||
patient.getManagingOrganization().setReference("#localOrganization");
|
||||
|
|
|
@ -3,9 +3,9 @@ package example;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu.valueset.AdministrativeGenderCodesEnum;
|
||||
import ca.uhn.fhir.model.dstu.valueset.IdentifierUseEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.IdentifierUseEnum;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.AdministrativeGenderEnum;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
|
@ -49,7 +49,7 @@ public class RestfulObservationResourceProvider implements IResourceProvider {
|
|||
patient.getIdentifier().get(0).setValue("00002");
|
||||
patient.addName().addFamily("Test");
|
||||
patient.getName().get(0).addGiven("PatientOne");
|
||||
patient.setGender(AdministrativeGenderCodesEnum.F);
|
||||
patient.setGender(AdministrativeGenderEnum.FEMALE);
|
||||
return patient;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class RestfulObservationResourceProvider implements IResourceProvider {
|
|||
patient.addName();
|
||||
patient.getName().get(0).addFamily("Test");
|
||||
patient.getName().get(0).addGiven("PatientOne");
|
||||
patient.getGender().setText("M");
|
||||
patient.setGender(AdministrativeGenderEnum.MALE);
|
||||
return Collections.singletonList(patient);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@ package example;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu.valueset.AdministrativeGenderCodesEnum;
|
||||
import ca.uhn.fhir.model.dstu.valueset.IdentifierUseEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.IdentifierUseEnum;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.AdministrativeGenderEnum;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
|
@ -50,7 +50,7 @@ public class RestfulPatientResourceProvider implements IResourceProvider {
|
|||
patient.getIdentifier().get(0).setValue("00002");
|
||||
patient.addName().addFamily("Test");
|
||||
patient.getName().get(0).addGiven("PatientOne");
|
||||
patient.setGender(AdministrativeGenderCodesEnum.F);
|
||||
patient.setGender(AdministrativeGenderEnum.FEMALE);
|
||||
return patient;
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ public class RestfulPatientResourceProvider implements IResourceProvider {
|
|||
patient.addName();
|
||||
patient.getName().get(0).addFamily(theFamilyName.getValue());
|
||||
patient.getName().get(0).addGiven("PatientOne");
|
||||
patient.getGender().setText("M");
|
||||
patient.setGender(AdministrativeGenderEnum.MALE);
|
||||
return Collections.singletonList(patient);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package example;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -20,17 +19,16 @@ import ca.uhn.fhir.model.api.TagList;
|
|||
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
|
||||
import ca.uhn.fhir.rest.annotation.TagListParam;
|
||||
import ca.uhn.fhir.model.dstu.composite.CodingDt;
|
||||
import ca.uhn.fhir.model.dstu.resource.Conformance;
|
||||
import ca.uhn.fhir.model.dstu.resource.DiagnosticReport;
|
||||
import ca.uhn.fhir.model.dstu.resource.Observation;
|
||||
import ca.uhn.fhir.model.dstu.resource.OperationOutcome;
|
||||
import ca.uhn.fhir.model.dstu.resource.Organization;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu.valueset.IdentifierUseEnum;
|
||||
import ca.uhn.fhir.model.dstu.valueset.IssueSeverityEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.IdentifierUseEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.IssueSeverityEnum;
|
||||
import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Conformance;
|
||||
import ca.uhn.fhir.model.dstu2.resource.DiagnosticReport;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Observation;
|
||||
import ca.uhn.fhir.model.dstu2.resource.OperationOutcome;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Organization;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.DateTimeDt;
|
||||
import ca.uhn.fhir.model.primitive.DecimalDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
|
@ -51,6 +49,7 @@ import ca.uhn.fhir.rest.annotation.ResourceParam;
|
|||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.rest.annotation.Since;
|
||||
import ca.uhn.fhir.rest.annotation.Sort;
|
||||
import ca.uhn.fhir.rest.annotation.TagListParam;
|
||||
import ca.uhn.fhir.rest.annotation.Transaction;
|
||||
import ca.uhn.fhir.rest.annotation.TransactionParam;
|
||||
import ca.uhn.fhir.rest.annotation.Update;
|
||||
|
@ -72,6 +71,7 @@ import ca.uhn.fhir.rest.param.TokenOrListParam;
|
|||
import ca.uhn.fhir.rest.param.TokenParam;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
|
@ -161,7 +161,7 @@ public List<Patient> findPatients(
|
|||
//START SNIPPET: referenceSimple
|
||||
@Search
|
||||
public List<Patient> findPatientsWithSimpleReference(
|
||||
@OptionalParam(name=Patient.SP_PROVIDER) ReferenceParam theProvider
|
||||
@OptionalParam(name=Patient.SP_CAREPROVIDER) ReferenceParam theProvider
|
||||
) {
|
||||
List<Patient> retVal=new ArrayList<Patient>();
|
||||
|
||||
|
@ -251,6 +251,45 @@ public List<Patient> findObservations(
|
|||
//END SNIPPET: referenceWithStaticChain
|
||||
|
||||
|
||||
//START SNIPPET: referenceWithDynamicChain
|
||||
@Search()
|
||||
public List<Observation> findBySubject(
|
||||
@RequiredParam(name=Observation.SP_SUBJECT, chainWhitelist = {"", Patient.SP_IDENTIFIER, Patient.SP_BIRTHDATE}) ReferenceParam subject
|
||||
) {
|
||||
List<Observation> observations = new ArrayList<Observation>();
|
||||
|
||||
String chain = subject.getChain();
|
||||
if (Patient.SP_IDENTIFIER.equals(chain)) {
|
||||
|
||||
// Because the chained parameter "subject.identifier" is actually of type
|
||||
// "token", we convert the value to a token before processing it.
|
||||
TokenParam tokenSubject = subject.toTokenParam();
|
||||
String system = tokenSubject.getSystem();
|
||||
String identifier = tokenSubject.getValue();
|
||||
|
||||
// TODO: populate all the observations for the identifier
|
||||
|
||||
} else if (Patient.SP_BIRTHDATE.equals(chain)) {
|
||||
|
||||
// Because the chained parameter "subject.birthdate" is actually of type
|
||||
// "date", we convert the value to a date before processing it.
|
||||
DateParam dateSubject = subject.toDateParam();
|
||||
DateTimeDt birthDate = dateSubject.getValueAsDateTimeDt();
|
||||
|
||||
// TODO: populate all the observations for the birthdate
|
||||
|
||||
} else if ("".equals(chain)) {
|
||||
|
||||
String resourceId = subject.getValue();
|
||||
// TODO: populate all the observations for the resource id
|
||||
|
||||
}
|
||||
|
||||
return observations;
|
||||
}
|
||||
//END SNIPPET: referenceWithDynamicChain
|
||||
|
||||
|
||||
//START SNIPPET: read
|
||||
@Read()
|
||||
public Patient getResourceById(@IdParam IdDt theId) {
|
||||
|
@ -661,11 +700,13 @@ public MethodOutcome updatePatient(@IdParam IdDt theId, @ResourceParam Patient t
|
|||
|
||||
String versionId = theId.getVersionIdPart();
|
||||
if (versionId != null) {
|
||||
// If the client passed in a version number in the request URL, which means they are
|
||||
// If the client passed in a version number in an If-Match header, they are
|
||||
// doing a version-aware update. You may wish to throw an exception if the supplied
|
||||
// version is not the latest version.
|
||||
// version is not the latest version. Note that as of DSTU2 the FHIR specification uses
|
||||
// ETags and If-Match to handle version aware updates, so PreconditionFailedException (HTTP 412)
|
||||
// is used instead of ResourceVersionConflictException (HTTP 409)
|
||||
if (detectedVersionConflict) {
|
||||
throw new ResourceVersionConflictException("Invalid version");
|
||||
throw new PreconditionFailedException("Unexpected version");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package example;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
|
||||
import ca.uhn.fhir.rest.server.ETagSupportEnum;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class ServerETagExamples {
|
||||
|
||||
// START SNIPPET: disablingETags
|
||||
@WebServlet(urlPatterns = { "/fhir/*" }, displayName = "FHIR Server")
|
||||
public class RestfulServerWithLogging extends RestfulServer {
|
||||
|
||||
@Override
|
||||
protected void initialize() throws ServletException {
|
||||
// ... define your resource providers here ...
|
||||
|
||||
// ETag support is enabled by default
|
||||
setETagSupport(ETagSupportEnum.ENABLED);
|
||||
}
|
||||
|
||||
}
|
||||
// END SNIPPET: disablingETags
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,79 +1,13 @@
|
|||
package example;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
||||
import ca.uhn.fhir.model.api.Tag;
|
||||
import ca.uhn.fhir.model.api.TagList;
|
||||
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import ca.uhn.fhir.rest.annotation.TagListParam;
|
||||
import ca.uhn.fhir.model.dstu.composite.CodingDt;
|
||||
import ca.uhn.fhir.model.dstu.resource.Conformance;
|
||||
import ca.uhn.fhir.model.dstu.resource.DiagnosticReport;
|
||||
import ca.uhn.fhir.model.dstu.resource.Observation;
|
||||
import ca.uhn.fhir.model.dstu.resource.OperationOutcome;
|
||||
import ca.uhn.fhir.model.dstu.resource.Organization;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu.valueset.IdentifierUseEnum;
|
||||
import ca.uhn.fhir.model.dstu.valueset.IssueSeverityEnum;
|
||||
import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum;
|
||||
import ca.uhn.fhir.model.primitive.DecimalDt;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.IssueSeverityEnum;
|
||||
import ca.uhn.fhir.model.dstu2.resource.OperationOutcome;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import ca.uhn.fhir.rest.annotation.AddTags;
|
||||
import ca.uhn.fhir.rest.annotation.Count;
|
||||
import ca.uhn.fhir.rest.annotation.Create;
|
||||
import ca.uhn.fhir.rest.annotation.DeleteTags;
|
||||
import ca.uhn.fhir.rest.annotation.GetTags;
|
||||
import ca.uhn.fhir.rest.annotation.History;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.IncludeParam;
|
||||
import ca.uhn.fhir.rest.annotation.Metadata;
|
||||
import ca.uhn.fhir.rest.annotation.OptionalParam;
|
||||
import ca.uhn.fhir.rest.annotation.Read;
|
||||
import ca.uhn.fhir.rest.annotation.RequiredParam;
|
||||
import ca.uhn.fhir.rest.annotation.ResourceParam;
|
||||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.rest.annotation.Since;
|
||||
import ca.uhn.fhir.rest.annotation.Sort;
|
||||
import ca.uhn.fhir.rest.annotation.Transaction;
|
||||
import ca.uhn.fhir.rest.annotation.TransactionParam;
|
||||
import ca.uhn.fhir.rest.annotation.Update;
|
||||
import ca.uhn.fhir.rest.annotation.Validate;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.SortOrderEnum;
|
||||
import ca.uhn.fhir.rest.api.SortSpec;
|
||||
import ca.uhn.fhir.rest.client.api.IBasicClient;
|
||||
import ca.uhn.fhir.rest.client.api.IRestfulClient;
|
||||
import ca.uhn.fhir.rest.param.CompositeParam;
|
||||
import ca.uhn.fhir.rest.param.DateParam;
|
||||
import ca.uhn.fhir.rest.param.DateRangeParam;
|
||||
import ca.uhn.fhir.rest.param.QuantityParam;
|
||||
import ca.uhn.fhir.rest.param.ReferenceParam;
|
||||
import ca.uhn.fhir.rest.param.StringAndListParam;
|
||||
import ca.uhn.fhir.rest.param.StringOrListParam;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.param.TokenOrListParam;
|
||||
import ca.uhn.fhir.rest.param.TokenParam;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public abstract class ServerExceptionsExample implements IResourceProvider {
|
||||
|
|
|
@ -3,18 +3,14 @@ package example;
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.ExtensionDt;
|
||||
import ca.uhn.fhir.model.dstu.composite.HumanNameDt;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu.valueset.IdentifierUseEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.IdentifierUseEnum;
|
||||
import ca.uhn.fhir.model.dstu2.composite.HumanNameDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.DateTimeDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.InterceptorAdapter;
|
||||
|
||||
public class ServerInterceptors {
|
||||
|
||||
|
@ -25,7 +21,7 @@ public static void main(String[] args) throws DataFormatException, IOException {
|
|||
// START SNIPPET: resourceExtension
|
||||
// Create an example patient
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier(IdentifierUseEnum.OFFICIAL, "urn:example", "7000135", null);
|
||||
patient.addIdentifier().setUse(IdentifierUseEnum.OFFICIAL).setSystem("urn:example").setValue("7000135");
|
||||
|
||||
// Create an extension
|
||||
ExtensionDt ext = new ExtensionDt();
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.util.List;
|
|||
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
||||
import ca.uhn.fhir.model.api.Tag;
|
||||
import ca.uhn.fhir.model.api.TagList;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import ca.uhn.fhir.context.FhirContext;
|
|||
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
||||
import ca.uhn.fhir.model.api.Tag;
|
||||
import ca.uhn.fhir.model.api.TagList;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ import org.apache.commons.io.filefilter.WildcardFileFilter;
|
|||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu.valueset.ContactSystemEnum;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.ContactPointSystemEnum;
|
||||
import ca.uhn.fhir.validation.FhirValidator;
|
||||
import ca.uhn.fhir.validation.ValidationResult;
|
||||
|
||||
|
@ -23,8 +23,8 @@ public class ValidatorExamples {
|
|||
// Create and populate a new patient object
|
||||
Patient p = new Patient();
|
||||
p.addName().addFamily("Smith").addGiven("John").addGiven("Q");
|
||||
p.addIdentifier("urn:foo:identifiers", "12345");
|
||||
p.addTelecom().setSystem(ContactSystemEnum.PHONE).setValue("416 123-4567");
|
||||
p.addIdentifier().setSystem("urn:foo:identifiers").setValue("12345");
|
||||
p.addTelecom().setSystem(ContactPointSystemEnum.PHONE).setValue("416 123-4567");
|
||||
|
||||
// Request a validator and apply it
|
||||
FhirValidator val = ctx.newValidator();
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>0.8-SNAPSHOT</version>
|
||||
<version>0.9-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -19,17 +19,10 @@
|
|||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>2.7</version>
|
||||
<<<<<<< HEAD
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
=======
|
||||
<inherited>false</inherited>
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
<report>scm</report>
|
||||
>>>>>>> d22a35788f57e9f7ce64bc8afc2ee7eaf29d94f2
|
||||
</reports>
|
||||
</reportSet>
|
||||
</reportSets>
|
||||
|
@ -46,11 +39,8 @@
|
|||
</reports>
|
||||
<configuration>
|
||||
<links>
|
||||
<link>http://docs.oracle.com/javaee/7/api</link>
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
<link>http://jamesagnew.github.io/hapi-fhir/apidocs</link>
|
||||
>>>>>>> d22a35788f57e9f7ce64bc8afc2ee7eaf29d94f2
|
||||
<link>http://jamesagnew.github.io/hapi-fhir/apidocs/</link>
|
||||
<link>https://docs.oracle.com/javaee/7/api/</link>
|
||||
</links>
|
||||
</configuration>
|
||||
</reportSet>
|
|
@ -1,5 +1,6 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/main/resources=UTF-8
|
||||
encoding//src/test/java=UTF-8
|
||||
encoding//src/test/resources=UTF-8
|
||||
encoding/<project>=UTF-8
|
||||
|
|
|
@ -13,6 +13,7 @@ org.eclipse.jdt.core.compiler.compliance=1.6
|
|||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
|
||||
|
@ -25,9 +26,9 @@ org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
|||
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
|
||||
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
|
||||
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
|
||||
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
|
@ -36,12 +37,25 @@ org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
|
|||
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
|
||||
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadoc=error
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
|
||||
org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
|
||||
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
|
||||
|
@ -79,7 +93,7 @@ org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
|||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
|
||||
|
@ -94,7 +108,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=
|
|||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
<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">
|
||||
<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>0.8-SNAPSHOT</version>
|
||||
<version>0.9-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>hapi-fhir-base</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
||||
<url>http://jamesagnew.github.io/hapi-fhir/</url>
|
||||
|
||||
|
||||
<name>HAPI FHIR - Core Library</name>
|
||||
|
||||
<dependencies>
|
||||
|
@ -37,23 +38,12 @@
|
|||
</dependency>
|
||||
|
||||
<!-- Only required for OpenID Connect Support -->
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.mitre</groupId>
|
||||
<artifactId>openid-connect-client</artifactId>
|
||||
<version>${mitreid-connect-version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security.oauth</groupId>
|
||||
<artifactId>spring-security-oauth2</artifactId>
|
||||
<version>2.0.2.RELEASE</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
-->
|
||||
<!--
|
||||
-->
|
||||
|
||||
<!-- <dependency> <groupId>org.mitre</groupId> <artifactId>openid-connect-client</artifactId>
|
||||
<version>${mitreid-connect-version}</version> <optional>true</optional> </dependency>
|
||||
<dependency> <groupId>org.springframework.security.oauth</groupId> <artifactId>spring-security-oauth2</artifactId>
|
||||
<version>2.0.2.RELEASE</version> <optional>true</optional> </dependency> -->
|
||||
<!-- -->
|
||||
|
||||
<!-- Only required for narrative generator support -->
|
||||
<dependency>
|
||||
<groupId>org.thymeleaf</groupId>
|
||||
|
@ -68,39 +58,27 @@
|
|||
<artifactId>cors-filter</artifactId>
|
||||
<version>${ebay_cors_filter_version}</version>
|
||||
<optional>true</optional>
|
||||
<!--
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<groupId>javax.servlet</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
-->
|
||||
<!-- <exclusions> <exclusion> <artifactId>servlet-api</artifactId> <groupId>javax.servlet</groupId>
|
||||
</exclusion> </exclusions> -->
|
||||
</dependency>
|
||||
|
||||
<!-- Only required for Schematron Validator Support -->
|
||||
<dependency>
|
||||
<groupId>com.phloc</groupId>
|
||||
<artifactId>phloc-schematron</artifactId>
|
||||
<version>${phloc_schematron_version}</version>
|
||||
<groupId>com.phloc</groupId>
|
||||
<artifactId>phloc-schematron</artifactId>
|
||||
<version>${phloc_schematron_version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.phloc</groupId>
|
||||
<artifactId>phloc-commons</artifactId>
|
||||
<version>${phloc_commons_version}</version>
|
||||
<groupId>com.phloc</groupId>
|
||||
<artifactId>phloc-commons</artifactId>
|
||||
<version>${phloc_commons_version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
<version>2.11.0</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
<!-- <dependency> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId>
|
||||
<version>2.11.0</version> <optional>true</optional> </dependency> -->
|
||||
|
||||
<!-- General -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
|
@ -110,12 +88,12 @@
|
|||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.9</version>
|
||||
<version>${commons_codec_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.4</version>
|
||||
<version>${commons_io_version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Logging -->
|
||||
|
@ -125,9 +103,9 @@
|
|||
<version>${slf4j_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<version>${slf4j_version}</version>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<version>${slf4j_version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
|
@ -140,7 +118,7 @@
|
|||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.3.3</version>
|
||||
<version>${apache_httpclient_version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
|
@ -151,7 +129,7 @@
|
|||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpcore</artifactId>
|
||||
<version>4.3.2</version>
|
||||
<version>${apache_httpcore_version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -202,72 +180,76 @@
|
|||
<id>SITE</id>
|
||||
<reporting>
|
||||
<plugins>
|
||||
<!--
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>findbugs-maven-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jxr-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<id>normal</id>
|
||||
<reports>
|
||||
<report>jxr</report>
|
||||
</reports>
|
||||
</reportSet>
|
||||
<reportSet>
|
||||
<id>restful-server-example</id>
|
||||
<reports>
|
||||
<report>jxr</report>
|
||||
</reports>
|
||||
<configuration>
|
||||
<sourcePath>../restful-server-example/src/main/java</sourcePath>
|
||||
<destDir>${project.reporting.outputDirectory}/rse-xref</destDir>
|
||||
<outputDirectory>tmp</outputDirectory>
|
||||
<reportOutputDirectory>rse-xref</reportOutputDirectory>
|
||||
</configuration>
|
||||
</reportSet>
|
||||
</reportSets>
|
||||
</plugin>
|
||||
-->
|
||||
<!--
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-linkcheck-plugin</artifactId>
|
||||
<version>1.1</version>
|
||||
<configuration>
|
||||
<forceSite>false</forceSite>
|
||||
</configuration>
|
||||
</plugin>
|
||||
-->
|
||||
<!-- <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>findbugs-maven-plugin</artifactId>
|
||||
<version>3.0.0</version> <configuration> </configuration> </plugin> <plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jxr-plugin</artifactId>
|
||||
<version>2.4</version> <reportSets> <reportSet> <id>normal</id> <reports>
|
||||
<report>jxr</report> </reports> </reportSet> <reportSet> <id>restful-server-example</id>
|
||||
<reports> <report>jxr</report> </reports> <configuration> <sourcePath>../restful-server-example/src/main/java</sourcePath>
|
||||
<destDir>${project.reporting.outputDirectory}/rse-xref</destDir> <outputDirectory>tmp</outputDirectory>
|
||||
<reportOutputDirectory>rse-xref</reportOutputDirectory> </configuration>
|
||||
</reportSet> </reportSets> </plugin> -->
|
||||
<!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-linkcheck-plugin</artifactId>
|
||||
<version>1.1</version> <configuration> <forceSite>false</forceSite> </configuration>
|
||||
</plugin> -->
|
||||
</plugins>
|
||||
</reporting>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>DIST</id>
|
||||
<id>ANDROID</id>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu</artifactId>
|
||||
<version>0.9-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-android</artifactId>
|
||||
<version>${slf4j_version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>${maven_assembly_plugin_version}</version>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>1.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<attach>false</attach>
|
||||
<descriptors>
|
||||
<descriptor>${project.basedir}/src/assembly/hapi-fhir-all.xml</descriptor>
|
||||
<!-- <descriptor>src/assembly/hapi-jdk14.xml</descriptor> -->
|
||||
</descriptors>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<createDependencyReducedPom>true</createDependencyReducedPom>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<!--
|
||||
<include>javax.json:javax.json-api</include>
|
||||
-->
|
||||
<include>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu</include>
|
||||
<include>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu</include>
|
||||
<include>org.glassfish:javax.json</include>
|
||||
<include>org.codehaus.woodstox:woodstox-core-asl</include>
|
||||
<include>javax.xml.stream:stax-api</include>
|
||||
<include>org.codehaus.woodstox:stax2-api</include>
|
||||
<include>org.slf4j:slf4j*</include>
|
||||
<include>org.apache.commons:*</include>
|
||||
<include>org.apache.httpcomponents:*</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>javax.xml.stream</pattern>
|
||||
<shadedPattern>ca.uhn.fhir.repackage.javax.xml.stream</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>javax.json</pattern>
|
||||
<shadedPattern>ca.uhn.fhir.repackage.javax.json</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
@ -275,6 +257,7 @@
|
|||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -25,27 +25,28 @@ import java.util.Collections;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.api.ICodeEnum;
|
||||
import ca.uhn.fhir.model.api.IDatatype;
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
|
||||
public abstract class BaseRuntimeChildDatatypeDefinition extends BaseRuntimeDeclaredChildDefinition {
|
||||
|
||||
private Class<? extends ICodeEnum> myCodeType;
|
||||
private Class<? extends IDatatype> myDatatype;
|
||||
private Class<? extends IBase> myDatatype;
|
||||
|
||||
private BaseRuntimeElementDefinition<?> myElementDefinition;
|
||||
|
||||
public BaseRuntimeChildDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IDatatype> theDatatype) {
|
||||
public BaseRuntimeChildDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IBase> theDatatype) {
|
||||
super(theField, theChildAnnotation, theDescriptionAnnotation, theElementName);
|
||||
assert theDatatype != IDatatype.class; // should use RuntimeChildAny
|
||||
myDatatype = theDatatype;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChildNameByDatatype(Class<? extends IElement> theDatatype) {
|
||||
public String getChildNameByDatatype(Class<? extends IBase> theDatatype) {
|
||||
if (myDatatype.equals(theDatatype)) {
|
||||
return getElementName();
|
||||
}
|
||||
|
@ -53,8 +54,8 @@ public abstract class BaseRuntimeChildDatatypeDefinition extends BaseRuntimeDecl
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IElement> theDatatype) {
|
||||
Class<? extends IElement> datatype = theDatatype;
|
||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IBase> theDatatype) {
|
||||
Class<? extends IBase> datatype = theDatatype;
|
||||
if (myDatatype.equals(datatype)) {
|
||||
return myElementDefinition;
|
||||
}
|
||||
|
@ -73,7 +74,7 @@ public abstract class BaseRuntimeChildDatatypeDefinition extends BaseRuntimeDecl
|
|||
return myCodeType;
|
||||
}
|
||||
|
||||
public Class<? extends IDatatype> getDatatype() {
|
||||
public Class<? extends IBase> getDatatype() {
|
||||
return myDatatype;
|
||||
}
|
||||
|
||||
|
@ -83,7 +84,7 @@ public abstract class BaseRuntimeChildDatatypeDefinition extends BaseRuntimeDecl
|
|||
}
|
||||
|
||||
@Override
|
||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
myElementDefinition = theClassToElementDefinitions.get(getDatatype());
|
||||
assert myElementDefinition != null : "Unknown type: " + getDatatype();
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -24,7 +24,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
|
||||
public abstract class BaseRuntimeChildDefinition {
|
||||
|
||||
|
@ -37,18 +37,18 @@ public abstract class BaseRuntimeChildDefinition {
|
|||
|
||||
public abstract BaseRuntimeElementDefinition<?> getChildByName(String theName);
|
||||
|
||||
public abstract BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IElement> theType);
|
||||
public abstract BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IBase> theType);
|
||||
|
||||
public abstract String getChildNameByDatatype(Class<? extends IElement> theDatatype);
|
||||
public abstract String getChildNameByDatatype(Class<? extends IBase> theDatatype);
|
||||
|
||||
public abstract IMutator getMutator();
|
||||
|
||||
public abstract Set<String> getValidChildNames();
|
||||
|
||||
abstract void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions);
|
||||
abstract void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions);
|
||||
|
||||
public interface IAccessor {
|
||||
List<? extends IElement> getValues(Object theTarget);
|
||||
List<? extends IBase> getValues(Object theTarget);
|
||||
}
|
||||
|
||||
public abstract String getElementName();
|
||||
|
@ -58,7 +58,7 @@ public abstract class BaseRuntimeChildDefinition {
|
|||
public abstract int getMin();
|
||||
|
||||
public interface IMutator {
|
||||
void addValue(Object theTarget, IElement theValue);
|
||||
void addValue(Object theTarget, IBase theValue);
|
||||
}
|
||||
|
||||
public String getExtensionUrl() {
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -30,6 +30,7 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
|
@ -185,7 +186,7 @@ public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChil
|
|||
|
||||
private final class FieldPlainMutator implements IMutator {
|
||||
@Override
|
||||
public void addValue(Object theTarget, IElement theValue) {
|
||||
public void addValue(Object theTarget, IBase theValue) {
|
||||
try {
|
||||
myField.set(theTarget, theValue);
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
@ -216,12 +217,12 @@ public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChil
|
|||
|
||||
private final class FieldListMutator implements IMutator {
|
||||
@Override
|
||||
public void addValue(Object theTarget, IElement theValue) {
|
||||
public void addValue(Object theTarget, IBase theValue) {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<IElement> existingList = (List<IElement>) myField.get(theTarget);
|
||||
List<IBase> existingList = (List<IBase>) myField.get(theTarget);
|
||||
if (existingList == null) {
|
||||
existingList = new ArrayList<IElement>(2);
|
||||
existingList = new ArrayList<IBase>(2);
|
||||
myField.set(theTarget, existingList);
|
||||
}
|
||||
existingList.add(theValue);
|
||||
|
@ -282,11 +283,11 @@ public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChil
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addValue(Object theTarget, IElement theValue) {
|
||||
public void addValue(Object theTarget, IBase theValue) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<IElement> existingList = (List<IElement>) myAccessor.getValues(theTarget);
|
||||
List<IBase> existingList = (List<IBase>) myAccessor.getValues(theTarget);
|
||||
if (existingList == null) {
|
||||
existingList = new ArrayList<IElement>();
|
||||
existingList = new ArrayList<IBase>();
|
||||
try {
|
||||
myMutatorMethod.invoke(theTarget, existingList);
|
||||
} catch (IllegalAccessException e) {
|
||||
|
@ -335,7 +336,7 @@ public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChil
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addValue(Object theTarget, IElement theValue) {
|
||||
public void addValue(Object theTarget, IBase theValue) {
|
||||
try {
|
||||
if (theValue != null && !myTargetReturnType.isAssignableFrom(theValue.getClass())) {
|
||||
throw new ConfigurationException("Value for field " + myElementName + " expects type " + myTargetReturnType + " but got " + theValue.getClass());
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -27,11 +27,11 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import ca.uhn.fhir.model.api.ICompositeElement;
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
|
||||
public abstract class BaseRuntimeElementCompositeDefinition<T extends ICompositeElement> extends BaseRuntimeElementDefinition<T> {
|
||||
public abstract class BaseRuntimeElementCompositeDefinition<T extends IBase> extends BaseRuntimeElementDefinition<T> {
|
||||
|
||||
private List<BaseRuntimeChildDefinition> myChildren = new ArrayList<BaseRuntimeChildDefinition>();
|
||||
private List<BaseRuntimeChildDefinition> myChildrenAndExtensions;
|
||||
|
@ -76,7 +76,7 @@ public abstract class BaseRuntimeElementCompositeDefinition<T extends IComposite
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
public void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
super.sealAndInitialize(theClassToElementDefinitions);
|
||||
|
||||
for (BaseRuntimeChildDefinition next : myChildren) {
|
||||
|
@ -91,7 +91,7 @@ public abstract class BaseRuntimeElementCompositeDefinition<T extends IComposite
|
|||
}
|
||||
for (String nextName : next.getValidChildNames()) {
|
||||
if (myNameToChild.containsKey(nextName)) {
|
||||
throw new ConfigurationException("Duplicate child name: " + nextName);
|
||||
throw new ConfigurationException("Duplicate child name[" + nextName + "] in Element[" + getName() + "]");
|
||||
} else {
|
||||
myNameToChild.put(nextName, next);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -28,11 +28,11 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
|
||||
|
||||
public abstract class BaseRuntimeElementDefinition<T extends IElement> {
|
||||
public abstract class BaseRuntimeElementDefinition<T extends IBase> {
|
||||
|
||||
private String myName;
|
||||
private Class<? extends T> myImplementingClass;
|
||||
|
@ -129,7 +129,7 @@ public abstract class BaseRuntimeElementDefinition<T extends IElement> {
|
|||
* Invoked prior to use to perform any initialization and make object
|
||||
* mutable
|
||||
*/
|
||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
for (BaseRuntimeChildDefinition next : myExtensions) {
|
||||
next.sealAndInitialize(theClassToElementDefinitions);
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ public abstract class BaseRuntimeElementDefinition<T extends IElement> {
|
|||
for (RuntimeChildDeclaredExtensionDefinition next : myExtensions) {
|
||||
String extUrl = next.getExtensionUrl();
|
||||
if (myUrlToExtension.containsKey(extUrl)) {
|
||||
throw new ConfigurationException("Duplicate extension URL: " + extUrl);
|
||||
throw new ConfigurationException("Duplicate extension URL[" + extUrl + "] in Element[" + getName() + "]");
|
||||
} else {
|
||||
myUrlToExtension.put(extUrl, next);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -20,6 +20,7 @@ package ca.uhn.fhir.context;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -29,6 +30,8 @@ import java.util.Map;
|
|||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.i18n.HapiLocalizer;
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
|
@ -50,23 +53,27 @@ import ca.uhn.fhir.util.FhirTerser;
|
|||
import ca.uhn.fhir.validation.FhirValidator;
|
||||
|
||||
/**
|
||||
* The FHIR context is the central starting point for the use of the HAPI FHIR API. It should be created once, and then used as a factory for various other types of objects (parsers, clients, etc.).
|
||||
* The FHIR context is the central starting point for the use of the HAPI FHIR API. It should be created once, and then
|
||||
* used as a factory for various other types of objects (parsers, clients, etc.).
|
||||
*
|
||||
* <p>
|
||||
* Important usage notes:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li>Thread safety: <b>This class is thread safe</b> and may be shared between multiple processing threads.</li>
|
||||
* <li>
|
||||
* Performance: <b>This class is expensive</b> to create, as it scans every resource class it needs to parse or encode to build up an internal model of those classes. For that reason, you should try
|
||||
* to create one FhirContext instance which remains for the life of your application and reuse that instance. Note that it will not cause problems to create multiple instances (ie. resources
|
||||
* originating from one FhirContext may be passed to parsers originating from another) but you will incur a performance penalty if a new FhirContext is created for every message you parse/encode.</li>
|
||||
* Performance: <b>This class is expensive</b> to create, as it scans every resource class it needs to parse or encode
|
||||
* to build up an internal model of those classes. For that reason, you should try to create one FhirContext instance
|
||||
* which remains for the life of your application and reuse that instance. Note that it will not cause problems to
|
||||
* create multiple instances (ie. resources originating from one FhirContext may be passed to parsers originating from
|
||||
* another) but you will incur a performance penalty if a new FhirContext is created for every message you parse/encode.
|
||||
* </li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*/
|
||||
public class FhirContext {
|
||||
|
||||
private static final List<Class<? extends IResource>> EMPTY_LIST = Collections.emptyList();
|
||||
private volatile Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> myClassToElementDefinition = Collections.emptyMap();
|
||||
private static final List<Class<? extends IBaseResource>> EMPTY_LIST = Collections.emptyList();
|
||||
private volatile Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> myClassToElementDefinition = Collections.emptyMap();
|
||||
private volatile Map<String, RuntimeResourceDefinition> myIdToResourceDefinition = Collections.emptyMap();
|
||||
private HapiLocalizer myLocalizer = new HapiLocalizer();
|
||||
private volatile Map<String, RuntimeResourceDefinition> myNameToElementDefinition = Collections.emptyMap();
|
||||
|
@ -74,7 +81,7 @@ public class FhirContext {
|
|||
private volatile INarrativeGenerator myNarrativeGenerator;
|
||||
private volatile IRestfulClientFactory myRestfulClientFactory;
|
||||
private volatile RuntimeChildUndeclaredExtensionDefinition myRuntimeChildUndeclaredExtensionDefinition;
|
||||
private IFhirVersion myVersion;
|
||||
private final IFhirVersion myVersion;
|
||||
|
||||
/**
|
||||
* Default constructor. In most cases this is the right constructor to use.
|
||||
|
@ -83,7 +90,7 @@ public class FhirContext {
|
|||
this(EMPTY_LIST);
|
||||
}
|
||||
|
||||
public FhirContext(Class<? extends IResource> theResourceType) {
|
||||
public FhirContext(Class<? extends IBaseResource> theResourceType) {
|
||||
this(toCollection(theResourceType));
|
||||
}
|
||||
|
||||
|
@ -91,22 +98,56 @@ public class FhirContext {
|
|||
this(toCollection(theResourceTypes));
|
||||
}
|
||||
|
||||
public FhirContext(Collection<Class<? extends IResource>> theResourceTypes) {
|
||||
scanResourceTypes(theResourceTypes);
|
||||
|
||||
if (FhirVersionEnum.DSTU1.isPresentOnClasspath()) {
|
||||
public FhirContext(Collection<Class<? extends IBaseResource>> theResourceTypes) {
|
||||
this(null, theResourceTypes);
|
||||
}
|
||||
|
||||
public FhirContext(FhirVersionEnum theVersion) {
|
||||
this(theVersion, null);
|
||||
}
|
||||
|
||||
private FhirContext(FhirVersionEnum theVersion, Collection<Class<? extends IBaseResource>> theResourceTypes) {
|
||||
if (theVersion != null) {
|
||||
if (!theVersion.isPresentOnClasspath()) {
|
||||
throw new IllegalStateException(getLocalizer().getMessage(FhirContext.class, "noStructuresForSpecifiedVersion", theVersion.name()));
|
||||
}
|
||||
myVersion = theVersion.getVersionImplementation();
|
||||
} else if (FhirVersionEnum.DSTU1.isPresentOnClasspath()) {
|
||||
myVersion = FhirVersionEnum.DSTU1.getVersionImplementation();
|
||||
} else if (FhirVersionEnum.DSTU2.isPresentOnClasspath()) {
|
||||
myVersion = FhirVersionEnum.DSTU2.getVersionImplementation();
|
||||
} else if (FhirVersionEnum.DEV.isPresentOnClasspath()) {
|
||||
myVersion = FhirVersionEnum.DEV.getVersionImplementation();
|
||||
} else {
|
||||
throw new IllegalStateException("Could not find any HAPI-FHIR structure JARs on the classpath. Note that as of HAPI-FHIR v0.8, a separate FHIR strcture JAR must be added to your classpath or project pom.xml");
|
||||
throw new IllegalStateException(getLocalizer().getMessage(FhirContext.class, "noStructures"));
|
||||
}
|
||||
|
||||
scanResourceTypes(toElementList(theResourceTypes));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<Class<? extends IElement>> toElementList(Collection<Class<? extends IBaseResource>> theResourceTypes) {
|
||||
if (theResourceTypes == null) {
|
||||
return null;
|
||||
}
|
||||
List<Class<? extends IElement>> resTypes = new ArrayList<Class<? extends IElement>>();
|
||||
for (Class<? extends IBaseResource> next : theResourceTypes) {
|
||||
resTypes.add((Class<? extends IElement>) next);
|
||||
}
|
||||
return resTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the scanned runtime model for the given type. This is an advanced feature which is generally only needed for extending the core library.
|
||||
* Returns the scanned runtime model for the given type. This is an advanced feature which is generally only needed
|
||||
* for extending the core library.
|
||||
*/
|
||||
public BaseRuntimeElementDefinition<?> getElementDefinition(Class<? extends IElement> theElementType) {
|
||||
return myClassToElementDefinition.get(theElementType);
|
||||
@SuppressWarnings("unchecked")
|
||||
public BaseRuntimeElementDefinition<?> getElementDefinition(Class<? extends IBase> theElementType) {
|
||||
BaseRuntimeElementDefinition<?> retVal = myClassToElementDefinition.get(theElementType);
|
||||
if (retVal == null) {
|
||||
retVal = scanDatatype((Class<? extends IElement>) theElementType);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/** For unit tests only */
|
||||
|
@ -115,7 +156,8 @@ public class FhirContext {
|
|||
}
|
||||
|
||||
/**
|
||||
* This feature is not yet in its final state and should be considered an internal part of HAPI for now - use with caution
|
||||
* This feature is not yet in its final state and should be considered an internal part of HAPI for now - use with
|
||||
* caution
|
||||
*/
|
||||
public HapiLocalizer getLocalizer() {
|
||||
if (myLocalizer == null) {
|
||||
|
@ -129,32 +171,44 @@ public class FhirContext {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the scanned runtime model for the given type. This is an advanced feature which is generally only needed for extending the core library.
|
||||
* Returns the scanned runtime model for the given type. This is an advanced feature which is generally only needed
|
||||
* for extending the core library.
|
||||
*/
|
||||
public RuntimeResourceDefinition getResourceDefinition(Class<? extends IResource> theResourceType) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public RuntimeResourceDefinition getResourceDefinition(Class<? extends IBaseResource> theResourceType) {
|
||||
if (theResourceType == null) {
|
||||
throw new NullPointerException("theResourceType can not be null");
|
||||
}
|
||||
if (Modifier.isAbstract(theResourceType.getModifiers())) {
|
||||
throw new IllegalArgumentException("Can not scan abstract or interface class (resource definitions must be concrete classes): " + theResourceType.getName());
|
||||
}
|
||||
|
||||
RuntimeResourceDefinition retVal = (RuntimeResourceDefinition) myClassToElementDefinition.get(theResourceType);
|
||||
if (retVal == null) {
|
||||
retVal = scanResourceType(theResourceType);
|
||||
retVal = scanResourceType((Class<? extends IResource>) theResourceType);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the scanned runtime model for the given type. This is an advanced feature which is generally only needed for extending the core library.
|
||||
* Returns the scanned runtime model for the given type. This is an advanced feature which is generally only needed
|
||||
* for extending the core library.
|
||||
*/
|
||||
public RuntimeResourceDefinition getResourceDefinition(IResource theResource) {
|
||||
public RuntimeResourceDefinition getResourceDefinition(IBaseResource theResource) {
|
||||
return getResourceDefinition(theResource.getClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the scanned runtime model for the given type. This is an advanced feature which is generally only needed for extending the core library.
|
||||
* Returns the scanned runtime model for the given type. This is an advanced feature which is generally only needed
|
||||
* for extending the core library.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public RuntimeResourceDefinition getResourceDefinition(String theResourceName) {
|
||||
String resourceName = theResourceName;
|
||||
|
||||
/*
|
||||
* TODO: this is a bit of a hack, really we should have a translation table based on a property file or something so that we can detect names like diagnosticreport
|
||||
* TODO: this is a bit of a hack, really we should have a translation table based on a property file or
|
||||
* something so that we can detect names like diagnosticreport
|
||||
*/
|
||||
if (Character.isLowerCase(resourceName.charAt(0))) {
|
||||
resourceName = WordUtils.capitalize(resourceName);
|
||||
|
@ -188,14 +242,16 @@ public class FhirContext {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the scanned runtime model for the given type. This is an advanced feature which is generally only needed for extending the core library.
|
||||
* Returns the scanned runtime model for the given type. This is an advanced feature which is generally only needed
|
||||
* for extending the core library.
|
||||
*/
|
||||
public RuntimeResourceDefinition getResourceDefinitionById(String theId) {
|
||||
return myIdToResourceDefinition.get(theId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the scanned runtime models. This is an advanced feature which is generally only needed for extending the core library.
|
||||
* Returns the scanned runtime models. This is an advanced feature which is generally only needed for extending the
|
||||
* core library.
|
||||
*/
|
||||
public Collection<RuntimeResourceDefinition> getResourceDefinitions() {
|
||||
return myIdToResourceDefinition.values();
|
||||
|
@ -220,10 +276,12 @@ public class FhirContext {
|
|||
* Create and return a new JSON parser.
|
||||
*
|
||||
* <p>
|
||||
* Thread safety: <b>Parsers are not guaranteed to be thread safe</b>. Create a new parser instance for every thread or every message being parsed/encoded.
|
||||
* Thread safety: <b>Parsers are not guaranteed to be thread safe</b>. Create a new parser instance for every thread
|
||||
* or every message being parsed/encoded.
|
||||
* </p>
|
||||
* <p>
|
||||
* Performance Note: <b>This method is cheap</b> to call, and may be called once for every message being processed without incurring any performance penalty
|
||||
* Performance Note: <b>This method is cheap</b> to call, and may be called once for every message being processed
|
||||
* without incurring any performance penalty
|
||||
* </p>
|
||||
*/
|
||||
public IParser newJsonParser() {
|
||||
|
@ -231,12 +289,16 @@ public class FhirContext {
|
|||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new client instance. This method requires an interface which is defined specifically for your use cases to contain methods for each of the RESTful operations you wish to
|
||||
* implement (e.g. "read ImagingStudy", "search Patient by identifier", etc.). This interface must extend {@link IRestfulClient} (or commonly its sub-interface {@link IBasicClient}). See the <a
|
||||
* href="http://hl7api.sourceforge.net/hapi-fhir/doc_rest_client.html">RESTful Client</a> documentation for more information on how to define this interface.
|
||||
* Instantiates a new client instance. This method requires an interface which is defined specifically for your use
|
||||
* cases to contain methods for each of the RESTful operations you wish to implement (e.g. "read ImagingStudy",
|
||||
* "search Patient by identifier", etc.). This interface must extend {@link IRestfulClient} (or commonly its
|
||||
* sub-interface {@link IBasicClient}). See the <a
|
||||
* href="http://hl7api.sourceforge.net/hapi-fhir/doc_rest_client.html">RESTful Client</a> documentation for more
|
||||
* information on how to define this interface.
|
||||
*
|
||||
* <p>
|
||||
* Performance Note: <b>This method is cheap</b> to call, and may be called once for every operation invocation without incurring any performance penalty
|
||||
* Performance Note: <b>This method is cheap</b> to call, and may be called once for every operation invocation
|
||||
* without incurring any performance penalty
|
||||
* </p>
|
||||
*
|
||||
* @param theClientType
|
||||
|
@ -252,16 +314,17 @@ public class FhirContext {
|
|||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new generic client. A generic client is able to perform any of the FHIR RESTful operations against a compliant server, but does not have methods defining the specific
|
||||
* functionality required (as is the case with {@link #newRestfulClient(Class, String) non-generic clients}).
|
||||
* Instantiates a new generic client. A generic client is able to perform any of the FHIR RESTful operations against
|
||||
* a compliant server, but does not have methods defining the specific functionality required (as is the case with
|
||||
* {@link #newRestfulClient(Class, String) non-generic clients}).
|
||||
*
|
||||
* <p>
|
||||
* Performance Note: <b>This method is cheap</b> to call, and may be called once for every operation invocation without incurring any performance penalty
|
||||
* Performance Note: <b>This method is cheap</b> to call, and may be called once for every operation invocation
|
||||
* without incurring any performance penalty
|
||||
* </p>
|
||||
*
|
||||
* @param theServerBase
|
||||
* The URL of the base for the restful FHIR server to connect to
|
||||
* @return
|
||||
*/
|
||||
public IGenericClient newRestfulGenericClient(String theServerBase) {
|
||||
return getRestfulClientFactory().newGenericClient(theServerBase);
|
||||
|
@ -283,10 +346,12 @@ public class FhirContext {
|
|||
* Create and return a new XML parser.
|
||||
*
|
||||
* <p>
|
||||
* Thread safety: <b>Parsers are not guaranteed to be thread safe</b>. Create a new parser instance for every thread or every message being parsed/encoded.
|
||||
* Thread safety: <b>Parsers are not guaranteed to be thread safe</b>. Create a new parser instance for every thread
|
||||
* or every message being parsed/encoded.
|
||||
* </p>
|
||||
* <p>
|
||||
* Performance Note: <b>This method is cheap</b> to call, and may be called once for every message being processed without incurring any performance penalty
|
||||
* Performance Note: <b>This method is cheap</b> to call, and may be called once for every message being processed
|
||||
* without incurring any performance penalty
|
||||
* </p>
|
||||
*/
|
||||
public IParser newXmlParser() {
|
||||
|
@ -294,13 +359,20 @@ public class FhirContext {
|
|||
}
|
||||
|
||||
private RuntimeResourceDefinition scanResourceType(Class<? extends IResource> theResourceType) {
|
||||
ArrayList<Class<? extends IResource>> resourceTypes = new ArrayList<Class<? extends IResource>>();
|
||||
ArrayList<Class<? extends IElement>> resourceTypes = new ArrayList<Class<? extends IElement>>();
|
||||
resourceTypes.add(theResourceType);
|
||||
Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> defs = scanResourceTypes(resourceTypes);
|
||||
Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> defs = scanResourceTypes(resourceTypes);
|
||||
return (RuntimeResourceDefinition) defs.get(theResourceType);
|
||||
}
|
||||
|
||||
private Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> scanResourceTypes(Collection<Class<? extends IResource>> theResourceTypes) {
|
||||
private BaseRuntimeElementDefinition<?> scanDatatype(Class<? extends IElement> theResourceType) {
|
||||
ArrayList<Class<? extends IElement>> resourceTypes = new ArrayList<Class<? extends IElement>>();
|
||||
resourceTypes.add(theResourceType);
|
||||
Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> defs = scanResourceTypes(resourceTypes);
|
||||
return defs.get(theResourceType);
|
||||
}
|
||||
|
||||
private Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> scanResourceTypes(Collection<Class<? extends IElement>> theResourceTypes) {
|
||||
ModelScanner scanner = new ModelScanner(this, myClassToElementDefinition, theResourceTypes);
|
||||
if (myRuntimeChildUndeclaredExtensionDefinition == null) {
|
||||
myRuntimeChildUndeclaredExtensionDefinition = scanner.getRuntimeChildUndeclaredExtensionDefinition();
|
||||
|
@ -310,7 +382,7 @@ public class FhirContext {
|
|||
nameToElementDefinition.putAll(myNameToElementDefinition);
|
||||
nameToElementDefinition.putAll(scanner.getNameToResourceDefinitions());
|
||||
|
||||
Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> classToElementDefinition = new HashMap<Class<? extends IElement>, BaseRuntimeElementDefinition<?>>();
|
||||
Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> classToElementDefinition = new HashMap<Class<? extends IBase>, BaseRuntimeElementDefinition<?>>();
|
||||
classToElementDefinition.putAll(myClassToElementDefinition);
|
||||
classToElementDefinition.putAll(scanner.getClassToElementDefinitions());
|
||||
|
||||
|
@ -328,25 +400,29 @@ public class FhirContext {
|
|||
}
|
||||
|
||||
/**
|
||||
* This feature is not yet in its final state and should be considered an internal part of HAPI for now - use with caution
|
||||
* This feature is not yet in its final state and should be considered an internal part of HAPI for now - use with
|
||||
* caution
|
||||
*/
|
||||
public void setLocalizer(HapiLocalizer theMessages) {
|
||||
myLocalizer = theMessages;
|
||||
}
|
||||
|
||||
public void setNarrativeGenerator(INarrativeGenerator theNarrativeGenerator) {
|
||||
if (theNarrativeGenerator != null) {
|
||||
theNarrativeGenerator.setFhirContext(this);
|
||||
}
|
||||
myNarrativeGenerator = theNarrativeGenerator;
|
||||
}
|
||||
|
||||
private static Collection<Class<? extends IResource>> toCollection(Class<? extends IResource> theResourceType) {
|
||||
ArrayList<Class<? extends IResource>> retVal = new ArrayList<Class<? extends IResource>>(1);
|
||||
private static Collection<Class<? extends IBaseResource>> toCollection(Class<? extends IBaseResource> theResourceType) {
|
||||
ArrayList<Class<? extends IBaseResource>> retVal = new ArrayList<Class<? extends IBaseResource>>(1);
|
||||
retVal.add(theResourceType);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static List<Class<? extends IResource>> toCollection(Class<?>[] theResourceTypes) {
|
||||
ArrayList<Class<? extends IResource>> retVal = new ArrayList<Class<? extends IResource>>(1);
|
||||
private static List<Class<? extends IBaseResource>> toCollection(Class<?>[] theResourceTypes) {
|
||||
ArrayList<Class<? extends IBaseResource>> retVal = new ArrayList<Class<? extends IBaseResource>>(1);
|
||||
for (Class<?> clazz : theResourceTypes) {
|
||||
if (!IResource.class.isAssignableFrom(clazz)) {
|
||||
throw new IllegalArgumentException(clazz.getCanonicalName() + " is not an instance of " + IResource.class.getSimpleName());
|
||||
|
@ -356,4 +432,25 @@ public class FhirContext {
|
|||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a new FhirContext with version {@link FhirVersionEnum#DSTU1}
|
||||
*/
|
||||
public static FhirContext forDstu1() {
|
||||
return new FhirContext(FhirVersionEnum.DSTU1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a new FhirContext with version {@link FhirVersionEnum#DEV}
|
||||
*/
|
||||
public static FhirContext forDev() {
|
||||
return new FhirContext(FhirVersionEnum.DEV);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a new FhirContext with version {@link FhirVersionEnum#DSTU2}
|
||||
*/
|
||||
public static FhirContext forDstu2() {
|
||||
return new FhirContext(FhirVersionEnum.DSTU2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -25,14 +25,44 @@ import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
|||
|
||||
public enum FhirVersionEnum {
|
||||
|
||||
DSTU1("ca.uhn.fhir.model.dstu.FhirDstu1");
|
||||
/*
|
||||
* ***********************
|
||||
* Don't auto-sort this type!!!
|
||||
*
|
||||
* Or more accurately, entries should be sorted from OLDEST FHIR release
|
||||
* to NEWEST FHIR release instead of alphabetically
|
||||
* ***********************
|
||||
*/
|
||||
|
||||
DSTU1("ca.uhn.fhir.model.dstu.FhirDstu1", null),
|
||||
|
||||
DSTU2("ca.uhn.fhir.model.dstu2.FhirDstu2", null),
|
||||
|
||||
DEV("ca.uhn.fhir.model.dev.FhirDev", null);
|
||||
|
||||
|
||||
private final String myVersionClass;
|
||||
private final FhirVersionEnum myEquivalent;
|
||||
private volatile Boolean myPresentOnClasspath;
|
||||
private volatile IFhirVersion myVersionImplementation;
|
||||
|
||||
FhirVersionEnum(String theVersionClass) {
|
||||
FhirVersionEnum(String theVersionClass, FhirVersionEnum theEquivalent) {
|
||||
myVersionClass = theVersionClass;
|
||||
myEquivalent = theEquivalent;
|
||||
}
|
||||
|
||||
public boolean isEquivalentTo(FhirVersionEnum theVersion) {
|
||||
if (this.equals(theVersion)) {
|
||||
return true;
|
||||
}
|
||||
if (myEquivalent != null) {
|
||||
return myEquivalent.equals(theVersion);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isNewerThan(FhirVersionEnum theVersion) {
|
||||
return ordinal() > theVersion.ordinal();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -20,13 +20,18 @@ package ca.uhn.fhir.context;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.AnnotatedElement;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
@ -43,11 +48,19 @@ import java.util.Set;
|
|||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.hl7.fhir.instance.model.BackboneElement;
|
||||
import org.hl7.fhir.instance.model.DomainResource;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.ICompositeType;
|
||||
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.Narrative;
|
||||
import org.hl7.fhir.instance.model.Reference;
|
||||
|
||||
import ca.uhn.fhir.model.api.CodeableConceptElement;
|
||||
import ca.uhn.fhir.model.api.ExtensionDt;
|
||||
import ca.uhn.fhir.model.api.IBoundCodeableConcept;
|
||||
import ca.uhn.fhir.model.api.ICodeEnum;
|
||||
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
||||
import ca.uhn.fhir.model.api.ICompositeElement;
|
||||
import ca.uhn.fhir.model.api.IDatatype;
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
|
@ -74,7 +87,7 @@ import ca.uhn.fhir.util.ReflectionUtil;
|
|||
class ModelScanner {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ModelScanner.class);
|
||||
|
||||
private Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> myClassToElementDefinitions = new HashMap<Class<? extends IElement>, BaseRuntimeElementDefinition<?>>();
|
||||
private Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> myClassToElementDefinitions = new HashMap<Class<? extends IBase>, BaseRuntimeElementDefinition<?>>();
|
||||
private Map<String, RuntimeResourceDefinition> myIdToResourceDefinition = new HashMap<String, RuntimeResourceDefinition>();
|
||||
private Map<String, RuntimeResourceDefinition> myNameToResourceDefinitions = new HashMap<String, RuntimeResourceDefinition>();
|
||||
|
||||
|
@ -86,30 +99,36 @@ class ModelScanner {
|
|||
|
||||
private RuntimeChildUndeclaredExtensionDefinition myRuntimeChildUndeclaredExtensionDefinition;
|
||||
|
||||
private Set<Class<? extends IElement>> myScanAlso = new HashSet<Class<? extends IElement>>();
|
||||
private Set<Class<? extends IBase>> myScanAlso = new HashSet<Class<? extends IBase>>();
|
||||
|
||||
private Set<Class<? extends ICodeEnum>> myScanAlsoCodeTable = new HashSet<Class<? extends ICodeEnum>>();
|
||||
|
||||
private FhirContext myContext;
|
||||
|
||||
ModelScanner(FhirContext theContext, Class<? extends IResource> theResourceTypes) throws ConfigurationException {
|
||||
myContext=theContext;
|
||||
Set<Class<? extends IElement>> singleton = new HashSet<Class<? extends IElement>>();
|
||||
ModelScanner(FhirContext theContext, Class<? extends IBaseResource> theResourceTypes) throws ConfigurationException {
|
||||
myContext = theContext;
|
||||
Set<Class<? extends IBase>> singleton = new HashSet<Class<? extends IBase>>();
|
||||
singleton.add(theResourceTypes);
|
||||
init(null, singleton);
|
||||
}
|
||||
|
||||
ModelScanner(FhirContext theContext, Collection<Class<? extends IResource>> theResourceTypes) throws ConfigurationException {
|
||||
myContext=theContext;
|
||||
init(null, new HashSet<Class<? extends IElement>>(theResourceTypes));
|
||||
ModelScanner(FhirContext theContext, Collection<Class<? extends IBaseResource>> theResourceTypes) throws ConfigurationException {
|
||||
myContext = theContext;
|
||||
init(null, new HashSet<Class<? extends IBase>>(theResourceTypes));
|
||||
}
|
||||
|
||||
ModelScanner(FhirContext theContext, Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theExistingDefinitions, Collection<Class<? extends IResource>> theResourceTypes) throws ConfigurationException {
|
||||
myContext=theContext;
|
||||
init(theExistingDefinitions, new HashSet<Class<? extends IElement>>(theResourceTypes));
|
||||
ModelScanner(FhirContext theContext, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theExistingDefinitions, Collection<Class<? extends IElement>> theResourceTypes) throws ConfigurationException {
|
||||
myContext = theContext;
|
||||
Set<Class<? extends IBase>> toScan;
|
||||
if (theResourceTypes != null) {
|
||||
toScan = new HashSet<Class<? extends IBase>>(theResourceTypes);
|
||||
} else {
|
||||
toScan = new HashSet<Class<? extends IBase>>();
|
||||
}
|
||||
init(theExistingDefinitions, toScan);
|
||||
}
|
||||
|
||||
public Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> getClassToElementDefinitions() {
|
||||
public Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> getClassToElementDefinitions() {
|
||||
return myClassToElementDefinitions;
|
||||
}
|
||||
|
||||
|
@ -129,7 +148,7 @@ class ModelScanner {
|
|||
return myRuntimeChildUndeclaredExtensionDefinition;
|
||||
}
|
||||
|
||||
private void addScanAlso(Class<? extends IElement> theType) {
|
||||
private void addScanAlso(Class<? extends IBase> theType) {
|
||||
if (theType.isInterface()) {
|
||||
return;
|
||||
}
|
||||
|
@ -167,7 +186,7 @@ class ModelScanner {
|
|||
}
|
||||
}
|
||||
|
||||
private void init(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theExistingDefinitions, Set<Class<? extends IElement>> toScan) {
|
||||
private void init(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theExistingDefinitions, Set<Class<? extends IBase>> toScan) {
|
||||
if (theExistingDefinitions != null) {
|
||||
myClassToElementDefinitions.putAll(theExistingDefinitions);
|
||||
}
|
||||
|
@ -175,13 +194,7 @@ class ModelScanner {
|
|||
int startSize = myClassToElementDefinitions.size();
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
InputStream str = ModelScanner.class.getResourceAsStream("/ca/uhn/fhir/model/dstu/fhirversion.properties");
|
||||
if (str == null) {
|
||||
str = ModelScanner.class.getResourceAsStream("ca/uhn/fhir/model/dstu/fhirversion.properties");
|
||||
}
|
||||
if (str == null) {
|
||||
throw new ConfigurationException("Can not find model property file on classpath: " + "/ca/uhn/fhir/model/dstu/model.properties");
|
||||
}
|
||||
InputStream str = myContext.getVersion().getFhirVersionPropertiesFile();
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
prop.load(str);
|
||||
|
@ -222,10 +235,10 @@ class ModelScanner {
|
|||
// toScan.add(QuantityDt.class);
|
||||
|
||||
do {
|
||||
for (Class<? extends IElement> nextClass : toScan) {
|
||||
for (Class<? extends IBase> nextClass : toScan) {
|
||||
scan(nextClass);
|
||||
}
|
||||
for (Iterator<Class<? extends IElement>> iter = myScanAlso.iterator(); iter.hasNext();) {
|
||||
for (Iterator<Class<? extends IBase>> iter = myScanAlso.iterator(); iter.hasNext();) {
|
||||
if (myClassToElementDefinitions.containsKey(iter.next())) {
|
||||
iter.remove();
|
||||
}
|
||||
|
@ -235,7 +248,7 @@ class ModelScanner {
|
|||
myScanAlso.clear();
|
||||
} while (!toScan.isEmpty());
|
||||
|
||||
for (Entry<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> nextEntry : myClassToElementDefinitions.entrySet()) {
|
||||
for (Entry<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> nextEntry : myClassToElementDefinitions.entrySet()) {
|
||||
if (theExistingDefinitions != null && theExistingDefinitions.containsKey(nextEntry.getKey())) {
|
||||
continue;
|
||||
}
|
||||
|
@ -251,38 +264,38 @@ class ModelScanner {
|
|||
ourLog.info("Done scanning FHIR library, found {} model entries in {}ms", size, time);
|
||||
}
|
||||
|
||||
private void scan(Class<? extends IElement> theClass) throws ConfigurationException {
|
||||
private void scan(Class<? extends IBase> theClass) throws ConfigurationException {
|
||||
BaseRuntimeElementDefinition<?> existingDef = myClassToElementDefinitions.get(theClass);
|
||||
if (existingDef != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ResourceDef resourceDefinition = theClass.getAnnotation(ResourceDef.class);
|
||||
ResourceDef resourceDefinition = pullAnnotation(theClass, ResourceDef.class);
|
||||
if (resourceDefinition != null) {
|
||||
if (!IResource.class.isAssignableFrom(theClass)) {
|
||||
throw new ConfigurationException("Resource type contains a @" + ResourceDef.class.getSimpleName() + " annotation but does not implement " + IResource.class.getCanonicalName() + ": " + theClass.getCanonicalName());
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends IResource> resClass = (Class<? extends IResource>) theClass;
|
||||
Class<? extends IBaseResource> resClass = (Class<? extends IBaseResource>) theClass;
|
||||
scanResource(resClass, resourceDefinition);
|
||||
}
|
||||
|
||||
DatatypeDef datatypeDefinition = theClass.getAnnotation(DatatypeDef.class);
|
||||
DatatypeDef datatypeDefinition = pullAnnotation(theClass, DatatypeDef.class);
|
||||
if (datatypeDefinition != null) {
|
||||
if (ICompositeDatatype.class.isAssignableFrom(theClass)) {
|
||||
if (ICompositeType.class.isAssignableFrom(theClass)) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends ICompositeDatatype> resClass = (Class<? extends ICompositeDatatype>) theClass;
|
||||
Class<? extends ICompositeType> resClass = (Class<? extends ICompositeType>) theClass;
|
||||
scanCompositeDatatype(resClass, datatypeDefinition);
|
||||
} else if (IPrimitiveDatatype.class.isAssignableFrom(theClass)) {
|
||||
} else if (IPrimitiveType.class.isAssignableFrom(theClass)) {
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
Class<? extends IPrimitiveDatatype<?>> resClass = (Class<? extends IPrimitiveDatatype<?>>) theClass;
|
||||
Class<? extends IPrimitiveType<?>> resClass = (Class<? extends IPrimitiveType<?>>) theClass;
|
||||
scanPrimitiveDatatype(resClass, datatypeDefinition);
|
||||
} else {
|
||||
throw new ConfigurationException("Resource type contains a @" + DatatypeDef.class.getSimpleName() + " annotation but does not implement " + IDatatype.class.getCanonicalName() + ": " + theClass.getCanonicalName());
|
||||
}
|
||||
}
|
||||
|
||||
Block blockDefinition = theClass.getAnnotation(Block.class);
|
||||
Block blockDefinition = pullAnnotation(theClass, Block.class);
|
||||
if (blockDefinition != null) {
|
||||
if (IResourceBlock.class.isAssignableFrom(theClass)) {
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -294,7 +307,7 @@ class ModelScanner {
|
|||
}
|
||||
|
||||
if (blockDefinition == null && datatypeDefinition == null && resourceDefinition == null) {
|
||||
throw new ConfigurationException("Resource type does not contain any valid HAPI-FHIR annotations: " + theClass.getCanonicalName());
|
||||
throw new ConfigurationException("Resource class[" + theClass.getName() + "] does not contain any valid HAPI-FHIR annotations");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -312,7 +325,7 @@ class ModelScanner {
|
|||
scanCompositeElementForChildren(theClass, resourceDef);
|
||||
}
|
||||
|
||||
private void scanCompositeDatatype(Class<? extends ICompositeDatatype> theClass, DatatypeDef theDatatypeDefinition) {
|
||||
private void scanCompositeDatatype(Class<? extends ICompositeType> theClass, DatatypeDef theDatatypeDefinition) {
|
||||
ourLog.debug("Scanning resource class: {}", theClass.getName());
|
||||
|
||||
RuntimeCompositeDatatypeDefinition resourceDef;
|
||||
|
@ -326,27 +339,27 @@ class ModelScanner {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void scanCompositeElementForChildren(Class<? extends ICompositeElement> theClass, BaseRuntimeElementCompositeDefinition<?> theDefinition) {
|
||||
private void scanCompositeElementForChildren(Class<? extends IBase> theClass, BaseRuntimeElementCompositeDefinition<?> theDefinition) {
|
||||
Set<String> elementNames = new HashSet<String>();
|
||||
TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> orderToElementDef = new TreeMap<Integer, BaseRuntimeDeclaredChildDefinition>();
|
||||
TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> orderToExtensionDef = new TreeMap<Integer, BaseRuntimeDeclaredChildDefinition>();
|
||||
|
||||
LinkedList<Class<? extends ICompositeElement>> classes = new LinkedList<Class<? extends ICompositeElement>>();
|
||||
LinkedList<Class<? extends IBase>> classes = new LinkedList<Class<? extends IBase>>();
|
||||
|
||||
/*
|
||||
* We scan classes for annotated fields in the class but also all of its superclasses
|
||||
*/
|
||||
Class<? extends ICompositeElement> current = theClass;
|
||||
Class<? extends IBase> current = theClass;
|
||||
do {
|
||||
classes.push(current);
|
||||
if (ICompositeElement.class.isAssignableFrom(current.getSuperclass())) {
|
||||
current = (Class<? extends ICompositeElement>) current.getSuperclass();
|
||||
current = (Class<? extends IBase>) current.getSuperclass();
|
||||
} else {
|
||||
current = null;
|
||||
}
|
||||
} while (current != null);
|
||||
|
||||
for (Class<? extends ICompositeElement> next : classes) {
|
||||
for (Class<? extends IBase> next : classes) {
|
||||
scanCompositeElementForChildren(next, elementNames, orderToElementDef, orderToExtensionDef);
|
||||
}
|
||||
|
||||
|
@ -380,26 +393,26 @@ class ModelScanner {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void scanCompositeElementForChildren(Class<? extends ICompositeElement> theClass, Set<String> elementNames, TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> theOrderToElementDef, TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> theOrderToExtensionDef) {
|
||||
private void scanCompositeElementForChildren(Class<? extends IBase> theClass, Set<String> elementNames, TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> theOrderToElementDef, TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> theOrderToExtensionDef) {
|
||||
int baseElementOrder = theOrderToElementDef.isEmpty() ? 0 : theOrderToElementDef.lastEntry().getKey() + 1;
|
||||
|
||||
for (Field next : theClass.getDeclaredFields()) {
|
||||
|
||||
if (Modifier.isFinal(next.getModifiers())) {
|
||||
ourLog.trace("Ignoring constant {} on target type {}", next.getName(), theClass);
|
||||
continue;
|
||||
}
|
||||
|
||||
Child childAnnotation = next.getAnnotation(Child.class);
|
||||
if (childAnnotation == null) {
|
||||
ourLog.trace("Ignoring non @Child field {} on target type {}",next.getName() , theClass);
|
||||
ourLog.trace("Ignoring constant {} on target type {}", next.getName(), theClass);
|
||||
continue;
|
||||
}
|
||||
|
||||
Description descriptionAnnotation = next.getAnnotation(Description.class);
|
||||
Child childAnnotation = pullAnnotation(next, Child.class);
|
||||
if (childAnnotation == null) {
|
||||
ourLog.trace("Ignoring non @Child field {} on target type {}", next.getName(), theClass);
|
||||
continue;
|
||||
}
|
||||
|
||||
Description descriptionAnnotation = pullAnnotation(next, Description.class);
|
||||
|
||||
TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> orderMap = theOrderToElementDef;
|
||||
Extension extensionAttr = next.getAnnotation(Extension.class);
|
||||
Extension extensionAttr = pullAnnotation(next, Extension.class);
|
||||
if (extensionAttr != null) {
|
||||
orderMap = theOrderToExtensionDef;
|
||||
}
|
||||
|
@ -422,8 +435,8 @@ class ModelScanner {
|
|||
}
|
||||
}
|
||||
if (order == Child.REPLACE_PARENT) {
|
||||
throw new ConfigurationException("Field " + next.getName() + "' on target type " + theClass.getSimpleName() + " has order() of REPLACE_PARENT (" + Child.REPLACE_PARENT + ") but no parent element with extension URL " + extensionAttr.url()
|
||||
+ " could be found on type " + next.getDeclaringClass().getSimpleName());
|
||||
throw new ConfigurationException("Field " + next.getName() + "' on target type " + theClass.getSimpleName() + " has order() of REPLACE_PARENT (" + Child.REPLACE_PARENT + ") but no parent element with extension URL " + extensionAttr.url() + " could be found on type "
|
||||
+ next.getDeclaringClass().getSimpleName());
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -453,16 +466,20 @@ class ModelScanner {
|
|||
}
|
||||
int min = childAnnotation.min();
|
||||
int max = childAnnotation.max();
|
||||
|
||||
/*
|
||||
* Anything that's marked as unknown is given a new ID that is <0 so that it doesn't conflict wityh any
|
||||
* given IDs and can be figured out later
|
||||
* Anything that's marked as unknown is given a new ID that is <0 so that it doesn't conflict with any given
|
||||
* IDs and can be figured out later
|
||||
*/
|
||||
while (order == Child.ORDER_UNKNOWN && orderMap.containsKey(order)) {
|
||||
order--;
|
||||
if (order == Child.ORDER_UNKNOWN) {
|
||||
order = Integer.MIN_VALUE;
|
||||
while (orderMap.containsKey(order)) {
|
||||
order++;
|
||||
}
|
||||
}
|
||||
|
||||
List<Class<? extends IElement>> choiceTypes = new ArrayList<Class<? extends IElement>>();
|
||||
for (Class<? extends IElement> nextChoiceType : childAnnotation.type()) {
|
||||
List<Class<? extends IBase>> choiceTypes = new ArrayList<Class<? extends IBase>>();
|
||||
for (Class<? extends IBase> nextChoiceType : childAnnotation.type()) {
|
||||
choiceTypes.add(nextChoiceType);
|
||||
}
|
||||
|
||||
|
@ -476,18 +493,18 @@ class ModelScanner {
|
|||
|
||||
Class<?> nextElementType = determineElementType(next);
|
||||
|
||||
if (nextElementType.equals(ContainedDt.class)) {
|
||||
if (nextElementType.equals(ContainedDt.class) || (childAnnotation.name().equals("contained") && DomainResource.class.isAssignableFrom(theClass))) {
|
||||
/*
|
||||
* Child is contained resources
|
||||
*/
|
||||
RuntimeChildContainedResources def = new RuntimeChildContainedResources(next, childAnnotation, descriptionAnnotation, elementName);
|
||||
orderMap.put(order, def);
|
||||
|
||||
} else if (choiceTypes.size() > 1 && !BaseResourceReferenceDt.class.isAssignableFrom(nextElementType)) {
|
||||
} else if (choiceTypes.size() > 1 && !BaseResourceReferenceDt.class.isAssignableFrom(nextElementType) && !Reference.class.isAssignableFrom(nextElementType)) {
|
||||
/*
|
||||
* Child is a choice element
|
||||
*/
|
||||
for (Class<? extends IElement> nextType : choiceTypes) {
|
||||
for (Class<? extends IBase> nextType : choiceTypes) {
|
||||
addScanAlso(nextType);
|
||||
}
|
||||
RuntimeChildChoiceDefinition def = new RuntimeChildChoiceDefinition(next, elementName, childAnnotation, descriptionAnnotation, choiceTypes);
|
||||
|
@ -505,34 +522,34 @@ class ModelScanner {
|
|||
/*
|
||||
* Child is an extension
|
||||
*/
|
||||
Class<? extends IElement> et = (Class<? extends IElement>) nextElementType;
|
||||
Class<? extends IBase> et = (Class<? extends IBase>) nextElementType;
|
||||
RuntimeChildDeclaredExtensionDefinition def = new RuntimeChildDeclaredExtensionDefinition(next, childAnnotation, descriptionAnnotation, extensionAttr, elementName, extensionAttr.url(), et);
|
||||
orderMap.put(order, def);
|
||||
if (IElement.class.isAssignableFrom(nextElementType)) {
|
||||
addScanAlso((Class<? extends IElement>) nextElementType);
|
||||
}
|
||||
} else if (BaseResourceReferenceDt.class.isAssignableFrom(nextElementType)) {
|
||||
} else if (BaseResourceReferenceDt.class.isAssignableFrom(nextElementType) || Reference.class.isAssignableFrom(nextElementType)) {
|
||||
/*
|
||||
* Child is a resource reference
|
||||
*/
|
||||
List<Class<? extends IResource>> refTypesList = new ArrayList<Class<? extends IResource>>();
|
||||
List<Class<? extends IBaseResource>> refTypesList = new ArrayList<Class<? extends IBaseResource>>();
|
||||
for (Class<? extends IElement> nextType : childAnnotation.type()) {
|
||||
if (IResource.class.isAssignableFrom(nextType) == false) {
|
||||
if (IBaseResource.class.isAssignableFrom(nextType) == false) {
|
||||
throw new ConfigurationException("Field '" + next.getName() + "' in class '" + next.getDeclaringClass().getCanonicalName() + "' is of type " + BaseResourceReferenceDt.class + " but contains a non-resource type: " + nextType.getCanonicalName());
|
||||
}
|
||||
refTypesList.add((Class<? extends IResource>) nextType);
|
||||
refTypesList.add((Class<? extends IBaseResource>) nextType);
|
||||
addScanAlso(nextType);
|
||||
}
|
||||
RuntimeChildResourceDefinition def = new RuntimeChildResourceDefinition(next, elementName, childAnnotation, descriptionAnnotation, refTypesList);
|
||||
orderMap.put(order, def);
|
||||
|
||||
} else if (IResourceBlock.class.isAssignableFrom(nextElementType)) {
|
||||
} else if (IResourceBlock.class.isAssignableFrom(nextElementType) || BackboneElement.class.isAssignableFrom(nextElementType)) {
|
||||
/*
|
||||
* Child is a resource block (i.e. a sub-tag within a resource) TODO: do these have a better name
|
||||
* according to HL7?
|
||||
*/
|
||||
|
||||
Class<? extends IResourceBlock> blockDef = (Class<? extends IResourceBlock>) nextElementType;
|
||||
Class<? extends IBase> blockDef = (Class<? extends IBase>) nextElementType;
|
||||
addScanAlso(blockDef);
|
||||
RuntimeChildResourceBlockDefinition def = new RuntimeChildResourceBlockDefinition(next, childAnnotation, descriptionAnnotation, elementName, blockDef);
|
||||
orderMap.put(order, def);
|
||||
|
@ -542,8 +559,8 @@ class ModelScanner {
|
|||
RuntimeChildAny def = new RuntimeChildAny(next, elementName, childAnnotation, descriptionAnnotation);
|
||||
orderMap.put(order, def);
|
||||
|
||||
} else if (IDatatype.class.isAssignableFrom(nextElementType)) {
|
||||
Class<? extends IDatatype> nextDatatype = (Class<? extends IDatatype>) nextElementType;
|
||||
} else if (IDatatype.class.isAssignableFrom(nextElementType) || IPrimitiveType.class.isAssignableFrom(nextElementType) || ICompositeType.class.isAssignableFrom(nextElementType)) {
|
||||
Class<? extends IBase> nextDatatype = (Class<? extends IBase>) nextElementType;
|
||||
|
||||
addScanAlso(nextDatatype);
|
||||
BaseRuntimeChildDatatypeDefinition def;
|
||||
|
@ -558,14 +575,14 @@ class ModelScanner {
|
|||
if (IBoundCodeableConcept.class.isAssignableFrom(nextElementType)) {
|
||||
IValueSetEnumBinder<Enum<?>> binder = getBoundCodeBinder(next);
|
||||
def = new RuntimeChildCompositeBoundDatatypeDefinition(next, elementName, childAnnotation, descriptionAnnotation, nextDatatype, binder);
|
||||
} else if (NarrativeDt.class.getSimpleName().equals(nextElementType.getSimpleName())) {
|
||||
} else if (NarrativeDt.class.getSimpleName().equals(nextElementType.getSimpleName()) || Narrative.class.getName().equals(nextElementType.getClass().getName())) {
|
||||
def = new RuntimeChildNarrativeDefinition(next, elementName, childAnnotation, descriptionAnnotation, nextDatatype);
|
||||
} else {
|
||||
def = new RuntimeChildCompositeDatatypeDefinition(next, elementName, childAnnotation, descriptionAnnotation, nextDatatype);
|
||||
}
|
||||
}
|
||||
|
||||
CodeableConceptElement concept = next.getAnnotation(CodeableConceptElement.class);
|
||||
CodeableConceptElement concept = pullAnnotation(next, CodeableConceptElement.class);
|
||||
if (concept != null) {
|
||||
if (!ICodedDatatype.class.isAssignableFrom(nextDatatype)) {
|
||||
throw new ConfigurationException("Field '" + elementName + "' in type '" + theClass.getCanonicalName() + "' is marked as @" + CodeableConceptElement.class.getCanonicalName() + " but type is not a subtype of " + ICodedDatatype.class.getName());
|
||||
|
@ -586,7 +603,48 @@ class ModelScanner {
|
|||
}
|
||||
}
|
||||
|
||||
private String scanPrimitiveDatatype(Class<? extends IPrimitiveDatatype<?>> theClass, DatatypeDef theDatatypeDefinition) {
|
||||
/**
|
||||
* There are two implementations of all of the annotations (e.g. {@link Child} and
|
||||
* {@link org.hl7.fhir.instance.model.annotations.Child}) since the HL7.org ones will eventually replace the HAPI
|
||||
* ones. Annotations can't extend each other or implement interfaces or anything like that, so rather than duplicate
|
||||
* all of the annotation processing code this method just creates an interface Proxy to simulate the HAPI
|
||||
* annotations if the HL7.org ones are found instead.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends Annotation> T pullAnnotation(AnnotatedElement theTarget, Class<T> theAnnotationType) {
|
||||
T retVal = theTarget.getAnnotation(theAnnotationType);
|
||||
if (retVal == null) {
|
||||
String sourceClassName = theAnnotationType.getName();
|
||||
String candidateAltClassName = sourceClassName.replace("ca.uhn.fhir.model.api.annotation", "org.hl7.fhir.instance.model.annotations");
|
||||
|
||||
if (!sourceClassName.equals(candidateAltClassName)) {
|
||||
try {
|
||||
final Class<? extends Annotation> altAnnotationClass = (Class<? extends Annotation>) Class.forName(candidateAltClassName);
|
||||
final Annotation altAnnotation = theTarget.getAnnotation(altAnnotationClass);
|
||||
if (altAnnotation == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ourLog.debug("Forwarding annotation request for [{}] to class [{}]", sourceClassName, candidateAltClassName);
|
||||
|
||||
InvocationHandler h = new InvocationHandler() {
|
||||
@Override
|
||||
public Object invoke(Object theProxy, Method theMethod, Object[] theArgs) throws Throwable {
|
||||
Method altMethod = altAnnotationClass.getMethod(theMethod.getName(), theMethod.getParameterTypes());
|
||||
return altMethod.invoke(altAnnotation, theArgs);
|
||||
}
|
||||
};
|
||||
retVal = (T) Proxy.newProxyInstance(theAnnotationType.getClassLoader(), new Class<?>[] { theAnnotationType }, h);
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private String scanPrimitiveDatatype(Class<? extends IPrimitiveType> theClass, DatatypeDef theDatatypeDefinition) {
|
||||
ourLog.debug("Scanning resource class: {}", theClass.getName());
|
||||
|
||||
String resourceName = theDatatypeDefinition.name();
|
||||
|
@ -607,7 +665,7 @@ class ModelScanner {
|
|||
return resourceName;
|
||||
}
|
||||
|
||||
private String scanResource(Class<? extends IResource> theClass, ResourceDef resourceDefinition) {
|
||||
private String scanResource(Class<? extends IBaseResource> theClass, ResourceDef resourceDefinition) {
|
||||
ourLog.debug("Scanning resource class: {}", theClass.getName());
|
||||
|
||||
boolean primaryNameProvider = true;
|
||||
|
@ -616,7 +674,7 @@ class ModelScanner {
|
|||
Class<?> parent = theClass.getSuperclass();
|
||||
primaryNameProvider = false;
|
||||
while (parent.equals(Object.class) == false && isBlank(resourceName)) {
|
||||
ResourceDef nextDef = parent.getAnnotation(ResourceDef.class);
|
||||
ResourceDef nextDef = pullAnnotation(parent, ResourceDef.class);
|
||||
if (nextDef != null) {
|
||||
resourceName = nextDef.name();
|
||||
}
|
||||
|
@ -656,7 +714,9 @@ class ModelScanner {
|
|||
RuntimeResourceDefinition resourceDef = new RuntimeResourceDefinition(myContext, resourceName, theClass, resourceDefinition);
|
||||
myClassToElementDefinitions.put(theClass, resourceDef);
|
||||
if (primaryNameProvider) {
|
||||
myNameToResourceDefinitions.put(resourceName, resourceDef);
|
||||
if (resourceDef.getStructureVersion() == myContext.getVersion().getVersion()) {
|
||||
myNameToResourceDefinitions.put(resourceName, resourceDef);
|
||||
}
|
||||
}
|
||||
scanCompositeElementForChildren(theClass, resourceDef);
|
||||
|
||||
|
@ -667,13 +727,13 @@ class ModelScanner {
|
|||
return resourceName;
|
||||
}
|
||||
|
||||
private void scanResourceForSearchParams(Class<? extends IResource> theClass, RuntimeResourceDefinition theResourceDef) {
|
||||
private void scanResourceForSearchParams(Class<? extends IBaseResource> theClass, RuntimeResourceDefinition theResourceDef) {
|
||||
|
||||
Map<String, RuntimeSearchParam> nameToParam = new HashMap<String, RuntimeSearchParam>();
|
||||
Map<Field, SearchParamDefinition> compositeFields = new LinkedHashMap<Field, SearchParamDefinition>();
|
||||
|
||||
for (Field nextField : theClass.getFields()) {
|
||||
SearchParamDefinition searchParam = nextField.getAnnotation(SearchParamDefinition.class);
|
||||
SearchParamDefinition searchParam = pullAnnotation(nextField, SearchParamDefinition.class);
|
||||
if (searchParam != null) {
|
||||
SearchParamTypeEnum paramType = SearchParamTypeEnum.valueOf(searchParam.type().toUpperCase());
|
||||
if (paramType == null) {
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -44,8 +44,9 @@ public class ProvidedResourceScanner {
|
|||
/**
|
||||
* If {@code theProvider} is tagged with the {@code ProvidesResources} annotation, this method will add every resource listed
|
||||
* by the {@code resources} method.
|
||||
* <p/>
|
||||
* notes:
|
||||
* <p>
|
||||
* Notes:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li>if {@code theProvider} isn't annotated with {@code resources} nothing is done; it's expected that most RestfulServers and
|
||||
* ResourceProviders won't be annotated.</li>
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -27,8 +27,9 @@ import java.util.Comparator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.api.IDatatype;
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
|
@ -41,10 +42,10 @@ public class RuntimeChildAny extends RuntimeChildChoiceDefinition {
|
|||
}
|
||||
|
||||
@Override
|
||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
List<Class<? extends IElement>> choiceTypes = new ArrayList<Class<? extends IElement>>();
|
||||
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
List<Class<? extends IBase>> choiceTypes = new ArrayList<Class<? extends IBase>>();
|
||||
|
||||
for (Class<? extends IElement> next : theClassToElementDefinitions.keySet()) {
|
||||
for (Class<? extends IBase> next : theClassToElementDefinitions.keySet()) {
|
||||
if (next.equals(XhtmlDt.class)) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -29,21 +29,21 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
|
||||
|
||||
public class RuntimeChildChoiceDefinition extends BaseRuntimeDeclaredChildDefinition {
|
||||
|
||||
private List<Class<? extends IElement>> myChoiceTypes;
|
||||
private List<Class<? extends IBase>> myChoiceTypes;
|
||||
private Map<String, BaseRuntimeElementDefinition<?>> myNameToChildDefinition;
|
||||
private Map<Class<? extends IElement>, String> myDatatypeToElementName;
|
||||
private Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> myDatatypeToElementDefinition;
|
||||
private Map<Class<? extends IBase>, String> myDatatypeToElementName;
|
||||
private Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> myDatatypeToElementDefinition;
|
||||
|
||||
public RuntimeChildChoiceDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, List<Class<? extends IElement>> theChoiceTypes) {
|
||||
public RuntimeChildChoiceDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, List<Class<? extends IBase>> theChoiceTypes) {
|
||||
super(theField, theChildAnnotation, theDescriptionAnnotation, theElementName);
|
||||
|
||||
myChoiceTypes = Collections.unmodifiableList(theChoiceTypes);
|
||||
|
@ -56,11 +56,11 @@ public class RuntimeChildChoiceDefinition extends BaseRuntimeDeclaredChildDefini
|
|||
super(theField, theChildAnnotation, theDescriptionAnnotation, theElementName);
|
||||
}
|
||||
|
||||
void setChoiceTypes(List<Class<? extends IElement>> theChoiceTypes) {
|
||||
void setChoiceTypes(List<Class<? extends IBase>> theChoiceTypes) {
|
||||
myChoiceTypes = Collections.unmodifiableList(theChoiceTypes);
|
||||
}
|
||||
|
||||
public List<Class<? extends IElement>> getChoices() {
|
||||
public List<Class<? extends IBase>> getChoices() {
|
||||
return myChoiceTypes;
|
||||
}
|
||||
|
||||
|
@ -78,21 +78,21 @@ public class RuntimeChildChoiceDefinition extends BaseRuntimeDeclaredChildDefini
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
myNameToChildDefinition = new HashMap<String, BaseRuntimeElementDefinition<?>>();
|
||||
myDatatypeToElementName = new HashMap<Class<? extends IElement>, String>();
|
||||
myDatatypeToElementDefinition = new HashMap<Class<? extends IElement>, BaseRuntimeElementDefinition<?>>();
|
||||
myDatatypeToElementName = new HashMap<Class<? extends IBase>, String>();
|
||||
myDatatypeToElementDefinition = new HashMap<Class<? extends IBase>, BaseRuntimeElementDefinition<?>>();
|
||||
|
||||
for (Class<? extends IElement> next : myChoiceTypes) {
|
||||
for (Class<? extends IBase> next : myChoiceTypes) {
|
||||
|
||||
String elementName;
|
||||
String alternateElementName = null;
|
||||
BaseRuntimeElementDefinition<?> nextDef;
|
||||
if (IResource.class.isAssignableFrom(next)) {
|
||||
if (IBaseResource.class.isAssignableFrom(next)) {
|
||||
elementName = getElementName() + StringUtils.capitalize(next.getSimpleName());
|
||||
alternateElementName = getElementName() + "Resource";
|
||||
List<Class<? extends IResource>> types = new ArrayList<Class<? extends IResource>>();
|
||||
types.add((Class<? extends IResource>) next);
|
||||
List<Class<? extends IBaseResource>> types = new ArrayList<Class<? extends IBaseResource>>();
|
||||
types.add((Class<? extends IBaseResource>) next);
|
||||
nextDef = new RuntimeResourceReferenceDefinition(elementName, types);
|
||||
nextDef.sealAndInitialize(theClassToElementDefinitions);
|
||||
} else {
|
||||
|
@ -105,7 +105,7 @@ public class RuntimeChildChoiceDefinition extends BaseRuntimeDeclaredChildDefini
|
|||
myNameToChildDefinition.put(alternateElementName, nextDef);
|
||||
}
|
||||
|
||||
if (IResource.class.isAssignableFrom(next)) {
|
||||
if (IBaseResource.class.isAssignableFrom(next)) {
|
||||
myDatatypeToElementDefinition.put(ResourceReferenceDt.class, nextDef);
|
||||
alternateElementName = getElementName() + "Resource";
|
||||
myDatatypeToElementName.put(ResourceReferenceDt.class, alternateElementName);
|
||||
|
@ -122,16 +122,16 @@ public class RuntimeChildChoiceDefinition extends BaseRuntimeDeclaredChildDefini
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getChildNameByDatatype(Class<? extends IElement> theDatatype) {
|
||||
public String getChildNameByDatatype(Class<? extends IBase> theDatatype) {
|
||||
return myDatatypeToElementName.get(theDatatype);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IElement> theDatatype) {
|
||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IBase> theDatatype) {
|
||||
return myDatatypeToElementDefinition.get(theDatatype);
|
||||
}
|
||||
|
||||
public Set<Class<? extends IElement>> getValidChildTypes() {
|
||||
public Set<Class<? extends IBase>> getValidChildTypes() {
|
||||
return Collections.unmodifiableSet((myDatatypeToElementDefinition.keySet()));
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -22,7 +22,8 @@ package ca.uhn.fhir.context;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import ca.uhn.fhir.model.api.IDatatype;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
|
@ -31,7 +32,7 @@ public class RuntimeChildCompositeBoundDatatypeDefinition extends RuntimeChildCo
|
|||
|
||||
private IValueSetEnumBinder<Enum<?>> myBinder;
|
||||
|
||||
public RuntimeChildCompositeBoundDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IDatatype> theDatatype, IValueSetEnumBinder<Enum<?>> theBinder) {
|
||||
public RuntimeChildCompositeBoundDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IBase> theDatatype, IValueSetEnumBinder<Enum<?>> theBinder) {
|
||||
super(theField, theElementName, theChildAnnotation, theDescriptionAnnotation, theDatatype);
|
||||
myBinder = theBinder;
|
||||
if (theBinder==null) {
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -22,13 +22,14 @@ package ca.uhn.fhir.context;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import ca.uhn.fhir.model.api.IDatatype;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
|
||||
public class RuntimeChildCompositeDatatypeDefinition extends BaseRuntimeChildDatatypeDefinition {
|
||||
|
||||
public RuntimeChildCompositeDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IDatatype> theDatatype) {
|
||||
public RuntimeChildCompositeDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IBase> theDatatype) {
|
||||
super(theField, theElementName, theChildAnnotation,theDescriptionAnnotation, theDatatype);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -25,7 +25,8 @@ import java.util.Collections;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import ca.uhn.fhir.model.dstu.composite.ContainedDt;
|
||||
|
@ -45,13 +46,13 @@ public class RuntimeChildContainedResources extends BaseRuntimeDeclaredChildDefi
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IElement> theType) {
|
||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IBase> theType) {
|
||||
assert theType.equals(ContainedDt.class);
|
||||
return myElem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChildNameByDatatype(Class<? extends IElement> theDatatype) {
|
||||
public String getChildNameByDatatype(Class<? extends IBase> theDatatype) {
|
||||
assert theDatatype.equals(ContainedDt.class);
|
||||
return getElementName();
|
||||
}
|
||||
|
@ -62,7 +63,7 @@ public class RuntimeChildContainedResources extends BaseRuntimeDeclaredChildDefi
|
|||
}
|
||||
|
||||
@Override
|
||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
myElem = new RuntimeElemContainedResources();
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -30,7 +30,9 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
|
@ -39,7 +41,7 @@ import ca.uhn.fhir.model.api.annotation.Extension;
|
|||
public class RuntimeChildDeclaredExtensionDefinition extends BaseRuntimeDeclaredChildDefinition {
|
||||
|
||||
private BaseRuntimeElementDefinition<?> myChildDef;
|
||||
private Class<? extends IElement> myChildType;
|
||||
private Class<? extends IBase> myChildType;
|
||||
private String myDatatypeChildName;
|
||||
private boolean myDefinedLocally;
|
||||
private String myExtensionUrl;
|
||||
|
@ -49,7 +51,7 @@ public class RuntimeChildDeclaredExtensionDefinition extends BaseRuntimeDeclared
|
|||
/**
|
||||
* @param theDefinedLocally See {@link Extension#definedLocally()}
|
||||
*/
|
||||
RuntimeChildDeclaredExtensionDefinition(Field theField, Child theChild, Description theDescriptionAnnotation, Extension theExtension, String theElementName, String theExtensionUrl, Class<? extends IElement> theChildType) throws ConfigurationException {
|
||||
RuntimeChildDeclaredExtensionDefinition(Field theField, Child theChild, Description theDescriptionAnnotation, Extension theExtension, String theElementName, String theExtensionUrl, Class<? extends IBase> theChildType) throws ConfigurationException {
|
||||
super(theField, theChild, theDescriptionAnnotation, theElementName);
|
||||
assert isNotBlank(theExtensionUrl);
|
||||
myExtensionUrl = theExtensionUrl;
|
||||
|
@ -72,7 +74,7 @@ public class RuntimeChildDeclaredExtensionDefinition extends BaseRuntimeDeclared
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IElement> theType) {
|
||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IBase> theType) {
|
||||
if (myChildType.equals(theType)) {
|
||||
return myChildDef;
|
||||
}
|
||||
|
@ -84,7 +86,7 @@ public class RuntimeChildDeclaredExtensionDefinition extends BaseRuntimeDeclared
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getChildNameByDatatype(Class<? extends IElement> theDatatype) {
|
||||
public String getChildNameByDatatype(Class<? extends IBase> theDatatype) {
|
||||
if (myChildType.equals(theDatatype) && myDatatypeChildName != null) {
|
||||
return myDatatypeChildName;
|
||||
} else {
|
||||
|
@ -92,7 +94,7 @@ public class RuntimeChildDeclaredExtensionDefinition extends BaseRuntimeDeclared
|
|||
}
|
||||
}
|
||||
|
||||
public Class<? extends IElement> getChildType() {
|
||||
public Class<? extends IBase> getChildType() {
|
||||
return myChildType;
|
||||
}
|
||||
|
||||
|
@ -119,7 +121,7 @@ public class RuntimeChildDeclaredExtensionDefinition extends BaseRuntimeDeclared
|
|||
return myModifier;
|
||||
}
|
||||
|
||||
public IElement newInstance() {
|
||||
public IBase newInstance() {
|
||||
try {
|
||||
return myChildType.newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
|
@ -130,7 +132,7 @@ public class RuntimeChildDeclaredExtensionDefinition extends BaseRuntimeDeclared
|
|||
}
|
||||
|
||||
@Override
|
||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
myUrlToChildExtension = new HashMap<String, RuntimeChildDeclaredExtensionDefinition>();
|
||||
|
||||
BaseRuntimeElementDefinition<?> elementDef = theClassToElementDefinitions.get(myChildType);
|
||||
|
@ -139,7 +141,7 @@ public class RuntimeChildDeclaredExtensionDefinition extends BaseRuntimeDeclared
|
|||
if ("valueResourceReference".equals(myDatatypeChildName)) {
|
||||
// Per one of the examples here: http://hl7.org/implement/standards/fhir/extensibility.html#extension
|
||||
myDatatypeChildName = "valueResource";
|
||||
List<Class<? extends IResource>> types = new ArrayList<Class<? extends IResource>>();
|
||||
List<Class<? extends IBaseResource>> types = new ArrayList<Class<? extends IBaseResource>>();
|
||||
types.add(IResource.class);
|
||||
myChildDef = new RuntimeResourceReferenceDefinition("valueResource", types);
|
||||
}else {
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -22,13 +22,14 @@ package ca.uhn.fhir.context;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import ca.uhn.fhir.model.api.IDatatype;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
|
||||
public class RuntimeChildNarrativeDefinition extends RuntimeChildCompositeDatatypeDefinition {
|
||||
|
||||
public RuntimeChildNarrativeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IDatatype> theDatatype) {
|
||||
public RuntimeChildNarrativeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IBase> theDatatype) {
|
||||
super(theField, theElementName, theChildAnnotation,theDescriptionAnnotation, theDatatype);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -22,6 +22,8 @@ package ca.uhn.fhir.context;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.api.IDatatype;
|
||||
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
|
@ -31,7 +33,7 @@ public class RuntimeChildPrimitiveBoundCodeDatatypeDefinition extends RuntimeChi
|
|||
|
||||
private IValueSetEnumBinder<Enum<?>> myBinder;
|
||||
|
||||
public RuntimeChildPrimitiveBoundCodeDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IDatatype> theDatatype, IValueSetEnumBinder<Enum<?>> theBinder) {
|
||||
public RuntimeChildPrimitiveBoundCodeDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IBase> theDatatype, IValueSetEnumBinder<Enum<?>> theBinder) {
|
||||
super(theField, theElementName, theDescriptionAnnotation, theChildAnnotation, theDatatype);
|
||||
|
||||
myBinder = theBinder;
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -22,13 +22,14 @@ package ca.uhn.fhir.context;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import ca.uhn.fhir.model.api.IDatatype;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
|
||||
public class RuntimeChildPrimitiveDatatypeDefinition extends BaseRuntimeChildDatatypeDefinition {
|
||||
|
||||
public RuntimeChildPrimitiveDatatypeDefinition(Field theField, String theElementName, Description theDescriptionAnnotation, Child theChildAnnotation, Class<? extends IDatatype> theDatatype) {
|
||||
public RuntimeChildPrimitiveDatatypeDefinition(Field theField, String theElementName, Description theDescriptionAnnotation, Child theChildAnnotation, Class<? extends IBase> theDatatype) {
|
||||
super(theField, theElementName, theChildAnnotation, theDescriptionAnnotation, theDatatype);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -25,17 +25,17 @@ import java.util.Collections;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
import ca.uhn.fhir.model.api.IResourceBlock;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
|
||||
public class RuntimeChildResourceBlockDefinition extends BaseRuntimeDeclaredChildDefinition {
|
||||
|
||||
private RuntimeResourceBlockDefinition myElementDef;
|
||||
private Class<? extends IResourceBlock> myResourceBlockType;
|
||||
private Class<? extends IBase> myResourceBlockType;
|
||||
|
||||
public RuntimeChildResourceBlockDefinition(Field theField, Child theChildAnnotation, Description theDescriptionAnnotation, String theElementName, Class<? extends IResourceBlock> theResourceBlockType) throws ConfigurationException {
|
||||
public RuntimeChildResourceBlockDefinition(Field theField, Child theChildAnnotation, Description theDescriptionAnnotation, String theElementName, Class<? extends IBase> theResourceBlockType) throws ConfigurationException {
|
||||
super(theField, theChildAnnotation, theDescriptionAnnotation, theElementName);
|
||||
myResourceBlockType = theResourceBlockType;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class RuntimeChildResourceBlockDefinition extends BaseRuntimeDeclaredChil
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getChildNameByDatatype(Class<? extends IElement> theDatatype) {
|
||||
public String getChildNameByDatatype(Class<? extends IBase> theDatatype) {
|
||||
if (myResourceBlockType.equals(theDatatype)) {
|
||||
return getElementName();
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class RuntimeChildResourceBlockDefinition extends BaseRuntimeDeclaredChil
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IElement> theDatatype) {
|
||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IBase> theDatatype) {
|
||||
if (myResourceBlockType.equals(theDatatype)) {
|
||||
return myElementDef;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class RuntimeChildResourceBlockDefinition extends BaseRuntimeDeclaredChil
|
|||
}
|
||||
|
||||
@Override
|
||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
myElementDef = (RuntimeResourceBlockDefinition) theClassToElementDefinitions.get(myResourceBlockType);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -28,7 +28,9 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
|
@ -37,10 +39,10 @@ import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
|
|||
public class RuntimeChildResourceDefinition extends BaseRuntimeDeclaredChildDefinition {
|
||||
|
||||
private BaseRuntimeElementDefinition<?> myRuntimeDef;
|
||||
private List<Class<? extends IResource>> myResourceTypes;
|
||||
private List<Class<? extends IBaseResource>> myResourceTypes;
|
||||
private Set<String> myValidChildNames;
|
||||
|
||||
public RuntimeChildResourceDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, List<Class<? extends IResource>> theResourceTypes) {
|
||||
public RuntimeChildResourceDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, List<Class<? extends IBaseResource>> theResourceTypes) {
|
||||
super(theField, theChildAnnotation, theDescriptionAnnotation, theElementName);
|
||||
myResourceTypes = theResourceTypes;
|
||||
|
||||
|
@ -50,7 +52,7 @@ public class RuntimeChildResourceDefinition extends BaseRuntimeDeclaredChildDefi
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getChildNameByDatatype(Class<? extends IElement> theDatatype) {
|
||||
public String getChildNameByDatatype(Class<? extends IBase> theDatatype) {
|
||||
if (BaseResourceReferenceDt.class.isAssignableFrom(theDatatype)) {
|
||||
return getElementName();
|
||||
}
|
||||
|
@ -58,7 +60,7 @@ public class RuntimeChildResourceDefinition extends BaseRuntimeDeclaredChildDefi
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IElement> theDatatype) {
|
||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IBase> theDatatype) {
|
||||
if (BaseResourceReferenceDt.class.isAssignableFrom(theDatatype)) {
|
||||
return myRuntimeDef;
|
||||
}
|
||||
|
@ -76,36 +78,48 @@ public class RuntimeChildResourceDefinition extends BaseRuntimeDeclaredChildDefi
|
|||
}
|
||||
|
||||
@Override
|
||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
myRuntimeDef = new RuntimeResourceReferenceDefinition(getElementName(), myResourceTypes);
|
||||
myRuntimeDef.sealAndInitialize(theClassToElementDefinitions);
|
||||
|
||||
myValidChildNames = new HashSet<String>();
|
||||
myValidChildNames.add(getElementName());
|
||||
|
||||
/*
|
||||
* [elementName]Resource is not actually valid FHIR but we've encountered it in the wild
|
||||
* so we'll accept it just to be nice
|
||||
*/
|
||||
myValidChildNames.add(getElementName() + "Resource");
|
||||
|
||||
for (Class<? extends IResource> next : myResourceTypes) {
|
||||
if (next == IResource.class) {
|
||||
for (Entry<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> nextEntry : theClassToElementDefinitions.entrySet()) {
|
||||
if (IResource.class.isAssignableFrom(nextEntry.getKey())) {
|
||||
RuntimeResourceDefinition nextDef = (RuntimeResourceDefinition) nextEntry.getValue();
|
||||
myValidChildNames.add(getElementName() + nextDef.getName());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
RuntimeResourceDefinition nextDef = (RuntimeResourceDefinition) theClassToElementDefinitions.get(next);
|
||||
if (nextDef == null) {
|
||||
throw new ConfigurationException("Can't find child of type: " + next.getCanonicalName() + " in " + getField().getDeclaringClass());
|
||||
}
|
||||
myValidChildNames.add(getElementName() + nextDef.getName());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Below has been disabled- We used to allow field names to contain the name of the resource
|
||||
* that they accepted. This wasn't valid but we accepted it just to be flexible because there
|
||||
* were some bad examples containing this. This causes conflicts with actual field names in
|
||||
* recent definitions though, so it has been disabled as of HAPI 0.9
|
||||
*/
|
||||
// for (Class<? extends IBaseResource> next : myResourceTypes) {
|
||||
// if (next == IResource.class) {
|
||||
// for (Entry<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> nextEntry : theClassToElementDefinitions.entrySet()) {
|
||||
// if (IResource.class.isAssignableFrom(nextEntry.getKey())) {
|
||||
// RuntimeResourceDefinition nextDef = (RuntimeResourceDefinition) nextEntry.getValue();
|
||||
// myValidChildNames.add(getElementName() + nextDef.getName());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// RuntimeResourceDefinition nextDef = (RuntimeResourceDefinition) theClassToElementDefinitions.get(next);
|
||||
// if (nextDef == null) {
|
||||
// throw new ConfigurationException("Can't find child of type: " + next.getCanonicalName() + " in " + getField().getDeclaringClass());
|
||||
// }
|
||||
// myValidChildNames.add(getElementName() + nextDef.getName());
|
||||
// }
|
||||
// }
|
||||
|
||||
myResourceTypes = Collections.unmodifiableList(myResourceTypes);
|
||||
myValidChildNames = Collections.unmodifiableSet(myValidChildNames);
|
||||
}
|
||||
|
||||
public List<Class<? extends IResource>> getResourceTypes() {
|
||||
public List<Class<? extends IBaseResource>> getResourceTypes() {
|
||||
return myResourceTypes;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -29,90 +29,29 @@ import java.util.Map.Entry;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.ExtensionDt;
|
||||
import ca.uhn.fhir.model.api.IDatatype;
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
|
||||
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
|
||||
|
||||
public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildDefinition {
|
||||
|
||||
private Map<String, BaseRuntimeElementDefinition<?>> myAttributeNameToDefinition;
|
||||
private Map<Class<? extends IElement>, String> myDatatypeToAttributeName;
|
||||
private Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> myDatatypeToDefinition;
|
||||
private Map<Class<? extends IBase>, String> myDatatypeToAttributeName;
|
||||
private Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> myDatatypeToDefinition;
|
||||
|
||||
public RuntimeChildUndeclaredExtensionDefinition() {
|
||||
// nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseRuntimeElementDefinition<?> getChildByName(String theName) {
|
||||
return myAttributeNameToDefinition.get(theName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getValidChildNames() {
|
||||
return myAttributeNameToDefinition.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChildNameByDatatype(Class<? extends IElement> theDatatype) {
|
||||
return myDatatypeToAttributeName.get(theDatatype);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IElement> theType) {
|
||||
return myDatatypeToDefinition.get(theType);
|
||||
}
|
||||
|
||||
@Override
|
||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
Map<String, BaseRuntimeElementDefinition<?>> datatypeAttributeNameToDefinition = new HashMap<String, BaseRuntimeElementDefinition<?>>();
|
||||
myDatatypeToAttributeName = new HashMap<Class<? extends IElement>, String>();
|
||||
|
||||
for (BaseRuntimeElementDefinition<?> next : theClassToElementDefinitions.values()) {
|
||||
if (next instanceof IRuntimeDatatypeDefinition) {
|
||||
// if (next.getName().equals("CodeableConcept")) {
|
||||
// System.out.println();
|
||||
// }
|
||||
|
||||
if (!((IRuntimeDatatypeDefinition) next).isSpecialization()) {
|
||||
String attrName = "value" + WordUtils.capitalize(next.getName());
|
||||
datatypeAttributeNameToDefinition.put(attrName, next);
|
||||
datatypeAttributeNameToDefinition.put(attrName.toLowerCase(), next);
|
||||
myDatatypeToAttributeName.put(next.getImplementingClass(), attrName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
myAttributeNameToDefinition = datatypeAttributeNameToDefinition;
|
||||
|
||||
myDatatypeToDefinition = new HashMap<Class<? extends IElement>, BaseRuntimeElementDefinition<?>>();
|
||||
|
||||
for (Entry<String, BaseRuntimeElementDefinition<?>> next : myAttributeNameToDefinition.entrySet()) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends IDatatype> type = (Class<? extends IDatatype>) next.getValue().getImplementingClass();
|
||||
myDatatypeToDefinition.put(type, next.getValue());
|
||||
}
|
||||
|
||||
// Resource Reference
|
||||
myDatatypeToAttributeName.put(ResourceReferenceDt.class, "valueResource");
|
||||
List<Class<? extends IResource>> types = new ArrayList<Class<? extends IResource>>();
|
||||
types.add(IResource.class);
|
||||
RuntimeResourceReferenceDefinition def = new RuntimeResourceReferenceDefinition("valueResource", types);
|
||||
def.sealAndInitialize(theClassToElementDefinitions);
|
||||
myAttributeNameToDefinition.put("valueResource", def);
|
||||
myDatatypeToDefinition.put(BaseResourceReferenceDt.class, def);
|
||||
myDatatypeToDefinition.put(ResourceReferenceDt.class, def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAccessor getAccessor() {
|
||||
return new IAccessor() {
|
||||
@Override
|
||||
public List<? extends IElement> getValues(Object theTarget) {
|
||||
public List<? extends IBase> getValues(Object theTarget) {
|
||||
ExtensionDt target = (ExtensionDt) theTarget;
|
||||
if (target.getValue() != null) {
|
||||
return Collections.singletonList(target.getValue());
|
||||
|
@ -123,18 +62,23 @@ public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildD
|
|||
}
|
||||
|
||||
@Override
|
||||
public IMutator getMutator() {
|
||||
return new IMutator() {
|
||||
@Override
|
||||
public void addValue(Object theTarget, IElement theValue) {
|
||||
ExtensionDt target = (ExtensionDt) theTarget;
|
||||
if (theValue instanceof IDatatype) {
|
||||
target.setValue((IDatatype) theTarget);
|
||||
} else {
|
||||
target.getUndeclaredExtensions().add((ExtensionDt) theValue);
|
||||
}
|
||||
}
|
||||
};
|
||||
public BaseRuntimeElementDefinition<?> getChildByName(String theName) {
|
||||
return myAttributeNameToDefinition.get(theName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IBase> theType) {
|
||||
return myDatatypeToDefinition.get(theType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChildNameByDatatype(Class<? extends IBase> theDatatype) {
|
||||
return myDatatypeToAttributeName.get(theDatatype);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return "extension";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -148,8 +92,69 @@ public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildD
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return "extension";
|
||||
public IMutator getMutator() {
|
||||
return new IMutator() {
|
||||
@Override
|
||||
public void addValue(Object theTarget, IBase theValue) {
|
||||
ExtensionDt target = (ExtensionDt) theTarget;
|
||||
if (theValue instanceof IDatatype) {
|
||||
target.setValue((IDatatype) theTarget);
|
||||
} else {
|
||||
target.getUndeclaredExtensions().add((ExtensionDt) theValue);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getValidChildNames() {
|
||||
return myAttributeNameToDefinition.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
Map<String, BaseRuntimeElementDefinition<?>> datatypeAttributeNameToDefinition = new HashMap<String, BaseRuntimeElementDefinition<?>>();
|
||||
myDatatypeToAttributeName = new HashMap<Class<? extends IBase>, String>();
|
||||
|
||||
for (BaseRuntimeElementDefinition<?> next : theClassToElementDefinitions.values()) {
|
||||
if (next instanceof IRuntimeDatatypeDefinition) {
|
||||
// if (next.getName().equals("CodeableConcept")) {
|
||||
// System.out.println();
|
||||
// }
|
||||
|
||||
if (!((IRuntimeDatatypeDefinition) next).isSpecialization()) {
|
||||
String attrName = createExtensionChildName(next);
|
||||
datatypeAttributeNameToDefinition.put(attrName, next);
|
||||
datatypeAttributeNameToDefinition.put(attrName.toLowerCase(), next);
|
||||
myDatatypeToAttributeName.put(next.getImplementingClass(), attrName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
myAttributeNameToDefinition = datatypeAttributeNameToDefinition;
|
||||
|
||||
myDatatypeToDefinition = new HashMap<Class<? extends IBase>, BaseRuntimeElementDefinition<?>>();
|
||||
|
||||
for (Entry<String, BaseRuntimeElementDefinition<?>> next : myAttributeNameToDefinition.entrySet()) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends IDatatype> type = (Class<? extends IDatatype>) next.getValue().getImplementingClass();
|
||||
myDatatypeToDefinition.put(type, next.getValue());
|
||||
}
|
||||
|
||||
// Resource Reference
|
||||
myDatatypeToAttributeName.put(ResourceReferenceDt.class, "valueResource");
|
||||
List<Class<? extends IBaseResource>> types = new ArrayList<Class<? extends IBaseResource>>();
|
||||
types.add(IBaseResource.class);
|
||||
RuntimeResourceReferenceDefinition def = new RuntimeResourceReferenceDefinition("valueResource", types);
|
||||
def.sealAndInitialize(theClassToElementDefinitions);
|
||||
myAttributeNameToDefinition.put("valueResource", def);
|
||||
myDatatypeToDefinition.put(BaseResourceReferenceDt.class, def);
|
||||
myDatatypeToDefinition.put(ResourceReferenceDt.class, def);
|
||||
}
|
||||
|
||||
public static String createExtensionChildName(BaseRuntimeElementDefinition<?> next) {
|
||||
String attrName = "value" + WordUtils.capitalize(next.getName());
|
||||
return attrName;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -20,16 +20,18 @@ package ca.uhn.fhir.context;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.*;
|
||||
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
|
||||
import org.hl7.fhir.instance.model.ICompositeType;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
|
||||
public class RuntimeCompositeDatatypeDefinition extends BaseRuntimeElementCompositeDefinition<ICompositeDatatype> implements IRuntimeDatatypeDefinition {
|
||||
public class RuntimeCompositeDatatypeDefinition extends BaseRuntimeElementCompositeDefinition<ICompositeType> implements IRuntimeDatatypeDefinition {
|
||||
|
||||
private boolean mySpecialization;
|
||||
|
||||
public RuntimeCompositeDatatypeDefinition(DatatypeDef theDef, Class<? extends ICompositeDatatype> theImplementingClass) {
|
||||
public RuntimeCompositeDatatypeDefinition(DatatypeDef theDef, Class<? extends ICompositeType> theImplementingClass) {
|
||||
super(theDef.name(), theImplementingClass);
|
||||
|
||||
String resourceName = theDef.name();
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -25,15 +25,16 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.ICompositeType;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||
|
||||
public class RuntimeExtensionDtDefinition extends RuntimeCompositeDatatypeDefinition {
|
||||
|
||||
private List<BaseRuntimeChildDefinition> myChildren;
|
||||
|
||||
public RuntimeExtensionDtDefinition(DatatypeDef theDef, Class<? extends ICompositeDatatype> theImplementingClass) {
|
||||
public RuntimeExtensionDtDefinition(DatatypeDef theDef, Class<? extends ICompositeType> theImplementingClass) {
|
||||
super(theDef, theImplementingClass);
|
||||
}
|
||||
|
||||
|
@ -43,7 +44,7 @@ public class RuntimeExtensionDtDefinition extends RuntimeCompositeDatatypeDefini
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
public void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
super.sealAndInitialize(theClassToElementDefinitions);
|
||||
|
||||
/*
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -20,20 +20,21 @@ package ca.uhn.fhir.context;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.*;
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
|
||||
public class RuntimePrimitiveDatatypeDefinition extends BaseRuntimeElementDefinition<IPrimitiveDatatype<?>> implements IRuntimeDatatypeDefinition {
|
||||
public class RuntimePrimitiveDatatypeDefinition extends BaseRuntimeElementDefinition<IPrimitiveType> implements IRuntimeDatatypeDefinition {
|
||||
|
||||
private boolean mySpecialization;
|
||||
|
||||
public RuntimePrimitiveDatatypeDefinition(DatatypeDef theDef, Class<? extends IPrimitiveDatatype<?>> theImplementingClass) {
|
||||
public RuntimePrimitiveDatatypeDefinition(DatatypeDef theDef, Class<? extends IPrimitiveType> theImplementingClass) {
|
||||
super(theDef.name(), theImplementingClass);
|
||||
|
||||
String resourceName = theDef.name();
|
||||
|
@ -50,7 +51,7 @@ public class RuntimePrimitiveDatatypeDefinition extends BaseRuntimeElementDefini
|
|||
}
|
||||
|
||||
@Override
|
||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -22,7 +22,8 @@ package ca.uhn.fhir.context;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.primitive.XhtmlDt;
|
||||
|
||||
public class RuntimePrimitiveDatatypeNarrativeDefinition extends BaseRuntimeElementDefinition<XhtmlDt> {
|
||||
|
@ -37,7 +38,7 @@ public class RuntimePrimitiveDatatypeNarrativeDefinition extends BaseRuntimeEle
|
|||
}
|
||||
|
||||
@Override
|
||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -27,11 +27,14 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
import ca.uhn.fhir.util.UrlUtil;
|
||||
|
||||
public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefinition<IResource> {
|
||||
public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefinition<IBaseResource> {
|
||||
|
||||
private RuntimeResourceDefinition myBaseDefinition;
|
||||
private Map<String, RuntimeSearchParam> myNameToSearchParam = new LinkedHashMap<String, RuntimeSearchParam>();
|
||||
|
@ -40,12 +43,25 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini
|
|||
private List<RuntimeSearchParam> mySearchParams;
|
||||
private FhirContext myContext;
|
||||
private String myId;
|
||||
private final FhirVersionEnum myStructureVersion;
|
||||
|
||||
public RuntimeResourceDefinition(FhirContext theContext, String theResourceName, Class<? extends IResource> theClass, ResourceDef theResourceAnnotation) {
|
||||
public FhirVersionEnum getStructureVersion() {
|
||||
return myStructureVersion;
|
||||
}
|
||||
|
||||
public RuntimeResourceDefinition(FhirContext theContext, String theResourceName, Class<? extends IBaseResource> theClass, ResourceDef theResourceAnnotation) {
|
||||
super(theResourceName, theClass);
|
||||
myContext= theContext;
|
||||
myResourceProfile = theResourceAnnotation.profile();
|
||||
myId = theResourceAnnotation.id();
|
||||
|
||||
try {
|
||||
IBaseResource instance = theClass.newInstance();
|
||||
myStructureVersion = ((IResource)instance).getStructureFhirVersionEnum();
|
||||
} catch (Exception e) {
|
||||
throw new ConfigurationException(myContext.getLocalizer().getMessage(getClass(), "nonInstantiableType", theClass.getName(), e.toString()), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -74,10 +90,30 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini
|
|||
return ChildTypeEnum.RESOURCE;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getResourceProfile() {
|
||||
return myResourceProfile;
|
||||
}
|
||||
|
||||
public String getResourceProfile(String theServerBase) {
|
||||
String profile;
|
||||
if (!myResourceProfile.isEmpty()) {
|
||||
profile = myResourceProfile;
|
||||
} else if (!myId.isEmpty()) {
|
||||
profile = myId;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (!UrlUtil.isValid(profile)) {
|
||||
String profileWithUrl = theServerBase + "/Profile/" + profile;
|
||||
if (UrlUtil.isValid(profileWithUrl)) {
|
||||
return profileWithUrl;
|
||||
}
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
|
||||
public RuntimeSearchParam getSearchParam(String theName) {
|
||||
return myNameToSearchParam.get(theName);
|
||||
}
|
||||
|
@ -91,7 +127,7 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
public void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
super.sealAndInitialize(theClassToElementDefinitions);
|
||||
|
||||
myNameToSearchParam = Collections.unmodifiableMap(myNameToSearchParam);
|
||||
|
@ -115,17 +151,26 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini
|
|||
} while (target.equals(Object.class)==false);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public synchronized IResource toProfile() {
|
||||
if (myProfileDef != null) {
|
||||
return myProfileDef;
|
||||
}
|
||||
|
||||
IResource retVal = myContext.getVersion().generateProfile(this);
|
||||
IResource retVal = myContext.getVersion().generateProfile(this, null);
|
||||
myProfileDef = retVal;
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public synchronized IResource toProfile(String theServerBase) {
|
||||
if (myProfileDef != null) {
|
||||
return myProfileDef;
|
||||
}
|
||||
|
||||
IResource retVal = myContext.getVersion().generateProfile(this, theServerBase);
|
||||
myProfileDef = retVal;
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.context;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -24,16 +24,19 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.Resource;
|
||||
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
|
||||
|
||||
public class RuntimeResourceReferenceDefinition extends BaseRuntimeElementDefinition<BaseResourceReferenceDt> {
|
||||
|
||||
private final List<Class<? extends IResource>> myResourceTypes;
|
||||
private HashMap<Class<? extends IResource>, RuntimeResourceDefinition> myResourceTypeToDefinition;
|
||||
private final List<Class<? extends IBaseResource>> myResourceTypes;
|
||||
private HashMap<Class<? extends IBaseResource>, RuntimeResourceDefinition> myResourceTypeToDefinition;
|
||||
|
||||
public RuntimeResourceReferenceDefinition(String theName, List<Class<? extends IResource>> theResourceTypes) {
|
||||
public RuntimeResourceReferenceDefinition(String theName, List<Class<? extends IBaseResource>> theResourceTypes) {
|
||||
super(theName, BaseResourceReferenceDt.class);
|
||||
if (theResourceTypes == null || theResourceTypes.isEmpty()) {
|
||||
throw new ConfigurationException("Element '" + theName + "' has no resource types noted");
|
||||
|
@ -41,15 +44,15 @@ public class RuntimeResourceReferenceDefinition extends BaseRuntimeElementDefini
|
|||
myResourceTypes = theResourceTypes;
|
||||
}
|
||||
|
||||
public List<Class<? extends IResource>> getResourceTypes() {
|
||||
public List<Class<? extends IBaseResource>> getResourceTypes() {
|
||||
return myResourceTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
void sealAndInitialize(Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
myResourceTypeToDefinition = new HashMap<Class<? extends IResource>, RuntimeResourceDefinition>();
|
||||
for (Class<? extends IResource> next : myResourceTypes) {
|
||||
if (next.equals(IResource.class)) {
|
||||
void sealAndInitialize(Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
myResourceTypeToDefinition = new HashMap<Class<? extends IBaseResource>, RuntimeResourceDefinition>();
|
||||
for (Class<? extends IBaseResource> next : myResourceTypes) {
|
||||
if (next.equals(IResource.class) || next.equals(Resource.class) || next.equals(IBaseResource.class)) {
|
||||
continue;
|
||||
}
|
||||
RuntimeResourceDefinition definition = (RuntimeResourceDefinition) theClassToElementDefinitions.get(next);
|
||||
|
|
|
@ -8,7 +8,7 @@ import ca.uhn.fhir.model.dstu.valueset.SearchParamTypeEnum;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.i18n;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -37,23 +37,27 @@ public class HapiLocalizer {
|
|||
myBundle = ResourceBundle.getBundle(HapiLocalizer.class.getPackage().getName() + ".hapi-messages");
|
||||
}
|
||||
|
||||
public String getMessage(String theKey, Object... theParameters) {
|
||||
public String getMessage(Class<?> theType, String theKey, Object... theParameters) {
|
||||
return getMessage(theType.getName() + '.' + theKey, theParameters);
|
||||
}
|
||||
|
||||
public String getMessage(String theQualifiedKey, Object... theParameters) {
|
||||
if (theParameters != null && theParameters.length > 0) {
|
||||
MessageFormat format = myKeyToMessageFormat.get(theKey);
|
||||
MessageFormat format = myKeyToMessageFormat.get(theQualifiedKey);
|
||||
if (format != null) {
|
||||
return format.format(theParameters).toString();
|
||||
}
|
||||
|
||||
String formatString = myBundle.getString(theKey);
|
||||
String formatString = myBundle.getString(theQualifiedKey);
|
||||
if (formatString== null) {
|
||||
formatString = "!MESSAGE!";
|
||||
}
|
||||
|
||||
format = new MessageFormat(formatString);
|
||||
myKeyToMessageFormat.put(theKey, format);
|
||||
myKeyToMessageFormat.put(theQualifiedKey, format);
|
||||
return format.format(theParameters).toString();
|
||||
} else {
|
||||
String retVal = myBundle.getString(theKey);
|
||||
String retVal = myBundle.getString(theQualifiedKey);
|
||||
if (retVal == null) {
|
||||
retVal = "!MESSAGE!";
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -82,7 +82,7 @@ public abstract class BaseIdentifiableElement extends BaseElement implements IId
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String theValue) throws DataFormatException {
|
||||
public IdDt setValue(String theValue) throws DataFormatException {
|
||||
throw new UnsupportedOperationException("Use IElement#setElementSpecificId(String) to set the element ID for an element");
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -22,6 +22,7 @@ package ca.uhn.fhir.model.api;
|
|||
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
|
||||
|
@ -67,9 +68,10 @@ public abstract class BasePrimitive<T> extends BaseIdentifiableElement implement
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setValue(T theValue) throws DataFormatException {
|
||||
public IPrimitiveType<T> setValue(T theValue) throws DataFormatException {
|
||||
myCoercedValue = theValue;
|
||||
updateStringValue();
|
||||
return this;
|
||||
}
|
||||
|
||||
protected void updateStringValue() {
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -20,20 +20,18 @@ package ca.uhn.fhir.model.api;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import ca.uhn.fhir.rest.gclient.StringClientParam;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
|
||||
import ca.uhn.fhir.model.base.resource.ResourceMetadataMap;
|
||||
import ca.uhn.fhir.model.dstu.composite.ContainedDt;
|
||||
import ca.uhn.fhir.model.dstu.composite.NarrativeDt;
|
||||
import ca.uhn.fhir.model.primitive.CodeDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.gclient.StringClientParam;
|
||||
import ca.uhn.fhir.util.ElementUtil;
|
||||
|
||||
public abstract class BaseResource extends BaseElement implements IResource {
|
||||
|
@ -54,9 +52,9 @@ public abstract class BaseResource extends BaseElement implements IResource {
|
|||
/**
|
||||
* <b>Fluent Client</b> search parameter constant for <b>_id</b>
|
||||
* <p>
|
||||
* Description: <b>the _id of a resource</b><br/>
|
||||
* Type: <b>string</b><br/>
|
||||
* Path: <b>Resource._id</b><br/>
|
||||
* Description: <b>the _id of a resource</b><br>
|
||||
* Type: <b>string</b><br>
|
||||
* Path: <b>Resource._id</b><br>
|
||||
* </p>
|
||||
*/
|
||||
public static final StringClientParam RES_ID = new StringClientParam(BaseResource.SP_RES_ID);
|
||||
|
@ -70,7 +68,7 @@ public abstract class BaseResource extends BaseElement implements IResource {
|
|||
@Child(name = "language", order = 0, min = 0, max = Child.MAX_UNLIMITED)
|
||||
private CodeDt myLanguage;
|
||||
|
||||
private Map<ResourceMetadataKeyEnum<?>, Object> myResourceMetadata;
|
||||
private ResourceMetadataMap myResourceMetadata;
|
||||
|
||||
@Child(name = "text", order = 1, min = 0, max = 1)
|
||||
private NarrativeDt myText;
|
||||
|
@ -99,9 +97,9 @@ public abstract class BaseResource extends BaseElement implements IResource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map<ResourceMetadataKeyEnum<?>, Object> getResourceMetadata() {
|
||||
public ResourceMetadataMap getResourceMetadata() {
|
||||
if (myResourceMetadata == null) {
|
||||
myResourceMetadata = new HashMap<ResourceMetadataKeyEnum<?>, Object>();
|
||||
myResourceMetadata = new ResourceMetadataMap();
|
||||
}
|
||||
return myResourceMetadata;
|
||||
}
|
||||
|
@ -136,7 +134,7 @@ public abstract class BaseResource extends BaseElement implements IResource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setResourceMetadata(Map<ResourceMetadataKeyEnum<?>, Object> theMap) {
|
||||
public void setResourceMetadata(ResourceMetadataMap theMap) {
|
||||
Validate.notNull(theMap, "The Map must not be null");
|
||||
myResourceMetadata = theMap;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -34,17 +34,24 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.model.base.resource.ResourceMetadataMap;
|
||||
import ca.uhn.fhir.model.primitive.BoundCodeDt;
|
||||
import ca.uhn.fhir.model.primitive.DecimalDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.model.primitive.IntegerDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.valueset.BundleEntrySearchModeEnum;
|
||||
import ca.uhn.fhir.model.valueset.BundleEntryTransactionOperationEnum;
|
||||
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.util.UrlUtil;
|
||||
|
||||
public class Bundle extends BaseBundle /* implements IElement */{
|
||||
|
||||
private ResourceMetadataMap myResourceMetadata;
|
||||
private BoundCodeDt<BundleTypeEnum> myType;
|
||||
private StringDt myBundleId;
|
||||
|
||||
private TagList myCategories;
|
||||
private List<BundleEntry> myEntries;
|
||||
private volatile transient Map<IdDt, IResource> myIdToEntries;
|
||||
|
@ -54,13 +61,12 @@ public class Bundle extends BaseBundle /* implements IElement */{
|
|||
private StringDt myLinkNext;
|
||||
private StringDt myLinkPrevious;
|
||||
private StringDt myLinkSelf;
|
||||
private InstantDt myPublished;
|
||||
private StringDt myTitle;
|
||||
private IntegerDt myTotalResults;
|
||||
private InstantDt myUpdated;
|
||||
|
||||
/**
|
||||
* @deprecated Tags wil become immutable in a future release of HAPI, so {@link #addCategory(String, String, String)} should be used instead
|
||||
* @deprecated Tags wil become immutable in a future release of HAPI, so
|
||||
* {@link #addCategory(String, String, String)} should be used instead
|
||||
*/
|
||||
public Tag addCategory() {
|
||||
Tag retVal = new Tag();
|
||||
|
@ -72,7 +78,6 @@ public class Bundle extends BaseBundle /* implements IElement */{
|
|||
getCategories().add(new Tag(theScheme, theTerm, theLabel));
|
||||
}
|
||||
|
||||
|
||||
public void addCategory(Tag theTag) {
|
||||
getCategories().add(theTag);
|
||||
}
|
||||
|
@ -119,10 +124,10 @@ public class Bundle extends BaseBundle /* implements IElement */{
|
|||
|
||||
if (theResource.getId() != null) {
|
||||
if (theResource.getId().isAbsolute()) {
|
||||
|
||||
|
||||
entry.getLinkSelf().setValue(theResource.getId().getValue());
|
||||
entry.getId().setValue(theResource.getId().toVersionless().getValue());
|
||||
|
||||
|
||||
} else if (StringUtils.isNotBlank(theResource.getId().getValue())) {
|
||||
|
||||
StringBuilder b = new StringBuilder();
|
||||
|
@ -157,21 +162,6 @@ public class Bundle extends BaseBundle /* implements IElement */{
|
|||
|
||||
// String resourceType = theContext.getResourceDefinition(theResource).getName();
|
||||
|
||||
String linkSearch = ResourceMetadataKeyEnum.LINK_SEARCH.get(theResource);
|
||||
if (isNotBlank(linkSearch)) {
|
||||
if (!UrlUtil.isAbsolute(linkSearch)) {
|
||||
linkSearch = (theServerBase + "/" + linkSearch);
|
||||
}
|
||||
entry.getLinkSearch().setValue(linkSearch);
|
||||
}
|
||||
|
||||
String linkAlternate = ResourceMetadataKeyEnum.LINK_ALTERNATE.get(theResource);
|
||||
if (isNotBlank(linkAlternate)) {
|
||||
if (!UrlUtil.isAbsolute(linkAlternate)) {
|
||||
linkSearch = (theServerBase + "/" + linkAlternate);
|
||||
}
|
||||
entry.getLinkAlternate().setValue(linkSearch);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +185,7 @@ public class Bundle extends BaseBundle /* implements IElement */{
|
|||
|
||||
IdDt previous = ResourceMetadataKeyEnum.PREVIOUS_ID.get(theResource);
|
||||
if (previous != null) {
|
||||
entry.getLinkAlternate().setValue(previous.withServerBase(theServerBase, def.getName()));
|
||||
entry.getLinkAlternate().setValue(previous.withServerBase(theServerBase, def.getName()).getValue());
|
||||
}
|
||||
|
||||
TagList tagList = ResourceMetadataKeyEnum.TAG_LIST.get(theResource);
|
||||
|
@ -205,9 +195,61 @@ public class Bundle extends BaseBundle /* implements IElement */{
|
|||
}
|
||||
}
|
||||
|
||||
String linkSearch = ResourceMetadataKeyEnum.LINK_SEARCH.get(theResource);
|
||||
if (isNotBlank(linkSearch)) {
|
||||
if (!UrlUtil.isAbsolute(linkSearch)) {
|
||||
linkSearch = (theServerBase + "/" + linkSearch);
|
||||
}
|
||||
entry.getLinkSearch().setValue(linkSearch);
|
||||
}
|
||||
|
||||
String linkAlternate = ResourceMetadataKeyEnum.LINK_ALTERNATE.get(theResource);
|
||||
if (isNotBlank(linkAlternate)) {
|
||||
if (!UrlUtil.isAbsolute(linkAlternate)) {
|
||||
linkSearch = (theServerBase + "/" + linkAlternate);
|
||||
}
|
||||
entry.getLinkAlternate().setValue(linkSearch);
|
||||
}
|
||||
|
||||
BundleEntrySearchModeEnum entryStatus = ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.get(theResource);
|
||||
if (entryStatus != null) {
|
||||
entry.getSearchMode().setValueAsEnum(entryStatus);
|
||||
}
|
||||
|
||||
BundleEntryTransactionOperationEnum entryTransactionOperation = ResourceMetadataKeyEnum.ENTRY_TRANSACTION_OPERATION.get(theResource);
|
||||
if (entryTransactionOperation != null) {
|
||||
entry.getTransactionOperation().setValueAsEnum(entryTransactionOperation);
|
||||
}
|
||||
|
||||
DecimalDt entryScore = ResourceMetadataKeyEnum.ENTRY_SCORE.get(theResource);
|
||||
if (entryScore != null) {
|
||||
entry.setScore(entryScore);
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
public StringDt getBundleId() {
|
||||
if (myBundleId == null) {
|
||||
myBundleId = new StringDt();
|
||||
}
|
||||
return myBundleId;
|
||||
}
|
||||
|
||||
public TagList getCategories() {
|
||||
if (myCategories == null) {
|
||||
myCategories = new TagList();
|
||||
}
|
||||
return myCategories;
|
||||
}
|
||||
|
||||
public List<BundleEntry> getEntries() {
|
||||
if (myEntries == null) {
|
||||
myEntries = new ArrayList<BundleEntry>();
|
||||
}
|
||||
return myEntries;
|
||||
}
|
||||
|
||||
// public static void main(String[] args) {
|
||||
//
|
||||
// FhirContext ctx = new FhirContext();
|
||||
|
@ -234,27 +276,6 @@ public class Bundle extends BaseBundle /* implements IElement */{
|
|||
// }
|
||||
//
|
||||
|
||||
public StringDt getBundleId() {
|
||||
if (myBundleId == null) {
|
||||
myBundleId = new StringDt();
|
||||
}
|
||||
return myBundleId;
|
||||
}
|
||||
|
||||
public TagList getCategories() {
|
||||
if (myCategories == null) {
|
||||
myCategories = new TagList();
|
||||
}
|
||||
return myCategories;
|
||||
}
|
||||
|
||||
public List<BundleEntry> getEntries() {
|
||||
if (myEntries == null) {
|
||||
myEntries = new ArrayList<BundleEntry>();
|
||||
}
|
||||
return myEntries;
|
||||
}
|
||||
|
||||
public StringDt getLinkBase() {
|
||||
if (myLinkBase == null) {
|
||||
myLinkBase = new StringDt();
|
||||
|
@ -298,18 +319,22 @@ public class Bundle extends BaseBundle /* implements IElement */{
|
|||
}
|
||||
|
||||
public InstantDt getPublished() {
|
||||
if (myPublished == null) {
|
||||
myPublished = new InstantDt();
|
||||
InstantDt retVal = (InstantDt) getResourceMetadata().get(ResourceMetadataKeyEnum.PUBLISHED);
|
||||
if (retVal == null) {
|
||||
retVal= new InstantDt();
|
||||
getResourceMetadata().put(ResourceMetadataKeyEnum.PUBLISHED, retVal);
|
||||
}
|
||||
return myPublished;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a resource from a bundle given its logical ID.
|
||||
* <p>
|
||||
* <b>Important usage notes</b>: This method ignores base URLs (so passing in an ID of <code>http://foo/Patient/123</code> will return a resource if it has the logical ID of
|
||||
* <code>http://bar/Patient/123</code>. Also, this method is intended to be used for bundles which have already been populated. It will cache its results for fast performance, but that means that
|
||||
* modifications to the bundle after this method is called may not be accurately reflected.
|
||||
* <b>Important usage notes</b>: This method ignores base URLs (so passing in an ID of
|
||||
* <code>http://foo/Patient/123</code> will return a resource if it has the logical ID of
|
||||
* <code>http://bar/Patient/123</code>. Also, this method is intended to be used for bundles which have already been
|
||||
* populated. It will cache its results for fast performance, but that means that modifications to the bundle after
|
||||
* this method is called may not be accurately reflected.
|
||||
* </p>
|
||||
*
|
||||
* @param theId
|
||||
|
@ -330,6 +355,13 @@ public class Bundle extends BaseBundle /* implements IElement */{
|
|||
return map.get(theId.toUnqualified());
|
||||
}
|
||||
|
||||
public ResourceMetadataMap getResourceMetadata() {
|
||||
if (myResourceMetadata == null) {
|
||||
myResourceMetadata = new ResourceMetadataMap();
|
||||
}
|
||||
return myResourceMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing all resources of the given type from this bundle
|
||||
*/
|
||||
|
@ -359,11 +391,20 @@ public class Bundle extends BaseBundle /* implements IElement */{
|
|||
return myTotalResults;
|
||||
}
|
||||
|
||||
public InstantDt getUpdated() {
|
||||
if (myUpdated == null) {
|
||||
myUpdated = new InstantDt();
|
||||
public BoundCodeDt<BundleTypeEnum> getType() {
|
||||
if (myType == null) {
|
||||
myType = new BoundCodeDt<BundleTypeEnum>(BundleTypeEnum.VALUESET_BINDER);
|
||||
}
|
||||
return myUpdated;
|
||||
return myType;
|
||||
}
|
||||
|
||||
public InstantDt getUpdated() {
|
||||
InstantDt retVal = (InstantDt) getResourceMetadata().get(ResourceMetadataKeyEnum.UPDATED);
|
||||
if (retVal == null) {
|
||||
retVal= new InstantDt();
|
||||
getResourceMetadata().put(ResourceMetadataKeyEnum.UPDATED, retVal);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -379,7 +420,11 @@ public class Bundle extends BaseBundle /* implements IElement */{
|
|||
}
|
||||
|
||||
public void setPublished(InstantDt thePublished) {
|
||||
myPublished = thePublished;
|
||||
getResourceMetadata().put(ResourceMetadataKeyEnum.PUBLISHED, thePublished);
|
||||
}
|
||||
|
||||
public void setType(BoundCodeDt<BundleTypeEnum> theType) {
|
||||
myType = theType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -24,9 +24,15 @@ import org.apache.commons.lang3.Validate;
|
|||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import ca.uhn.fhir.model.primitive.BoundCodeDt;
|
||||
import ca.uhn.fhir.model.primitive.CodeDt;
|
||||
import ca.uhn.fhir.model.primitive.DecimalDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.primitive.XhtmlDt;
|
||||
import ca.uhn.fhir.model.valueset.BundleEntrySearchModeEnum;
|
||||
import ca.uhn.fhir.model.valueset.BundleEntryTransactionOperationEnum;
|
||||
import ca.uhn.fhir.util.ElementUtil;
|
||||
|
||||
public class BundleEntry extends BaseBundle {
|
||||
|
@ -41,17 +47,25 @@ public class BundleEntry extends BaseBundle {
|
|||
private StringDt myDeletedByEmail;
|
||||
private StringDt myDeletedByName;
|
||||
private StringDt myDeletedComment;
|
||||
private IdDt myDeletedResourceId;
|
||||
private CodeDt myDeletedResourceType;
|
||||
private StringDt myDeletedResourceVersion;
|
||||
private StringDt myLinkAlternate;
|
||||
private StringDt myLinkBase;
|
||||
private StringDt myLinkSearch;
|
||||
private StringDt myLinkSelf;
|
||||
private InstantDt myPublished;
|
||||
private IResource myResource;
|
||||
private DecimalDt myScore;
|
||||
private BoundCodeDt<BundleEntrySearchModeEnum> mySearchMode;
|
||||
private BoundCodeDt<BundleEntryTransactionOperationEnum> myTransactionOperation;
|
||||
private XhtmlDt mySummary;
|
||||
private StringDt myTitle;
|
||||
private InstantDt myUpdated;
|
||||
|
||||
/**
|
||||
* @deprecated Tags wil become immutable in a future release of HAPI, so {@link #addCategory(String, String, String)} should be used instead
|
||||
* @deprecated Tags wil become immutable in a future release of HAPI, so
|
||||
* {@link #addCategory(String, String, String)} should be used instead
|
||||
*/
|
||||
public Tag addCategory() {
|
||||
Tag retVal = new Tag();
|
||||
|
@ -105,6 +119,37 @@ public class BundleEntry extends BaseBundle {
|
|||
return myDeletedComment;
|
||||
}
|
||||
|
||||
public IdDt getDeletedResourceId() {
|
||||
if (myDeletedResourceId == null) {
|
||||
myDeletedResourceId = new IdDt();
|
||||
}
|
||||
return myDeletedResourceId;
|
||||
}
|
||||
|
||||
public CodeDt getDeletedResourceType() {
|
||||
if (myDeletedResourceType == null) {
|
||||
myDeletedResourceType = new CodeDt();
|
||||
}
|
||||
return myDeletedResourceType;
|
||||
}
|
||||
|
||||
public StringDt getDeletedResourceVersion() {
|
||||
if (myDeletedResourceVersion == null) {
|
||||
myDeletedResourceVersion = new StringDt();
|
||||
}
|
||||
return myDeletedResourceVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Setting IDs on bundle entries is redundant since resources already have an ID field. Instead of
|
||||
* providing an ID using this method, set the ID on the resource using {@link IResource#setId(IdDt)} or
|
||||
* if this entry represents a deleted resource, use {@link #setDeletedResourceId(IdDt)}.
|
||||
*/
|
||||
@Override
|
||||
public IdDt getId() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
public StringDt getLinkAlternate() {
|
||||
if (myLinkAlternate == null) {
|
||||
myLinkAlternate = new StringDt();
|
||||
|
@ -112,6 +157,16 @@ public class BundleEntry extends BaseBundle {
|
|||
return myLinkAlternate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use resource ID to determine base URL
|
||||
*/
|
||||
public StringDt getLinkBase() {
|
||||
if (myLinkBase == null) {
|
||||
myLinkBase = new StringDt();
|
||||
}
|
||||
return myLinkBase;
|
||||
}
|
||||
|
||||
public StringDt getLinkSearch() {
|
||||
if (myLinkSearch == null) {
|
||||
myLinkSearch = new StringDt();
|
||||
|
@ -137,6 +192,14 @@ public class BundleEntry extends BaseBundle {
|
|||
return myResource;
|
||||
}
|
||||
|
||||
public DecimalDt getScore() {
|
||||
if (myScore == null) {
|
||||
myScore = new DecimalDt();
|
||||
}
|
||||
return myScore;
|
||||
}
|
||||
|
||||
|
||||
public XhtmlDt getSummary() {
|
||||
if (mySummary == null) {
|
||||
mySummary = new XhtmlDt();
|
||||
|
@ -151,10 +214,22 @@ public class BundleEntry extends BaseBundle {
|
|||
return myTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated <b>DSTU2 Note:</b> As of DSTU2, bundle entries no longer have an updated time (this bit of metadata
|
||||
* has been moved to the resource <meta/> element so it is redundant here). In preparation for
|
||||
* DSTU2, it is recommended that you migrate code away from using this method and over to using resource
|
||||
* metadata instead.
|
||||
*/
|
||||
public InstantDt getUpdated() {
|
||||
if (myUpdated == null) {
|
||||
myUpdated = new InstantDt();
|
||||
}
|
||||
if (myUpdated.isEmpty() && myResource != null) {
|
||||
InstantDt resourceUpdated = ResourceMetadataKeyEnum.UPDATED.get(myResource);
|
||||
if (resourceUpdated != null && !resourceUpdated.isEmpty()) {
|
||||
return resourceUpdated;
|
||||
}
|
||||
}
|
||||
return myUpdated;
|
||||
}
|
||||
|
||||
|
@ -162,7 +237,11 @@ public class BundleEntry extends BaseBundle {
|
|||
public boolean isEmpty() {
|
||||
//@formatter:off
|
||||
return super.isEmpty() &&
|
||||
ElementUtil.isEmpty(myCategories, myDeletedAt, myLinkAlternate, myLinkSelf, myPublished, myResource, mySummary, myTitle, myUpdated, myDeletedByEmail, myDeletedByName, myDeletedComment);
|
||||
ElementUtil.isEmpty(
|
||||
myDeletedResourceId, myDeletedResourceType, myDeletedResourceVersion, myDeletedAt,
|
||||
myScore, mySearchMode, myTransactionOperation, myCategories,
|
||||
myLinkAlternate, myLinkSelf, myPublished, myResource, mySummary,
|
||||
myTitle, myUpdated, myDeletedByEmail, myDeletedByName, myDeletedComment);
|
||||
//@formatter:on
|
||||
}
|
||||
|
||||
|
@ -188,10 +267,37 @@ public class BundleEntry extends BaseBundle {
|
|||
myDeletedComment = theDeletedComment;
|
||||
}
|
||||
|
||||
public void setDeletedResourceId(IdDt theDeletedResourceId) {
|
||||
myDeletedResourceId = theDeletedResourceId;
|
||||
}
|
||||
|
||||
public void setDeletedResourceType(CodeDt theDeletedResourceType) {
|
||||
myDeletedResourceType = theDeletedResourceType;
|
||||
}
|
||||
|
||||
public void setDeletedResourceVersion(StringDt theDeletedResourceVersion) {
|
||||
myDeletedResourceVersion = theDeletedResourceVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Bundle entries no longer have an ID in DSTU2, as ID is explicitly stated in the resource itself.
|
||||
*/
|
||||
@Override
|
||||
public void setId(IdDt theId) {
|
||||
super.setId(theId);
|
||||
}
|
||||
|
||||
public void setLinkAlternate(StringDt theLinkAlternate) {
|
||||
myLinkAlternate = theLinkAlternate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use resource ID to determine base URL
|
||||
*/
|
||||
public void setLinkBase(StringDt theLinkBase) {
|
||||
myLinkBase = theLinkBase;
|
||||
}
|
||||
|
||||
public void setLinkSearch(StringDt theLinkSearch) {
|
||||
myLinkSearch = theLinkSearch;
|
||||
}
|
||||
|
@ -212,6 +318,17 @@ public class BundleEntry extends BaseBundle {
|
|||
myResource = theResource;
|
||||
}
|
||||
|
||||
public void setScore(DecimalDt theScore) {
|
||||
myScore = theScore;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated <b>DSTU2 Note:</b> As of DSTU2, bundle entries no longer have an updated time (this bit of metadata
|
||||
* has been moved to the resource <meta/> element so it is redundant here). In preparation for
|
||||
* DSTU2, it is recommended that you migrate code away from using this method and over to using resource
|
||||
* metadata instead.
|
||||
*/
|
||||
public void setUpdated(InstantDt theUpdated) {
|
||||
Validate.notNull(theUpdated, "Updated may not be null");
|
||||
myUpdated = theUpdated;
|
||||
|
@ -229,4 +346,29 @@ public class BundleEntry extends BaseBundle {
|
|||
return b.toString();
|
||||
}
|
||||
|
||||
public BoundCodeDt<BundleEntrySearchModeEnum> getSearchMode() {
|
||||
if (mySearchMode == null) {
|
||||
mySearchMode = new BoundCodeDt<BundleEntrySearchModeEnum>(BundleEntrySearchModeEnum.VALUESET_BINDER);
|
||||
}
|
||||
return mySearchMode;
|
||||
}
|
||||
|
||||
public void setSearchMode(BoundCodeDt<BundleEntrySearchModeEnum> theSearchMode) {
|
||||
mySearchMode = theSearchMode;
|
||||
}
|
||||
|
||||
public BoundCodeDt<BundleEntryTransactionOperationEnum> getTransactionOperation() {
|
||||
if (myTransactionOperation == null) {
|
||||
myTransactionOperation = new BoundCodeDt<BundleEntryTransactionOperationEnum>(BundleEntryTransactionOperationEnum.VALUESET_BINDER);
|
||||
}
|
||||
return myTransactionOperation;
|
||||
}
|
||||
|
||||
public void setTransactionOperation(BoundCodeDt<BundleEntryTransactionOperationEnum> theTransactionOperation) {
|
||||
myTransactionOperation = theTransactionOperation;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package ca.uhn.fhir.model.api;
|
||||
|
||||
import org.hl7.fhir.instance.model.ICompositeType;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -22,6 +24,6 @@ package ca.uhn.fhir.model.api;
|
|||
|
||||
|
||||
|
||||
public interface ICompositeDatatype extends IDatatype, ICompositeElement {
|
||||
public interface ICompositeDatatype extends IDatatype, ICompositeElement, ICompositeType {
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package ca.uhn.fhir.model.api;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -22,9 +24,6 @@ package ca.uhn.fhir.model.api;
|
|||
|
||||
|
||||
|
||||
public interface IElement {
|
||||
|
||||
boolean isEmpty();
|
||||
|
||||
public interface IElement extends IBase {
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -20,16 +20,28 @@ package ca.uhn.fhir.model.api;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.IServerConformanceProvider;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
|
||||
public interface IFhirVersion {
|
||||
|
||||
IResource generateProfile(RuntimeResourceDefinition theRuntimeResourceDefinition);
|
||||
|
||||
Object createServerConformanceProvider(RestfulServer theServer);
|
||||
|
||||
FhirVersionEnum getVersion();
|
||||
|
||||
IResourceProvider createServerProfilesProvider(RestfulServer theRestfulServer);
|
||||
|
||||
InputStream getFhirVersionPropertiesFile();
|
||||
|
||||
IResource generateProfile(RuntimeResourceDefinition theRuntimeResourceDefinition, String theServerBase);
|
||||
|
||||
IServerConformanceProvider<? extends IBaseResource> createServerConformanceProvider(RestfulServer theRestfulServer);
|
||||
|
||||
String getPathToSchemaDefinitions();
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -20,9 +20,11 @@ package ca.uhn.fhir.model.api;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
|
||||
public interface IPrimitiveDatatype<T> extends IDatatype {
|
||||
public interface IPrimitiveDatatype<T> extends IDatatype, IPrimitiveType<T> {
|
||||
|
||||
void setValueAsString(String theValue) throws DataFormatException;
|
||||
|
||||
|
@ -30,5 +32,5 @@ public interface IPrimitiveDatatype<T> extends IDatatype {
|
|||
|
||||
T getValue();
|
||||
|
||||
void setValue(T theValue) throws DataFormatException;
|
||||
IPrimitiveType<T> setValue(T theValue) throws DataFormatException;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -5,7 +5,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -41,18 +41,20 @@ public interface IQueryParameterType {
|
|||
public void setValueAsQueryToken(String theQualifier, String theValue);
|
||||
|
||||
/**
|
||||
* This method is generally only called by HAPI itself, and should not need to be called from user code.
|
||||
* Returns a representation of this parameter's value as it will be represented "over the wire". In other
|
||||
* words, how it will be presented in a URL (although not URL escaped)
|
||||
*
|
||||
* <p>
|
||||
* See FHIR specification <a href="http://www.hl7.org/implement/standards/fhir/search.html#ptypes">2.2.2 Search
|
||||
* SearchParameter Types</a> for information on the <b>token</b> format
|
||||
* </p>
|
||||
*
|
||||
* @return Returns a representation of this parameter's value as it will be represented "over the wire". In other
|
||||
* words, how it will be presented in a URL (although not URL escaped)
|
||||
*/
|
||||
public String getValueAsQueryToken();
|
||||
|
||||
/**
|
||||
* This method is generally only called by HAPI itself, and should not need to be called from user code.
|
||||
*
|
||||
* This method will return any qualifier that should be appended to the parameter name (e.g ":exact")
|
||||
*/
|
||||
public String getQueryParameterQualifier();
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -20,9 +20,8 @@ package ca.uhn.fhir.model.api;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
import ca.uhn.fhir.model.base.resource.ResourceMetadataMap;
|
||||
import ca.uhn.fhir.model.dstu.composite.ContainedDt;
|
||||
import ca.uhn.fhir.model.dstu.composite.NarrativeDt;
|
||||
import ca.uhn.fhir.model.primitive.CodeDt;
|
||||
|
@ -37,9 +36,9 @@ import ca.uhn.fhir.model.primitive.IdDt;
|
|||
* Note that this class is a part of HAPI's model API, used to define
|
||||
* structure classes. Users will often interact with this interface, but
|
||||
* should not need to implement it directly.
|
||||
* <p>
|
||||
* </p>
|
||||
*/
|
||||
public interface IResource extends ICompositeElement {
|
||||
public interface IResource extends ICompositeElement, org.hl7.fhir.instance.model.IBaseResource {
|
||||
|
||||
/**
|
||||
* Returns the contained resource list for this resource.
|
||||
|
@ -49,7 +48,7 @@ public interface IResource extends ICompositeElement {
|
|||
* encoding, and copying contained resources from this list to their
|
||||
* appropriate references when parsing) so it is generally not neccesary to
|
||||
* interact with this list directly. Instead, in a server you can place
|
||||
* resource instances in reference fields (such as {@link ca.uhn.fhir.model.dstu.resource.Patient#setManagingOrganization(ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt)})
|
||||
* resource instances in reference fields (such as <code>Patient#setManagingOrganization(ResourceReferenceDt)</code> )
|
||||
* and the resource will be automatically contained. In a client, contained resources will
|
||||
* be automatically populated into their appropriate fields by the HAPI parser.
|
||||
* </p>
|
||||
|
@ -88,7 +87,7 @@ public interface IResource extends ICompositeElement {
|
|||
* @see ResourceMetadataKeyEnum for a list of allowable keys and the object
|
||||
* types that values of a given key must use.
|
||||
*/
|
||||
Map<ResourceMetadataKeyEnum<?>, Object> getResourceMetadata();
|
||||
ResourceMetadataMap getResourceMetadata();
|
||||
|
||||
/**
|
||||
* Returns the narrative block for this resource
|
||||
|
@ -122,7 +121,7 @@ public interface IResource extends ICompositeElement {
|
|||
* @throws NullPointerException
|
||||
* The map must not be null
|
||||
*/
|
||||
void setResourceMetadata(Map<ResourceMetadataKeyEnum<?>, Object> theMap);
|
||||
void setResourceMetadata(ResourceMetadataMap theMap);
|
||||
|
||||
/**
|
||||
* Returns a String representing the name of this Resource. This return
|
||||
|
@ -133,4 +132,10 @@ public interface IResource extends ICompositeElement {
|
|||
*/
|
||||
String getResourceName();
|
||||
|
||||
/**
|
||||
* Returns the FHIR version represented by this structure
|
||||
*/
|
||||
public ca.uhn.fhir.context.FhirVersionEnum getStructureFhirVersionEnum();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -22,13 +22,20 @@ package ca.uhn.fhir.model.api;
|
|||
|
||||
import static org.apache.commons.lang3.StringUtils.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import ca.uhn.fhir.model.primitive.DecimalDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.valueset.BundleEntrySearchModeEnum;
|
||||
import ca.uhn.fhir.model.valueset.BundleEntryTransactionOperationEnum;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
|
||||
/**
|
||||
|
@ -36,7 +43,7 @@ import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
|||
* data elements which are sent/receieved in HTTP Headers along with read/create resource requests, or properties which can be found in bundle entries.
|
||||
* <p>
|
||||
* To access or set resource metadata values, every resource has a metadata map, and this class provides convenient getters/setters for interacting with that map. For example, to get a resource's
|
||||
* {@link UPDATED} value, which is the "last updated" time for that resource, use the following code:
|
||||
* {@link #UPDATED} value, which is the "last updated" time for that resource, use the following code:
|
||||
* </p>
|
||||
* <p>
|
||||
* <code>InstantDt updated = ResourceMetadataKeyEnum.UPDATED.get(resource);</code>
|
||||
|
@ -45,7 +52,7 @@ import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
|||
* To set this value, use the following:
|
||||
* </p>
|
||||
* <p>
|
||||
* <code>InstantDt update = new InstantDt("2011-01-02T11:22:33.0000Z"); // populate with the actual time<br/>
|
||||
* <code>InstantDt update = new InstantDt("2011-01-02T11:22:33.0000Z"); // populate with the actual time<br>
|
||||
* ResourceMetadataKeyEnum.UPDATED.put(resource, update);</code>
|
||||
* </p>
|
||||
* <p>
|
||||
|
@ -74,6 +81,28 @@ public abstract class ResourceMetadataKeyEnum<T> {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The value for this key represents a {@link List} of profile IDs that this
|
||||
* resource claims to conform to.
|
||||
*
|
||||
* <p>
|
||||
* Values for this key are of type <b>List<IdDt></b>. Note that the returned list is
|
||||
* <i>unmodifiable</i>, so you need to create a new list and call <code>put</code> to
|
||||
* change its value.
|
||||
* </p>
|
||||
*/
|
||||
public static final ResourceMetadataKeyEnum<List<IdDt>> PROFILES = new ResourceMetadataKeyEnum<List<IdDt>>("PROFILES") {
|
||||
@Override
|
||||
public List<IdDt> get(IResource theResource) {
|
||||
return getIdListFromMetadataOrNullIfNone(theResource.getResourceMetadata(), PROFILES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(IResource theResource, List<IdDt> theObject) {
|
||||
theResource.getResourceMetadata().put(PROFILES, theObject);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The value for this key represents a previous ID used to identify this resource. This key is currently only used internally during transaction method processing.
|
||||
* <p>
|
||||
|
@ -191,7 +220,7 @@ public abstract class ResourceMetadataKeyEnum<T> {
|
|||
* Values for this key are of type <b>{@link IdDt}</b>
|
||||
* </p>
|
||||
*
|
||||
* @deprecated The {@link IResource#getId()} resource ID will now be populated with the version ID via the {@link IdDt#getUnqualifiedVersionId()} method
|
||||
* @deprecated The {@link IResource#getId()} resource ID will now be populated with the version ID via the {@link IdDt#getVersionIdPart()} method
|
||||
*/
|
||||
@Deprecated
|
||||
public static final ResourceMetadataKeyEnum<IdDt> VERSION_ID = new ResourceMetadataKeyEnum<IdDt>("VERSION_ID") {
|
||||
|
@ -206,6 +235,24 @@ public abstract class ResourceMetadataKeyEnum<T> {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The value for this key is the version ID of the resource object.
|
||||
* <p>
|
||||
* Values for this key are of type <b>{@link String}</b>
|
||||
* </p>
|
||||
*/
|
||||
public static final ResourceMetadataKeyEnum<String> VERSION = new ResourceMetadataKeyEnum<String>("VERSION") {
|
||||
@Override
|
||||
public String get(IResource theResource) {
|
||||
return getStringFromMetadataOrNullIfNone(theResource.getResourceMetadata(), VERSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(IResource theResource, String theObject) {
|
||||
theResource.getResourceMetadata().put(VERSION, theObject);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* If present and populated with a string, provides the "search link" (the link element in the bundle entry with <code>rel="search"</code>). Server implementations may populate this with a
|
||||
* complete URL, in which case the URL will be placed as-is in the bundle. They may alternately specify a resource relative URL (e.g. "Patient?name=tester") in which case the server will convert
|
||||
|
@ -246,6 +293,83 @@ public abstract class ResourceMetadataKeyEnum<T> {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* If present and populated with a {@link BundleEntrySearchModeEnum}, contains the "bundle entry search mode",
|
||||
* which is the value of the status field in the Bundle entry containing this resource. The value for this key
|
||||
* corresponds to field <code>Bundle.entry.search.mode</code>.
|
||||
* This value can be
|
||||
* set to provide a status value of "include" for included resources being returned by a server, or to
|
||||
* "match" to indicate that the resource was returned because it matched the given search criteria.
|
||||
* <p>
|
||||
* Note that status is only used in FHIR DSTU2 and later.
|
||||
* </p>
|
||||
* <p>
|
||||
* Values for this key are of type <b>{@link BundleEntrySearchModeEnum}</b>
|
||||
* </p>
|
||||
*/
|
||||
public static final ResourceMetadataKeyEnum<BundleEntrySearchModeEnum> ENTRY_SEARCH_MODE = new ResourceMetadataKeyEnum<BundleEntrySearchModeEnum>("ENTRY_SEARCH_MODE") {
|
||||
@Override
|
||||
public BundleEntrySearchModeEnum get(IResource theResource) {
|
||||
return getEnumFromMetadataOrNullIfNone(theResource.getResourceMetadata(), ENTRY_SEARCH_MODE, BundleEntrySearchModeEnum.class, BundleEntrySearchModeEnum.VALUESET_BINDER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(IResource theResource, BundleEntrySearchModeEnum theObject) {
|
||||
theResource.getResourceMetadata().put(ENTRY_SEARCH_MODE, theObject);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* If present and populated with a {@link BundleEntryTransactionOperationEnum}, contains the "bundle entry transaction operation",
|
||||
* which is the value of the status field in the Bundle entry containing this resource. The value for this key
|
||||
* corresponds to field <code>Bundle.entry.transaction.operation</code>.
|
||||
* This value can be
|
||||
* set in resources being transmitted to a server to provide a status value of "create" or "update" to indicate behaviour the
|
||||
* server should observe. It may also be set to similar values (or to "noop") in resources being returned by
|
||||
* a server as a result of a transaction to indicate to the client what operation was actually performed.
|
||||
* <p>
|
||||
* Note that status is only used in FHIR DSTU2 and later.
|
||||
* </p>
|
||||
* <p>
|
||||
* Values for this key are of type <b>{@link BundleEntryTransactionOperationEnum}</b>
|
||||
* </p>
|
||||
*/
|
||||
public static final ResourceMetadataKeyEnum<BundleEntryTransactionOperationEnum> ENTRY_TRANSACTION_OPERATION = new ResourceMetadataKeyEnum<BundleEntryTransactionOperationEnum>("ENTRY_TRANSACTION_OPERATION") {
|
||||
@Override
|
||||
public BundleEntryTransactionOperationEnum get(IResource theResource) {
|
||||
return getEnumFromMetadataOrNullIfNone(theResource.getResourceMetadata(), ENTRY_TRANSACTION_OPERATION, BundleEntryTransactionOperationEnum.class, BundleEntryTransactionOperationEnum.VALUESET_BINDER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(IResource theResource, BundleEntryTransactionOperationEnum theObject) {
|
||||
theResource.getResourceMetadata().put(ENTRY_TRANSACTION_OPERATION, theObject);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Denotes the search score which a given resource should match in a transaction. See the
|
||||
* FHIR transaction definition for information about this. Corresponds to
|
||||
* the value in <code>Bundle.entry.score</code> in a Bundle resource.
|
||||
* <p>
|
||||
* Note that search URL is only used in FHIR DSTU2 and later.
|
||||
* </p>
|
||||
* <p>
|
||||
* Values for this key are of type <b>{@link DecimalDt}</b>
|
||||
* </p>
|
||||
*/
|
||||
public static final ResourceMetadataKeyEnum<DecimalDt> ENTRY_SCORE = new ResourceMetadataKeyEnum<DecimalDt>("ENTRY_SCORE") {
|
||||
@Override
|
||||
public DecimalDt get(IResource theResource) {
|
||||
return getDecimalFromMetadataOrNullIfNone(theResource.getResourceMetadata(), ENTRY_SCORE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(IResource theResource, DecimalDt theObject) {
|
||||
theResource.getResourceMetadata().put(ENTRY_SCORE, theObject);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private final String myValue;
|
||||
|
||||
public ResourceMetadataKeyEnum(String theValue) {
|
||||
|
@ -291,7 +415,31 @@ public abstract class ResourceMetadataKeyEnum<T> {
|
|||
}
|
||||
|
||||
private static IdDt getIdFromMetadataOrNullIfNone(Map<ResourceMetadataKeyEnum<?>, Object> theResourceMetadata, ResourceMetadataKeyEnum<?> theKey) {
|
||||
return toId(theKey, theResourceMetadata.get(theKey));
|
||||
}
|
||||
|
||||
private static List<IdDt> getIdListFromMetadataOrNullIfNone(Map<ResourceMetadataKeyEnum<?>, Object> theResourceMetadata, ResourceMetadataKeyEnum<?> theKey) {
|
||||
Object retValObj = theResourceMetadata.get(theKey);
|
||||
if (retValObj instanceof List) {
|
||||
List<?> retValList = (List<?>)retValObj;
|
||||
for (Object next : retValList) {
|
||||
if (!(next instanceof IdDt)) {
|
||||
List<IdDt> retVal = new ArrayList<IdDt>();
|
||||
for (Object nextVal : retValList) {
|
||||
retVal.add(toId(theKey, nextVal));
|
||||
}
|
||||
return Collections.unmodifiableList(retVal);
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
List<IdDt> retVal = (List<IdDt>) retValList;
|
||||
return Collections.unmodifiableList(retVal);
|
||||
} else {
|
||||
return Collections.singletonList(toId(theKey, retValObj));
|
||||
}
|
||||
}
|
||||
|
||||
private static IdDt toId(ResourceMetadataKeyEnum<?> theKey, Object retValObj) {
|
||||
if (retValObj == null) {
|
||||
return null;
|
||||
} else if (retValObj instanceof String) {
|
||||
|
@ -330,6 +478,64 @@ public abstract class ResourceMetadataKeyEnum<T> {
|
|||
+ InstantDt.class.getCanonicalName());
|
||||
}
|
||||
|
||||
private static StringDt getStringDtFromMetadataOrNullIfNone(Map<ResourceMetadataKeyEnum<?>, Object> theResourceMetadata, ResourceMetadataKeyEnum<StringDt> theKey) {
|
||||
Object retValObj = theResourceMetadata.get(theKey);
|
||||
if (retValObj == null) {
|
||||
return null;
|
||||
} else if (retValObj instanceof String) {
|
||||
if (StringUtils.isBlank((String) retValObj)) {
|
||||
return null;
|
||||
}
|
||||
return new StringDt((String) retValObj);
|
||||
} else if (retValObj instanceof StringDt) {
|
||||
if (((StringDt) retValObj).isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
return (StringDt) retValObj;
|
||||
}
|
||||
}
|
||||
throw new InternalErrorException("Found an object of type '" + retValObj.getClass().getCanonicalName() + "' in resource metadata for key " + theKey.name() + " - Expected "
|
||||
+ InstantDt.class.getCanonicalName());
|
||||
}
|
||||
|
||||
|
||||
private static DecimalDt getDecimalFromMetadataOrNullIfNone(Map<ResourceMetadataKeyEnum<?>, Object> theResourceMetadata, ResourceMetadataKeyEnum<DecimalDt> theKey) {
|
||||
Object retValObj = theResourceMetadata.get(theKey);
|
||||
if (retValObj == null) {
|
||||
return null;
|
||||
} else if (retValObj instanceof DecimalDt) {
|
||||
if (((DecimalDt) retValObj).isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
return (DecimalDt) retValObj;
|
||||
}
|
||||
} else if (retValObj instanceof String) {
|
||||
if (StringUtils.isBlank((String) retValObj)) {
|
||||
return null;
|
||||
}
|
||||
return new DecimalDt((String) retValObj);
|
||||
} else if (retValObj instanceof Double) {
|
||||
return new DecimalDt((Double) retValObj);
|
||||
}
|
||||
throw new InternalErrorException("Found an object of type '" + retValObj.getClass().getCanonicalName() + "' in resource metadata for key " + theKey.name() + " - Expected "
|
||||
+ InstantDt.class.getCanonicalName());
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T extends Enum<?>> T getEnumFromMetadataOrNullIfNone(Map<ResourceMetadataKeyEnum<?>, Object> theResourceMetadata, ResourceMetadataKeyEnum<T> theKey, Class<T> theEnumType, IValueSetEnumBinder<T> theBinder) {
|
||||
Object retValObj = theResourceMetadata.get(theKey);
|
||||
if (retValObj == null) {
|
||||
return null;
|
||||
} else if (theEnumType.equals(retValObj.getClass())) {
|
||||
return (T) retValObj;
|
||||
} else if (retValObj instanceof String) {
|
||||
return theBinder.fromCodeString((String) retValObj);
|
||||
}
|
||||
throw new InternalErrorException("Found an object of type '" + retValObj.getClass().getCanonicalName() + "' in resource metadata for key " + theKey.name() + " - Expected "
|
||||
+ InstantDt.class.getCanonicalName());
|
||||
}
|
||||
|
||||
private static String getStringFromMetadataOrNullIfNone(Map<ResourceMetadataKeyEnum<?>, Object> theResourceMetadata, ResourceMetadataKeyEnum<String> theKey) {
|
||||
Object retValObj = theResourceMetadata.get(theKey);
|
||||
if (retValObj == null) {
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
@ -142,6 +142,8 @@ public class Tag extends BaseElement implements IElement {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the label and returns a reference to this tag
|
||||
*
|
||||
* @deprecated Tags will become immutable in a future release of HAPI in order to facilitate
|
||||
* ensuring that the TagList acts as an unordered set. Use the constructor to set this field when creating a new
|
||||
* tag object
|
||||
|
@ -152,6 +154,8 @@ public class Tag extends BaseElement implements IElement {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the scheme and returns a reference to this tag
|
||||
*
|
||||
* @deprecated Tags will become immutable in a future release of HAPI in order to facilitate
|
||||
* ensuring that the TagList acts as an unordered set. Use the constructor to set this field when creating a new
|
||||
* tag object
|
||||
|
@ -162,6 +166,8 @@ public class Tag extends BaseElement implements IElement {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the term and returns a reference to this tag
|
||||
*
|
||||
* @deprecated Tags will become immutable in a future release of HAPI in order to facilitate
|
||||
* ensuring that the TagList acts as an unordered set. Use the constructor to set this field when creating a new
|
||||
* tag object
|
||||
|
|
|
@ -4,7 +4,7 @@ package ca.uhn.fhir.model.api;
|
|||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 University Health Network
|
||||
* 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.
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue