Skip to content

Commit

Permalink
Merge pull request #1530 from opensrp/fix-prefix-ec-member
Browse files Browse the repository at this point in the history
Fix population of prefix field during edit of member registration
  • Loading branch information
Rkareko authored Oct 8, 2021
2 parents 4c2856f + bba9aa2 commit 320b6bc
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions opensrp-reveal/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ android {
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
resValue "string", 'opensrp_base_url', '"https://reveal-zm.smartregister.org/opensrp/"'
buildConfigField "Integer", "DATABASE_VERSION", '14'
buildConfigField "Integer", "DATABASE_VERSION", '15'
buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '250'
buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '100'
buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2'
Expand All @@ -165,7 +165,7 @@ android {

debug {
resValue "string", 'opensrp_base_url', '"https://reveal-stage.smartregister.org/opensrp/"'
buildConfigField "Integer", "DATABASE_VERSION", '14'
buildConfigField "Integer", "DATABASE_VERSION", '15'
buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '250'
buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '100'
buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2'
Expand Down
8 changes: 8 additions & 0 deletions opensrp-reveal/src/main/assets/ec_client_fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,14 @@
"concept": "159635AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
},
{
"column_name": "prefix",
"type": "Event",
"json_mapping": {
"field": "obs.fieldCode",
"concept": "Prefix"
}
},
{
"column_name": "occupation",
"type": "Event",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.smartregister.reveal.util.Constants;
import org.smartregister.reveal.util.Constants.DatabaseKeys;
import org.smartregister.reveal.util.Country;
import org.smartregister.reveal.util.FamilyConstants;
import org.smartregister.reveal.util.FamilyConstants.EventType;
import org.smartregister.reveal.util.Utils;
import org.smartregister.util.DatabaseMigrationUtils;
Expand Down Expand Up @@ -146,6 +147,9 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
case 14:
upgradeToVersion14(db);
break;
case 15:
upgradeToVersion15(db);
break;
default:
break;
}
Expand Down Expand Up @@ -309,6 +313,12 @@ private void upgradeToVersion14(SQLiteDatabase db) {
db.execSQL(String.format("UPDATE %s set %s = ? WHERE %s like ? OR %s not like ?", STRUCTURE_TABLE, DatabaseKeys.TASK_SYNC_STATUS, DatabaseKeys.GEOJSON, DatabaseKeys.GEOJSON), new String[]{BaseRepository.TYPE_Created, "%serverVersion\":0%", "%serverVersion%"});
}

private void upgradeToVersion15(SQLiteDatabase db) {
if (!isColumnExists(db, FAMILY_MEMBER, FamilyConstants.DatabaseKeys.PREFIX)) {
db.execSQL(String.format("ALTER TABLE %s ADD COLUMN %s VARCHAR", FAMILY_MEMBER, FamilyConstants.DatabaseKeys.PREFIX));
}
}

private void clientProcessEvents(List<String> eventTypes) {
//client process events after 5 seconds so that get calls to getDatabase return
new Timer().schedule(new TimerTask() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ interface DatabaseKeys {
String SLEEPS_OUTDOORS = "sleeps_outdoors";
String PHONE_NUMBER = "phone_number";
String IS_FAMILY_HEAD = "is_family_head";
String PREFIX = "prefix";
}

interface FormKeys {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ private void initMap() {
jsonDbMap.put(DatabaseKeys.SLEEPS_OUTDOORS, DatabaseKeys.SLEEPS_OUTDOORS);
jsonDbMap.put(DatabaseKeys.PHONE_NUMBER, DatabaseKeys.PHONE_NUMBER);
jsonDbMap.put(FormKeys.SURNAME, LAST_NAME);
jsonDbMap.put(DatabaseKeys.PREFIX, DatabaseKeys.PREFIX);

}

Expand Down

0 comments on commit 320b6bc

Please sign in to comment.