コード例 #1
0
  private void searchForPatient(String name, String hospitalNumber, String dob) {
    if (name.equals(".")) name = " ";
    else name = name.trim();
    pd =
        new CustomDialogs()
            .showProgressDialog(ServiceUserSearchActivity.this, "Fetching Information");

    SmartApiClient.getAuthorizedApiClient()
        .getServiceUserByNameDobHospitalNum(
            name,
            hospitalNumber.trim(),
            dob.trim(),
            new Callback<BaseModel>() {
              @Override
              public void success(BaseModel baseModel, Response response) {
                if (baseModel.getServiceUsers().size() != 0) {
                  BaseModel.getInstance().setServiceUsers(baseModel.getServiceUsers());
                  BaseModel.getInstance().setPregnancies(baseModel.getPregnancies());
                  BaseModel.getInstance().setBabies(baseModel.getBabies());
                  BaseModel.getInstance().setAntiDHistories(baseModel.getAntiDHistories());

                  if (changeActivity) {
                    startActivity(intent);
                    getHistories();
                  } else {
                    serviceUserList = baseModel.getServiceUsers();
                    adapterListResults.notifyDataSetChanged();
                  }
                } else {
                  llNoUserFound.setVisibility(View.VISIBLE);
                  adapterListResults.notifyDataSetChanged();
                }
                pd.dismiss();
              }

              @Override
              public void failure(RetrofitError error) {
                Timber.d("ServiceUserSearchActivity user search failure = " + error);
                adapterListResults.notifyDataSetChanged();
                llNoUserFound.setVisibility(View.VISIBLE);
                pd.dismiss();
              }
            });
  }
コード例 #2
0
  private void getHistories() {
    getRecentBabyPosition();
    getRecentBabyId();
    getRecentPregnancy();
    SmartApiClient.getAuthorizedApiClient()
        .getVitKHistories(
            bId,
            new Callback<BaseModel>() {
              @Override
              public void success(BaseModel baseModel, Response response) {
                Collections.sort(
                    baseModel.getVitKHistories(),
                    new Comparator<VitKHistory>() {

                      @Override
                      public int compare(VitKHistory a, VitKHistory b) {
                        int valA;
                        int valB;

                        valA = a.getId();
                        valB = b.getId();

                        return -((Integer) valA).compareTo(valB);
                      }
                    });
                BaseModel.getInstance().setVitKHistories(baseModel.getVitKHistories());
                Timber.d("vit k history done");
              }

              @Override
              public void failure(RetrofitError error) {
                Timber.d("vit k history failure = " + error);
              }
            });
    SmartApiClient.getAuthorizedApiClient()
        .getHearingHistories(
            bId,
            new Callback<BaseModel>() {
              @Override
              public void success(BaseModel baseModel, Response response) {
                Collections.sort(
                    baseModel.getHearingHistories(),
                    new Comparator<HearingHistory>() {

                      @Override
                      public int compare(HearingHistory a, HearingHistory b) {
                        int valA;
                        int valB;

                        valA = a.getId();
                        valB = b.getId();

                        return -((Integer) valA).compareTo(valB);
                      }
                    });
                BaseModel.getInstance().setHearingHistories(baseModel.getHearingHistories());
                Timber.d("hearing history done");
              }

              @Override
              public void failure(RetrofitError error) {
                Timber.d("hearing history failure = " + error);
              }
            });
    SmartApiClient.getAuthorizedApiClient()
        .getNbstHistories(
            bId,
            new Callback<BaseModel>() {
              @Override
              public void success(BaseModel baseModel, Response response) {
                Collections.sort(
                    baseModel.getNbstHistories(),
                    new Comparator<NbstHistory>() {

                      @Override
                      public int compare(NbstHistory a, NbstHistory b) {
                        int valA;
                        int valB;

                        valA = a.getId();
                        valB = b.getId();

                        return -((Integer) valA).compareTo(valB);
                      }
                    });
                BaseModel.getInstance().setNbstHistories(baseModel.getNbstHistories());
                Timber.d("nbst history done");
              }

              @Override
              public void failure(RetrofitError error) {
                Timber.d("nbst history failure = " + error);
              }
            });
    SmartApiClient.getAuthorizedApiClient()
        .getFeedingHistoriesByPregId(
            BaseModel.getInstance().getPregnancies().get(p).getId(),
            new Callback<BaseModel>() {
              @Override
              public void success(BaseModel baseModel, Response response) {
                Collections.sort(
                    baseModel.getFeedingHistories(),
                    new Comparator<FeedingHistory>() {

                      @Override
                      public int compare(FeedingHistory a, FeedingHistory b) {
                        int valA;
                        int valB;

                        valA = a.getId();
                        valB = b.getId();

                        return -((Integer) valA).compareTo(valB);
                      }
                    });
                BaseModel.getInstance().setFeedingHistories(baseModel.getFeedingHistories());
                Timber.d("feeding history done");
              }

              @Override
              public void failure(RetrofitError error) {
                Timber.d("feeding history failure = " + error);
              }
            });
  }