Skip to content

Commit

Permalink
updated the main contact activity for the optibp widget
Browse files Browse the repository at this point in the history
  • Loading branch information
junaidwarsivd committed Mar 31, 2022
1 parent 7190e2c commit 70bb18d
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
import com.google.gson.reflect.TypeToken;
import com.vijay.jsonwizard.constants.JsonFormConstants;
import com.vijay.jsonwizard.rules.RuleConstant;
import com.vijay.jsonwizard.utils.FormUtils;

import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.smartregister.anc.library.AncLibrary;
import org.smartregister.anc.library.R;
import org.smartregister.anc.library.constants.ANCJsonFormConstants;
import org.smartregister.anc.library.contract.ContactContract;
import org.smartregister.anc.library.domain.Contact;
import org.smartregister.anc.library.model.PartialContact;
Expand Down Expand Up @@ -55,6 +57,7 @@ public class MainContactActivity extends BaseContactActivity implements ContactC
private List<String> globalValueFields = new ArrayList<>();
private List<String> editableFields = new ArrayList<>();
private String baseEntityId;
private String womanOpenSRPId;
private String womanAge = "";
private final List<String> invisibleRequiredFields = new ArrayList<>();
private final String[] contactForms = new String[]{ConstantsUtils.JsonFormUtils.ANC_QUICK_CHECK, ConstantsUtils.JsonFormUtils.ANC_PROFILE,
Expand All @@ -72,6 +75,7 @@ protected void onResume() {
(Map<String, String>) getIntent().getSerializableExtra(ConstantsUtils.IntentKeyUtils.CLIENT_MAP);
if (womanDetails != null && womanDetails.size() > 0) {
womanAge = String.valueOf(Utils.getAgeFromDate(womanDetails.get(DBConstantsUtils.KeyUtils.DOB)));
womanOpenSRPId = womanDetails.get(DBConstantsUtils.KeyUtils.ANC_ID);
}
if (!presenter.baseEntityIdExists()) {
presenter.setBaseEntityId(baseEntityId);
Expand Down Expand Up @@ -657,6 +661,16 @@ private void updateDefaultValues(JSONArray stepArray, int i, JSONObject fieldObj
}
}
}

if (fieldObject.getString(JsonFormConstants.KEY).equals(ANCJsonFormConstants.KeyConstants.OPTIBP_BUTTON)
|| fieldObject.getString(JsonFormConstants.KEY).equals(ANCJsonFormConstants.KeyConstants.OPTIBP_BUTTON_SECOND)) {
if (fieldObject.has(JsonFormConstants.OptibpConstants.OPTIBP_KEY_DATA)) {
fieldObject.remove(JsonFormConstants.OptibpConstants.OPTIBP_KEY_DATA);
}
JSONObject optiBPData = FormUtils.createOptiBPDataObject(baseEntityId, womanOpenSRPId);
fieldObject.put(JsonFormConstants.OptibpConstants.OPTIBP_KEY_DATA, optiBPData);
}

}

private void getValueMap(JSONObject object) throws JSONException {
Expand Down

0 comments on commit 70bb18d

Please sign in to comment.