Package com.ibm.fhir.profile
Class ProfileBuilder
- java.lang.Object
-
- com.ibm.fhir.profile.ProfileBuilder
-
public class ProfileBuilder extends Object
A utility class for building profiles from a base structure definition
-
-
Constructor Summary
Constructors Constructor Description ProfileBuilder(Class<?> type, String url, String version)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ElementDefinition.Binding
binding(BindingStrength strength, String valueSet)
Create a value set binding from the given strength and valueSet.static ElementDefinition.Binding
binding(BindingStrength strength, String valueSet, String maxValueSet)
Create a value set binding from the given strength, value set, and max value set.ProfileBuilder
binding(String id, ElementDefinition.Binding binding)
Add value set binding to the element definition with the given id.StructureDefinition
build()
Create aStructureDefinition
instance from this profile builder.ProfileBuilder
cardinality(String id, int min, String max)
Add a cardinality constraint to the element definition with the given id.static ElementDefinition.Constraint
constraint(String key, ConstraintSeverity severity, String human, String expression)
Create a constraint from the given key, severity, human-readable description, and FHIRPath expression.ProfileBuilder
constraint(String id, ElementDefinition.Constraint... constraint)
Add constraint objects to the element definition with the given id,static ElementDefinition.Slicing.Discriminator
discriminator(DiscriminatorType type, String path)
Create a discriminator from the given discriminator type and path.ProfileBuilder
fixed(String id, Element fixed)
Add a fixed value constraint to the element definition with the given id.ProfileBuilder
pattern(String id, Element pattern)
Add a pattern value constraint to the element definition with the given id.static List<String>
profile(String... profile)
Create a list of profiles (FHIR string) from the provided Java strings.ProfileBuilder
slice(String id, String sliceName, Class<?> type, int min, String max)
Add a slice to the element definition the given id.static ElementDefinition.Slicing
slicing(ElementDefinition.Slicing.Discriminator discriminator, SlicingRules rules)
Create a slicing from the given discriminator and slicing rules.ProfileBuilder
slicing(String id, ElementDefinition.Slicing slicing)
Add a slice definition to the element definition with the given id.static List<String>
targetProfile(String... targetProfile)
Create a list of target profiles (FHIR string) from the provided Java strings.static ElementDefinition.Type
type(String code)
Create a type from the given code.ProfileBuilder
type(String id, ElementDefinition.Type... type)
Add a type constraint to the element definition with the given id.static ElementDefinition.Type
type(String code, List<String> profile)
Create a type from the given code and profile.static ElementDefinition.Type
type(String code, List<String> profile, List<String> targetProfile)
Create a type from the given code, profile, and target profile.
-
-
-
Method Detail
-
binding
public ProfileBuilder binding(String id, ElementDefinition.Binding binding)
Add value set binding to the element definition with the given id.- Parameters:
id
- the idbinding
- the value set binding- Returns:
- this profile builder
-
build
public StructureDefinition build()
Create aStructureDefinition
instance from this profile builder.- Returns:
- a
StructureDefinition
instance
-
cardinality
public ProfileBuilder cardinality(String id, int min, String max)
Add a cardinality constraint to the element definition with the given id.- Parameters:
id
- the idmin
- the minimum cardinalitymax
- the maximum cardinality- Returns:
- this profile builder
-
constraint
public ProfileBuilder constraint(String id, ElementDefinition.Constraint... constraint)
Add constraint objects to the element definition with the given id,- Parameters:
id
- the idconstraint
- the constraint object- Returns:
- this profile builder
-
fixed
public ProfileBuilder fixed(String id, Element fixed)
Add a fixed value constraint to the element definition with the given id.- Parameters:
id
- the idfixed
- the fixed value- Returns:
- this profile builder
-
pattern
public ProfileBuilder pattern(String id, Element pattern)
Add a pattern value constraint to the element definition with the given id.- Parameters:
id
- the idpattern
- the pattern value- Returns:
- this profile builder
-
slice
public ProfileBuilder slice(String id, String sliceName, Class<?> type, int min, String max)
Add a slice to the element definition the given id.- Parameters:
id
- the idsliceName
- the slice nametype
- the typemin
- the minimum cardinalitymax
- the maximum cardinality- Returns:
- this profile builder
-
slicing
public ProfileBuilder slicing(String id, ElementDefinition.Slicing slicing)
Add a slice definition to the element definition with the given id.- Parameters:
id
- the idslicing
- the slicing- Returns:
- this profile builder
-
type
public ProfileBuilder type(String id, ElementDefinition.Type... type)
Add a type constraint to the element definition with the given id.- Parameters:
id
- the idtype
- the type- Returns:
- this profile builder
-
binding
public static ElementDefinition.Binding binding(BindingStrength strength, String valueSet)
Create a value set binding from the given strength and valueSet.- Parameters:
strength
- the strengthvalueSet
- the value set- Returns:
- a value set binding
-
binding
public static ElementDefinition.Binding binding(BindingStrength strength, String valueSet, String maxValueSet)
Create a value set binding from the given strength, value set, and max value set.- Parameters:
strength
- the strengthvalueSet
- the value setmaxValueSet
- the max value set- Returns:
- a value set binding
-
constraint
public static ElementDefinition.Constraint constraint(String key, ConstraintSeverity severity, String human, String expression)
Create a constraint from the given key, severity, human-readable description, and FHIRPath expression.- Parameters:
key
- the keyseverity
- the severityhuman
- the human-readable descriptionexpression
- the FHIRPath expression- Returns:
- a constraint
-
discriminator
public static ElementDefinition.Slicing.Discriminator discriminator(DiscriminatorType type, String path)
Create a discriminator from the given discriminator type and path.- Parameters:
type
- the discriminator typepath
- the path- Returns:
- a discriminator
-
slicing
public static ElementDefinition.Slicing slicing(ElementDefinition.Slicing.Discriminator discriminator, SlicingRules rules)
Create a slicing from the given discriminator and slicing rules.- Parameters:
discriminator
- the discriminatorrules
- the slicing rules- Returns:
- a slicing
-
profile
public static List<String> profile(String... profile)
Create a list of profiles (FHIR string) from the provided Java strings.- Parameters:
profile
- the profile- Returns:
- a list of profiles (FHIR string)
-
targetProfile
public static List<String> targetProfile(String... targetProfile)
Create a list of target profiles (FHIR string) from the provided Java strings.- Parameters:
targetProfile
- the target profile- Returns:
- a list of target profiles (FHIR string)
-
type
public static ElementDefinition.Type type(String code)
Create a type from the given code.- Parameters:
code
- the code- Returns:
- a type
-
type
public static ElementDefinition.Type type(String code, List<String> profile)
Create a type from the given code and profile.- Parameters:
code
- the codeprofile
- the profile- Returns:
- a type
-
-