Skip to content

Commit

Permalink
WD|Edit Form Name to load #4
Browse files Browse the repository at this point in the history
  • Loading branch information
baksosapi committed Nov 16, 2017
1 parent b1dd497 commit f042d4c
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
import butterknife.ButterKnife;
import util.BidanFormUtils;

import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KARTU_IBU_ANC_CLOSE;
import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KARTU_IBU_ANC_REGISTRATION;
import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KARTU_IBU_ANC_RENCANA_PERSALINAN;
import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KARTU_IBU_ANC_VISIT;
import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KARTU_IBU_ANC_VISIT_INTEGRASI;
import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KARTU_IBU_ANC_VISIT_LABTEST;
import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KOHORT_PNC_REGISTRATION;

public class KANCSmartRegisterActivity extends SecuredNativeSmartRegisterActivity implements
LocationSelectorDialogFragment.OnLocationSelectedListener, DisplayFormListener{

Expand Down Expand Up @@ -174,17 +182,6 @@ public void saveFormSubmission(String formSubmission, String id, String formName
context().formSubmissionRouter().handleSubmission(submission, formName);
switchToBaseFragment(formSubmission); // Unnecessary!! passing on data

if(formName.equals("registrasi_ibu")) {
Log.d(TAG, "saveFormSubmission: it was registrasi_ibu form");
// FieldOverrides fieldOverrides = new FieldOverrides(combined.toString());

fieldOverrides.put("ibuCaseId",submission.entityId());
FieldOverrides fo = new FieldOverrides(fieldOverrides.toString());

activatingOtherForm("registrasi_anak", null, fo.getJSONString());
/// activatingForm("registrasi_anak", null, fo.getJSONString());
}

//end capture flurry log for FS
String end = timer.format(new Date());
Map<String, String> FS = new HashMap<String, String>();
Expand All @@ -199,8 +196,6 @@ public void saveFormSubmission(String formSubmission, String id, String formName
e.printStackTrace();
}



}

public void activatingOtherForm(final String formName, final String entityId, final String metaData) {
Expand Down Expand Up @@ -245,7 +240,7 @@ public void OnLocationSelected(String locationJSONString) {

if (combined != null) {
FieldOverrides fieldOverrides = new FieldOverrides(combined.toString());
startFormActivity("registrasi_ibu", null, fieldOverrides.getJSONString());
startFormActivity(KARTU_IBU_ANC_REGISTRATION, null, fieldOverrides.getJSONString());
}
}

Expand Down Expand Up @@ -389,10 +384,13 @@ public void onBackPressed() {

private String[] buildFormNameList(){
List<String> formNames = new ArrayList<String>();
formNames.add("registrasi_ibu");
formNames.add("registrasi_anak");
formNames.add("close_form");
formNames.add("kohort_bayi_immunization");
formNames.add(KARTU_IBU_ANC_VISIT);
formNames.add(KARTU_IBU_ANC_VISIT_INTEGRASI);
formNames.add(KARTU_IBU_ANC_VISIT_LABTEST);
formNames.add(KARTU_IBU_ANC_RENCANA_PERSALINAN);
formNames.add(KOHORT_PNC_REGISTRATION);
formNames.add(KARTU_IBU_ANC_CLOSE);

return formNames.toArray(new String[formNames.size()]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
import butterknife.ButterKnife;
import util.BidanFormUtils;

import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KOHORT_CHILD_REGISTRATION;
import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KARTU_IBU_ANC_CLOSE;
import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KARTU_IBU_ANC_RENCANA_PERSALINAN;
import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KARTU_IBU_ANC_VISIT;
import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KARTU_IBU_ANC_VISIT_INTEGRASI;
import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KARTU_IBU_ANC_VISIT_LABTEST;
import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KOHORT_PNC_REGISTRATION;

public class KChildSmartRegisterActivity extends SecuredNativeSmartRegisterActivity implements
LocationSelectorDialogFragment.OnLocationSelectedListener, DisplayFormListener{

Expand Down Expand Up @@ -175,17 +183,6 @@ public void saveFormSubmission(String formSubmission, String id, String formName
context().formSubmissionRouter().handleSubmission(submission, formName);
switchToBaseFragment(formSubmission); // Unnecessary!! passing on data

if(formName.equals("registrasi_ibu")) {
Log.d(TAG, "saveFormSubmission: it was registrasi_ibu form");
// FieldOverrides fieldOverrides = new FieldOverrides(combined.toString());

fieldOverrides.put("ibuCaseId",submission.entityId());
FieldOverrides fo = new FieldOverrides(fieldOverrides.toString());

activatingOtherForm("registrasi_anak", null, fo.getJSONString());
/// activatingForm("registrasi_anak", null, fo.getJSONString());
}

//end capture flurry log for FS
String end = timer.format(new Date());
Map<String, String> FS = new HashMap<String, String>();
Expand Down Expand Up @@ -246,7 +243,7 @@ public void OnLocationSelected(String locationJSONString) {

if (combined != null) {
FieldOverrides fieldOverrides = new FieldOverrides(combined.toString());
startFormActivity("registrasi_ibu", null, fieldOverrides.getJSONString());
startFormActivity(KOHORT_CHILD_REGISTRATION, null, fieldOverrides.getJSONString());
}
}

Expand Down Expand Up @@ -390,10 +387,12 @@ public void onBackPressed() {

private String[] buildFormNameList(){
List<String> formNames = new ArrayList<String>();
formNames.add("registrasi_ibu");
formNames.add("registrasi_anak");
formNames.add("close_form");
formNames.add("kohort_bayi_immunization");
formNames.add(KARTU_IBU_ANC_VISIT);
formNames.add(KARTU_IBU_ANC_VISIT_INTEGRASI);
formNames.add(KARTU_IBU_ANC_VISIT_LABTEST);
formNames.add(KARTU_IBU_ANC_RENCANA_PERSALINAN);
formNames.add(KOHORT_PNC_REGISTRATION);
formNames.add(KARTU_IBU_ANC_CLOSE);
return formNames.toArray(new String[formNames.size()]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
import butterknife.ButterKnife;
import util.BidanFormUtils;

import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KOHORT_KB_CLOSE;
import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KOHORT_KB_REGISTRATION;
import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KOHORT_KB_UPDATE;

public class KFPSmartRegisterActivity extends SecuredNativeSmartRegisterActivity implements
LocationSelectorDialogFragment.OnLocationSelectedListener, DisplayFormListener{

Expand Down Expand Up @@ -175,17 +179,6 @@ public void saveFormSubmission(String formSubmission, String id, String formName
context().formSubmissionRouter().handleSubmission(submission, formName);
switchToBaseFragment(formSubmission); // Unnecessary!! passing on data

if(formName.equals("registrasi_ibu")) {
Log.d(TAG, "saveFormSubmission: it was registrasi_ibu form");
// FieldOverrides fieldOverrides = new FieldOverrides(combined.toString());

fieldOverrides.put("ibuCaseId",submission.entityId());
FieldOverrides fo = new FieldOverrides(fieldOverrides.toString());

activatingOtherForm("registrasi_anak", null, fo.getJSONString());
/// activatingForm("registrasi_anak", null, fo.getJSONString());
}

//end capture flurry log for FS
String end = timer.format(new Date());
Map<String, String> FS = new HashMap<String, String>();
Expand Down Expand Up @@ -246,7 +239,7 @@ public void OnLocationSelected(String locationJSONString) {

if (combined != null) {
FieldOverrides fieldOverrides = new FieldOverrides(combined.toString());
startFormActivity("registrasi_ibu", null, fieldOverrides.getJSONString());
startFormActivity(KOHORT_KB_REGISTRATION, null, fieldOverrides.getJSONString());
}
}

Expand Down Expand Up @@ -390,10 +383,9 @@ public void onBackPressed() {

private String[] buildFormNameList(){
List<String> formNames = new ArrayList<String>();
formNames.add("registrasi_ibu");
formNames.add("registrasi_anak");
formNames.add("close_form");
formNames.add("kohort_bayi_immunization");
formNames.add(KOHORT_KB_REGISTRATION);
formNames.add(KOHORT_KB_UPDATE);
formNames.add(KOHORT_KB_CLOSE);
return formNames.toArray(new String[formNames.size()]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.widget.Toast;

import com.flurry.android.FlurryAgent;

Expand Down Expand Up @@ -42,6 +43,13 @@
import butterknife.Bind;
import butterknife.ButterKnife;
import util.BidanFormUtils;
import util.formula.Support;

import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.ANAK_BAYI_REGISTRATION;
import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KARTU_IBU_ANC_REGISTRATION;
import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KARTU_IBU_CLOSE;
import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KOHORT_MOTHER_REGISTRATION;
import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KOHORT_KB_PELAYANAN;

public class KMotherSmartRegisterActivity extends SecuredNativeSmartRegisterActivity implements
LocationSelectorDialogFragment.OnLocationSelectedListener, DisplayFormListener{
Expand Down Expand Up @@ -174,15 +182,9 @@ public void saveFormSubmission(String formSubmission, String id, String formName
context().formSubmissionRouter().handleSubmission(submission, formName);
switchToBaseFragment(formSubmission); // Unnecessary!! passing on data

if(formName.equals("kartu_ibu_registration")) {
Log.d(TAG, "saveFormSubmission: it was kartu_ibu_registration form");

fieldOverrides.put("ibuCaseId",submission.entityId());
FieldOverrides fo = new FieldOverrides(fieldOverrides.toString());

// activatingOtherForm("registrasi_anak", null, fo.getJSONString());

}
// if(formName.equals("kartu_ibu_registration")){
// saveuniqueid();
// }

//end capture flurry log for FS
String end = timer.format(new Date());
Expand All @@ -205,6 +207,11 @@ public void saveFormSubmission(String formSubmission, String id, String formName

@Override
public void OnLocationSelected(String locationJSONString) {
if(Support.ONSYNC) {
Toast.makeText(this,"Data still Synchronizing, please wait",Toast.LENGTH_SHORT).show();
return;
}

JSONObject combined = null;

try {
Expand All @@ -226,7 +233,7 @@ public void OnLocationSelected(String locationJSONString) {

if (combined != null) {
FieldOverrides fieldOverrides = new FieldOverrides(combined.toString());
startFormActivity("registrasi_ibu", null, fieldOverrides.getJSONString());
startFormActivity(KOHORT_MOTHER_REGISTRATION, null, fieldOverrides.getJSONString());
}
}

Expand Down Expand Up @@ -369,14 +376,16 @@ public void onBackPressed() {
}

private String[] buildFormNameList(){
List<String> formNames = new ArrayList<String>();
formNames.add("registrasi_ibu");
formNames.add("registrasi_anak");
formNames.add("close_form");
formNames.add("kohort_bayi_immunization");
List<String> formNames = new ArrayList<>();
formNames.add(KOHORT_MOTHER_REGISTRATION);
formNames.add(KOHORT_KB_PELAYANAN);
formNames.add(KARTU_IBU_ANC_REGISTRATION);
formNames.add(ANAK_BAYI_REGISTRATION);
formNames.add(KARTU_IBU_CLOSE);
return formNames.toArray(new String[formNames.size()]);
}


@Override
protected void onPause() {
super.onPause();
Expand Down Expand Up @@ -435,5 +444,15 @@ public void onClick(DialogInterface dialog, int which) {
}
};

public void saveuniqueid() {
// try {
// JSONObject uniqueId = new JSONObject(LoginActivity.generator.uniqueIdController().getUniqueIdJson());
// String uniq = uniqueId.getString("unique_id");
// LoginActivity.generator.uniqueIdController().updateCurrentUniqueId(uniq);
// } catch (JSONException e) {
// e.printStackTrace();
// }
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
import butterknife.ButterKnife;
import util.BidanFormUtils;

import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KARTU_IBU_PNC_CLOSE;
import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KARTU_IBU_PNC_OA;
import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KARTU_IBU_PNC_POSPARTUM_KB;
import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KOHORT_PNC_REGISTRATION;
import static org.smartregister.bidan_cloudant.utils.AllConstantsINA.FormNames.KARTU_IBU_PNC_VISIT;

public class KPNCSmartRegisterActivity extends SecuredNativeSmartRegisterActivity implements
LocationSelectorDialogFragment.OnLocationSelectedListener, DisplayFormListener{

Expand Down Expand Up @@ -246,7 +252,7 @@ public void OnLocationSelected(String locationJSONString) {

if (combined != null) {
FieldOverrides fieldOverrides = new FieldOverrides(combined.toString());
startFormActivity("registrasi_ibu", null, fieldOverrides.getJSONString());
startFormActivity(KOHORT_PNC_REGISTRATION, null, fieldOverrides.getJSONString());
}
}

Expand Down Expand Up @@ -389,11 +395,13 @@ public void onBackPressed() {
}

private String[] buildFormNameList(){
List<String> formNames = new ArrayList<String>();
formNames.add("registrasi_ibu");
formNames.add("registrasi_anak");
formNames.add("close_form");
formNames.add("kohort_bayi_immunization");
List<String> formNames = new ArrayList<>();
formNames.add(KARTU_IBU_PNC_VISIT);
formNames.add(KARTU_IBU_PNC_POSPARTUM_KB);
formNames.add(KARTU_IBU_PNC_CLOSE);
formNames.add(KARTU_IBU_PNC_OA);
formNames.add(KARTU_IBU_PNC_CLOSE);

return formNames.toArray(new String[formNames.size()]);
}

Expand Down
Loading

0 comments on commit f042d4c

Please sign in to comment.