Skip to content

Commit

Permalink
RA| added type field to vaccine cards to differentiate between child …
Browse files Browse the repository at this point in the history
…and mother vaccines
  • Loading branch information
raihan-mpower committed Aug 1, 2017
1 parent 0fcdd53 commit aa7b5a7
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ private void showVaccineNotifications(List<Vaccine> vaccineList, List<Alert> ale
private void addVaccineGroup(int canvasId, JSONObject vaccineGroupData, List<Vaccine> vaccineList, List<Alert> alerts) {
LinearLayout vaccineGroupCanvasLL = (LinearLayout) findViewById(R.id.vaccine_group_canvas_ll);
VaccineGroup curGroup = new VaccineGroup(this);
curGroup.setData(vaccineGroupData, childDetails, vaccineList, alerts);
curGroup.setData(vaccineGroupData, childDetails, vaccineList, alerts,"child");
curGroup.setOnRecordAllClickListener(new VaccineGroup.OnRecordAllClickListener() {
@Override
public void onClick(VaccineGroup vaccineGroup, ArrayList<VaccineWrapper> dueVaccines) {
Expand Down Expand Up @@ -895,7 +895,7 @@ private void updateVaccineGroupViews(View view, final ArrayList<VaccineWrapper>
if (Looper.myLooper() == Looper.getMainLooper()) {
if (undo) {
vaccineGroup.setVaccineList(vaccineList);
vaccineGroup.updateWrapperStatus(wrappers);
vaccineGroup.updateWrapperStatus(wrappers,"child");
}
vaccineGroup.updateViews(wrappers);

Expand All @@ -906,7 +906,7 @@ private void updateVaccineGroupViews(View view, final ArrayList<VaccineWrapper>
public void run() {
if (undo) {
vaccineGroup.setVaccineList(vaccineList);
vaccineGroup.updateWrapperStatus(wrappers);
vaccineGroup.updateWrapperStatus(wrappers,"child");
}
vaccineGroup.updateViews(wrappers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ private void showVaccineNotifications(List<Vaccine> vaccineList, List<Alert> ale
private void addVaccineGroup(int canvasId, JSONObject vaccineGroupData, List<Vaccine> vaccineList, List<Alert> alerts) {
LinearLayout vaccineGroupCanvasLL = (LinearLayout) findViewById(R.id.vaccine_group_canvas_ll);
VaccineGroup curGroup = new VaccineGroup(this);
curGroup.setData(vaccineGroupData, childDetails, vaccineList, alerts);
curGroup.setData(vaccineGroupData, childDetails, vaccineList, alerts,"mother");
curGroup.setOnRecordAllClickListener(new VaccineGroup.OnRecordAllClickListener() {
@Override
public void onClick(VaccineGroup vaccineGroup, ArrayList<VaccineWrapper> dueVaccines) {
Expand Down Expand Up @@ -892,7 +892,7 @@ private void updateVaccineGroupViews(View view, final ArrayList<VaccineWrapper>
if (Looper.myLooper() == Looper.getMainLooper()) {
if (undo) {
vaccineGroup.setVaccineList(vaccineList);
vaccineGroup.updateWrapperStatus(wrappers);
vaccineGroup.updateWrapperStatus(wrappers,"mother");
}
vaccineGroup.updateViews(wrappers);

Expand All @@ -903,7 +903,7 @@ private void updateVaccineGroupViews(View view, final ArrayList<VaccineWrapper>
public void run() {
if (undo) {
vaccineGroup.setVaccineList(vaccineList);
vaccineGroup.updateWrapperStatus(wrappers);
vaccineGroup.updateWrapperStatus(wrappers,"mother");
}
vaccineGroup.updateViews(wrappers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ public class VaccineCardAdapter extends BaseAdapter {
private final Context context;
private HashMap<String, VaccineCard> vaccineCards;
private final VaccineGroup vaccineGroup;
private final String type;

public VaccineCardAdapter(Context context, VaccineGroup vaccineGroup) throws JSONException {
public VaccineCardAdapter(Context context, VaccineGroup vaccineGroup,String type) throws JSONException {
this.context = context;
this.vaccineGroup = vaccineGroup;
vaccineCards = new HashMap<>();
this.type = type;
}

@Override
Expand Down Expand Up @@ -99,7 +101,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
vaccineWrapper.setPatientName(childName.trim());

vaccineGroup.updateWrapper(vaccineWrapper);
vaccineGroup.updateWrapperStatus(vaccineWrapper);
vaccineGroup.updateWrapperStatus(vaccineWrapper,type);
vaccineCard.setVaccineWrapper(vaccineWrapper);

vaccineCards.put(vaccineName, vaccineCard);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,19 +464,17 @@ public ContentValues processCaseModel(JSONObject entity, JSONObject clientClassi
@Override
public void updateFTSsearch(String tableName, String entityId, ContentValues contentValues) {
super.updateFTSsearch(tableName, entityId, contentValues);
Log.v("tablename",tableName);
Log.v("contentValues",contentValues.toString());
// if (contentValues != null && StringUtils.containsIgnoreCase(tableName, "child")) {
// String dob = contentValues.getAsString("dob");
//
// if (StringUtils.isBlank(dob)) {
// return;
// }
//
// DateTime birthDateTime = new DateTime(dob);
// VaccineSchedule.updateOfflineAlerts(entityId, birthDateTime, "child");
// ServiceSchedule.updateOfflineAlerts(entityId, birthDateTime);
// }
if (contentValues != null && StringUtils.containsIgnoreCase(tableName, "child")) {
String dob = contentValues.getAsString("dob");

if (StringUtils.isBlank(dob)) {
return;
}

DateTime birthDateTime = new DateTime(dob);
VaccineSchedule.updateOfflineAlerts(entityId, birthDateTime, "child");
ServiceSchedule.updateOfflineAlerts(entityId, birthDateTime);
}
if (contentValues != null && StringUtils.containsIgnoreCase(tableName, "mother")) {
String dob = contentValues.getAsString("dob");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class VaccineGroup extends LinearLayout implements View.OnClickListener,
private OnVaccineUndoClickListener onVaccineUndoClickListener;
private SimpleDateFormat READABLE_DATE_FORMAT = new SimpleDateFormat("dd MMMM, yyyy", Locale.US);
private boolean modalOpen;
private String type;

private static enum State {
IN_PAST,
Expand Down Expand Up @@ -128,11 +129,12 @@ private void init(Context context) {
recordAllTV.setOnClickListener(this);
}

public void setData(JSONObject vaccineData, CommonPersonObjectClient childDetails, List<Vaccine> vaccines, List<Alert> alerts) {
public void setData(JSONObject vaccineData, CommonPersonObjectClient childDetails, List<Vaccine> vaccines, List<Alert> alerts,String type) {
this.vaccineData = vaccineData;
this.childDetails = childDetails;
this.vaccineList = vaccines;
this.alertList = alerts;
this.type = type;
updateViews();
}

Expand Down Expand Up @@ -209,7 +211,7 @@ private void updateStatusViews() {
private void updateVaccineCards(ArrayList<VaccineWrapper> vaccinesToUpdate) {
if (vaccineCardAdapter == null) {
try {
vaccineCardAdapter = new VaccineCardAdapter(context, this);
vaccineCardAdapter = new VaccineCardAdapter(context, this,type);
vaccinesGV.setAdapter(vaccineCardAdapter);
} catch (JSONException e) {
Log.e(TAG, Log.getStackTraceString(e));
Expand Down Expand Up @@ -302,15 +304,15 @@ public void setModalOpen(boolean modalOpen) {
this.modalOpen = modalOpen;
}

public void updateWrapperStatus(VaccineWrapper tag) {
public void updateWrapperStatus(VaccineWrapper tag,String type) {
List<Vaccine> vaccineList = getVaccineList();

List<Alert> alertList = getAlertList();

Map<String, Date> recievedVaccines = receivedVaccines(vaccineList);

String dobString = Utils.getValue(getChildDetails().getColumnmaps(), "dob", false);
List<Map<String, Object>> sch = generateScheduleList("mother", new DateTime(dobString), recievedVaccines, alertList);
List<Map<String, Object>> sch = generateScheduleList(type, new DateTime(dobString), recievedVaccines, alertList);

for (Map<String, Object> m : sch) {
VaccineRepo.Vaccine vaccine = (VaccineRepo.Vaccine) m.get("vaccine");
Expand All @@ -329,13 +331,13 @@ public void updateWrapperStatus(VaccineWrapper tag) {
}
}

public void updateWrapperStatus(ArrayList<VaccineWrapper> tags) {
public void updateWrapperStatus(ArrayList<VaccineWrapper> tags,String type) {
if (tags == null) {
return;
}

for (VaccineWrapper tag : tags) {
updateWrapperStatus(tag);
updateWrapperStatus(tag,type);
}
}

Expand Down

0 comments on commit aa7b5a7

Please sign in to comment.