Welcome to MOST’s Report Module documentation¶
The MOST project aims to achieve an open, modular and scalable solution for the creation, execution and management of remote clinical consultations with direct interaction between specialists.
The project consists of a set of frameworks that deal with different aspects and technologies useful for the creation of telemedicine applications.
Report Framework¶
The Report Framework allows you to load, display and edit clinical records in your mobile applications, automatically built by json structures representing specific OpenEHR Archetypes.
TREE:
Most report Dependences¶
The Most-Report Freamework depends on the SuperTooltips Lib .
Basic Concepts¶
The Most EhrLib allow you to build, display and edit Open EHR based archetypes (http://www.openehr.org/) into your android applications. The lib uses specific json schemas for describing the structure, the ontology and the content of each archetype.
For example, assuming you want to build the well known Blood Pressure archetype, at least the following json schemas must be provided:
- adl_structure__blood_pressure.json: it contains the structure of the archetype, corresponding to the ADL structure defined by the Open EHR standard
- datatypes__blood_pressure.json: it contains the description of all datatypes used by this archetype (e.g: DV_QUANTITY, DV_CLUSTER and so on)
- ontology__blood_pressure.json: it contains the ontology of this archetype (i.e a textual title and description of each item of the archetype)
Note that for representing any archetype, the previous json schemas are mandatory. Optionally, if you need to customize the visual layout of the archetype, you can also specify a layout json schema, layout__blood_pressure.json, as explained in the next section.
Basic Example: how to build a single archetype: Blood Pressure¶
This section explains how to build, step by step, a Blood Pressure archetype and how to display it in an Android Application
First of all you need to build the json schemas. Let start with the adl_structure__blood_pressure.json:
{
"archetype_class": "openEHR-EHR-OBSERVATION.blood_pressure.v1",
"archetype_details": {
"data": {
"at0001": [
{
"events": [
{
"at0006": {
"data": {
"at0003": [
{
"items": {
"at0004": "DATA_NODE::DV_QUANTITY",
"at0005": "DATA_NODE::DV_QUANTITY",
"at1006": "DATA_NODE::DV_QUANTITY",
"at1007": "DATA_NODE::DV_QUANTITY",
"at0033": "DATA_NODE::DV_TEXT"
}
}
]
},
"state": {
"at0007": [
{
"items": {
"at0008": "DATA_NODE::DV_CODED_TEXT",
"at1052": "DATA_NODE::DV_TEXT"
},
"at1030": "ARCHETYPE_NODE",
"at1043": "DATA_NODE::DV_CODED_TEXT",
"at1005": "DATA_NODE::DV_QUANTITY"
}
]
}
},
"at1042": "DATA_NODE::MATH_FUNCTION"
}
]
}
]
}
}
}
Note that the structure is very similar to the corresponding ADL structure defined by the Open EHR adl structure (you can find the adl structure of the Blood Pressure Archetype here: http://openehr.org/ckm/). Each item of the structure has a unique identifier (such as “at0004”) that represents a specific item of the archetype. Each item is of a specific type (for example, the item at0004 is a DV_QUANTITY item).
The datatype description of each item is specified in the datatypes__blood_pressure.json schema:
{
"title": "at0000",
"datatypes": {
"data": {
"at0004": {
"path": "data[at0001]/events[at0006]/data[at0003]/items[at0004]",
"type": "DV_QUANTITY",
"attributes": {
"unit_of_measure": "mm[Hg]",
"precision": 2,
"range": {
"min": 10,
"max": 180
}
}
},
"at0005": {
"path": "data[at0001]/events[at0006]/data[at0003]/items[at0005]",
"type": "DV_QUANTITY",
"attributes": {
"unit_of_measure": "mm[Hg]",
"precision": 2,
"range": {
"min": 10,
"max": 180
}
}
},
"at1006": {
"path": "data[at0001]/events[at0006]/data[at0003]/items[at1006]",
"type": "DV_QUANTITY",
"attributes": {
"unit_of_measure": "mm[Hg]",
"precision": 2,
"range": {
"min": 10,
"max": 180
}
}
},
"at1007": {
"path": "data[at0001]/events[at0006]/data[at0003]/items[at1007]",
"type": "DV_QUANTITY",
"attributes": {
"unit_of_measure": "mm[Hg]",
"precision": 2,
"range": {
"min": 10,
"max": 180
}
}
},
"at0033": {
"path": "data[at0001]/events[at0006]/data[at0003]/items[at0033]",
"type": "DV_TEXT",
"attributes": {}
}
}
}
}
All datatypes are specified into the datatypes json dictionary. In the example above you defined the data section of the archetype, so that, there is the corresponding data json dictionary containing the data type description of all items contained inside it. For example, there is the item0004 with the following informations:
"at0004": {
"path": "data[at0001]/events[at0006]/data[at0003]/items[at0004]",
"type": "DV_QUANTITY",
"attributes": {
"unit_of_measure": "mm[Hg]",
"precision": 2,
"range": {
"min": 10,
"max": 180
}
}
}
The item at0004 is a DV_QUANTITY item, located inside the ADL structure of the archetype at the absolute path data[at0001]/events[at0006]/data[at0003]/items[at0004]. Note that each datatype has specific attributes that can be specified. In this example, the DV_QUANTITY item has its unit of measure, precision and a range of allowed numeric values. Again, see the Open EHR reference for getting more informations about Open EHR data types.
The description of each item is specified by the ontology__blood_pressure.json schema:
{
"en":{
"at0000":{
"text":"Blood Pressure",
"description":"The local measurement of arterial blood pressure which is a surrogate for arterial. pressure in the systemic circulation. Most commonly, use of the term 'blood pressure' refers to measurement of brachial artery pressure in the upper arm."
},
"at0001":{
"text":"history",
"description":"History Structural node."
},
"at0003":{
"text":"blood pressure",
"description":"internal"
},
"at0004":{
"text":"Systolic",
"description":"Peak systemic arterial blood pressure - measured in systolic or contraction phase of the heart cycle."
},
"at0005":{
"text":"Diastolic",
"description":"Minimum systemic arterial blood pressure - measured in the diastolic or relaxation phase of the heart cycle."
},
"at0006":{
"text":"any event",
"description":"Default event."
},
"at0007":{
"text":"state structure",
"description":"internal"
},
"at0008":{
"text":"Position",
"description":"The position of the subject at the time of measurement."
},
"at0011":{
"text":"Tree",
"description":"List Structure"
},
"at0013":{
"text":"Cuff Size",
"description":"The size of the cuff used for blood pressure measurement."
},
"at0033":{
"text":"Comment",
"description":"Comment on blood pressure measurement."
},
"at1006":{
"text":"Mean Arterial Pressure",
"description":"The average arterial pressure that occurs over the entire course of the heart contraction and relaxation cycle."
},
"at1007":{
"text":"Pulse Pressure",
"description":"The difference between the systolic and diastolic pressure."
},
"at0033":{
"text":"Comment",
"description":"Comment on blood pressure measurement."
},
"at1000":{
"text":"Standing",
"description":"Standing at the time of blood pressure measurement."
},
"at1001":{
"text":"Sitting",
"description":"Sitting (for example on bed or chair) at the time of blood pressure measurement."
},
"at1002":{
"text":"Reclining",
"description":"Reclining at the time of blood pressure measurement."
},
"at1003":{
"text":"Lying",
"description":"Lying flat at the time of blood pressure measurement."
},
"at1014":{
"text":"Lying with tilt to left",
"description":"Lying flat with some lateral tilt, usually angled towards the left side. Commonly required in the last trimester of pregnancy to relieve aortocaval compression."
},
"at1052":{
"text":"Confounding factors",
"description":"Comment on and record other incidental factors that may be contributing to the blood pressure measurement. For example, level of anxiety or 'white coat syndrome'; pain or fever; changes in atmospheric pressure etc."
},
"at1025":{
"text":"Blood Pressure",
"description":"Included archetype, just for testing"
}
},
"es-ar":{
"at0000":{
"text":"Presión Arterial",
"description":"La medición local de la tensión arterial que deriva de la medida de la presión arterial en la circulación sistémica. Comúnmente el uso de 'presión arterial' se refiere a la medida de la presión de la arteria braquial por encima del pliegue del codo."
},
"at0001":{
"text":"historia",
"description":"historia Nodo estructural"
},
"at0003":{
"text":"blood pressure",
"description":"internal"
},
"at0004":{
"text":"Sistólica",
"description":"Presión arterial sistólica pico - medido en sístole o la fase de contracción del ciclo cardíaco."
},
"at0005":{
"text":"Diástole",
"description":"Presión arterial sistémica mínima - medido durante la diástole o fase de relajación del ciclo cardíaco."
},
"at0006":{
"text":"cualquier evento",
"description":"Evento por defecto."
},
"at0007":{
"text":"state structure",
"description":"internal"
},
"at0008":{
"text":"Posición",
"description":"La posición del individuo en el momento del registro."
},
"at0011":{
"text":"estructura de lista",
"description":"estructura tipo lista"
},
"at0013":{
"text":"Tamaño del manguito",
"description":"El tamaño del manguito usado para la toma de la presión arterial."
},
"at0033":{
"text":"Comment",
"description":"Comment on blood pressure measurement."
},
"at1006":{
"text":"Presión Arterial Media",
"description":"La presión arterial promedio que ocurre durante el ciclo entero de la contracción y relajación del corazon."
},
"at1007":{
"text":"Presión de Pulso",
"description":"La diferencia entre la presión sistólica y la presión diastólica."
},
"at0033":{
"text":"Comentario",
"description":"Comentario sobre la medición de la presión sanguínea"
},
"at1000":{
"text":"De pie",
"description":"De pie al momento de la medición de la tensión arterial."
},
"at1001":{
"text":"Sentado",
"description":"Sentado (en la cama o en una silla) durante el registro de la presión arterial."
},
"at1002":{
"text":"Reclinado",
"description":"Reclinado (semisentado) durante el registro de la presión arterial."
},
"at1003":{
"text":"Acostado",
"description":"Acostado horizontal durante la medición de la presión arterial"
},
"at1014":{
"text":"Acostado e inclinado levemente sobre su costado izquierdo",
"description":"Acostado horizontal e inclinado levemente sobre su costado izquierdo. Comúnmente se requiere durante el último trimestre del embarazo para aliviar la compresión aortocava."
},
"at1052":{
"text":"Factores confluentes",
"description":"Comentario y registro sobre otros factores que pueden incidir sobre la medición de la presión arterial. Por ejemplo: nivel de ansiedad o \"síndrome del guardapolvo blanco\"; dolor o fiebre; cambios en la presión atmosférica etc."
},
"at1025":{
"text":"Presión Arterial",
"description":"Included archetype, just for testing"
}
}
}
In this example, you are handling the English and the Spanish language. For each item, a textual label and a short description is provided for both languages.
Finally, you can optionally provide a layout__blood_pressure.json schema (for example if you want to display the item of the systolic pressure before the item of the diastolic pressure)
{
"sections":[
"data"
],
"items":{
"data[at0001]/events[at0006]/data[at0003]/items[at0004]":{
"priority":1
},
"data[at0001]/events[at0006]/data[at0003]/items[at0005]":{
"priority":2
},
"data[at0001]/events[at0006]/data[at0003]/items[at1006]":{
"priority":3
},
"data[at0001]/events[at0006]/data[at0003]/items[at1007]":{
"priority":4
},
"data[at0001]/events[at0006]/data[at0003]/items[at0033]":{
"priority":5
},
"data[at0001]/events[at0006]/state[at0007]/items[at0008]":{
"priority":1,
"widget":"it.crs4.ehrlib.widgets.DvCodedTextAsListWidget"
},
"data[at0001]/events[at0006]/state[at0007]/items[at1052]":{
"priority":2
}
}
}
In this example, you use the priority attribute for specifying the display order of each item (items with lower priority are displayed before). If you want, you can also display an item with a custom widget, by specifying the java class representing that datatype in the widget attribute. Note that you don’t have to specify all items of the datatype, because all items of the datatypes will be rendered anyway. A layout specifies only the displaying order, not a sub set of items to be displayed. Note that you can display a sub set of an archetype item by providing a list of items to be excluded by using a TemplateProvider, as explained later in this guide. Finally, if you prefer, you can use aliases for referring to each item in a more human-readable way, as follows:
{
"sections":[
"data"
],
"aliases" :
{
"data[at0001]/events[at0006]/data[at0003]/items[at0004]": "Systolic",
"data[at0001]/events[at0006]/data[at0003]/items[at0005]": "Diastolic",
"data[at0001]/events[at0006]/data[at0003]/items[at1006]": "Arterial Pressure",
"data[at0001]/events[at0006]/data[at0003]/items[at1007]": "Pulse Pressure"
},
"items":{
"Systolic":{
"priority":1
},
"Diastolic":{
"priority":2
},
"Arterial Pressure":{
"priority":3
},
"Pulse Pressure":{
"priority":4
},
"data[at0001]/events[at0006]/data[at0003]/items[at0033]":{
"priority":5
},
"data[at0001]/events[at0006]/state[at0007]/items[at0008]":{
"priority":1,
"widget":"it.crs4.ehrlib.widgets.DvCodedTextAsListWidget"
},
"data[at0001]/events[at0006]/state[at0007]/items[at1052]":{
"priority":2
}
}
}
Now that you have defined all json schema, you can instance a WidgetProvider, the library class that uses the json schemas for building the corresponding archetype. A simple way for getting an Android View containing the Blood Pressure archetype could be the following:
Context xtx = getActivity();
WidgetProvider widgetProvider = new WidgetProvider(ctx,
WidgetProvider.parseFileToString(ctx,"datatypes__blood_pressure.json"), // datatypes schema
WidgetProvider.parseFileToString(ctx,"ontology__blood_pressure.json"), // ontology schema
WidgetProvider.parseFileToString(ctx,"adl_structure__blood_pressure.json"), // adl structure schema
WidgetProvider.parseFileToString(ctx,"layout__blood_pressure.json"), // layout schema
"en"); // default ontology language
// build the Archetype, according to the json schemas
FormContainer formContainer = widgetProvider.buildFormView(0);
// Retrieve the ViewGroup of the form, so it can be added to the Activity context
ViewGroup rootView = formContainer.getLayout();
The code above assumes that you saved all your json files into the assets folder of your example. The final visual result inside an Android Activity could be similar to the following (note that you can found the complete source code of this example in the examples folder of the repository):

Advanced Example: how to display more than one archetype in an Activity: introduction to the TemplateProvider and the ArchetypeSchemaProvider¶
If you need to build and display more than one archetype in your activity, the most convenient way is to use the TemplateProvider and the ArchetypeSchemaProvider classes. This section will explain, by an easy example, how to include in the same activity two archetypes by using a Template.
- Let assume you want to build a Template including the following two Open EHR archetypes:
- openEHR-EHR-OBSERVATION.blood_pressure.v1 (the blood pressure archetype already used in the previous example)
- openEHR-EHR-OBSERVATION.ecg.v1 (the ECG Archetype)
First of all, you have to create, inside the assets folder, a folder that will contain all the json schemas for both the archetypes. For instance, you can create a folder called archetypes and, inside of it, two other folders, called blood_pressure and ecg, containing all the json schema files related, respectively, to the blood pressure and to the ECG archetype (see the pitcure below)

- Note that, in general, if you put the json schema files of a generic archetype into a folder called XXX, the name of each json file must comply with the following rules:
- adl_structure__XXX.json (mandatory, the json file containing the adl structure of the archetype)
- datatypes__XXX.json (mandatory, the json file containing the datatypes of the archetype)
- layout__XXX.json (optional, the json file containing the layout of the archetype)
- ontology__XXX.json (mandatory, the json file containing the ontology of the archetype)
These naming rules are needed if you intend to build the archetypes by using the ArchetypeSchemaProvider , an utility class of the Most Report Library that automatically retrieves the content of all the json schemas for each archetype.
Now you have to create a properties file (called archetypes.properties in this example) containing a mapping between the name of each archetype (in this example, openEHR-EHR-OBSERVATION.blood_pressure.v1 and openEHR-EHR-OBSERVATION.ecg.v1) and the corresponding name of the folder containing its json schema files. The content of the archetypes.properties of this example is the followiing:
openEHR-EHR-OBSERVATION.blood_pressure.v1=blood_pressure
openEHR-EHR-OBSERVATION.ecg.v1=ecg
Finally, you have to define the Json file containing the structure of the visual template (in this example, ecg_bp_template.json) that includes an ordered list of the archetypes that will be built and rendered in the activity:
{
"id":"my_template_id",
"name":"ECG & BLOOD PRESSURE",
"definition":[
{
"archetype_class":"openEHR-EHR-OBSERVATION.blood_pressure.v1",
"exclude":["at0004", "at0005"]
}
,
{
"archetype_class":"openEHR-EHR-OBSERVATION.ecg.v1",
"exclude":[]
}
,
]
}
Into the section definition there is the ordered list of all the archetypes to be rendered, Blood Pressure and ECG. Note that the Blood Pressure definition also contains two items (the systolic pressure “at0004” , and the diastolic pressure “at0005”) that will not be displayed into the activity, because specified into the “exclude” json array.
At this point, you are ready to create the visual template for the Android Activity:
Context ctx = getApplicationContext();
// build the ArchetypeSchemaProvider passing to the constructor the archetypes.properties file name and the root folder name containing all the json schema folders.
ArchetypeSchemaProvider asp = new ArchetypeSchemaProvider(ctx, "archetypes.properties", "archetypes");
// Build the template, passing to the constructor the json schema describing the template, the jsut created ArchetypeSchemaProvider and the defualt ontoly language
TemplateProvider tp = new TemplateProvider(ctx,WidgetProvider.parseFileToString(ctx, "ecg_bp_template.json"), asp, "en");
// Retrieve the ordered list of widget providers, the first one related to the Blood Pressure archetype, the second one to the ECG archetype
List<WidgetProvider> wps = tp.getWidgetProviders();
Now you can access to any of the WidgetProvider of the template. So, as you have already seen in the previous example, you can retrieve the ViewGroup of each archetype and add it to your activity layout. The final visual result could be similar to the following (again, you can found the complete source code of this example in the examples folder of the Most Report repository):

Javadoc¶
it.crs4.most.ehrlib¶
ArchetypeFragment¶
-
public class
ArchetypeFragment
extends Fragment¶ This class allows you to display an Archetype in a Fragment. You just have to provide the
WidgetProvider
handling the archetype you want to include to the constructor or, if you prefer, you can use thesetWidgetProvider(WidgetProvider)
method (in this second case, remember to call this method before adding the fragment to the container).
Constructors¶
-
public
ArchetypeFragment
(WidgetProvider wp)¶ Create an Archetype fragment by providing the WidgetProvider
Parameters: - wp –
Methods¶
-
public FormContainer
getFormContainer
()¶ Get the form container of this fragment
Returns: the form container of this archetype fragment
-
public WidgetProvider
getwidgetProvider
()¶ Returns: the widget provider of this Archetype Fragment
-
public View
onCreateView
(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)¶
-
public void
setWidgetProvider
(WidgetProvider wp)¶ Set the widget provider for this fragment. This method must called BEFORE adding the fragment to itws container.
Parameters: - wp –
ArchetypeSchemaProvider¶
-
public class
ArchetypeSchemaProvider
¶ Utility class that provides a convenient way for getting the json schemas needed for loading an archetype on the EhrLibViewer.
Constructors¶
-
public
ArchetypeSchemaProvider
(Context context, String archetypesPropertyFile, String schemasRootDir)¶ Provides default datatypes, layouts and ontology schema for specific archetypes. All available archetype schema must be specified in a property file provided as input argument
Parameters: - context – the application context
- archetypesPropertyFile – the path of the Archetype Property file, containing a list of key-values like =
- schemasRootDir – the root dir (under assets folder) containing all archetypes schemaa (note that each subfolder is a folder for a specific archetype. e.g blood_pressure)
Methods¶
-
public String
getAdlStructureSchema
(String archetypeClass)¶ Get the adl schema for the specified archetype class, or null if not available
Parameters: - archetypeClass – the archetype class, (e.g openEHR-EHR-OBSERVATION.blood_pressure.v1)
Returns: the json schema representing the internal structure of this specific archetype, or null if not available
-
public String
getDatatypesSchema
(String archetypeClass)¶ Get the datatypes schema for the specified archetype class, or null if not available
Parameters: - archetypeClass – the archetype class, (e.g openEHR-EHR-OBSERVATION.blood_pressure.v1)
Returns: the json schema containing the internal structure of datatypes used for visually representing this specific archetype, or null if not available
-
public String
getLayoutSchema
(String archetypeClass)¶ Get the Layout schema for the specified archetype class, or null if not available
Parameters: - archetypeClass – the archetype class, (e.g openEHR-EHR-OBSERVATION.blood_pressure.v1)
Returns: the json schema of the default layout, or null if not available
-
public String
getOntologySchema
(String archetypeClass)¶ Get the ontology schema for the specified archetype class, or null if not available
Parameters: - archetypeClass – the archetype class, (e.g openEHR-EHR-OBSERVATION.blood_pressure.v1)
Returns: the json schema of the default ontology, or null if not available
FormContainer¶
-
public class
FormContainer
¶ A Form Container contains the list of
DatatypeWidget
widgets included in a Form along with the visual layout containing them.
Fields¶
-
List<DatatypeWidget<EhrDatatype>>
widgets
¶ The widgets.
Constructors¶
-
public
FormContainer
(ViewGroup layout, List<DatatypeWidget<EhrDatatype>> widgets, int index)¶ Creates a new Form Container
Parameters: - layout – the layout the layout containing all the
DatatypeWidget
- widgets – the list of the
DatatypeWidget
- index – the index of this form
- layout – the layout the layout containing all the
Methods¶
-
public List<DatatypeWidget<EhrDatatype>>
getWidgets
()¶ Get the widgets of this form container.
Returns: the widgets
-
public void
resetAllWidgets
()¶ Reset the content of all widgets of this form according to the current value of their underlying data types.
-
public void
resetWidget
(int index)¶ Reset the content of the selected widget according to the current value of the underlying data type.
Parameters: - index – the index
-
public void
submitAllWidgets
()¶ Submit all widgets.
Throws: - InvalidDatatypeException – if any of the widgets contains invalid data
-
public void
submitWidget
(int index)¶ Update the value of the underlying data type according to the current content of the widget.
Parameters: - index – the widget index
Throws: - InvalidDatatypeException – if the content cannot be converted to the datatype.
PriorityComparison¶
-
public class
PriorityComparison
implements Comparator<DatatypeWidget<EhrDatatype>>¶ Helper class for sorting widgets by priority.
Constructors¶
Methods¶
-
public int
compare
(DatatypeWidget<EhrDatatype> item1, DatatypeWidget<EhrDatatype> item2)¶
TemplateProvider¶
-
public class
TemplateProvider
¶ This class represents a visual Archetypes Template, according to the OpenEHR specifications. A template is an ordered list of
WidgetProvider
, each of them contains the layout of a specific archetype of the template-
Constructors¶
-
public
TemplateProvider
(Context ctx, String templateSchema, ArchetypeSchemaProvider archetypeSchemaProvider, String language)¶ Creates the template, building all the archetypes specified in the provided json schemas.
Parameters: - ctx – the application Context
- templateSchema – the json schema of the template
- archetypeSchemaProvider – the archetype schema provider
- language – the default ontology language
Throws: - JSONException – if an error occurred during the parsing of the json schemas
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¶
-
protected Map<String, List<DatatypeWidget<EhrDatatype>>>
clusterWidgetsMap
¶ The cluster widgets map.
-
public static final LayoutParams
defaultLayoutParams
¶ The Constant defaultLayoutParams.
-
protected Map<String, List<DatatypeWidget<EhrDatatype>>>
sectionWidgetsMap
¶ The section widgets map.
Constructors¶
-
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 –
-
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
-
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¶
-
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
-
public List<DatatypeWidget<EhrDatatype>>
getClusterWidgets
(String cluster, int itemIndex)¶
-
public Context
getContext
()¶ Get the application context
Returns: the application context
-
public JSONObject
getOntology
()¶ Get the json schema containing the ontology of this archetype
Returns: the ontology json schema
-
public List<DatatypeWidget<EhrDatatype>>
getSectionWidgets
(String section, int itemIndex)¶
-
public JSONObject
toJson
()¶ get a Json representation of the current state of this archetype.
Returns: the JSON object
-
public void
updateOntologyLanguage
(String lang)¶ Update the ontology of all
DatatypeWidget
widgets.Parameters: - lang – the language code (ISO 639-1:2002)
it.crs4.most.ehrlib.datatypes¶
DvBoolean¶
-
public class
DvBoolean
extends EhrDatatype¶ This class represents a DV_BOOLEAN item, according to the definition provided by the OpenEHR Data Type Information Model
Constructors¶
DvCluster¶
-
public class
DvCluster
extends EhrDatatype¶ It is a particular datatype that is a container for other datatypes.
Constructors¶
DvCodedText¶
-
public class
DvCodedText
extends EhrDatatype¶ This class represents a DV_CODED_TEXT item, according to the definition provided by the OpenEHR Data Type Information Model
Constructors¶
Methods¶
-
public int
getSelectedOptionIndex
()¶ Gets the selected option index.
Returns: the selected option index
DvQuantity¶
-
public class
DvQuantity
extends EhrDatatype¶ This class represents a DV_QUANTITY item, according to the definition provided by the OpenEHR Data Type Information Model
Constructors¶
Methods¶
-
public double
getMagnitude
()¶ Gets the current magnitude value of this datatype.
Returns: the magnitude
-
public int
getMax
()¶ Gets the maximum value admitted for this DV_QUANTITY item
Returns: the maximum value admitted for this DV_QUANTITY item
-
public int
getMaxPrecision
()¶ Gets the maximum precision (i.e the maximum number of decimal digits admitted for this DV_QUANTITY item)
Returns: the maximum precision
-
public int
getMin
()¶ Gets the minimum value admitted for this DV_QUANTITY item
Returns: the minimum value admitted for this DV_QUANTITY item
-
public boolean
isValid
(double value)¶ Checks if the value provided as argument is valid for this DV_QUANTITY item or not.
Parameters: - value – the value to be checked
Returns: True
, if ithe calue is valid,False
otherwise
-
public void
setMagnitude
(double magnitude)¶ Sets the magnitude value.
Parameters: - magnitude – the new magnitude value
Throws: - InvalidDatatypeException – if a not valid magnitude value is specified
-
public void
setMax
(int max)¶ Sets the maximum value admitted for this DV_QUANTITY item
Parameters: - max – the maximum value admitted for this DV_QUANTITY item
-
public void
setMaxtPrecision
(int precision)¶ Sets the maximum precision (i.e the maximum number of decimal digits admitted for this DV_QUANTITY item)
Parameters: - precision – the highest precision
-
public void
setMin
(int min)¶ Sets the minimum value admitted for this DV_QUANTITY item
Parameters: - min – the minimum value admitted for this DV_QUANTITY item
DvText¶
-
public class
DvText
extends EhrDatatype¶ This class represents a DV_TEXT item, according to the definition provided by the OpenEHR Data Type Information Model
Constructors¶
EhrDatatype¶
-
public abstract class
EhrDatatype
¶ This is the base class for all data types included in a generic Archetype, as defined by the OpenEHR ADL structure
Fields¶
-
protected EhrDatatypeChangeListener
datatypeChangeListener
¶ The datatype change listener.
Methods¶
-
public abstract void
fromJSON
(JSONObject data)¶ Load the new content of this datatype from a json schema.
Parameters: - data – the json structure representing this datatype
Throws: - InvalidDatatypeException – the invalid datatype exception
- JSONException – if a malformed json structure was provided
-
public boolean
isCluster
()¶ Returns: True
if this datatype is a container for other datatypes,False
otherwise
-
public boolean
isInnerArchetype
()¶ Returns: True
if this datatype is an archetype itselfFalse
otherwise
-
protected abstract void
setAttributes
(JSONObject attributes)¶ Sets the attributes for this datatype. Generally, different datatypes have different attributes.
Parameters: - attributes – the json structure containing all the attributes of this datatype.
Throws: - JSONException – if a malformed json structure was provided
-
public void
setDatatypeChangeListener
(EhrDatatypeChangeListener datatypeChangeListener)¶ Sets the Event listener interface for ‘change’ events.
Parameters: - datatypeChangeListener – the Listener where to notify any content modification of this datatype
EhrDatatypeChangeListener¶
-
public interface
EhrDatatypeChangeListener
<T extends EhrDatatype>¶ The listener interface for receiving ehrDatatypeChange events. The class that is interested in processing a ehrDatatypeChange event implements this interface, and the object created with that class is registered with a component using the component’s
EhrDatatype.setDatatypeChangeListener(EhrDatatypeChangeListener)
method. When the ehrDatatypeChange event occurs, that object’s appropriate method is invoked.Parameters: - <T> – the generic datatype extending the
EhrDatatype
- <T> – the generic datatype extending the
InnerArchetype¶
-
public class
InnerArchetype
extends EhrDatatype¶ This class represents an Archetype item included in another one.
Constructors¶
-
public
InnerArchetype
(WidgetProvider wp, String path, JSONObject attributes)¶ Instantiates a new Archetype item.
Parameters: - wp – the Widget Provider of the archetype
- path – the absolute path of the archetype inside the json structure
- attributes –
it.crs4.most.ehrlib.exceptions¶
InvalidDatatypeException¶
-
public class
InvalidDatatypeException
extends Exception¶ This exception is called when a user attempts to set an invalid value to a
EhrDatatype
item.
it.crs4.most.ehrlib.parser¶
AdlParser¶
-
public class
AdlParser
¶ This class provides methods for exploring, retrieving and updating the contents of a JSON structure representing an OpenEHR Archetype
Constructors¶
Methods¶
-
public AdlStructure
getItemsContainer
(String path)¶ Get an ADL structure containing all the items included in an archetype path. The path must be the absolute path of any of its items. For instance, providing the path data[at0001]/events[at0006]/data[at0003]/items[at0004] , this method returns the ADL structure included in data[at0001]/events[at0006]/data[at0003]
Parameters: - path – the path of an item
Returns: the AdlStructure
-
public AdlStructure
getStructureByPath
(String path)¶ Get the structure corresponding to the specified path.
Parameters: - path – the path of an item
Returns: the AdlStructure
-
public void
replaceContent
(String path, int index, JSONObject newContent)¶ Replace the content of a json structure.
Parameters: - path – the path of the json substructure to be replaced
- index – the index of the json instance
- newContent – the json structure containing the new json content
Throws: - JSONException – the JSON exception
AdlStructure¶
-
public class
AdlStructure
¶ The Class AdlStructure contains a JSON structure representing a whole or a part of an OpenEHR Archetype.
Constructors¶
Methods¶
-
public StructureCardinality
getCardinality
()¶ Gets the cardinality of this ADL structure
Returns: the cardinality
StructureCardinality¶
-
public enum
StructureCardinality
¶ The StructureCardinalityenum represents athe cardinality of a section of an ADL Archetype.
Enum Constants¶
-
public static final StructureCardinality
MULTIPLE
¶
-
public static final StructureCardinality
UNIQUE
¶
-
public static final StructureCardinality
UNKNOWN
¶
it.crs4.most.ehrlib.widgets¶
DatatypeWidget¶
-
public abstract class
DatatypeWidget
<T extends EhrDatatype> implements EhrDatatypeChangeListener<T>¶ This the base class for all DatatypeWidgets. A
DatatypeWidget
is a visual and interactive widget mapped on a specificEhrDatatype
. A user can instantiate aDatatypeWidget
for reading, editing and saving the content of theEhrDatatype
handled by it.Parameters: - <T> – the generic
EhrDatatype
- <T> – the generic
Fields¶
-
protected WidgetProvider
_widget_provider
¶
Constructors¶
-
public
DatatypeWidget
(WidgetProvider provider, String name, T datatype, int parent_index)¶ Instantiates a new
DatatypeWidget
widget.Parameters: - context – the context
- name – the name of this widget
- datatype – the
EhrDatatype
to be handled by this widget - ontology – the ontology used
- parent_index – the parent_index
Methods¶
-
public T
getDatatype
()¶ Gets the
EhrDatatype
handled by this widgetReturns: the EhrDatatype
-
public int
getPriority
()¶ returns the visual priority of this widget (essentially this means it’s physical location in the form).
Returns: the priority
-
public View
getView
()¶ get the Root View containing this widget’s view elements.
Returns: the view
-
public WidgetProvider
getWidgetProvider
()¶
-
protected abstract void
replaceTooltip
(ToolTip tooltip)¶ Replace tooltip.
Parameters: - tooltip – the tooltip
-
public abstract void
reset
()¶ Reset all fields of this widget according to the current underlying datatype value.
-
public abstract void
save
()¶ Update the value of the underlying datatype according to the current value of the fields of this widget.
Throws: - InvalidDatatypeException – if the current value of the fields cannot be converted to a datatype value
-
public void
setPriority
(int value)¶ sets the visual priority of this widget essentially this means it’s physical location in the form.
Parameters: - value – the new priority
DvBooleanWidget¶
-
public class
DvBooleanWidget
extends DatatypeWidget<DvBoolean> implements ToolTipView.OnToolTipViewClickedListener¶ This class represents a visual widget mapped on a
DvBoolean
datatype.
Constructors¶
-
public
DvBooleanWidget
(WidgetProvider provider, String name, String path, JSONObject attributes, int parentIndex)¶ Instantiates a new
DvBooleanWidget
Parameters:
Methods¶
-
public void
onToolTipViewClicked
(ToolTipView arg0)¶ See also:
com.nhaarman.supertooltips.ToolTipView.OnToolTipViewClickedListener.onToolTipViewClicked(com.nhaarman.supertooltips.ToolTipView)
-
protected void
replaceTooltip
(ToolTip tooltip)¶ See also:
it.crs4.most.ehrlib.widgets.DatatypeWidget.replaceTooltip(com.nhaarman.supertooltips.ToolTip)
-
public void
reset
()¶ See also:
it.crs4.most.ehrlib.widgets.DatatypeWidget.reset()
-
protected void
updateLabelsContent
()¶ See also:
it.crs4.most.ehrlib.widgets.DatatypeWidget.updateLabelsContent()
DvClusterWidget¶
-
public class
DvClusterWidget
extends DatatypeWidget<DvCluster>¶ This class represents a visual widget mapped on a
DvCluster
datatype.
Constructors¶
-
public
DvClusterWidget
(WidgetProvider provider, String name, String path, JSONObject attributes, int parentIndex)¶ Instantiate a new DvClusterWidget
Parameters:
DvCodedTextAsListWidget¶
-
public class
DvCodedTextAsListWidget
extends DatatypeWidget<DvCodedText>¶ This class represents a visual widget mapped on a
DvCodedText
datatype. It renders all the options of theDvCodedText
datatype in a ListView.
Constructors¶
-
public
DvCodedTextAsListWidget
(WidgetProvider provider, String name, String path, JSONObject attributes, int parentIndex)¶ Instantiates a new
DvCodedTextAsListWidget
Parameters: - provider – the widget provider
- name – the name of this widget
- path – the path of the
DvCodedText
mapped on this widget - attributes – the attributes of the
DvCodedText
mapped on this widget - parentIndex – the parent index
Methods¶
-
public void
onEhrDatatypeChanged
(DvCodedText datatype)¶ See also:
it.crs4.most.ehrlib.datatypes.EhrDatatypeChangeListener.onEhrDatatypeChanged(it.crs4.most.ehrlib.datatypes.EhrDatatype)
-
protected void
replaceTooltip
(ToolTip tooltip)¶ See also:
{@linkit.crs4.most.ehrlib.widgets.DatatypeWidget.replaceTooltip(com.nhaarman.supertooltips.ToolTip)}
-
public void
reset
()¶ See also:
it.crs4.most.ehrlib.widgets.DatatypeWidget.reset()
-
protected void
updateLabelsContent
()¶ See also:
it.crs4.most.ehrlib.widgets.DatatypeWidget.updateLabelsContent()
DvCodedTextWidget¶
-
public class
DvCodedTextWidget
extends DatatypeWidget<DvCodedText>¶ This class represents a visual widget mapped on a
DvCodedText
datatype. It renders all the options of theDvCodedText
datatype in a Combobox.
Constructors¶
-
public
DvCodedTextWidget
(WidgetProvider provider, String name, String path, JSONObject attributes, int parentIndex)¶ Instantiates a new
DvCodedTextWidget
Parameters: - provider – the widget provider
- name – the name of this widget
- path – the path of the
DvCodedText
mapped on this widget - attributes – the attributes of the
DvCodedText
mapped on this widget - parentIndex – the parent index
Methods¶
-
public void
onEhrDatatypeChanged
(DvCodedText datatype)¶ See also:
it.crs4.most.ehrlib.datatypes.EhrDatatypeChangeListener.onEhrDatatypeChanged(it.crs4.most.ehrlib.datatypes.EhrDatatype)
-
public void
reset
()¶ See also:
it.crs4.most.ehrlib.widgets.DatatypeWidget.reset()
DvQuantityWidget¶
-
public class
DvQuantityWidget
extends DatatypeWidget<DvQuantity>¶ This class represents a visual widget mapped on a
DvQuantity
datatype.
Fields¶
Constructors¶
-
public
DvQuantityWidget
(WidgetProvider provider, String name, String path, JSONObject attributes, int parentIndex)¶ Instantiates a new
DvQuantityWidget
Parameters: - provider – the widget provider
- name – the name of this widget
- path – the path of the
DvQuantity
mapped on this widget - attributes – the attributes of the
DvQuantity
mapped on this widget - parentIndex – the parent index
Methods¶
-
public void
onEhrDatatypeChanged
(DvQuantity datatype)¶ See also:
it.crs4.most.ehrlib.datatypes.EhrDatatypeChangeListener.onEhrDatatypeChanged(it.crs4.most.ehrlib.datatypes.EhrDatatype)
-
protected void
replaceTooltip
(ToolTip tooltip)¶ See also:
it.crs4.most.ehrlib.widgets.DatatypeWidget.replaceTooltip(com.nhaarman.supertooltips.ToolTip)
-
public void
reset
()¶ See also:
it.crs4.most.ehrlib.widgets.DatatypeWidget.reset()
-
protected void
updateLabelsContent
()¶ See also:
it.crs4.most.ehrlib.widgets.DatatypeWidget.updateLabelsContent()
DvTextWidget¶
-
public class
DvTextWidget
extends DatatypeWidget<DvText> implements ToolTipView.OnToolTipViewClickedListener¶ This class represents a visual widget mapped on a
DvText
datatype.
Constructors¶
-
public
DvTextWidget
(WidgetProvider provider, String name, String path, JSONObject attributes, int parentIndex)¶ Instantiates a new
DvTextWidget
Parameters:
Methods¶
-
public void
onToolTipViewClicked
(ToolTipView arg0)¶ See also:
com.nhaarman.supertooltips.ToolTipView.OnToolTipViewClickedListener.onToolTipViewClicked(com.nhaarman.supertooltips.ToolTipView)
-
protected void
replaceTooltip
(ToolTip tooltip)¶ See also:
it.crs4.most.ehrlib.widgets.DatatypeWidget.replaceTooltip(com.nhaarman.supertooltips.ToolTip)
-
public void
reset
()¶ See also:
it.crs4.most.ehrlib.widgets.DatatypeWidget.reset()
-
protected void
updateLabelsContent
()¶ See also:
it.crs4.most.ehrlib.widgets.DatatypeWidget.updateLabelsContent()
InnerArchetypeWidget¶
-
public class
InnerArchetypeWidget
extends DatatypeWidget<InnerArchetype>¶ This class represents a visual widget mapped on a
InnerArchetype
datatype.
Constructors¶
-
public
InnerArchetypeWidget
(WidgetProvider provider, String name, String path, JSONObject attributes, int parentIndex)¶ Instantiate a new InnerArchetypeWidget
Parameters: - provider – the widget provider
- name – the name of this widget
- path – the path of the
InnerArchetype
mapped on this widget - attributes – the attributes of the
InnerArchetype
mapped on this widget - parentIndex – the parent index of this widget
Methods¶
-
public void
onEhrDatatypeChanged
(InnerArchetype datatype)¶ See also:
it.crs4.most.ehrlib.datatypes.EhrDatatypeChangeListener.onEhrDatatypeChanged(it.crs4.most.ehrlib.datatypes.EhrDatatype)
-
public void
reset
()¶ See also:
it.crs4.most.ehrlib.widgets.DatatypeWidget.reset()
it.crs4.most.ehrlib.widgets.filters¶
DvQuantityFilter¶
-
public class
DvQuantityFilter
¶ This class is internally used by the
DvQuantityWidget
.
Fields¶
Constructors¶
-
public
DvQuantityFilter
(EditText editText, TextView validityTextView, DvQuantity dvQuantity)¶ Instantiates a new dv quantity filter.
Parameters: - editText – the edit text
- validityTextView – the validity text view
- dvQuantity – the dv quantity
Examples¶
All the following examples are located in the folder client/android/examples/ of the Most-Report repository.
- EhrLibArchetypeViewerExample This example shows you:
- how to load an Archetype into an Activity, according to the provided json schema files
- how to read, edit and save the content of the Archetype
- how to get textual informations about any item of the archetype
- how to read the json file containing the current content of the archetype
- EhrTemplateViewerExample This example explains you:
- how to load a template of archetypes into an Activity, according to the provided json schema files
- how to read, edit and save the content of the Archetypes of the template
- how to get textual informations about any item of each archetype of the template
- NestedArchetypeActivityExample This example contains all the features of the EhrTemplateViewerExample example, and in addition, shows you:
- how to read the json file containing the current content of each archetype of the template
- how the library supports archetypes including other archetypes inside it
- For running the Android examples, open your preferred IDE (e.g Eclipse) and do the following:
- Import the EhrLib project library (located in the folder client/android/src/EhrLib of the Most-Report Repository)
- Import the `SuperTooltips Lib <https://github.com/nhaarman/supertooltips/>`_library and add it as a dependency of the EhrLib project
- Import your preferred Android project example located in the android/examples folder and add the EhrLib project as Library reference
- Build the projects
- Deploy the application on an android device or emulator
License¶
/*!
* Project MOST - Moving Outcomes to Standard Telemedicine Practice
* http://most.crs4.it/
*
* Copyright 2014, CRS4 srl. (http://www.crs4.it/)
* Dual licensed under the MIT or GPL Version 2 licenses.
* See license-GPLv2.txt or license-MIT.txt
*/
Authors¶
Code author: Stefano Leone Monni <stefano.monni@crs4.it>
Code author: Cecilia Mascia <cmascia@crs4.it>
Code author: Francesco Cabras <francesco.cabras@crs4.it>