Skip to content

Commit

Permalink
Merge pull request #112 from OpenSRP/fix-offline-login
Browse files Browse the repository at this point in the history
Fix offline login
  • Loading branch information
ellykits authored Mar 26, 2021
2 parents 3b1a443 + 94bca12 commit e0d3c5d
Show file tree
Hide file tree
Showing 14 changed files with 352 additions and 108 deletions.
162 changes: 151 additions & 11 deletions opensrp-path-zeir/src/main/assets/ec_client_fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
"field": "identifiers.zeir_id"
}
},
{
"column_name": "opensrp_id",
"type": "Client",
"json_mapping": {
"field": "identifiers.ZEIR_ID"
}
},
{
"column_name": "opensrp_id",
"type": "Client",
Expand Down Expand Up @@ -66,6 +73,20 @@
"field": "identifiers.zeir_id"
}
},
{
"column_name": "zeir_id",
"type": "Client",
"json_mapping": {
"field": "identifiers.ZEIR_ID"
}
},
{
"column_name": "zeir_id",
"type": "Client",
"json_mapping": {
"field": "identifiers.M_ZEIR_ID"
}
},
{
"column_name": "dod",
"type": "Client",
Expand Down Expand Up @@ -135,26 +156,25 @@
}
},
{
"column_name": "mother_guardian_number",
"column_name": "mother_guardian_nrc",
"type": "Client",
"json_mapping": {
"field": "attributes.mother_guardian_number"
"field": "attributes.NRC_Number"
}
},
{
"column_name": "chw_name",
"type": "Event",
"column_name": "mother_guardian_number",
"type": "Client",
"json_mapping": {
"field": "obs.fieldCode",
"concept": "chw_name"
"field": "attributes.mother_guardian_number"
}
},
{
"column_name": "chw_phone_number",
"column_name": "mother_guardian_number",
"type": "Event",
"json_mapping": {
"field": "obs.fieldCode",
"concept": "chw_phone_number"
"concept": "159635AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
},
{
Expand Down Expand Up @@ -197,20 +217,42 @@
"field": "attributes.child_birth_certificate"
}
},
{
"column_name": "child_birth_certificate",
"type": "Client",
"json_mapping": {
"field": "attributes.Child_Birth_Certificate"
}
},
{
"column_name": "child_register_card_number",
"type": "Client",
"json_mapping": {
"field": "attributes.child_register_card_number"
}
},
{
"column_name": "child_register_card_number",
"type": "Client",
"json_mapping": {
"field": "attributes.Child_Register_Card_Number"
}
},
{
"column_name": "first_health_facility_contract",
"type": "Client",
"json_mapping": {
"field": "attributes.first_health_facility_contract"
}
},
{
"column_name": "first_health_facility_contract",
"type": "Event",
"json_mapping": {
"field": "obs.fieldCode",
"concept": "163260AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
},
{
"column_name": "place_of_birth",
"type": "Client",
Expand All @@ -225,32 +267,63 @@
"field": "attributes.father_guardian_name"
}
},
{
"column_name": "father_guardian_name",
"type": "Event",
"json_mapping": {
"field": "obs.fieldCode",
"concept": "1594AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
},
{
"column_name": "father_nrc_number",
"type": "Client",
"json_mapping": {
"field": "attributes.father_nrc_number"
}
},
{
"column_name": "father_nrc_number",
"type": "Client",
"json_mapping": {
"field": "attributes.Father_NRC_Number"
}
},
{
"column_name": "place_of_birth",
"type": "Client",
"json_mapping": {
"field": "attributes.place_of_birth"
}
},
{
"column_name": "place_of_birth",
"type": "Event",
"json_mapping": {
"field": "obs.fieldCode",
"concept": "1572AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
},
{
"column_name": "home_facility",
"type": "Client",
"json_mapping": {
"field": "addresses.address1"
"field": "addresses.address5"
}
},
{
"column_name": "birth_facility_name",
"type": "Client",
"json_mapping": {
"field": "addresses.address2"
"field": "addresses.address6"
}
},
{
"column_name": "birth_facility_name",
"type": "Event",
"json_mapping": {
"field": "obs.fieldCode",
"concept": "163531AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
},
{
Expand All @@ -260,6 +333,14 @@
"field": "attributes.birth_facility_name_other"
}
},
{
"column_name": "birth_facility_name_other",
"type": "Event",
"json_mapping": {
"field": "obs.fieldCode",
"concept": "160632AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
},
{
"column_name": "residential_area",
"type": "Client",
Expand All @@ -268,33 +349,62 @@
}
},
{
"column_name": "child_zone",
"column_name": "residential_area",
"type": "Client",
"json_mapping": {
"field": "addresses.address3"
}
},
{
"column_name": "child_zone",
"type": "Client",
"json_mapping": {
"field": "addresses.address4"
}
},
{
"column_name": "residential_address",
"type": "Client",
"json_mapping": {
"field": "attributes.residential_address"
}
},
{
"column_name": "residential_address",
"type": "Client",
"json_mapping": {
"field": "addresses.address2"
}
},
{
"column_name": "physical_landmark",
"type": "Client",
"json_mapping": {
"field": "attributes.physical_landmark"
}
},
{
"column_name": "physical_landmark",
"type": "Client",
"json_mapping": {
"field": "addresses.address1"
}
},
{
"column_name": "pmtct_status",
"type": "Client",
"json_mapping": {
"field": "attributes.pmtct_status"
}
},
{
"column_name": "pmtct_status",
"type": "Event",
"json_mapping": {
"field": "obs.fieldCode",
"concept": "1396AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
},
{
"column_name": "inactive",
"type": "Client",
Expand Down Expand Up @@ -329,6 +439,36 @@
"json_mapping": {
"field": "attributes.dateRemoved"
}
},
{
"column_name": "chw_name",
"type": "Event",
"json_mapping": {
"field": "obs.fieldCode",
"concept": "chw_name"
}
},
{
"column_name": "chw_name",
"type": "Client",
"json_mapping": {
"field": "attributes.CHW_Name"
}
},
{
"column_name": "chw_phone_number",
"type": "Event",
"json_mapping": {
"field": "obs.fieldCode",
"concept": "chw_phone_number"
}
},
{
"column_name": "chw_phone_number",
"type": "Client",
"json_mapping": {
"field": "attributes.CHW_Phone_Number"
}
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"key": "home_facility",
"openmrs_entity_parent": "usual_residence",
"openmrs_entity": "person_address",
"openmrs_entity_id": "address1",
"openmrs_entity_id": "address5",
"openmrs_data_type": "text",
"type": "spinner",
"sub_type": "location",
Expand Down Expand Up @@ -378,7 +378,7 @@
"key": "birth_facility_name",
"openmrs_entity_parent": "usual_residence",
"openmrs_entity": "person_address",
"openmrs_entity_id": "address2",
"openmrs_entity_id": "address6",
"openmrs_data_type": "text",
"type": "spinner",
"sub_type": "location",
Expand Down Expand Up @@ -432,7 +432,7 @@
"key": "child_zone",
"openmrs_entity_parent": "usual_residence",
"openmrs_entity": "person_address",
"openmrs_entity_id": "address3",
"openmrs_entity_id": "address4",
"openmrs_data_type": "text",
"type": "spinner",
"sub_type": "location",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.smartregister.client.utils.domain.Form;
import org.smartregister.pathzeir.R;
import org.smartregister.pathzeir.fragment.ChildRegistrationDataFragment;
import org.smartregister.pathzeir.util.AppConstants;
import org.smartregister.pathzeir.util.AppJsonFormUtils;
import org.smartregister.pathzeir.util.AppUtils;
import org.smartregister.util.FormUtils;
Expand All @@ -42,6 +41,8 @@

import timber.log.Timber;

import static org.smartregister.pathzeir.util.FormUtils.obtainUpdatedForm;

/**
* Created by ndegwamartin on 06/03/2019.
*/
Expand Down Expand Up @@ -153,7 +154,6 @@ protected void navigateToRegisterActivity() {

@Override
public void startFormActivity(String formData) {
String formDataString = formData;
if (StringUtils.isNotBlank(formData)) {
try {
Intent intent;
Expand All @@ -171,14 +171,14 @@ public void startFormActivity(String formData) {
form.setActionBarBackground(R.color.actionbar);
form.setNavigationBackground(R.color.primary_dark);
intent = new Intent(this, JsonWizardFormActivity.class);
formDataString = obtainUpdatedForm(formJson);
} else {
form.setWizard(false);
form.setHideSaveLabel(true);
form.setNextLabel("");
intent = new Intent(this, org.smartregister.child.util.Utils.metadata().childFormActivity);
}

String formDataString = obtainUpdatedForm(formJson, childDetails, getContext());
intent.putExtra(JsonFormConstants.JSON_FORM_KEY.FORM, form);
intent.putExtra(JsonFormConstants.JSON_FORM_KEY.JSON, formDataString);
intent.putExtra(JsonFormConstants.PERFORM_FORM_TRANSLATION, true);
Expand All @@ -189,20 +189,6 @@ public void startFormActivity(String formData) {
}
}

private String obtainUpdatedForm(JSONObject formJson) throws JSONException {
JSONArray fields = JsonFormUtils.fields(formJson);
for (int i = 0; i < fields.length(); i++) {
JSONObject field = fields.getJSONObject(i);
if (field != null && field.getString(JsonFormConstants.TYPE).equalsIgnoreCase(JsonFormConstants.DATE_PICKER)
&& !childDetails.getDetails().isEmpty() && childDetails.getDetails().containsKey(AppConstants.KeyConstants.DOB)) {
Date date = Utils.dobStringToDate(childDetails.getDetails().get(AppConstants.KeyConstants.DOB));
field.put(JsonFormConstants.MIN_DATE, new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()).format(date));
field.put(JsonFormConstants.MAX_DATE, AppConstants.KeyConstants.TODAY);
}
}
return formJson.toString();
}

@Override
protected String getReportDeceasedMetadata() {
try {
Expand Down
Loading

0 comments on commit e0d3c5d

Please sign in to comment.