WidgetProvider

public class WidgetProvider

A WidgetProvider lets you build a set of visual and interactive widgets corresponding to a specific OpenEHR Archetype. The Archetype description is specified by a set of json structures (to be provided to the class constructor).

Fields

_container

protected LinearLayout _container

The _container.

_layout

protected LinearLayout _layout

The _layout.

_viewport

protected ScrollView _viewport

The _viewport.

clusterWidgetsMap

protected Map<String, List<DatatypeWidget<EhrDatatype>>> clusterWidgetsMap

The cluster widgets map.

defaultLayoutParams

public static final LayoutParams defaultLayoutParams

The Constant defaultLayoutParams.

sectionWidgetsMap

protected Map<String, List<DatatypeWidget<EhrDatatype>>> sectionWidgetsMap

The section widgets map.

Constructors

WidgetProvider

public WidgetProvider(Context context, ArchetypeSchemaProvider asp, String archetypeClassName, String language, String jsonExclude)

Setup a Widget provider representing a specific archetype, according to the specified Archetype Schema Provider and archetype class name

Parameters:
  • context – get application context
  • asp – the Archetype Schema Provider
  • archetypeClassName – the name of the archetype class to be built (e.g: openEHR-EHR-OBSERVATION.blood_pressure.v1)
  • language – the default ontology language
  • jsonExclude – the json array containing a list of item ids to be excluded from the archetype
Throws:
  • InvalidDatatypeException
  • JSONException

WidgetProvider

public WidgetProvider(Context context, String jsonDatatypes, String jsonOntology, String jsonAdlStructure, String jsonLayoutSchema, String language)

Setup a Widget provider representing a specific archetype, according to the specified json datatypes schema , json archetype structure and json ontology.

Parameters:
  • context – the application context
  • jsonDatatypes
    • the json description of all datatypes used by this archetype, subdivided in sections
  • jsonOntology
    • the json ontology (it includes a textual description of each item of the archetype)
  • jsonAdlStructure
    • the initial json structure of the archetype (optionally including initial values)
  • jsonLayoutSchema – (optional, it can be null) the layout schema containing informations about visual rendering (sections, custom widgets, priorities..)
  • language
    • the default language code (any language code included in the ontology json schema)
Throws:
  • InvalidDatatypeException
  • JSONException – the JSON exception

WidgetProvider

public WidgetProvider(Context context, String jsonDatatypes, String jsonOntology, String jsonAdlStructure, String jsonLayoutSchema, String language, String jsonExclude)

Setup a Widget provider representing a specific archetype, according to the specified json datatypes schema , json archetype structure and json ontology.

Parameters:
  • context – the application context
  • jsonDatatypes
    • the json description of all datatypes used by this archetype, subdivided in sections
  • jsonOntology
    • the json ontology (it includes a textual description of each item of the archetype)
  • jsonAdlStructure
    • the initial json structure of the archetype (optionally including initial values)
  • jsonLayoutSchema – (optional, it can be null) the layout schema containing informations about visual rendering (sections, custom widgets, priorities..)
  • jsonExclude – (optional, it can be null) the list of archetype items (i.e their id , like “at0004”) to exclude from the viewer
  • language
    • the default language code (any language code included in the ontology json schema)
Throws:
  • InvalidDatatypeException
  • JSONException
    • if an error occurred during the parsing of the json schemas

Methods

buildFormView

public FormContainer buildFormView(int index)

build a view containing all widgets according to the json archetype structure, layout and ontology, All widgets are rendered in a vertical layout, optionally ordered by section and/or item priority (if specified in the layout json schema)

Parameters:
  • index – the index of this Form Container
Returns:

the FormContainer containing all widgets, ordered by section and item priority in a vertical layout

getClusterWidgets

public List<DatatypeWidget<EhrDatatype>> getClusterWidgets(String cluster, int itemIndex)

getContext

public Context getContext()

Get the application context

Returns:the application context

getDatatypesSchema

public JSONObject getDatatypesSchema()

getOntology

public JSONObject getOntology()

Get the json schema containing the ontology of this archetype

Returns:the ontology json schema

getOntology

public static JSONObject getOntology(String data, String language)

Get the ontology .

Parameters:
  • data – the ontology schema (including all available languages)
  • language – the selected language
Returns:

a json object containing the ontology of the specified language

getSectionWidgets

public List<DatatypeWidget<EhrDatatype>> getSectionWidgets(String section, int itemIndex)

getSections

public String[] getSections()

Get the sections of this archetype structure.

Returns:the sections

parseFileToString

public static String parseFileToString(Context context, String filename)

Parses the file to string.

Parameters:
  • context – the context
  • filename – the filename
Returns:

the string

toJson

public JSONObject toJson()

get a Json representation of the current state of this archetype.

Returns:the JSON object

updateOntologyLanguage

public void updateOntologyLanguage(String lang)

Update the ontology of all DatatypeWidget widgets.

Parameters:
  • lang – the language code (ISO 639-1:2002)

updateSectionsJsonContent

public void updateSectionsJsonContent(int index)

Update the json structure according to the current value of the datatype widgets belonging to this form.

Parameters:
  • index – the form index
Throws:
  • JSONException – the JSON exception
Returns:

the updated json structure