Details
-
New Feature
-
Status: Closed
-
Non-Essential
-
Resolution: Fixed
-
None
-
None
-
None
-
High
Description
Frequently we want to allow implementations to add attributes to different domain objects that are custom to that specific implementation. (This is equivalent to adding a column to a table in custom software.)
For example Person has PersonAttribute (and PersonAttributeType), Visit has VisitAttribute (and VisitAttributeType), etc.
The pattern we used when implementing PersonAttribute and PersonAttributeType (i.e. have a "format" column which specifies the java class of the attribute value) isn't quite right, so we want to provide a better mechanism. Initially this will be used in Visit Attributes, but eventually it will be extended to other attributes as well.
We will add "AttributeTypeHandler", an interface whose implementations:
- control the way that values are converted to and from Strings (for database storage)
- control what widget is displayed in the UI for this attribute type
Finding a way to implement this without mixing up our API and UI layers is going to be tricky...
Approximate design:
interface AttributeHandler<T> { // T is the type returned by this handler, e.g. java.lang.String or java.util.Date. String getName(Locale locale); String serialize(T); T deserialize(String); } /** hint to UI technology to display this as a dropdown */ interface ConstrainedOptionAttributeHandler<T> extends AttributeType<T> { Map<String, String> getOptions(Locale locale) // should return an ordered map from attribute value to display label } /** hint to UI technology to display this as an autosuggest */ interface SuggestedOptionsAttributeHandler<T> extends AttributeType<T> { Map<String, String> getSuggestions(String typedSoFar, Locale locale) // should return an ordered map from attribute value to display label } /** explicitly specify what UI widget to use */ interface WidgetDrivenAttributeHandler<T> extends AttributeType<T> { String getWidgetName(); Map<String, Object> getWidgetConfiguration(); }
Gliffy Diagrams
Attachments
Issue Links
- discovered while testing
-
TRUNK-3861 enhanced supports for person attributes with encounter form info
-
- Closed
-
- is depended on by
-
TRUNK-2131 Add 'Visit Attribute' to data model
-
- Closed
-
-
TRUNK-2244 Domain object, liquibase, and hibernate mapping for VisitAttributeType
-
- Closed
-
-
TRUNK-2264 Domain object, liquibase, and hibernate mapping for ProviderAttributeType
-
- Closed
-