Skip to content

Commit

Permalink
Add form name to the client events list for processing #4
Browse files Browse the repository at this point in the history
  • Loading branch information
baksosapi committed Mar 20, 2018
1 parent 6eb35a0 commit fdce8b1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

public class BidanClientProcessor extends ClientProcessor {

public static final String[] CLIENT_EVENTS = {"Registrasi Bidan", "Child Registration", "Identitas Ibu"};
public static final String[] CLIENT_EVENTS = {"Registrasi Bidan", "Child Registration", "Identitas Ibu",
"Dokumentasi Persalinan", "Tambah Bayi", "Tambah KB"};
// public static final String baseEntityIdJSONKey = "baseEntityId";
// protected static final String providerIdJSONKey = "providerId";
// protected static final String VALUES_KEY = "values";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,17 @@ private void generateClientAndEventModelsForFormSubmission(FormSubmission formSu
formInstance, clientVersion);

Event e = formEntityConverter.getEventFromFormSubmission(v2FormSubmission);

if (Arrays.asList(CLIENT_EVENTS).contains(e.getEventType())) {
android.util.Log.e(TAG, "generateClientAndEventModelsForFormSubmission:hasClient ");
org.smartregister.util.Utils.startAsyncTask(new SavePatientAsyncTask(v2FormSubmission, mContext, true, e), null);
} else {
android.util.Log.e(TAG, "generateClientAndEventModelsForFormSubmission:noClient " + e.getEventType());
org.smartregister.util.Utils.startAsyncTask(new SavePatientAsyncTask(v2FormSubmission, mContext, false, e), null);

}
org.smartregister.util.Utils.startAsyncTask(new SavePatientAsyncTask(v2FormSubmission, mContext,
Arrays.asList(CLIENT_EVENTS).contains(e.getEventType()), e), null);

// if (Arrays.asList(CLIENT_EVENTS).contains(e.getEventType())) {
// android.util.Log.e(TAG, "generateClientAndEventModelsForFormSubmission:hasClient ");
// org.smartregister.util.Utils.startAsyncTask(new SavePatientAsyncTask(v2FormSubmission, mContext, true, e), null);
// } else {
// android.util.Log.e(TAG, "generateClientAndEventModelsForFormSubmission:noClient " + e.getEventType());
// org.smartregister.util.Utils.startAsyncTask(new SavePatientAsyncTask(v2FormSubmission, mContext, false, e), null);
//
// }
}

private void printClient(Client client) {
Expand Down Expand Up @@ -1179,30 +1181,30 @@ protected Void doInBackground(Void... params) {
saveEvent(event);
Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create();

if (eventType != null) {

if (event.getEventType().equals("Identitas Ibus")) {
JSONObject json = eventClientRepository.getClientByBaseEntityId(event.getBaseEntityId());
android.util.Log.e(TAG, "doInBackground:json " + json.toString());
Client client = gson.fromJson(json.toString(), Client.class);
saveClient(client);
} else if (event.getEventType().equals("Registrasi Vaksinator")) {
JSONObject json = eventClientRepository.getClientByBaseEntityId(event.getBaseEntityId());
Client client = gson.fromJson(json.toString(), Client.class);
// client.addAttribute("kartu_ibu", "kartu_ibu");
saveClient(client);
} else if (event.getEventType().equals("Child Registration")) {
JSONObject json = eventClientRepository.getClientByBaseEntityId(event.getBaseEntityId());
Client client = gson.fromJson(json.toString(), Client.class);
// client.addAttribute("anak", "anak");
saveClient(client);
} else if (event.getEventType().equals(EditClientFormNameList())) {
JSONObject json = eventClientRepository.getClientByBaseEntityId(event.getBaseEntityId());
Client client = gson.fromJson(json.toString(), Client.class);
client.addAttribute("edit", "edit");
saveClient(client);
}
}
// if (eventType != null) {
//
// if (event.getEventType().equals("Identitas Ibus")) {
// JSONObject json = eventClientRepository.getClientByBaseEntityId(event.getBaseEntityId());
// android.util.Log.e(TAG, "doInBackground:json " + json.toString());
// Client client = gson.fromJson(json.toString(), Client.class);
// saveClient(client);
// } else if (event.getEventType().equals("Registrasi Vaksinator")) {
// JSONObject json = eventClientRepository.getClientByBaseEntityId(event.getBaseEntityId());
// Client client = gson.fromJson(json.toString(), Client.class);
// // client.addAttribute("kartu_ibu", "kartu_ibu");
// saveClient(client);
// } else if (event.getEventType().equals("Child Registration")) {
// JSONObject json = eventClientRepository.getClientByBaseEntityId(event.getBaseEntityId());
// Client client = gson.fromJson(json.toString(), Client.class);
// // client.addAttribute("anak", "anak");
// saveClient(client);
// } else if (event.getEventType().equals(EditClientFormNameList())) {
// JSONObject json = eventClientRepository.getClientByBaseEntityId(event.getBaseEntityId());
// Client client = gson.fromJson(json.toString(), Client.class);
// client.addAttribute("edit", "edit");
// saveClient(client);
// }
// }

Map<String, Map<String, Object>> dep = formEntityConverter.
getDependentClientsFromFormSubmission(formSubmission);
Expand Down

0 comments on commit fdce8b1

Please sign in to comment.