Skip to main content

Android MeData Service

Functions

syncMeDataDefinitions

suspend fun syncMeDataDefinitions(): Result<Unit>

Synchronizes all MeData definitions with the Orchestrator and updates local storage.

Parameters: None.

syncMeDataDefinitions

fun syncMeDataDefinitions(
onSuccess: () -> Unit,
onError: ((Throwable) -> Unit)? = null
): Unit

Synchronizes all MeData definitions with the Orchestrator and updates local storage.

Parameters:

  • onSuccess: () -> Unit — Called when synchronization completes.
  • onError: ((Throwable) -> Unit)? — Called when an error occurs.

getMeDataDefinitions

suspend fun getMeDataDefinitions(): Result<List<MeDataDefinition>>

Retrieves all available MeData definitions from local storage.

Parameters: None.

getMeDataDefinitions

fun getMeDataDefinitions(
onSuccess: (List<MeDataDefinition>) -> Unit,
onError: ((Throwable) -> Unit)? = null
): List<MeDataDefinition>?

Retrieves all available MeData definitions from local storage.

Parameters:

  • onSuccess: (List<MeDataDefinition>) -> Unit — Called with the list of definitions.
  • onError: ((Throwable) -> Unit)? — Called when an error occurs.

getMeDataDefinition

suspend fun getMeDataDefinition(name: String): Result<MeDataDefinition?>

Retrieves a single MeData definition by its name.

Parameters:

  • name: String — MeData definition name.

getMeDataDefinition

fun getMeDataDefinition(
name: String,
onSuccess: (MeDataDefinition?) -> Unit,
onError: ((Throwable) -> Unit)? = null
): MeDataDefinition?

Retrieves a single MeData definition by its name.

Parameters:

  • name: String — MeData definition name.
  • onSuccess: (MeDataDefinition?) -> Unit — Called with the definition or null.
  • onError: ((Throwable) -> Unit)? — Called when an error occurs.

getMeDataCategories

suspend fun getMeDataCategories(): Result<List<MeDataCategory>?>

Returns the list of MeData categories used for grouping and UI organization.

Parameters: None.

getMeDataCategories

fun getMeDataCategories(
onSuccess: (List<MeDataCategory>?) -> Unit,
onError: ((Throwable) -> Unit)? = null
): List<MeDataCategory>?

Returns the list of MeData categories used for grouping and UI organization.

Parameters:

  • onSuccess: (List<MeDataCategory>?) -> Unit — Called with the category list or null.
  • onError: ((Throwable) -> Unit)? — Called when an error occurs.

getMeDataDefinitionsByCategory

suspend fun getMeDataDefinitionsByCategory(name: String): Result<List<MeDataDefinition>?>

Retrieves MeData definitions that belong to the specified category.

Parameters:

  • name: String — Category name.

getMeDataDefinitionsByCategory

fun getMeDataDefinitionsByCategory(
name: String,
onSuccess: (List<MeDataDefinition>?) -> Unit,
onError: ((Throwable) -> Unit)? = null
): List<MeDataDefinition>?

Retrieves MeData definitions that belong to the specified category.

Parameters:

  • name: String — Category name.
  • onSuccess: (List<MeDataDefinition>?) -> Unit — Called with the definitions or null.
  • onError: ((Throwable) -> Unit)? — Called when an error occurs.

getMeDataRecords

suspend fun getMeDataRecords(name: String): Result<List<MeDataRecord>?>

Retrieves all recorded values for the given MeData definition.

Parameters:

  • name: String — MeData definition name.

getMeDataRecords

fun getMeDataRecords(
name: String,
onSuccess: (List<MeDataRecord>?) -> Unit,
onError: ((Throwable) -> Unit)? = null
): List<MeDataRecord>?

Retrieves all recorded values for the given MeData definition.

Parameters:

  • name: String — MeData definition name.
  • onSuccess: (List<MeDataRecord>?) -> Unit — Called with the records or null.
  • onError: ((Throwable) -> Unit)? — Called when an error occurs.

getLastMeDataRecord

suspend fun getLastMeDataRecord(name: String): Result<MeDataRecord?>

Returns the most recent MeData record for the specified definition.

Parameters:

  • name: String — MeData definition name.

getLastMeDataRecord

fun getLastMeDataRecord(
name: String,
onSuccess: (MeDataRecord?) -> Unit,
onError: ((Throwable) -> Unit)? = null
): MeDataRecord?

Returns the most recent MeData record for the specified definition.

Parameters:

  • name: String — MeData definition name.
  • onSuccess: (MeDataRecord?) -> Unit — Called with the latest record or null.
  • onError: ((Throwable) -> Unit)? — Called when an error occurs.

saveMeDataRecord

suspend fun saveMeDataRecord(name: String, values: Any?): Result<Unit>

Saves a new MeData record for the specified definition.

Parameters:

  • name: String — MeData definition name.
  • values: Any? — Encoded record value(s), must match the definition's value type.

saveMeDataRecord

fun saveMeDataRecord(
name: String,
values: Any?,
onSuccess: () -> Unit,
onError: ((Throwable) -> Unit)? = null
): Unit

Saves a new MeData record for the specified definition.

Parameters:

  • name: String — MeData definition name.
  • values: Any? — Encoded record value(s), must match the definition's value type.
  • onSuccess: () -> Unit — Called when the record is saved successfully.
  • onError: ((Throwable) -> Unit)? — Called when an error occurs.

collectMeData

suspend fun collectMeData(
context: Context,
meDataDefinitionNames: List<String>
): Result<Map<String, Any?>>

Collects the requested MeData items and returns a key–value map.

Parameters:

  • context: Context — Android context.
  • meDataDefinitionNames: List<String> — List of MeData definition names to collect.

collectMeData

fun collectMeData(
context: Context,
meDataDefinitionNames: List<String>,
onSuccess: (Map<String, Any?>) -> Unit,
onError: ((Throwable) -> Unit)? = null
): Map<String, Any?>

Collects the requested MeData items and returns a key–value map.

Parameters:

  • context: Context — Android context.
  • meDataDefinitionNames: List<String> — List of MeData definition names to collect.
  • onSuccess: (Map<String, Any?>) -> Unit — Called with a map of definition name to collected value.
  • onError: ((Throwable) -> Unit)? — Called when an error occurs.

collectAllNatives

suspend fun collectAllNatives(context: Context): Result<Unit>

Collects all native MeData items.

Parameters:

  • context: Context — Android context.

Classes

MeDataDefinition

data class MeDataDefinition(
val id: UUID,
val name: String,
val text: String,
val source: String,
val script: Script? = null,
val valueDef: ValueDefinition? = null,
val category: MeDataCategory? = null,
val iconUrl: String? = null,
val description: String? = null,
val sharable: Boolean? = false,
val hidden: Boolean? = false,
val storageSettings: MeDataStorageSettings? = MeDataStorageSettings(),
val question: Question? = null
)

MeDataStorageSettings

data class MeDataStorageSettings(
val onlyIfChanged: Boolean? = false,
val longLimit: Int? = 100
)

DataType

enum class DataType(val type: String?) {
STRING("STRING"),
NUMBER("NUMBER"),
BOOLEAN("BOOLEAN"),
DATETIME("DATETIME"),
IMAGE("IMAGE"),
VIDEO("VIDEO"),
OBJECT("OBJECT"),
UNKNOWN(null)
}

EnumeratedValue

data class EnumeratedValue(
val id: UUID,
val name: String,
val text: String,
val description: String? = null,
val imageUrl: String? = null
)

EnumeratedValueConstraints

data class EnumeratedValueConstraints(
val allowNone: Boolean? = false,
val allowIdk: Boolean? = false,
val allowNa: Boolean? = false,
val allowOther: Boolean? = false
)

MeDataCategory

data class MeDataCategory(
val id: String,
val text: String,
val name: String,
val iconUrl: String? = null,
val description: String? = null
)

MeDataType

enum class MeDataType(val type: String) {
NATIVE("NATIVE"),
QA_BASED("QA"),
SCRIPTED("SCRIPT"),
INFERRED("INFERRED"),
UNKNOWN("")
}

Question

data class Question(
var id: UUID,
var name: String,
var text: String,
var description: String? = null,
var imageUrl: String? = null
)

QuestionDefinition

data class QuestionDefinition(
var valueDef: ValueDefinition,
var question: Question,
var isMeData: Boolean,
var contextKey: String
)

ValueDefinition

data class ValueDefinition(
val type: String,
val constraints: ValueTypeConstraints? = null,
val multivalued: Boolean? = false,
val multiValueConstraints: MultiValueConstraints? = null,
val enumerated: Boolean? = false,
val enumeratedValues: List<EnumeratedValue>? = listOf(),
val enumeratedValueConstraints: EnumeratedValueConstraints? = null
)

ValueTypeConstraints

data class ValueTypeConstraints(
val minValue: Int? = null,
val maxValue: Int? = null,
val regex: String? = null,
val allowCamera: Boolean? = false,
val allowGallery: Boolean? = false
)

MultiValueConstraints

data class MultiValueConstraints(
val minValue: Int,
val maxValue: Int
)

MeData

data class MeData(
val id: UUID,
val definitionName: String,
val records: List<MeDataRecord>
)

MeDataRecord

data class MeDataRecord(
val id: UUID,
val meDataDefinitionId: String,
val notAvailable: Boolean,
val date: Double,
val values: List<MeDataValue>
)

MeDataValue

data class MeDataValue(
val id: UUID,
val evName: String?,
val value: String
)