diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java index 919176e94..fec3210b4 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java @@ -110,6 +110,7 @@ import org.hl7.fhir.r5.model.Bundle.HTTPVerb; import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent; import org.hl7.fhir.r5.model.ValueSet.ValueSetComposeComponent; import org.hl7.fhir.r5.profilemodel.ProfiledElement; +import org.hl7.fhir.r5.profilemodel.ProfiledElementBuilder; import org.hl7.fhir.r5.renderers.OperationOutcomeRenderer; import org.hl7.fhir.r5.terminologies.CodeSystemUtilities; import org.hl7.fhir.r5.terminologies.TerminologyClient; @@ -2394,4 +2395,11 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte this.packageTracker = packageTracker; return this; } + + + @Override + public ProfiledElementBuilder getProfiledElementBuilder() { + // TODO Auto-generated method stub + return new ProfiledElementBuilder(this); + } } \ No newline at end of file diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java index 40338f6f6..57d8c2571 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java @@ -66,6 +66,7 @@ import org.hl7.fhir.r5.model.StructureMap; import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent; import org.hl7.fhir.r5.profilemodel.ProfiledElement; +import org.hl7.fhir.r5.profilemodel.ProfiledElementBuilder; import org.hl7.fhir.r5.terminologies.ValueSetExpander.TerminologyServiceErrorClass; import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome; import org.hl7.fhir.r5.utils.validation.IResourceValidator; @@ -802,84 +803,6 @@ public interface IWorkerContext { public String getSpecUrl(); - /** - * Given a profile, return a tree of elements in the profile model. This builds the profile model - * for the latest version of the nominated profile - * - * THe tree of elements in the profile model is different to the the base resource: - * - some elements are removed (max = 0) - * - extensions are turned into named elements - * - slices are turned into named elements - * - element properties - doco, cardinality, binding etc is updated for what the profile says - * - * When built with this method, the profile element can't have instance data - * - * Warning: profiles and resources can be recursive; you can't iterate this tree until it you get - * to the leaves because you will never get to a child that doesn't have children - * - */ - public ProfiledElement buildProfileElement(String url); - - /** - * Given a profile, return a tree of elements in the profile model. This builds the profile model - * for the nominated version of the nominated profile - * - * THe tree of elements in the profile model is different to the the base resource: - * - some elements are removed (max = 0) - * - extensions are turned into named elements - * - slices are turned into named elements - * - element properties - doco, cardinality, binding etc is updated for what the profile says - * - * When built with this method, the profile element can't have instance data - * - * Warning: profiles and resources can be recursive; you can't iterate this tree until it you get - * to the leaves because you will never get to a child that doesn't have children - * - */ - public ProfiledElement buildProfileElement(String url, String version); - - /** - * Given a profile, return a tree of elements in the profile model with matching instance data. - * This builds the profile model for the latest version of the nominated profile and matches - * the data in the resource against the profile. Data can be added or read from the profile element - * - * THe tree of elements in the profile model is different to the the base resource: - * - some elements are removed (max = 0) - * - extensions are turned into named elements - * - slices are turned into named elements - * - element properties - doco, cardinality, binding etc is updated for what the profile says - * - * When built with this method, the profile element can't have instance data - * - * Warning: profiles and resources can be recursive; you can't iterate this tree until it you get - * to the leaves because you will never get to a child that doesn't have children - * - */ - public ProfiledElement buildProfileElement(String url, Resource resource); - - /** - * Given a profile, return a tree of elements in the profile model with matching instance data. - * This builds the profile model for the nominated version of the nominated profile and matches - * the data in the resource against the profile. Data can be added or read from the profile element - * - * THe tree of elements in the profile model is different to the the base resource: - * - some elements are removed (max = 0) - * - extensions are turned into named elements - * - slices are turned into named elements - * - element properties - doco, cardinality, binding etc is updated for what the profile says - * - * When built with this method, the profile element can't have instance data - * - */ - public ProfiledElement buildProfileElement(String url, String version, Resource resource); - - /** - * Given a profile, construct an empty resource of the type being profiled (to use as input - * to the buildProfileElement method - * - * No version, because the version doesn't change the type of the resource - */ - public Resource makeProfileBase(String url); - + public ProfiledElementBuilder getProfiledElementBuilder(); } \ No newline at end of file diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java index aec56b3c6..3377d6e70 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java @@ -68,6 +68,7 @@ import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule; import org.hl7.fhir.r5.model.StructureMap.StructureMapModelMode; import org.hl7.fhir.r5.model.StructureMap.StructureMapStructureComponent; import org.hl7.fhir.r5.profilemodel.ProfiledElement; +import org.hl7.fhir.r5.profilemodel.ProfiledElementBuilder; import org.hl7.fhir.r5.terminologies.CodeSystemUtilities; import org.hl7.fhir.r5.terminologies.JurisdictionUtilities; import org.hl7.fhir.r5.terminologies.TerminologyClient; @@ -762,36 +763,5 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon return VersionUtilities.getSpecUrl(getVersion())+"/"; } - @Override - public ProfiledElement buildProfileElement(String url) { - // TODO Auto-generated method stub - return null; - } - - @Override - public ProfiledElement buildProfileElement(String url, String version) { - // TODO Auto-generated method stub - return null; - } - - @Override - public ProfiledElement buildProfileElement(String url, Resource resource) { - // TODO Auto-generated method stub - return null; - } - - @Override - public ProfiledElement buildProfileElement(String url, String version, Resource resource) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Resource makeProfileBase(String url) { - // TODO Auto-generated method stub - return null; - } - - } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/profilemodel/ProfiledElementBuilder.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/profilemodel/ProfiledElementBuilder.java new file mode 100644 index 000000000..38752e9e7 --- /dev/null +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/profilemodel/ProfiledElementBuilder.java @@ -0,0 +1,107 @@ +package org.hl7.fhir.r5.profilemodel; + +import org.hl7.fhir.r5.context.IWorkerContext; +import org.hl7.fhir.r5.model.Resource; + +import kotlin.NotImplementedError; + +public class ProfiledElementBuilder { + + private IWorkerContext context; + + public ProfiledElementBuilder(IWorkerContext context) { + super(); + this.context = context; + } + + + /** + * Given a profile, return a tree of elements in the profile model. This builds the profile model + * for the latest version of the nominated profile + * + * THe tree of elements in the profile model is different to the the base resource: + * - some elements are removed (max = 0) + * - extensions are turned into named elements + * - slices are turned into named elements + * - element properties - doco, cardinality, binding etc is updated for what the profile says + * + * When built with this method, the profile element can't have instance data + * + * Warning: profiles and resources can be recursive; you can't iterate this tree until it you get + * to the leaves because you will never get to a child that doesn't have children + * + */ + public ProfiledElement buildProfileElement(String url) { + throw new NotImplementedError("NOt done yet"); + } + + /** + * Given a profile, return a tree of elements in the profile model. This builds the profile model + * for the nominated version of the nominated profile + * + * THe tree of elements in the profile model is different to the the base resource: + * - some elements are removed (max = 0) + * - extensions are turned into named elements + * - slices are turned into named elements + * - element properties - doco, cardinality, binding etc is updated for what the profile says + * + * When built with this method, the profile element can't have instance data + * + * Warning: profiles and resources can be recursive; you can't iterate this tree until it you get + * to the leaves because you will never get to a child that doesn't have children + * + */ + public ProfiledElement buildProfileElement(String url, String version) { + throw new NotImplementedError("NOt done yet"); + } + + /** + * Given a profile, return a tree of elements in the profile model with matching instance data. + * This builds the profile model for the latest version of the nominated profile and matches + * the data in the resource against the profile. Data can be added or read from the profile element + * + * THe tree of elements in the profile model is different to the the base resource: + * - some elements are removed (max = 0) + * - extensions are turned into named elements + * - slices are turned into named elements + * - element properties - doco, cardinality, binding etc is updated for what the profile says + * + * When built with this method, the profile element can't have instance data + * + * Warning: profiles and resources can be recursive; you can't iterate this tree until it you get + * to the leaves because you will never get to a child that doesn't have children + * + */ + public ProfiledElement buildProfileElement(String url, Resource resource) { + throw new NotImplementedError("NOt done yet"); + } + + /** + * Given a profile, return a tree of elements in the profile model with matching instance data. + * This builds the profile model for the nominated version of the nominated profile and matches + * the data in the resource against the profile. Data can be added or read from the profile element + * + * THe tree of elements in the profile model is different to the the base resource: + * - some elements are removed (max = 0) + * - extensions are turned into named elements + * - slices are turned into named elements + * - element properties - doco, cardinality, binding etc is updated for what the profile says + * + * When built with this method, the profile element can't have instance data + * + */ + public ProfiledElement buildProfileElement(String url, String version, Resource resource) { + throw new NotImplementedError("NOt done yet"); + } + + /** + * Given a profile, construct an empty resource of the type being profiled (to use as input + * to the buildProfileElement method + * + * No version, because the version doesn't change the type of the resource + */ + public Resource makeProfileBase(String url) { + throw new NotImplementedError("NOt done yet"); + } + +}