Merge branch 'master' of github.com:jamesagnew/hapi-fhir

This commit is contained in:
jamesagnew 2015-02-09 22:26:17 -05:00
commit 9828d27eec
35 changed files with 360 additions and 237 deletions

View File

@ -21,7 +21,7 @@
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>0.9-SNAPSHOT</version>
</dependency>
<dependency>

View File

@ -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());
}

View File

@ -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 {

View File

@ -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")

View File

@ -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();

View File

@ -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;
@ -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
}

View File

@ -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

View File

@ -8,10 +8,10 @@ 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.dstu.valueset.AdministrativeGenderCodesEnum;
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;
@ -47,7 +47,7 @@ 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
@ -72,7 +72,7 @@ public class GenericClientExample {
// 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
@ -106,7 +106,7 @@ public class GenericClientExample {
System.out.println("Version ID: " + patient.getId().getVersionIdPart());
// Now let's make a change to the resource
patient.setGender(AdministrativeGenderCodesEnum.F);
patient.setGender(AdministrativeGenderEnum.FEMALE);
// Invoke the server update method - Because the resource has
// a version, it will be included in the request sent to
@ -147,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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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");

View File

@ -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 {

View File

@ -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" })

View File

@ -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();

View File

@ -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");

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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,15 @@ 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;
@ -52,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;
@ -163,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>();

View File

@ -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 {

View File

@ -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();

View File

@ -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;

View File

@ -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;

View File

@ -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();

View File

@ -20,11 +20,14 @@ package ca.uhn.fhir.model.primitive;
* #L%
*/
import static ca.uhn.fhir.model.api.TemporalPrecisionEnum.*;
import static ca.uhn.fhir.model.api.TemporalPrecisionEnum.DAY;
import static ca.uhn.fhir.model.api.TemporalPrecisionEnum.MILLI;
import static ca.uhn.fhir.model.api.TemporalPrecisionEnum.MONTH;
import static ca.uhn.fhir.model.api.TemporalPrecisionEnum.SECOND;
import static ca.uhn.fhir.model.api.TemporalPrecisionEnum.YEAR;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.GregorianCalendar;
@ -330,13 +333,7 @@ public abstract class BaseDateTimeDt extends BasePrimitive<Date> {
}
/**
* Sets the precision for this datatype using field values from {@link Calendar}. Valid values are:
* <ul>
* <li>{@link Calendar#SECOND}
* <li>{@link Calendar#DAY_OF_MONTH}
* <li>{@link Calendar#MONTH}
* <li>{@link Calendar#YEAR}
* </ul>
* Sets the precision for this datatype
*
* @throws DataFormatException
*/
@ -372,15 +369,23 @@ public abstract class BaseDateTimeDt extends BasePrimitive<Date> {
updateStringValue();
}
/**
* Sets the value for this type using the given Java Date object as the time, and using the
* default precision for this datatype, as well as the local timezone as determined by the
* local operating system. Both of these properties may be modified in subsequent calls
* if neccesary.
*/
@Override
public BaseDateTimeDt setValue(Date theValue) {
clearTimeZone();
super.setValue(theValue);
setValue(theValue, getDefaultPrecisionForDatatype());
return this;
}
/**
* Sets the value of this date/time using the specified level of precision
* Sets the value for this type using the given Java Date object as the time, and using the
* specified precision, as well as the local timezone as determined by the
* local operating system. Both of these properties may be modified in subsequent calls
* if neccesary.
*
* @param theValue
* The date value
@ -390,8 +395,8 @@ public abstract class BaseDateTimeDt extends BasePrimitive<Date> {
*/
public void setValue(Date theValue, TemporalPrecisionEnum thePrecision) throws DataFormatException {
clearTimeZone();
super.setValue(theValue);
myPrecision = thePrecision;
super.setValue(theValue);
}
@Override

View File

@ -9,7 +9,7 @@
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:hapi-fhir-server-resourceproviders-dev.xml
classpath:hapi-fhir-server-resourceproviders-dstu2.xml
/WEB-INF/hapi-fhir-server-database-config.xml
/WEB-INF/hapi-fhir-server-config.xml
/WEB-INF/hapi-fhir-tester-application-context.xml

View File

@ -49,12 +49,12 @@
<version>${phloc_commons_version}</version>
</dependency>
<dependency>
<!--dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jpaserver-test</artifactId>
<version>0.9-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependency-->
<dependency>
<groupId>org.springframework</groupId>

View File

@ -3,6 +3,7 @@ package ca.uhn.fhir.model.primitive;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
@ -17,6 +18,7 @@ import org.junit.Test;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
import ca.uhn.fhir.model.dstu.resource.Condition;
import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.validation.ValidationResult;
@ -33,6 +35,22 @@ public class BaseDateTimeDtTest {
myDateInstantZoneParser = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss.SSSZ", TimeZone.getTimeZone("GMT-02:00"));
}
/**
* See #101
*/
@Test
public void testPrecision() throws Exception {
Calendar cal = Calendar.getInstance();
cal.setTime(myDateInstantParser.parse("2012-01-02 22:31:02.333"));
cal.setTimeZone(TimeZone.getTimeZone("EST"));
Patient patient = new Patient();
patient.setBirthDate(cal.getTime(), TemporalPrecisionEnum.DAY);
String out = ourCtx.newXmlParser().encodeResourceToString(patient);
assertThat(out, containsString("<birthDate value=\"2012-01-02\"/>"));
}
@Test
public void setTimezoneToZulu() {
DateTimeDt dt = new DateTimeDt(new Date(816411488000L));

View File

@ -0,0 +1,57 @@
package ca.uhn.fhir.model.primitive;
import static org.junit.Assert.assertEquals;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import org.junit.Before;
import org.junit.Test;
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
public class BaseDateTimeDtTest {
private SimpleDateFormat myDateInstantParser;
@Before
public void before() {
myDateInstantParser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
}
/**
* See HAPI #101 - https://github.com/jamesagnew/hapi-fhir/issues/101
*/
@Test
public void testPrecisionRespectedForSetValueWithPrecision() throws Exception {
Calendar cal = Calendar.getInstance();
cal.setTime(myDateInstantParser.parse("2012-01-02 22:31:02.333"));
cal.setTimeZone(TimeZone.getTimeZone("EST"));
Date time = cal.getTime();
DateDt date = new DateDt();
date.setValue(time, TemporalPrecisionEnum.DAY);
assertEquals("2012-01-02", date.getValueAsString());
}
/**
* See HAPI #101 - https://github.com/jamesagnew/hapi-fhir/issues/101
*/
@Test
public void testPrecisionRespectedForSetValue() throws Exception {
Calendar cal = Calendar.getInstance();
cal.setTime(myDateInstantParser.parse("2012-01-02 22:31:02.333"));
cal.setTimeZone(TimeZone.getTimeZone("EST"));
Date time = cal.getTime();
DateDt date = new DateDt();
date.setValue(time);
assertEquals("2012-01-02", date.getValueAsString());
}
}

View File

@ -29,11 +29,21 @@
<artifactId>hapi-fhir-base</artifactId>
<version>0.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jpaserver-base</artifactId>
<version>0.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>0.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>0.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dev</artifactId>
@ -57,12 +67,12 @@
<scope>provided</scope>
</dependency>
<dependency>
<!-- <dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jpaserver-test</artifactId>
<version>0.9-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependency>-->
<dependency>
<groupId>ch.qos.logback</groupId>

View File

@ -421,17 +421,17 @@ public class Controller {
private boolean extractSearchParamsDev(IResource theConformance, String resourceName, TreeSet<String> includes, TreeSet<String> sortParams, List<RestQuery> queries, boolean haveSearchParams,
List<List<String>> queryIncludes) {
ca.uhn.fhir.model.dev.resource.Conformance conformance = (ca.uhn.fhir.model.dev.resource.Conformance) theConformance;
for (ca.uhn.fhir.model.dev.resource.Conformance.Rest nextRest : conformance.getRest()) {
for (ca.uhn.fhir.model.dev.resource.Conformance.RestResource nextRes : nextRest.getResource()) {
ca.uhn.fhir.model.dstu2.resource.Conformance conformance = (ca.uhn.fhir.model.dstu2.resource.Conformance) theConformance;
for (ca.uhn.fhir.model.dstu2.resource.Conformance.Rest nextRest : conformance.getRest()) {
for (ca.uhn.fhir.model.dstu2.resource.Conformance.RestResource nextRes : nextRest.getResource()) {
if (nextRes.getTypeElement().getValue().equals(resourceName)) {
for (StringDt next : nextRes.getSearchInclude()) {
if (next.isEmpty() == false) {
includes.add(next.getValue());
}
}
for (ca.uhn.fhir.model.dev.resource.Conformance.RestResourceSearchParam next : nextRes.getSearchParam()) {
if (next.getTypeElement().getValueAsEnum() != ca.uhn.fhir.model.dev.valueset.SearchParamTypeEnum.COMPOSITE) {
for (ca.uhn.fhir.model.dstu2.resource.Conformance.RestResourceSearchParam next : nextRes.getSearchParam()) {
if (next.getTypeElement().getValueAsEnum() != ca.uhn.fhir.model.dstu2.valueset.SearchParamTypeEnum.COMPOSITE) {
sortParams.add(next.getNameElement().getValue());
}
}
@ -1083,21 +1083,21 @@ public class Controller {
private IResource loadAndAddConfDev(final HomeRequest theRequest, final ModelMap theModel) {
IGenericClient client = getContext(theRequest).newRestfulGenericClient(theRequest.getServerBase(myConfig));
ca.uhn.fhir.model.dev.resource.Conformance conformance;
ca.uhn.fhir.model.dstu2.resource.Conformance conformance;
try {
conformance = (ca.uhn.fhir.model.dev.resource.Conformance) client.conformance();
conformance = (ca.uhn.fhir.model.dstu2.resource.Conformance) client.conformance();
} catch (Exception e) {
ourLog.warn("Failed to load conformance statement", e);
theModel.put("errorMsg", "Failed to load conformance statement, error was: " + e.toString());
conformance = new ca.uhn.fhir.model.dev.resource.Conformance();
conformance = new ca.uhn.fhir.model.dstu2.resource.Conformance();
}
theModel.put("jsonEncodedConf", getContext(theRequest).newJsonParser().encodeResourceToString(conformance));
Map<String, Number> resourceCounts = new HashMap<String, Number>();
long total = 0;
for (ca.uhn.fhir.model.dev.resource.Conformance.Rest nextRest : conformance.getRest()) {
for (ca.uhn.fhir.model.dev.resource.Conformance.RestResource nextResource : nextRest.getResource()) {
for (ca.uhn.fhir.model.dstu2.resource.Conformance.Rest nextRest : conformance.getRest()) {
for (ca.uhn.fhir.model.dstu2.resource.Conformance.RestResource nextResource : nextRest.getResource()) {
List<ExtensionDt> exts = nextResource.getUndeclaredExtensionsByUrl(RESOURCE_COUNT_EXT_URL);
if (exts != null && exts.size() > 0) {
Number nextCount = ((DecimalDt) (exts.get(0).getValue())).getValueAsNumber();
@ -1109,10 +1109,10 @@ public class Controller {
theModel.put("resourceCounts", resourceCounts);
if (total > 0) {
for (ca.uhn.fhir.model.dev.resource.Conformance.Rest nextRest : conformance.getRest()) {
Collections.sort(nextRest.getResource(), new Comparator<ca.uhn.fhir.model.dev.resource.Conformance.RestResource>() {
for (ca.uhn.fhir.model.dstu2.resource.Conformance.Rest nextRest : conformance.getRest()) {
Collections.sort(nextRest.getResource(), new Comparator<ca.uhn.fhir.model.dstu2.resource.Conformance.RestResource>() {
@Override
public int compare(ca.uhn.fhir.model.dev.resource.Conformance.RestResource theO1, ca.uhn.fhir.model.dev.resource.Conformance.RestResource theO2) {
public int compare(ca.uhn.fhir.model.dstu2.resource.Conformance.RestResource theO1, ca.uhn.fhir.model.dstu2.resource.Conformance.RestResource theO2) {
DecimalDt count1 = new DecimalDt();
List<ExtensionDt> count1exts = theO1.getUndeclaredExtensionsByUrl(RESOURCE_COUNT_EXT_URL);
if (count1exts != null && count1exts.size() > 0) {

View File

@ -11,14 +11,7 @@ import org.eclipse.jetty.webapp.WebAppContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.dao.IFhirSystemDao;
import ca.uhn.fhir.jpa.provider.JpaConformanceProviderDstu1;
import ca.uhn.fhir.jpa.provider.JpaSystemProvider;
import ca.uhn.fhir.jpa.rp.dstu2.DiagnosticReportResourceProvider;
import ca.uhn.fhir.jpa.rp.dstu2.ObservationResourceProvider;
import ca.uhn.fhir.jpa.rp.dstu2.OrganizationResourceProvider;
import ca.uhn.fhir.jpa.rp.dstu2.PatientResourceProvider;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.Include;
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
@ -26,10 +19,8 @@ import ca.uhn.fhir.model.api.TagList;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
import ca.uhn.fhir.model.dstu.resource.DiagnosticReport;
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.dstu.resource.Questionnaire;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.annotation.IncludeParam;
import ca.uhn.fhir.rest.annotation.OptionalParam;

View File

@ -128,6 +128,10 @@
<id>twilson650</id>
<name>Tom Wilson</name>
</developer>
<developer>
<id>esteban-aliverti</id>
<name>Esteban Aliverti</name>
</developer>
</developers>
<licenses>

View File

@ -101,6 +101,11 @@
if StAX API was configured to use a different provider. Thanks to
James Butler for reporting and figuring out where the issue was!
</action>
<action type="fix" issue="101">
Calling BaseDateTimeDt#setValue(Date, TemporalPrecisionEnum) did not always actually respect
the given precision when the value was encoded. Thanks to jacksonjesse for
reporting!
</action>
<action type="fix" issue="103">
Encoders (both XML and JSON) will no longer encode contained resources if they are
not referenced anywhere in the resource via a local reference. This is just a convenience

View File

@ -56,11 +56,18 @@
There are many places in the FHIR specification where a "coded" string is
used. This means that a code must be chosen from a list of allowable values.
</p>
<h4>Closed Valuesets / Codes</h4>
<p>
In these cases, HAPI tries to simplify the process by providing Java Enum
types, which can be used to reduce complexity and provide compile-time
checking.
The FHIR specification defines a number of "closed" ValueSets, such as
the one used for
<!-- TODO: replace the link below with a non GitHub link once DSTU2 is balloted -->
<a href="http://hl7-fhir.github.io/administrative-gender.html">Patient.gender</a>
(<i>note that this field was not a closed ValueSet in DSTU1 but is as of DSTU2</i>).
These valuesets must either be empty, or be populated with a value drawn from
the list of allowable values defined by FHIR. HAPI provides special typesafe
Enums to help in dealing with these fields.
</p>
<macro name="snippet">
@ -68,6 +75,42 @@
<param name="file" value="examples/src/main/java/example/FhirDataModel.java" />
</macro>
<h4>Open Valusets / CodeableConcepts</h4>
<p>
The FHIR specification also defines a number of "open" ValueSets, such as
the one used for
<a href="http://hl7.org/implement/standards/fhir/valueset-marital-status.html">Patient.maritalStatus</a>.
These fields may define a set of allowable codes, but also allow you to
use your own codes instead if none of the given codes matches your needs. This
is called an <a href="http://hl7.org/implement/standards/fhir/terminologies.html#incomplete">incomplete binding</a>.
Some fields may even define a set of codes that serve as nothing more than
an example as to the type of codes that would be used there. This is known as
an <a href="http://hl7.org/implement/standards/fhir/terminologies.html#example">example binding</a>.
</p>
<p>
For these fields, a CodeableConcept datatype is generally used by the
FHIR specification. This datatype allows multiple "codings", which
are a code and codesystem pair, optionally with a display name as well.
The following example shows how to interact with this type.
</p>
<macro name="snippet">
<param name="id" value="codeableConcepts" />
<param name="file" value="examples/src/main/java/example/FhirDataModel.java" />
</macro>
<p>
HAPI also provides typesafe enums to help in working with CodeableConcept
fields.
</p>
<macro name="snippet">
<param name="id" value="codeableConceptEnums" />
<param name="file" value="examples/src/main/java/example/FhirDataModel.java" />
</macro>
</subsection>
<subsection name="Convenience Methods">