diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ExtensionDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ExtensionDt.java index f33340a6905..0899a296e6f 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ExtensionDt.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ExtensionDt.java @@ -1,6 +1,6 @@ package ca.uhn.fhir.model.api; -import org.thymeleaf.util.Validate; +import org.apache.commons.lang3.Validate; import ca.uhn.fhir.model.api.annotation.Child; import ca.uhn.fhir.model.api.annotation.DatatypeDef; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/ResourceReferenceDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/ResourceReferenceDt.java index 3b9c7b83e2c..c555d1537c3 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/ResourceReferenceDt.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/ResourceReferenceDt.java @@ -120,6 +120,7 @@ public class ResourceReferenceDt * A reference to a location at which the other resource is found. The reference may a relative reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#') refer to contained resources *
*/ + @Override public StringDt getReference() { if (myReference == null) { myReference = new StringDt(); diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/AdverseReaction.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/AdverseReaction.java index c49e6cf4f20..0cbbaeca412 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/AdverseReaction.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/AdverseReaction.java @@ -56,6 +56,12 @@ import ca.uhn.fhir.model.primitive.DateTimeDt; * Requirements: * Used to track reactions when it is unknown the exact cause but there's a desire to flag/track potential causes. Also used to capture reactions that are significant for inclusion in the health record or as evidence for an allergy or intolerance. * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/AdverseReaction + *
+ * */ @ResourceDef(name="AdverseReaction", profile="http://hl7.org/fhir/profiles/AdverseReaction", id="adversereaction") public class AdverseReaction extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Alert.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Alert.java index b0d05cebd91..9466748f063 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Alert.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Alert.java @@ -48,6 +48,12 @@ import ca.uhn.fhir.model.primitive.StringDt; * Requirements: * * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/Alert + *
+ * */ @ResourceDef(name="Alert", profile="http://hl7.org/fhir/profiles/Alert", id="alert") public class Alert extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Conformance.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Conformance.java index c6929b3d8bd..91fa3943a53 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Conformance.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Conformance.java @@ -69,6 +69,12 @@ import ca.uhn.fhir.model.primitive.UriDt; * Requirements: * * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/Conformance + *
+ * */ @ResourceDef(name="Conformance", profile="http://hl7.org/fhir/profiles/Conformance", id="conformance") public class Conformance extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Device.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Device.java index 6a228a410f0..90f1a82573e 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Device.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Device.java @@ -50,6 +50,12 @@ import ca.uhn.fhir.model.primitive.UriDt; * Requirements: * Allows institutions to track their devices. * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/Device + *
+ * */ @ResourceDef(name="Device", profile="http://hl7.org/fhir/profiles/Device", id="device") public class Device extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/DiagnosticOrder.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/DiagnosticOrder.java index c1ebe512972..fcef04603fc 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/DiagnosticOrder.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/DiagnosticOrder.java @@ -55,6 +55,12 @@ import ca.uhn.fhir.model.primitive.StringDt; * Requirements: * * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/DiagnosticOrder + *
+ * */ @ResourceDef(name="DiagnosticOrder", profile="http://hl7.org/fhir/profiles/DiagnosticOrder", id="diagnosticorder") public class DiagnosticOrder extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/DiagnosticReport.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/DiagnosticReport.java index f153b988c7f..65aff370ea7 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/DiagnosticReport.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/DiagnosticReport.java @@ -57,6 +57,12 @@ import ca.uhn.fhir.model.primitive.StringDt; * Requirements: * To support reporting for any diagnostic report into a clinical data repository. * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/DiagnosticReport + *
+ * */ @ResourceDef(name="DiagnosticReport", profile="http://hl7.org/fhir/profiles/DiagnosticReport", id="diagnosticreport") public class DiagnosticReport extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Encounter.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Encounter.java index 2bff69d41bc..d08608d0c23 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Encounter.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Encounter.java @@ -59,6 +59,12 @@ import ca.uhn.fhir.model.primitive.CodeDt; * Requirements: * * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/Encounter + *
+ * */ @ResourceDef(name="Encounter", profile="http://hl7.org/fhir/profiles/Encounter", id="encounter") public class Encounter extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Group.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Group.java index 47aba66bba1..83ff009fa1c 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Group.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Group.java @@ -56,6 +56,12 @@ import ca.uhn.fhir.model.primitive.StringDt; * Requirements: * * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/Group + *
+ * */ @ResourceDef(name="Group", profile="http://hl7.org/fhir/profiles/Group", id="group") public class Group extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/ImagingStudy.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/ImagingStudy.java index 32fb139d8d7..b4d9d1927cc 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/ImagingStudy.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/ImagingStudy.java @@ -59,6 +59,12 @@ import ca.uhn.fhir.model.primitive.UriDt; * Requirements: * * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/ImagingStudy + *
+ * */ @ResourceDef(name="ImagingStudy", profile="http://hl7.org/fhir/profiles/ImagingStudy", id="imagingstudy") public class ImagingStudy extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Location.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Location.java index 35e5cf888a8..005ef9bef80 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Location.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Location.java @@ -57,6 +57,12 @@ import ca.uhn.fhir.model.primitive.StringDt; * Requirements: * * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/Location + *
+ * */ @ResourceDef(name="Location", profile="http://hl7.org/fhir/profiles/Location", id="location") public class Location extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Media.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Media.java index e643e588c0b..bb06730710d 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Media.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Media.java @@ -53,6 +53,12 @@ import ca.uhn.fhir.model.primitive.StringDt; * Requirements: * * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/Media + *
+ * */ @ResourceDef(name="Media", profile="http://hl7.org/fhir/profiles/Media", id="media") public class Media extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Medication.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Medication.java index f31a05d0edc..644a3caf550 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Medication.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Medication.java @@ -51,6 +51,12 @@ import ca.uhn.fhir.model.primitive.StringDt; * Requirements: * * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/Medication + *
+ * */ @ResourceDef(name="Medication", profile="http://hl7.org/fhir/profiles/Medication", id="medication") public class Medication extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Observation.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Observation.java index 1ec5d2581e1..87be1f7656e 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Observation.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Observation.java @@ -67,6 +67,12 @@ import ca.uhn.fhir.model.primitive.StringDt; * Requirements: * Observations are a key aspect of healthcare. This resource is used to capture those that do not require more sophisticated mechanisms. * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/Observation + *
+ * */ @ResourceDef(name="Observation", profile="http://hl7.org/fhir/profiles/Observation", id="observation") public class Observation extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/OperationOutcome.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/OperationOutcome.java index c34e12ce48a..d157b03b821 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/OperationOutcome.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/OperationOutcome.java @@ -48,6 +48,12 @@ import ca.uhn.fhir.model.primitive.StringDt; * Requirements: * * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/OperationOutcome + *
+ * */ @ResourceDef(name="OperationOutcome", profile="http://hl7.org/fhir/profiles/OperationOutcome", id="operationoutcome") public class OperationOutcome extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Organization.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Organization.java index 8fc8f7dfd71..3b6c82c59e5 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Organization.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Organization.java @@ -55,6 +55,12 @@ import ca.uhn.fhir.model.primitive.StringDt; * Requirements: * * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/Organization + *
+ * */ @ResourceDef(name="Organization", profile="http://hl7.org/fhir/profiles/Organization", id="organization") public class Organization extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Patient.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Patient.java index 057f9fd05da..7eb4b86be78 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Patient.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Patient.java @@ -64,6 +64,12 @@ import ca.uhn.fhir.model.primitive.IntegerDt; * Requirements: * Tracking patient is the center of the healthcare process * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/Patient + *
+ * */ @ResourceDef(name="Patient", profile="http://hl7.org/fhir/profiles/Patient", id="patient") public class Patient extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Practitioner.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Practitioner.java index dbf3c9d5a1f..2cfef555766 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Practitioner.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Practitioner.java @@ -59,6 +59,12 @@ import ca.uhn.fhir.model.primitive.DateTimeDt; * Requirements: * Need to track doctors, staff, locums etc. for both healthcare practitioners, funders, etc. * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/Practitioner + *
+ * */ @ResourceDef(name="Practitioner", profile="http://hl7.org/fhir/profiles/Practitioner", id="practitioner") public class Practitioner extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Profile.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Profile.java index b4fdd0fb33b..94565db32af 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Profile.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Profile.java @@ -67,6 +67,12 @@ import ca.uhn.fhir.model.primitive.UriDt; * Requirements: * * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/Profile + *
+ * */ @ResourceDef(name="Profile", profile="http://hl7.org/fhir/profiles/Profile", id="profile") public class Profile extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Query.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Query.java index e5f3885fc3d..0429fb8e894 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Query.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Query.java @@ -50,6 +50,12 @@ import ca.uhn.fhir.model.primitive.UriDt; * Requirements: * * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/Query + *
+ * */ @ResourceDef(name="Query", profile="http://hl7.org/fhir/profiles/Query", id="query") public class Query extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Questionnaire.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Questionnaire.java index 5aeb8a832e6..91438039570 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Questionnaire.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Questionnaire.java @@ -64,6 +64,12 @@ import ca.uhn.fhir.model.primitive.StringDt; * Requirements: * To support structured, hierarchical registration of data gathered using digital forms and other questionnaires. * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/Questionnaire + *
+ * */ @ResourceDef(name="Questionnaire", profile="http://hl7.org/fhir/profiles/Questionnaire", id="questionnaire") public class Questionnaire extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/RelatedPerson.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/RelatedPerson.java index 4a7dba81c3a..2e135a7b268 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/RelatedPerson.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/RelatedPerson.java @@ -51,6 +51,12 @@ import ca.uhn.fhir.model.primitive.BoundCodeableConceptDt; * Requirements: * Need to track persons related to the patient or the healthcare process. * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/RelatedPerson + *
+ * */ @ResourceDef(name="RelatedPerson", profile="http://hl7.org/fhir/profiles/RelatedPerson", id="relatedperson") public class RelatedPerson extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Specimen.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Specimen.java index 1857ff88abf..6c5a7185b9d 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Specimen.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Specimen.java @@ -61,6 +61,12 @@ import ca.uhn.fhir.model.primitive.StringDt; * Requirements: * * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/Specimen + *
+ * */ @ResourceDef(name="Specimen", profile="http://hl7.org/fhir/profiles/Specimen", id="specimen") public class Specimen extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Substance.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Substance.java index 44a43479f56..eb45d51475e 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Substance.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Substance.java @@ -56,6 +56,12 @@ import ca.uhn.fhir.model.primitive.StringDt; * Requirements: * * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/Substance + *
+ * */ @ResourceDef(name="Substance", profile="http://hl7.org/fhir/profiles/Substance", id="substance") public class Substance extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/ValueSet.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/ValueSet.java index c1194bde529..d32bd9b392a 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/ValueSet.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/ValueSet.java @@ -57,6 +57,12 @@ import ca.uhn.fhir.model.primitive.UriDt; * Requirements: * * + * + *+ * Profile Definition: + * http://hl7.org/fhir/profiles/ValueSet + *
+ * */ @ResourceDef(name="ValueSet", profile="http://hl7.org/fhir/profiles/ValueSet", id="valueset") public class ValueSet extends BaseResource implements IResource { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BoundCodeableConceptDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BoundCodeableConceptDt.java index c3c51aa7f01..4e502533b1e 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BoundCodeableConceptDt.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BoundCodeableConceptDt.java @@ -2,6 +2,7 @@ package ca.uhn.fhir.model.primitive; import static org.apache.commons.lang3.StringUtils.*; +import java.util.Collection; import java.util.HashSet; import java.util.Set; @@ -19,12 +20,17 @@ public class BoundCodeableConceptDttrue
(which is the default), most whitespace will
+ * be trimmed from the generated narrative before it is returned.
+ * + * Note that in order to preserve formatting, not all whitespace is trimmed. + * Repeated whitespace characters (e.g. "\n \n ") will be + * trimmed to a single space. + *
+ */ + public boolean isCleanWhitespace() { + return myCleanWhitespace; + } + + /** + * If set totrue
, which is the default, if any failure occurs
+ * during narrative generation the generator will suppress any generated
+ * exceptions, and simply return a default narrative indicating that no
+ * narrative is available.
+ */
+ public boolean isIgnoreFailures() {
+ return myIgnoreFailures;
+ }
+
+ /**
+ * If set to true, will return an empty narrative block for any profiles
+ * where no template is available
+ */
+ public boolean isIgnoreMissingTemplates() {
+ return myIgnoreMissingTemplates;
+ }
+
+ /**
+ * If set to true
(which is the default), most whitespace will
+ * be trimmed from the generated narrative before it is returned.
+ * + * Note that in order to preserve formatting, not all whitespace is trimmed. + * Repeated whitespace characters (e.g. "\n \n ") will be + * trimmed to a single space. + *
+ */ + public void setCleanWhitespace(boolean theCleanWhitespace) { + myCleanWhitespace = theCleanWhitespace; + } + + /** + * If set totrue
, which is the default, if any failure occurs
+ * during narrative generation the generator will suppress any generated
+ * exceptions, and simply return a default narrative indicating that no
+ * narrative is available.
+ */
+ public void setIgnoreFailures(boolean theIgnoreFailures) {
+ myIgnoreFailures = theIgnoreFailures;
+ }
+
+ /**
+ * If set to true, will return an empty narrative block for any profiles
+ * where no template is available
+ */
+ public void setIgnoreMissingTemplates(boolean theIgnoreMissingTemplates) {
+ myIgnoreMissingTemplates = theIgnoreMissingTemplates;
+ }
+
+ private void loadProperties(String propFileName) throws IOException {
+ Properties file = new Properties();
+
+ InputStream resource = loadResource(propFileName);
+ file.load(resource);
+ for (Object nextKeyObj : file.keySet()) {
+ String nextKey = (String) nextKeyObj;
+ if (nextKey.endsWith(".profile")) {
+ String name = nextKey.substring(0, nextKey.indexOf(".profile"));
+ if (isBlank(name)) {
+ continue;
+ }
+
+ String narrativeName = file.getProperty(name + ".narrative");
+ if (isBlank(narrativeName)) {
+ continue;
+ }
+
+ String narrative = IOUtils.toString(loadResource(narrativeName));
+ myProfileToNarrativeTemplate.put(file.getProperty(nextKey), narrative);
+ } else if (nextKey.endsWith(".dtclass")) {
+ String name = nextKey.substring(0, nextKey.indexOf(".dtclass"));
+ if (isBlank(name)) {
+ continue;
+ }
+
+ String className = file.getProperty(nextKey);
+
+ Class> dtClass;
+ try {
+ dtClass = Class.forName(className);
+ } catch (ClassNotFoundException e) {
+ ourLog.warn("Unknown datatype class '{}' identified in narrative file {}", name, propFileName);
+ continue;
+ }
+
+ String narrativeName = file.getProperty(name + ".dtnarrative");
+ if (isBlank(narrativeName)) {
+ continue;
+ }
+
+ String narrative = IOUtils.toString(loadResource(narrativeName));
+ myDatatypeClassNameToNarrativeTemplate.put(dtClass.getCanonicalName(), narrative);
+ }
+
+ }
+ }
+
+ private InputStream loadResource(String name) throws IOException {
+ if (name.startsWith("classpath:")) {
+ String cpName = name.substring("classpath:".length());
+ InputStream resource = DefaultThymeleafNarrativeGenerator.class.getResourceAsStream(cpName);
+ if (resource == null) {
+ resource = DefaultThymeleafNarrativeGenerator.class.getResourceAsStream("/" + cpName);
+ if (resource == null) {
+ throw new ConfigurationException("Can not find '" + cpName + "' on classpath");
+ }
+ }
+ return resource;
+ } else if (name.startsWith("file:")) {
+ File file = new File(name.substring("file:".length()));
+ if (file.exists() == false) {
+ throw new IOException("Can not read file: " + file.getAbsolutePath());
+ }
+ return new FileInputStream(file);
+ } else {
+ throw new IllegalArgumentException("Invalid resource name: '" + name + "'");
+ }
+ }
+
+ static String cleanWhitespace(String theResult) {
+ StringBuilder b = new StringBuilder();
+ boolean inWhitespace = false;
+ boolean betweenTags = false;
+ boolean lastNonWhitespaceCharWasTagEnd = false;
+ for (int i = 0; i < theResult.length(); i++) {
+ char nextChar = theResult.charAt(i);
+ if (nextChar == '>') {
+ b.append(nextChar);
+ betweenTags = true;
+ lastNonWhitespaceCharWasTagEnd = true;
+ continue;
+ } else if (nextChar == '\n' || nextChar == '\r') {
+ // if (inWhitespace) {
+ // b.append(' ');
+ // inWhitespace = false;
+ // }
+ continue;
+ }
+
+ if (betweenTags) {
+ if (Character.isWhitespace(nextChar)) {
+ inWhitespace = true;
+ } else if (nextChar == '<') {
+ if (inWhitespace && !lastNonWhitespaceCharWasTagEnd) {
+ b.append(' ');
+ }
+ inWhitespace = false;
+ b.append(nextChar);
+ inWhitespace = false;
+ betweenTags = false;
+ lastNonWhitespaceCharWasTagEnd = false;
+ } else {
+ lastNonWhitespaceCharWasTagEnd = false;
+ if (inWhitespace) {
+ b.append(' ');
+ inWhitespace = false;
+ }
+ b.append(nextChar);
+ }
+ } else {
+ b.append(nextChar);
+ }
+ }
+ return b.toString();
+ }
+
+ public class MyProcessor extends AbstractAttrProcessor {
+
+ protected MyProcessor() {
+ super("narrative");
+ }
+
+ @Override
+ public int getPrecedence() {
+ return 0;
+ }
+
+ @Override
+ protected ProcessorResult processAttribute(Arguments theArguments, Element theElement, String theAttributeName) {
+ final String attributeValue = theElement.getAttributeValue(theAttributeName);
+
+ final Configuration configuration = theArguments.getConfiguration();
+ final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(configuration);
+
+ final IStandardExpression expression = expressionParser.parseExpression(configuration, theArguments, attributeValue);
+ final Object value = expression.execute(configuration, theArguments);
+
+ Context context = new Context();
+ context.setVariable("resource", value);
+
+ String result = myDatatypeTemplateEngine.process(value.getClass().getCanonicalName(), context);
+ Document dom = DOMUtils.getXhtmlDOMFor(new StringReader(result));
+
+ theElement.removeAttribute(theAttributeName);
+ theElement.clearChildren();
+
+ Element firstChild = (Element) dom.getFirstChild();
+ for (Node next : firstChild.getChildren()) {
+ theElement.addChild(next);
+ }
+
+ return ProcessorResult.ok();
+ }
+
+ }
+
+ private final class DatatypeResourceResolver implements IResourceResolver {
+ @Override
+ public String getName() {
+ return getClass().getCanonicalName();
+ }
+
+ @Override
+ public InputStream getResourceAsStream(TemplateProcessingParameters theTemplateProcessingParameters, String theClassName) {
+ String template = myDatatypeClassNameToNarrativeTemplate.get(theClassName);
+ if (template == null) {
+ throw new NullPointerException("No narrative template exists for datatype: " + theClassName);
+ }
+ return new ReaderInputStream(new StringReader(template));
+ }
+ }
+
+ // public String generateString(Patient theValue) {
+ //
+ // Context context = new Context();
+ // context.setVariable("resource", theValue);
+ // String result =
+ // myProfileTemplateEngine.process("ca/uhn/fhir/narrative/Patient.html",
+ // context);
+ //
+ // ourLog.info("Result: {}", result);
+ //
+ // return result;
+ // }
+
+ private final class ProfileResourceResolver implements IResourceResolver {
+ @Override
+ public String getName() {
+ return getClass().getCanonicalName();
+ }
+
+ @Override
+ public InputStream getResourceAsStream(TemplateProcessingParameters theTemplateProcessingParameters, String theResourceName) {
+ String template = myProfileToNarrativeTemplate.get(theResourceName);
+ if (template == null) {
+ ourLog.info("No narative template for resource profile: {}", theResourceName);
+ return new ReaderInputStream(new StringReader(""));
+ }
+ return new ReaderInputStream(new StringReader(template));
+ }
+ }
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/narrative/CustomThymeleafNarrativeGenerator.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/narrative/CustomThymeleafNarrativeGenerator.java
new file mode 100644
index 00000000000..ee184a9f5ea
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/narrative/CustomThymeleafNarrativeGenerator.java
@@ -0,0 +1,24 @@
+package ca.uhn.fhir.narrative;
+
+import java.io.IOException;
+
+public class CustomThymeleafNarrativeGenerator extends BaseThymeleafNarrativeGenerator {
+
+ /**
+ * Create a new narrative generator
+ *
+ * @param thePropertyFile
+ * The name of the property file, in one of the following
+ * formats:
+ * true
(which is the default), most whitespace will be trimmed from the generated narrative before it is returned.
- * - * Note that in order to preserve formatting, not all whitespace is trimmed. Repeated whitespace characters (e.g. "\n \n ") will be trimmed to a single space. - *
- */ - public boolean isCleanWhitespace() { - return myCleanWhitespace; - } - - public void setCleanWhitespace(boolean theCleanWhitespace) { - myCleanWhitespace = theCleanWhitespace; - } - public DefaultThymeleafNarrativeGenerator() throws IOException { - myProfileToNarrativeTemplate = new HashMaptrue
, which is the default, if any failure occurs during narrative generation the generator will suppress any generated exceptions, and simply return a default narrative
- * indicating that no narrative is available.
- */
- public boolean isIgnoreFailures() {
- return myIgnoreFailures;
- }
-
- /**
- * If set to true, will return an empty narrative block for any profiles where no template is available
- */
- public boolean isIgnoreMissingTemplates() {
- return myIgnoreMissingTemplates;
- }
-
- private void loadProperties(String propFileName) throws IOException {
- Properties file = new Properties();
-
- InputStream resource = loadResource(propFileName);
- file.load(resource);
- for (Object nextKeyObj : file.keySet()) {
- String nextKey = (String) nextKeyObj;
- if (nextKey.endsWith(".profile")) {
- String name = nextKey.substring(0, nextKey.indexOf(".profile"));
- if (isBlank(name)) {
- continue;
- }
-
- String narrativeName = file.getProperty(name + ".narrative");
- if (isBlank(narrativeName)) {
- continue;
- }
-
- String narrative = IOUtils.toString(loadResource(narrativeName));
- myProfileToNarrativeTemplate.put(file.getProperty(nextKey), narrative);
- } else if (nextKey.endsWith(".dtclass")) {
- String name = nextKey.substring(0, nextKey.indexOf(".dtclass"));
- if (isBlank(name)) {
- continue;
- }
-
- String className = file.getProperty(nextKey);
-
- Class> dtClass;
- try {
- dtClass = Class.forName(className);
- } catch (ClassNotFoundException e) {
- ourLog.warn("Unknown datatype class '{}' identified in narrative file {}", name, propFileName);
- continue;
- }
-
- String narrativeName = file.getProperty(name + ".dtnarrative");
- if (isBlank(narrativeName)) {
- continue;
- }
-
- String narrative = IOUtils.toString(loadResource(narrativeName));
- myDatatypeClassNameToNarrativeTemplate.put(dtClass.getCanonicalName(), narrative);
- }
-
- }
- }
-
- private InputStream loadResource(String name) {
- if (name.startsWith("classpath:")) {
- String cpName = name.substring("classpath:".length());
- InputStream resource = DefaultThymeleafNarrativeGenerator.class.getResourceAsStream(cpName);
- if (resource == null) {
- resource = DefaultThymeleafNarrativeGenerator.class.getResourceAsStream("/" + cpName);
- if (resource == null) {
- throw new ConfigurationException("Can not find '" + cpName + "' on classpath");
- }
- }
- return resource;
- } else {
- throw new IllegalArgumentException("Invalid resource name: '" + name + "'");
- }
- }
-
- /**
- * If set to true
, which is the default, if any failure occurs during narrative generation the generator will suppress any generated exceptions, and simply return a default narrative
- * indicating that no narrative is available.
- */
- public void setIgnoreFailures(boolean theIgnoreFailures) {
- myIgnoreFailures = theIgnoreFailures;
- }
-
- // public String generateString(Patient theValue) {
- //
- // Context context = new Context();
- // context.setVariable("resource", theValue);
- // String result = myProfileTemplateEngine.process("ca/uhn/fhir/narrative/Patient.html", context);
- //
- // ourLog.info("Result: {}", result);
- //
- // return result;
- // }
-
- /**
- * If set to true, will return an empty narrative block for any profiles where no template is available
- */
- public void setIgnoreMissingTemplates(boolean theIgnoreMissingTemplates) {
- myIgnoreMissingTemplates = theIgnoreMissingTemplates;
- }
-
- private final class DatatypeResourceResolver implements IResourceResolver {
- @Override
- public String getName() {
- return getClass().getCanonicalName();
- }
-
- @Override
- public InputStream getResourceAsStream(TemplateProcessingParameters theTemplateProcessingParameters, String theClassName) {
- String template = myDatatypeClassNameToNarrativeTemplate.get(theClassName);
- if (template == null) {
- throw new NullPointerException("No narrative template exists for datatype: " + theClassName);
- }
- return new ReaderInputStream(new StringReader(template));
- }
- }
-
- public class MyProcessor extends AbstractAttrProcessor {
-
- protected MyProcessor() {
- super("narrative");
- }
-
- @Override
- public int getPrecedence() {
- return 0;
- }
-
- @Override
- protected ProcessorResult processAttribute(Arguments theArguments, Element theElement, String theAttributeName) {
- final String attributeValue = theElement.getAttributeValue(theAttributeName);
-
- final Configuration configuration = theArguments.getConfiguration();
- final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(configuration);
-
- final IStandardExpression expression = expressionParser.parseExpression(configuration, theArguments, attributeValue);
- final Object value = expression.execute(configuration, theArguments);
-
- Context context = new Context();
- context.setVariable("resource", value);
-
- String result = myDatatypeTemplateEngine.process(value.getClass().getCanonicalName(), context);
- Document dom = DOMUtils.getXhtmlDOMFor(new StringReader(result));
-
- theElement.removeAttribute(theAttributeName);
- theElement.clearChildren();
-
- Element firstChild = (Element) dom.getFirstChild();
- for (Node next : firstChild.getChildren()) {
- theElement.addChild(next);
- }
-
- return ProcessorResult.ok();
- }
-
- }
-
- private final class ProfileResourceResolver implements IResourceResolver {
- @Override
- public String getName() {
- return getClass().getCanonicalName();
- }
-
- @Override
- public InputStream getResourceAsStream(TemplateProcessingParameters theTemplateProcessingParameters, String theResourceName) {
- String template = myProfileToNarrativeTemplate.get(theResourceName);
- if (template == null) {
- ourLog.info("No narative template for resource profile: {}", theResourceName);
- return new ReaderInputStream(new StringReader(""));
- }
- return new ReaderInputStream(new StringReader(template));
- }
- }
-
}
diff --git a/hapi-fhir-base/src/main/resources/ca/uhn/fhir/narrative/AddressDt.html b/hapi-fhir-base/src/main/resources/ca/uhn/fhir/narrative/AddressDt.html
new file mode 100644
index 00000000000..6f8d62dc38f
--- /dev/null
+++ b/hapi-fhir-base/src/main/resources/ca/uhn/fhir/narrative/AddressDt.html
@@ -0,0 +1,8 @@
+Identifier | -8708660 | +8708660 |
Address | -
- - |
+ |
Date of birth | -- 22 March 2012 - | +22 March 2012 |