diff --git a/examples/src/main/java/example/ExtensionsDstu2.java b/examples/src/main/java/example/ExtensionsDstu2.java index 2cb26bcfbd8..fe0a272ce5f 100644 --- a/examples/src/main/java/example/ExtensionsDstu2.java +++ b/examples/src/main/java/example/ExtensionsDstu2.java @@ -7,7 +7,10 @@ import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.model.api.ExtensionDt; import ca.uhn.fhir.model.dstu2.composite.HumanNameDt; import ca.uhn.fhir.model.dstu2.resource.Patient; +import ca.uhn.fhir.model.dstu2.resource.Questionnaire; +import ca.uhn.fhir.model.dstu2.resource.Questionnaire.GroupQuestion; import ca.uhn.fhir.model.dstu2.valueset.IdentifierUseEnum; +import ca.uhn.fhir.model.primitive.CodeDt; import ca.uhn.fhir.model.primitive.DateTimeDt; import ca.uhn.fhir.model.primitive.StringDt; import ca.uhn.fhir.parser.DataFormatException; @@ -17,7 +20,21 @@ public class ExtensionsDstu2 { @SuppressWarnings("unused") public static void main(String[] args) throws DataFormatException, IOException { - + { + Questionnaire q= new Questionnaire(); + GroupQuestion item = q.getGroup().addQuestion(); + item.setText("Hello"); + + ExtensionDt extension = new ExtensionDt(false, "http://hl7.org/fhir/StructureDefinition/translation"); + item.getTextElement().addUndeclaredExtension(extension); + + extension.addUndeclaredExtension(new ExtensionDt(false, "lang", new CodeDt("es"))); + extension.addUndeclaredExtension(new ExtensionDt(false, "cont", new StringDt("hola"))); + + System.out.println(FhirContext.forDstu2().newJsonParser().setPrettyPrint(true).encodeResourceToString(q)); + } + + // START SNIPPET: resourceExtension // Create an example patient Patient patient = new Patient(); diff --git a/examples/src/main/java/example/RestfulPatientResourceProviderMore.java b/examples/src/main/java/example/RestfulPatientResourceProviderMore.java index 6121b06febf..5805a294a25 100644 --- a/examples/src/main/java/example/RestfulPatientResourceProviderMore.java +++ b/examples/src/main/java/example/RestfulPatientResourceProviderMore.java @@ -617,7 +617,7 @@ public List getDiagnosticReport( @RequiredParam(name=DiagnosticReport.SP_IDENTIFIER) TokenParam theIdentifier, - @IncludeParam(allow= {"DiagnosticReport.subject"}) + @IncludeParam(allow= {"DiagnosticReport:subject"}) Set theIncludes ) { List retVal = new ArrayList(); @@ -626,7 +626,7 @@ public List getDiagnosticReport( DiagnosticReport report = loadSomeDiagnosticReportFromDatabase(theIdentifier); // If the client has asked for the subject to be included: - if (theIncludes.contains(new Include("DiagnosticReport.subject"))) { + if (theIncludes.contains(new Include("DiagnosticReport:subject"))) { // The resource reference should contain the ID of the patient IdDt subjectId = report.getSubject().getReference(); @@ -665,7 +665,7 @@ public List getDiagnosticReport( @RequiredParam(name=DiagnosticReport.SP_IDENTIFIER) TokenParam theIdentifier, - @IncludeParam(allow= {"DiagnosticReport.subject"}) + @IncludeParam(allow= {"DiagnosticReport:subject"}) String theInclude ) { List retVal = new ArrayList(); @@ -674,7 +674,7 @@ public List getDiagnosticReport( DiagnosticReport report = loadSomeDiagnosticReportFromDatabase(theIdentifier); // If the client has asked for the subject to be included: - if ("DiagnosticReport.subject".equals(theInclude)) { + if ("DiagnosticReport:subject".equals(theInclude)) { // The resource reference should contain the ID of the patient IdDt subjectId = report.getSubject().getReference(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java index 4121f9be2e9..47023bd1946 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java @@ -49,17 +49,15 @@ import org.junit.AfterClass; import org.junit.Ignore; import org.junit.Test; +import ca.uhn.fhir.model.api.*; import ca.uhn.fhir.model.api.Bundle; -import ca.uhn.fhir.model.api.BundleEntry; -import ca.uhn.fhir.model.api.IResource; -import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum; -import ca.uhn.fhir.model.api.TemporalPrecisionEnum; import ca.uhn.fhir.model.dstu2.composite.CodingDt; import ca.uhn.fhir.model.dstu2.composite.MetaDt; import ca.uhn.fhir.model.dstu2.composite.PeriodDt; import ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt; import ca.uhn.fhir.model.dstu2.resource.*; import ca.uhn.fhir.model.dstu2.resource.Bundle.Entry; +import ca.uhn.fhir.model.dstu2.resource.Questionnaire.GroupQuestion; import ca.uhn.fhir.model.dstu2.valueset.AnswerFormatEnum; import ca.uhn.fhir.model.dstu2.valueset.EncounterClassEnum; import ca.uhn.fhir.model.dstu2.valueset.EncounterStateEnum; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderQuestionnaireResponseDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderQuestionnaireResponseDstu3Test.java index 0e7b3a0ac04..9d29126d2f6 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderQuestionnaireResponseDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderQuestionnaireResponseDstu3Test.java @@ -16,6 +16,7 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.hl7.fhir.dstu3.model.*; +import org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemComponent; import org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType; import org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseStatus; import org.hl7.fhir.instance.model.api.IIdType; @@ -58,6 +59,7 @@ public class ResourceProviderQuestionnaireResponseDstu3Test extends BaseResource } ourRestServer.registerInterceptor(ourValidatingInterceptor); } + }