Models

This section gives you an overview of data models used by the KMP (Android/Java) SDK.

Record

The smallest unit of data that can be stored and referenced by the Data4Life platform is called a record. A record contains the following:

  • Payload of either medical data in the form of an encrypted FHIR resource (Fast Healthcare Interoperability Resources) or generic data

  • Metadata that’s needed to properly associate a record with a user

  • Annotations Custom tags saved as strings that the user can use in order to filter or identify the existing resources.

Payload

A record payload can contain:

  1. Anything that can be modeled by a FHIR (STU3 or R4) resource. From a single vital sign measurement, such as body temperature, to a complex document linking to or containing multiple attachments and measuring many megabytes in size.

  2. Generic Data (called App Data)

For these cases we have three types of records: Fhir3Record, Fhir4Record and DataRecord.

FHIR restrictions

FHIR payload must be of type DomainResource.

FHIR References are not actively resolved and stay as they are. Meaning they are not available in PHDP. In case referenced data points should be available, we recommend containing them in the FHIR resource, see here. Otherwise, you need to maintain the FHIR references within the PHDP manually.

FHIR payload that contains Attachment is limited to following file formats:

  • JPEG - including JPEG/JFIF

  • PNG – Portable Network Graphics

  • TIFF – Tagged Image File Format

  • DCM – Digital Imaging and Communications in Medicine

  • PDF – Portable Document Format

and size is limited to 20 MB.

Attachment.data needs to be base64 encoded.

Fhir3Record

The Fhir3Record model:

data class Fhir3Record<T : Fhir3Resource>(
    override val identifier: String,
    override val resource: T,
    override val meta: ModelContract.Meta,
    override val annotations: Annotations
) : CallContract.Record<T>, Record()

Fhir4Record

The Fhir4Record model:

class Fhir4Record<T : Fhir4Resource>(
    override val identifier: String,
    override val resource: T,
    override val meta: ModelContract.Meta,
    override val annotations: Annotations
) : CallContract.Record<T>, Record()

Data restrictions

Resource type is limited to ByteArray and needs to be base64 encoded.

Size is limited to 1 MB.

DataRecord

The DataRecord model:

data class DataRecord<T : DataContract.Resource>(
    override val identifier: String,
    override val resource: T,
    override val meta: ModelContract.Meta,
    override val annotations: Annotations
) : CallContract.Record<T>, Record()

Metadata

The Metadata data model holds read-only information about records.

interface Meta : Serializable {
    val createdDate: LocalDate
    val updatedDate: LocalDateTime
    val status: RecordStatus
}

Status can be active, pending deletion or deleted.

enum class RecordStatus(val id: String) {
    Active("Active"),
    Pending("Pending"),
    Deleted("Deleted")
}

Annotations

Annotations are saved as encrypted strings alongside the record to help filter or identify existing records.

Custom

Custom annotations could be freely selected to help identify your own data points. It is a good practise to prepend the annotation with a namespace to avoid name collisions.

  • The annotations cannot contain empty strings.

  • Uppercase characters will always be lowercased, due to internal requirements. So you should only use lowercase.

System

The system additionally manages its own set of annotations, which could be used to identify records.

  • resource type: is it a FHIR 3 Observation or FHIR 4 Observation or data record

  • version: version of FHIR used (not supported for DataRecord)

  • updatedAt: date of update

  • clientId: which client last changed the data, when new Record created clientId is set as owner

  • partnerId: which partner last changed the data, when new Record created partnerId is set as owner