@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_settings) { mNavigationHandler.switchFragment(new SettingsFragment(), SettingsFragment.TAG, true); } return super.onOptionsItemSelected(item); }
@Override public void onClick(View view) { switch (view.getId()) { case R.id.select_organisation_unit: { OrgUnitDialogFragment fragment = OrgUnitDialogFragment.newInstance(this); fragment.show(getChildFragmentManager()); break; } case R.id.select_program: { ProgramDialogFragment fragment = ProgramDialogFragment.newInstance( this, mState.getOrgUnitId(), Program.MULTIPLE_EVENTS_WITH_REGISTRATION, Program.SINGLE_EVENT_WITH_REGISTRATION); fragment.show(getChildFragmentManager()); break; } case R.id.register_new_event: { EnrollmentFragment enrollmentFragment = EnrollmentFragment.newInstance(mState.getOrgUnitId(), mState.getProgramId()); mNavigationHandler.switchFragment( enrollmentFragment, EnrollmentFragment.class.getName(), true); break; } case R.id.upcoming_events_button: { UpcomingEventsFragment fragment = new UpcomingEventsFragment(); mNavigationHandler.switchFragment(fragment, UpcomingEventsFragment.class.getName(), true); } } }
@Subscribe public void onItemClick(OnTrackedEntityInstanceClick eventClick) { if (eventClick.isOnDescriptionClick()) { ProgramOverviewFragment fragment = ProgramOverviewFragment.newInstance( mState.getOrgUnitId(), mState.getProgramId(), eventClick.getTrackedEntityInstance().localId); mNavigationHandler.switchFragment(fragment, ProgramOverviewFragment.CLASS_TAG, true); } else { switch (eventClick.getStatus()) { case SENT: Dhis2.getInstance() .showErrorDialog( getActivity(), getString(R.string.event_sent), getString(R.string.status_sent_description), R.drawable.ic_from_server); break; case OFFLINE: Dhis2.getInstance() .showErrorDialog( getActivity(), getString(R.string.event_offline), getString(R.string.status_offline_description), R.drawable.ic_offline); break; case ERROR: { String message = getErrorDescription(eventClick.getTrackedEntityInstance()); Dhis2.getInstance() .showErrorDialog( getActivity(), getString(R.string.event_error), message, R.drawable.ic_event_error); break; } } } }
private void editTrackedEntityInstanceProfile() { TrackedEntityInstanceProfileFragment fragment = TrackedEntityInstanceProfileFragment.newInstance( getArguments().getLong(TRACKEDENTITYINSTANCE_ID), getArguments().getString(PROGRAM_ID)); mNavigationHandler.switchFragment(fragment, TrackedEntityInstanceProfileFragment.TAG, true); }
public void showDataEntryFragment(Event event, String programStage) { Bundle args = getArguments(); DataEntryFragment fragment; String progId = mForm.getProgram().getId(); // new line :AgeToday if (event == null) { fragment = DataEntryFragment.newInstanceWithEnrollment( args.getString(ORG_UNIT_ID), args.getString(PROGRAM_ID), programStage, mForm.getEnrollment().localId); } else if (progId.equals("u9FZUM7kn38") && event != null) { /*- The If-Else block below is used to add the AgeToday Feature, a requirement for the HPV Campaign Program -*/ fragment = DataEntryFragment.newInstanceWithEnrollment( args.getString(ORG_UNIT_ID), args.getString(PROGRAM_ID), programStage, event.getLocalEnrollmentId(), event.getLocalId()); Enrollment enrollment = DataValueController.getEnrollment(event.getLocalEnrollmentId()); List<TrackedEntityAttributeValue> teav = enrollment.getAttributes(); // getActionBar().setSubtitle("Learner's AgeToday is: " + displayAge); // getActionBar().setDisplayShowTitleEnabled(true); for (TrackedEntityAttributeValue val : teav) { System.out.println("The learner details are: ->" + val.getValue()); } // If passport number is entered then : String learnerDob = teav.get(4).getValue(); // String learnerDob = teav.get(3).getValue(); Training Instance - Position for LearnerDOB // when IDNumber is entered String learnerDob = teav.get(2).getValue(); // Staging Instance // String learnerDob = teav.get(3).getValue(); if (!isValidDate(learnerDob)) learnerDob = teav.get(3).getValue(); System.out.println("What is in learnerstring :" + learnerDob); // --Use Joda Time to compute the learner's age today LocalDate birthdate = new LocalDate(learnerDob); LocalDate now = new LocalDate(); // Compute learners age today Years learnersAgeToday = Years.yearsBetween(birthdate, now); System.out.println("The learners age today is:====>" + learnersAgeToday); ageToday = String.valueOf(learnersAgeToday); StringBuilder sbAgeToday = new StringBuilder(ageToday); sbAgeToday.delete(0, 1); sbAgeToday.append("EARS"); System.out.println("The OLD learners age is:" + ageToday); // String myDisplay = printLearnersAge(); displayAge = sbAgeToday.toString(); System.out.println("THE NEW LEARNERS AGE FIXED: " + displayAge); // List<ProgramStageDataElement> programStageDataElements = // MetaDataController.getProgramStageDataElements // (MetaDataController.getProgramStage(event.getProgramStageId())); // for(ProgramStageDataElement de: programStageDataElements) { // System.out.println("The data elements in the program are:" + de.getDataElement()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder .setMessage("The learner's Age Today is: " + displayAge) .setCancelable(false) .setTitle("Learner's Age Today Notification") .setPositiveButton( "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); AlertDialog dialog = builder.create(); dialog.show(); } else { fragment = DataEntryFragment.newInstanceWithEnrollment( args.getString(ORG_UNIT_ID), args.getString(PROGRAM_ID), programStage, event.getLocalEnrollmentId(), event.getLocalId()); } mNavigationHandler.switchFragment(fragment, ProgramOverviewFragment.CLASS_TAG, true); }
public void enroll() { EnrollmentFragment enrollmentFragment = EnrollmentFragment.newInstance( mState.getOrgUnitId(), mState.getProgramId(), mState.getTrackedEntityInstanceId()); mNavigationHandler.switchFragment(enrollmentFragment, EnrollmentFragment.class.getName(), true); }