migrate

suspend fun migrate()


suspend fun migrate(migrationConfigs: List<MigrationConfig>?, previousVersion: Int)

This function is responsible for migrating data by updating the resources based on the provided data queries and key-value configurations. It retrieves the latest migration version from shared preferences and performs the migration only if the new version is greater than or equal to the latest migration version.

This function uses JSONPath instead of FHIRPath because JSONPath allows setting of values for a given path. The syntax is almost similar to FHIRPath with a few exceptions. JSONPath uses the '$' to refer to the root of the JSON unlike FHIRPath that uses the ResourceType.The implementation uses both '$' and ' ResourceType', the ResourceType will be replaced with a dollar sign at runtime.

Examples: Given this Patient object:

{
"resourceType": "Patient",
"id": "example",
"name": [
{
"use": "official",
"given": [
"Peter",
"James"
],
"family": "Chalmers"
}
],
"birthDate": "1974-12-25",
"deceased": {
"boolean": false
},
"active": true,
"gender": "male"
}

Valid expressions (format in key, value -> description) include:

"$.name[0].use", "casual" -> Update the first name usage from "official" to "casual"
"Patient.gender", "male" -> Update the gender from "female" to "male"
"$.birthDate", "1996-12-32" -> Update the birth date from "1974-12-25" to "1996-12-32"