正在查看: St.John's v1.0.9 应用的 HealthInfoFragment.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: St.John's v1.0.9 应用的 HealthInfoFragment.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mcb.stjohnsemschool.fragment;
import android.R;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.mcb.stjohnsemschool.adapter.BMIAdapter;
import com.mcb.stjohnsemschool.adapter.ChestMeasurementAdapter;
import com.mcb.stjohnsemschool.adapter.ClinicalEvaluationsAdapter;
import com.mcb.stjohnsemschool.adapter.DentalAdapter;
import com.mcb.stjohnsemschool.adapter.HealthImmunizationsAdapter;
import com.mcb.stjohnsemschool.adapter.HealthIssuesAdapter;
import com.mcb.stjohnsemschool.adapter.OtherMedicalHistoryAdapter;
import com.mcb.stjohnsemschool.adapter.PastMedicalHistoryAdapter;
import com.mcb.stjohnsemschool.adapter.VisionAdapter;
import com.mcb.stjohnsemschool.interfaces.OnImageCapturedInterface;
import com.mcb.stjohnsemschool.model.ClinicalEvaluationMasterModel;
import com.mcb.stjohnsemschool.model.ClinicalEvaluationsModel;
import com.mcb.stjohnsemschool.model.HealthBMIModel;
import com.mcb.stjohnsemschool.model.HealthHistoryModel;
import com.mcb.stjohnsemschool.model.HealthImmunizationMasterModel;
import com.mcb.stjohnsemschool.model.HealthImmunizationModel;
import com.mcb.stjohnsemschool.model.HealthIssuesModel;
import com.mcb.stjohnsemschool.model.OtherMedicalHistoryMasterModel;
import com.mcb.stjohnsemschool.model.OtherMedicalHistoryModel;
import com.mcb.stjohnsemschool.model.PastMedicalHistoryMasterModel;
import com.mcb.stjohnsemschool.model.PastMedicalHistoryModel;
import com.mcb.stjohnsemschool.model.StudentInfoModel;
import com.mcb.stjohnsemschool.model.StudentMedicalHistoryTypeMasterModel;
import com.mcb.stjohnsemschool.services.ApiClient;
import com.mcb.stjohnsemschool.services.ApiInterface;
import com.mcb.stjohnsemschool.utils.FileUtils;
import com.mcb.stjohnsemschool.utils.NonScrollListView;
import com.mcb.stjohnsemschool.utils.TransparentProgressDialog;
import com.mcb.stjohnsemschool.utils.Utility;
import com.mcxiaoke.koi.Const;
import com.microsoft.identity.common.java.eststelemetry.SchemaConstants;
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog;
import cz.msebera.android.httpclient.protocol.HTTP;
import io.ably.lib.util.AgentHeaderCreator;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class HealthInfoFragment extends Fragment implements View.OnClickListener, DatePickerDialog.OnDateSetListener, PastMedicalHistoryAdapter.PastMedicalHistoryDetails, ClinicalEvaluationsAdapter.ClinicalEvaluationsDetails, OtherMedicalHistoryAdapter.OtherMedicalHistoryDetails, HealthIssuesAdapter.HealthIssueDetails, HealthImmunizationsAdapter.HealthImmunizationsDetails, OnImageCapturedInterface {
private static final String TAG = "com.mcb.stjohnsemschool.fragment.HealthInfoFragment";
private Activity activity;
private int clinicalEvaluationId;
private ClinicalEvaluationsAdapter.ClinicalEvaluationsDetails clinicalEvaluationsDetails;
private ConnectivityManager conMgr;
private Context context;
private DatePickerDialog healthImmunizationsDateDialog;
private HealthImmunizationsAdapter.HealthImmunizationsDetails healthImmunizationsDetails;
private int healthImmunizationsId;
private HealthIssuesAdapter.HealthIssueDetails healthIssueDetails;
private int healthIssueId;
private DatePickerDialog healthIssuesDateDialog;
private ImageView mAddAllergies;
private ImageView mAddClinicalEvaluations;
private ImageView mAddHealthImmunizations;
private ImageView mAddHealthIssues;
private ImageView mAddPastMedicalHistory;
private NonScrollListView mAllergies;
private TextView mAttachedFile;
private TextView mBMI;
private LinearLayout mBMILL;
private NonScrollListView mBMIList;
private TextView mBloodGroup;
private NonScrollListView mChestMeasurement;
private NonScrollListView mClinicalEvaluations;
private EditText mClinicalEvaluationsComments;
private Dialog mClinicalEvaluationsDialog;
private TextView mClinicalEvaluationsHeader;
private Spinner mClinicalEvaluationsSpn;
private TextView mDOB;
private NonScrollListView mDental;
private TextView mHealthImmunizations;
private EditText mHealthImmunizationsComments;
private Dialog mHealthImmunizationsDialog;
private TextView mHealthImmunizationsHeader;
private LinearLayout mHealthImmunizationsLL;
private EditText mHealthImmunizationsObservedOn;
private Spinner mHealthImmunizationsSpn;
private EditText mHealthImmunizationsVaccineType;
private NonScrollListView mHealthIssues;
private EditText mHealthIssuesComments;
private Dialog mHealthIssuesDialog;
private EditText mHealthIssuesDoctor;
private TextView mHealthIssuesHeader;
private EditText mHealthIssuesObservedOn;
private TextView mHealthIssuesObservedOnHeader;
private Spinner mHealthIssuesSpn;
private TextView mHealthIssuesTitle;
private CheckBox mHistoryAvailable;
private NonScrollListView mImmunizations;
private CheckBox mIsAbnormal;
private TextView mMedicalHistory;
private LinearLayout mMedicalHistoryLL;
private TextView mName;
private EditText mOtherMedicalHistoryComments;
private Dialog mOtherMedicalHistoryDialog;
private TextView mOtherMedicalHistoryHeader;
private EditText mOtherMedicalHistoryObservedOn;
private Spinner mOtherMedicalHistorySpn;
private NonScrollListView mPastMedicalHistory;
private EditText mPastMedicalHistoryComments;
private Dialog mPastMedicalHistoryDialog;
private TextView mPastMedicalHistoryHeader;
private EditText mPastMedicalHistoryObservedOn;
private Spinner mPastMedicalHistorySpn;
private TransparentProgressDialog mProgressbar;
private Button mSaveClinicalEvaluations;
private Button mSaveHealthImmunizations;
private Button mSaveHealthIssues;
private Button mSaveOtherMedicalHistory;
private Button mSavePastMedicalHistory;
private SharedPreferences mSharedPref;
private ImageView mStudentPic;
private TextView mTermName;
private TextView mUpload;
private NonScrollListView mVision;
private OnImageCapturedInterface onImageCaptured;
private DatePickerDialog otherMedicalHistoryDateDialog;
private OtherMedicalHistoryAdapter.OtherMedicalHistoryDetails otherMedicalHistoryDetails;
private int otherMedicalHistoryId;
private DatePickerDialog pastMedicalHistoryDateDialog;
private PastMedicalHistoryAdapter.PastMedicalHistoryDetails pastMedicalHistoryDetails;
private int pastMedicalHistoryId;
private SimpleDateFormat sdf;
private String branchId = SchemaConstants.Value.FALSE;
private String branchSectionId = SchemaConstants.Value.FALSE;
private String studentEnrollmentId = SchemaConstants.Value.FALSE;
private String academicYearId = SchemaConstants.Value.FALSE;
private String userId = SchemaConstants.Value.FALSE;
private String orgId = SchemaConstants.Value.FALSE;
private String filePath = "";
private boolean isEdit = false;
private boolean isFromBrowse = false;
private Calendar pastMedicalHistoryCalendar = Calendar.getInstance();
private Calendar otherMedicalHistoryCalendar = Calendar.getInstance();
private Calendar healthIssuesCalendar = Calendar.getInstance();
private Calendar healthImmunizationsCalendar = Calendar.getInstance();
private ArrayList<PastMedicalHistoryMasterModel> pastMedicalHistoryMaster = new ArrayList<>();
private ArrayList<ClinicalEvaluationMasterModel> clinicalEvaluationsMaster = new ArrayList<>();
private ArrayList<OtherMedicalHistoryMasterModel> otherMedicalHistoryMaster = new ArrayList<>();
private ArrayList<StudentMedicalHistoryTypeMasterModel> healthIssuesMaster = new ArrayList<>();
private ArrayList<HealthImmunizationMasterModel> healthImmunizationsMaster = new ArrayList<>();
private PastMedicalHistoryModel pastMedicalHistoryModel = null;
private ClinicalEvaluationsModel clinicalEvaluationsModel = null;
private OtherMedicalHistoryModel otherMedicalHistoryModel = null;
private HealthIssuesModel healthIssuesModel = null;
private HealthImmunizationModel healthImmunizationModel = null;
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
return layoutInflater.inflate(2131558712, viewGroup, false);
}
public void onActivityCreated(Bundle bundle) {
super.onActivityCreated(bundle);
FragmentActivity activity = getActivity();
this.activity = activity;
Context applicationContext = activity.getApplicationContext();
this.context = applicationContext;
this.pastMedicalHistoryDetails = this;
this.clinicalEvaluationsDetails = this;
this.otherMedicalHistoryDetails = this;
this.healthIssueDetails = this;
this.healthImmunizationsDetails = this;
this.onImageCaptured = this;
SharedPreferences sharedPreferences = applicationContext.getSharedPreferences("", 0);
this.mSharedPref = sharedPreferences;
this.branchId = sharedPreferences.getString("BranchIdKey", this.branchId);
this.branchSectionId = this.mSharedPref.getString("BranchSectionIDKey", this.branchSectionId);
this.academicYearId = this.mSharedPref.getString("academicyearIdKey", this.academicYearId);
this.studentEnrollmentId = this.mSharedPref.getString("studentEnrollmentIdKey", this.studentEnrollmentId);
this.userId = this.mSharedPref.getString("UseridKey", this.userId);
this.orgId = this.mSharedPref.getString("orgnizationIdKey", this.orgId);
this.sdf = new SimpleDateFormat("dd MMM yyyy", Locale.US);
initializations();
}
private void initializations() {
this.mProgressbar = new TransparentProgressDialog(this.activity, 2131231479);
this.mStudentPic = (ImageView) getView().findViewById(2131362713);
this.mName = (TextView) getView().findViewById(2131364222);
this.mTermName = (TextView) getView().findViewById(2131364379);
this.mBloodGroup = (TextView) getView().findViewById(2131363967);
this.mDOB = (TextView) getView().findViewById(2131364056);
this.mBMI = (TextView) getView().findViewById(2131363969);
this.mMedicalHistory = (TextView) getView().findViewById(2131364201);
this.mHealthImmunizations = (TextView) getView().findViewById(2131364130);
this.mBMILL = (LinearLayout) getView().findViewById(2131362841);
this.mMedicalHistoryLL = (LinearLayout) getView().findViewById(2131362893);
this.mHealthImmunizationsLL = (LinearLayout) getView().findViewById(2131362877);
this.mPastMedicalHistory = (NonScrollListView) getView().findViewById(2131362998);
this.mClinicalEvaluations = (NonScrollListView) getView().findViewById(2131362961);
this.mAllergies = (NonScrollListView) getView().findViewById(2131362951);
this.mHealthIssues = (NonScrollListView) getView().findViewById(2131362982);
this.mImmunizations = (NonScrollListView) getView().findViewById(2131362981);
this.mBMIList = (NonScrollListView) getView().findViewById(2131362954);
this.mChestMeasurement = (NonScrollListView) getView().findViewById(2131362958);
this.mDental = (NonScrollListView) getView().findViewById(2131362970);
this.mVision = (NonScrollListView) getView().findViewById(2131363011);
this.mAddPastMedicalHistory = (ImageView) getView().findViewById(2131362691);
this.mAddClinicalEvaluations = (ImageView) getView().findViewById(2131362656);
this.mAddAllergies = (ImageView) getView().findViewById(2131362642);
this.mAddHealthIssues = (ImageView) getView().findViewById(2131362676);
this.mAddHealthImmunizations = (ImageView) getView().findViewById(2131362674);
this.mPastMedicalHistory.setDividerHeight(0);
this.mClinicalEvaluations.setDividerHeight(0);
this.mAllergies.setDividerHeight(0);
this.mHealthIssues.setDividerHeight(0);
this.mImmunizations.setDividerHeight(0);
this.mBMIList.setDividerHeight(0);
this.mChestMeasurement.setDividerHeight(0);
this.mDental.setDividerHeight(0);
this.mVision.setDividerHeight(0);
this.mBMI.setOnClickListener(this);
this.mMedicalHistory.setOnClickListener(this);
this.mHealthImmunizations.setOnClickListener(this);
this.mAddPastMedicalHistory.setOnClickListener(this);
this.mAddClinicalEvaluations.setOnClickListener(this);
this.mAddAllergies.setOnClickListener(this);
this.mAddHealthIssues.setOnClickListener(this);
this.mAddHealthImmunizations.setOnClickListener(this);
String string = this.mSharedPref.getString("ProfilePicPath", "");
String string2 = this.mSharedPref.getString("Name", "");
if (string != null && string.length() > 0 && !string.equalsIgnoreCase("null")) {
Glide.with(this.context).load(string).apply(new RequestOptions().circleCrop()).into(this.mStudentPic);
} else {
Glide.with(this.context).load(2131231345).apply(new RequestOptions().circleCrop()).into(this.mStudentPic);
}
this.mName.setText(string2);
this.mBMI.performClick();
createPastMedicalHistoryDialog();
createClinicalEvaluationsDialog();
createOtherMedicalHistoryDialog();
createHealthIssuesDialog();
createHealthImmuniztionsDialog();
getStudentProfile();
}
private void createPastMedicalHistoryDialog() {
Dialog dialog = new Dialog(this.activity);
this.mPastMedicalHistoryDialog = dialog;
dialog.requestWindowFeature(1);
this.mPastMedicalHistoryDialog.setContentView(2131558656);
this.mPastMedicalHistoryDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
this.mPastMedicalHistoryDialog.setCancelable(true);
this.mPastMedicalHistoryHeader = (TextView) this.mPastMedicalHistoryDialog.findViewById(2131364270);
this.mPastMedicalHistorySpn = (Spinner) this.mPastMedicalHistoryDialog.findViewById(2131363659);
this.mHistoryAvailable = (CheckBox) this.mPastMedicalHistoryDialog.findViewById(2131362141);
this.mPastMedicalHistoryObservedOn = (EditText) this.mPastMedicalHistoryDialog.findViewById(2131362408);
this.mPastMedicalHistoryComments = (EditText) this.mPastMedicalHistoryDialog.findViewById(2131362407);
this.mSavePastMedicalHistory = (Button) this.mPastMedicalHistoryDialog.findViewById(2131362066);
((ImageView) this.mPastMedicalHistoryDialog.findViewById(2131362692)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (HealthInfoFragment.this.mPastMedicalHistoryDialog == null || !HealthInfoFragment.this.mPastMedicalHistoryDialog.isShowing()) {
return;
}
HealthInfoFragment.this.mPastMedicalHistoryDialog.dismiss();
}
});
Calendar calendar = Calendar.getInstance();
this.pastMedicalHistoryCalendar = calendar;
this.mPastMedicalHistoryObservedOn.setText(this.sdf.format(calendar.getTime()));
this.mPastMedicalHistoryObservedOn.setInputType(0);
this.mPastMedicalHistoryObservedOn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
HealthInfoFragment.this.createPastMedicalHistoryDateDialog();
}
});
this.mPastMedicalHistorySpn.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long j) {
if (HealthInfoFragment.this.pastMedicalHistoryMaster.size() > 0) {
HealthInfoFragment healthInfoFragment = HealthInfoFragment.this;
healthInfoFragment.pastMedicalHistoryId = ((PastMedicalHistoryMasterModel) healthInfoFragment.pastMedicalHistoryMaster.get(i)).getPastMedicalHistoryId();
}
}
});
this.mSavePastMedicalHistory.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String trim = HealthInfoFragment.this.mPastMedicalHistoryObservedOn.getText().toString().trim();
String trim2 = HealthInfoFragment.this.mPastMedicalHistoryComments.getText().toString().trim();
boolean isChecked = HealthInfoFragment.this.mHistoryAvailable.isChecked();
if (trim.length() <= 0 || trim2.length() <= 0 || HealthInfoFragment.this.pastMedicalHistoryId <= 0) {
if (HealthInfoFragment.this.pastMedicalHistoryId == 0) {
Toast.makeText(HealthInfoFragment.this.context, "Please select past medical history", 0).show();
return;
} else if (trim.length() == 0) {
Toast.makeText(HealthInfoFragment.this.context, "Please select observed on", 0).show();
return;
} else {
if (trim2.length() == 0) {
Toast.makeText(HealthInfoFragment.this.context, "Please enter comments", 0).show();
return;
}
return;
}
}
if (HealthInfoFragment.this.mPastMedicalHistoryDialog != null && HealthInfoFragment.this.mPastMedicalHistoryDialog.isShowing()) {
HealthInfoFragment.this.mPastMedicalHistoryDialog.dismiss();
}
if (HealthInfoFragment.this.isEdit) {
HealthInfoFragment.this.updatePastMedicalHistoryData(trim, trim2, isChecked ? 1 : 0);
} else {
HealthInfoFragment.this.savePastMedicalHistoryData(trim, trim2, isChecked ? 1 : 0);
}
}
});
}
private void createClinicalEvaluationsDialog() {
Dialog dialog = new Dialog(this.activity);
this.mClinicalEvaluationsDialog = dialog;
dialog.requestWindowFeature(1);
this.mClinicalEvaluationsDialog.setContentView(2131558651);
this.mClinicalEvaluationsDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
this.mClinicalEvaluationsDialog.setCancelable(true);
this.mClinicalEvaluationsHeader = (TextView) this.mClinicalEvaluationsDialog.findViewById(2131364016);
this.mClinicalEvaluationsSpn = (Spinner) this.mClinicalEvaluationsDialog.findViewById(2131363648);
this.mIsAbnormal = (CheckBox) this.mClinicalEvaluationsDialog.findViewById(2131362142);
this.mClinicalEvaluationsComments = (EditText) this.mClinicalEvaluationsDialog.findViewById(2131362378);
this.mSaveClinicalEvaluations = (Button) this.mClinicalEvaluationsDialog.findViewById(2131362060);
((ImageView) this.mClinicalEvaluationsDialog.findViewById(2131362657)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (HealthInfoFragment.this.mClinicalEvaluationsDialog == null || !HealthInfoFragment.this.mClinicalEvaluationsDialog.isShowing()) {
return;
}
HealthInfoFragment.this.mClinicalEvaluationsDialog.dismiss();
}
});
this.mClinicalEvaluationsSpn.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long j) {
if (HealthInfoFragment.this.clinicalEvaluationsMaster.size() > 0) {
HealthInfoFragment healthInfoFragment = HealthInfoFragment.this;
healthInfoFragment.clinicalEvaluationId = ((ClinicalEvaluationMasterModel) healthInfoFragment.clinicalEvaluationsMaster.get(i)).getClinicalEvaluationId();
}
}
});
this.mSaveClinicalEvaluations.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String trim = HealthInfoFragment.this.mClinicalEvaluationsComments.getText().toString().trim();
boolean isChecked = HealthInfoFragment.this.mIsAbnormal.isChecked();
if (trim.length() <= 0 || HealthInfoFragment.this.clinicalEvaluationId <= 0) {
if (HealthInfoFragment.this.clinicalEvaluationId == 0) {
Toast.makeText(HealthInfoFragment.this.context, "Please select clinical evaluation", 0).show();
return;
} else {
if (trim.length() == 0) {
Toast.makeText(HealthInfoFragment.this.context, "Please enter comments", 0).show();
return;
}
return;
}
}
if (HealthInfoFragment.this.mClinicalEvaluationsDialog != null && HealthInfoFragment.this.mClinicalEvaluationsDialog.isShowing()) {
HealthInfoFragment.this.mClinicalEvaluationsDialog.dismiss();
}
if (HealthInfoFragment.this.isEdit) {
HealthInfoFragment.this.updateClinicalEvaluations(trim, isChecked ? 1 : 0);
} else {
HealthInfoFragment.this.saveClinicalEvaluations(trim, isChecked ? 1 : 0);
}
}
});
}
private void createOtherMedicalHistoryDialog() {
Dialog dialog = new Dialog(this.activity);
this.mOtherMedicalHistoryDialog = dialog;
dialog.requestWindowFeature(1);
this.mOtherMedicalHistoryDialog.setContentView(2131558655);
this.mOtherMedicalHistoryDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
this.mOtherMedicalHistoryDialog.setCancelable(true);
this.mOtherMedicalHistoryHeader = (TextView) this.mOtherMedicalHistoryDialog.findViewById(2131364259);
this.mOtherMedicalHistorySpn = (Spinner) this.mOtherMedicalHistoryDialog.findViewById(2131363658);
this.mOtherMedicalHistoryObservedOn = (EditText) this.mOtherMedicalHistoryDialog.findViewById(2131362405);
this.mOtherMedicalHistoryComments = (EditText) this.mOtherMedicalHistoryDialog.findViewById(2131362404);
this.mSaveOtherMedicalHistory = (Button) this.mOtherMedicalHistoryDialog.findViewById(2131362065);
((ImageView) this.mOtherMedicalHistoryDialog.findViewById(2131362690)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (HealthInfoFragment.this.mOtherMedicalHistoryDialog == null || !HealthInfoFragment.this.mOtherMedicalHistoryDialog.isShowing()) {
return;
}
HealthInfoFragment.this.mOtherMedicalHistoryDialog.dismiss();
}
});
Calendar calendar = Calendar.getInstance();
this.otherMedicalHistoryCalendar = calendar;
this.mOtherMedicalHistoryObservedOn.setText(this.sdf.format(calendar.getTime()));
this.mOtherMedicalHistoryObservedOn.setInputType(0);
this.mOtherMedicalHistoryObservedOn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
HealthInfoFragment.this.createOtherMedicalHistoryDateDialog();
}
});
this.mOtherMedicalHistorySpn.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long j) {
if (HealthInfoFragment.this.otherMedicalHistoryMaster.size() > 0) {
HealthInfoFragment healthInfoFragment = HealthInfoFragment.this;
healthInfoFragment.otherMedicalHistoryId = ((OtherMedicalHistoryMasterModel) healthInfoFragment.otherMedicalHistoryMaster.get(i)).getOtherMedicalHistoryId();
}
}
});
this.mSaveOtherMedicalHistory.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String trim = HealthInfoFragment.this.mOtherMedicalHistoryObservedOn.getText().toString().trim();
String trim2 = HealthInfoFragment.this.mOtherMedicalHistoryComments.getText().toString().trim();
if (trim.length() <= 0 || trim2.length() <= 0 || HealthInfoFragment.this.otherMedicalHistoryId <= 0) {
if (HealthInfoFragment.this.otherMedicalHistoryId == 0) {
Toast.makeText(HealthInfoFragment.this.context, "Please select allergies / current medication", 0).show();
return;
} else if (trim.length() == 0) {
Toast.makeText(HealthInfoFragment.this.context, "Please select observed on", 0).show();
return;
} else {
if (trim2.length() == 0) {
Toast.makeText(HealthInfoFragment.this.context, "Please enter comments", 0).show();
return;
}
return;
}
}
if (HealthInfoFragment.this.mOtherMedicalHistoryDialog != null && HealthInfoFragment.this.mOtherMedicalHistoryDialog.isShowing()) {
HealthInfoFragment.this.mOtherMedicalHistoryDialog.dismiss();
}
if (HealthInfoFragment.this.isEdit) {
HealthInfoFragment.this.updateOtherMedicalHistory(trim, trim2);
} else {
HealthInfoFragment.this.saveOtherMedicalHistory(trim, trim2);
}
}
});
}
private void createHealthIssuesDialog() {
Dialog dialog = new Dialog(this.activity);
this.mHealthIssuesDialog = dialog;
dialog.requestWindowFeature(1);
this.mHealthIssuesDialog.setContentView(2131558654);
this.mHealthIssuesDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
this.mHealthIssuesDialog.setCancelable(true);
this.mHealthIssuesHeader = (TextView) this.mHealthIssuesDialog.findViewById(2131364152);
this.mHealthIssuesTitle = (TextView) this.mHealthIssuesDialog.findViewById(2131364143);
this.mHealthIssuesSpn = (Spinner) this.mHealthIssuesDialog.findViewById(2131363657);
this.mHealthIssuesObservedOnHeader = (TextView) this.mHealthIssuesDialog.findViewById(2131364147);
this.mHealthIssuesObservedOn = (EditText) this.mHealthIssuesDialog.findViewById(2131362395);
this.mHealthIssuesDoctor = (EditText) this.mHealthIssuesDialog.findViewById(2131362394);
this.mHealthIssuesComments = (EditText) this.mHealthIssuesDialog.findViewById(2131362393);
this.mUpload = (TextView) this.mHealthIssuesDialog.findViewById(2131364405);
this.mAttachedFile = (TextView) this.mHealthIssuesDialog.findViewById(2131363952);
this.mSaveHealthIssues = (Button) this.mHealthIssuesDialog.findViewById(2131362063);
((ImageView) this.mHealthIssuesDialog.findViewById(2131362677)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (HealthInfoFragment.this.mHealthIssuesDialog == null || !HealthInfoFragment.this.mHealthIssuesDialog.isShowing()) {
return;
}
HealthInfoFragment.this.mHealthIssuesDialog.dismiss();
}
});
Calendar calendar = Calendar.getInstance();
this.healthIssuesCalendar = calendar;
this.mHealthIssuesObservedOn.setText(this.sdf.format(calendar.getTime()));
this.mHealthIssuesObservedOn.setInputType(0);
this.mHealthIssuesObservedOn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
HealthInfoFragment.this.createHealthIssuesDateDialog();
}
});
this.mUpload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ArrayList arrayList = new ArrayList();
HealthInfoFragment.this.isFromBrowse = false;
FileUploadFragmentDialog fileUploadFragmentDialog = new FileUploadFragmentDialog(arrayList, false, HealthInfoFragment.this.onImageCaptured);
fileUploadFragmentDialog.show(HealthInfoFragment.this.getActivity().getSupportFragmentManager(), fileUploadFragmentDialog.getTag());
}
});
this.mHealthIssuesSpn.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long j) {
if (HealthInfoFragment.this.healthIssuesMaster.size() > 0) {
HealthInfoFragment healthInfoFragment = HealthInfoFragment.this;
healthInfoFragment.healthIssueId = ((StudentMedicalHistoryTypeMasterModel) healthInfoFragment.healthIssuesMaster.get(i)).getOrganisationMedicalHistoryId();
}
}
});
this.mSaveHealthIssues.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String trim = HealthInfoFragment.this.mHealthIssuesObservedOn.getText().toString().trim();
String trim2 = HealthInfoFragment.this.mHealthIssuesDoctor.getText().toString().trim();
String trim3 = HealthInfoFragment.this.mHealthIssuesComments.getText().toString().trim();
if (trim.length() <= 0 || trim2.length() <= 0 || trim3.length() <= 0 || HealthInfoFragment.this.healthIssueId <= 0) {
if (HealthInfoFragment.this.healthIssueId == 0) {
Toast.makeText(HealthInfoFragment.this.context, "Please select health issue", 0).show();
return;
}
if (trim.length() == 0) {
Toast.makeText(HealthInfoFragment.this.context, "Please select observed on", 0).show();
return;
} else if (trim2.length() == 0) {
Toast.makeText(HealthInfoFragment.this.context, "Please enter doctor name", 0).show();
return;
} else {
if (trim3.length() == 0) {
Toast.makeText(HealthInfoFragment.this.context, "Please enter comments", 0).show();
return;
}
return;
}
}
if (HealthInfoFragment.this.mHealthIssuesDialog != null && HealthInfoFragment.this.mHealthIssuesDialog.isShowing()) {
HealthInfoFragment.this.mHealthIssuesDialog.dismiss();
}
if (HealthInfoFragment.this.isEdit) {
HealthInfoFragment.this.updateHealthIssue(trim2, trim3);
} else {
HealthInfoFragment.this.saveHealthIssues(trim, trim2, trim3);
}
}
});
}
private void createHealthImmuniztionsDialog() {
Dialog dialog = new Dialog(this.activity);
this.mHealthImmunizationsDialog = dialog;
dialog.requestWindowFeature(1);
this.mHealthImmunizationsDialog.setContentView(2131558653);
this.mHealthImmunizationsDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
this.mHealthImmunizationsDialog.setCancelable(true);
this.mHealthImmunizationsHeader = (TextView) this.mHealthImmunizationsDialog.findViewById(2131364137);
this.mHealthImmunizationsSpn = (Spinner) this.mHealthImmunizationsDialog.findViewById(2131363656);
this.mHealthImmunizationsVaccineType = (EditText) this.mHealthImmunizationsDialog.findViewById(2131362392);
this.mHealthImmunizationsObservedOn = (EditText) this.mHealthImmunizationsDialog.findViewById(2131362391);
this.mHealthImmunizationsComments = (EditText) this.mHealthImmunizationsDialog.findViewById(2131362390);
this.mSaveHealthImmunizations = (Button) this.mHealthImmunizationsDialog.findViewById(2131362062);
((ImageView) this.mHealthImmunizationsDialog.findViewById(2131362675)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (HealthInfoFragment.this.mHealthImmunizationsDialog == null || !HealthInfoFragment.this.mHealthImmunizationsDialog.isShowing()) {
return;
}
HealthInfoFragment.this.mHealthImmunizationsDialog.dismiss();
}
});
Calendar calendar = Calendar.getInstance();
this.healthImmunizationsCalendar = calendar;
this.mHealthImmunizationsObservedOn.setText(this.sdf.format(calendar.getTime()));
this.mHealthImmunizationsObservedOn.setInputType(0);
this.mHealthImmunizationsObservedOn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
HealthInfoFragment.this.createHealthImmunizationsDateDialog();
}
});
this.mHealthImmunizationsSpn.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long j) {
if (HealthInfoFragment.this.healthImmunizationsMaster.size() > 0) {
HealthInfoFragment healthInfoFragment = HealthInfoFragment.this;
healthInfoFragment.healthImmunizationsId = ((HealthImmunizationMasterModel) healthInfoFragment.healthImmunizationsMaster.get(i)).getHealthImmunizationId();
}
}
});
this.mSaveHealthImmunizations.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String trim = HealthInfoFragment.this.mHealthImmunizationsObservedOn.getText().toString().trim();
String trim2 = HealthInfoFragment.this.mHealthImmunizationsVaccineType.getText().toString().trim();
String trim3 = HealthInfoFragment.this.mHealthImmunizationsComments.getText().toString().trim();
if (trim2.length() <= 0 || trim.length() <= 0 || trim3.length() <= 0 || HealthInfoFragment.this.healthImmunizationsId <= 0) {
if (HealthInfoFragment.this.healthImmunizationsId == 0) {
Toast.makeText(HealthInfoFragment.this.context, "Please select health immunizations", 0).show();
return;
}
if (trim2.length() == 0) {
Toast.makeText(HealthInfoFragment.this.context, "Please select vaccine type", 0).show();
return;
} else if (trim.length() == 0) {
Toast.makeText(HealthInfoFragment.this.context, "Please select observed on", 0).show();
return;
} else {
if (trim3.length() == 0) {
Toast.makeText(HealthInfoFragment.this.context, "Please enter comments", 0).show();
return;
}
return;
}
}
if (HealthInfoFragment.this.mHealthImmunizationsDialog != null && HealthInfoFragment.this.mHealthImmunizationsDialog.isShowing()) {
HealthInfoFragment.this.mHealthImmunizationsDialog.dismiss();
}
if (HealthInfoFragment.this.isEdit) {
HealthInfoFragment.this.updateHealthImmunizations(trim2, trim, trim3);
} else {
HealthInfoFragment.this.saveHealthImmunizations(trim2, trim, trim3);
}
}
});
}
public void createPastMedicalHistoryDateDialog() {
this.pastMedicalHistoryDateDialog = DatePickerDialog.newInstance(this, this.pastMedicalHistoryCalendar.get(1), this.pastMedicalHistoryCalendar.get(2), this.pastMedicalHistoryCalendar.get(5));
this.pastMedicalHistoryDateDialog.setMaxDate(Calendar.getInstance());
this.pastMedicalHistoryDateDialog.setThemeDark(false);
this.pastMedicalHistoryDateDialog.setAccentColor(ContextCompat.getColor(this.context, 2131099650));
this.pastMedicalHistoryDateDialog.show(this.activity.getFragmentManager(), "Datepickerdialog");
}
public void createOtherMedicalHistoryDateDialog() {
this.otherMedicalHistoryDateDialog = DatePickerDialog.newInstance(this, this.otherMedicalHistoryCalendar.get(1), this.otherMedicalHistoryCalendar.get(2), this.otherMedicalHistoryCalendar.get(5));
this.otherMedicalHistoryDateDialog.setMaxDate(Calendar.getInstance());
this.otherMedicalHistoryDateDialog.setThemeDark(false);
this.otherMedicalHistoryDateDialog.setAccentColor(ContextCompat.getColor(this.context, 2131099650));
this.otherMedicalHistoryDateDialog.show(this.activity.getFragmentManager(), "Datepickerdialog");
}
public void createHealthIssuesDateDialog() {
this.healthIssuesDateDialog = DatePickerDialog.newInstance(this, this.healthIssuesCalendar.get(1), this.healthIssuesCalendar.get(2), this.healthIssuesCalendar.get(5));
this.healthIssuesDateDialog.setMaxDate(Calendar.getInstance());
this.healthIssuesDateDialog.setThemeDark(false);
this.healthIssuesDateDialog.setAccentColor(ContextCompat.getColor(this.context, 2131099650));
this.healthIssuesDateDialog.show(this.activity.getFragmentManager(), "Datepickerdialog");
}
public void createHealthImmunizationsDateDialog() {
this.healthImmunizationsDateDialog = DatePickerDialog.newInstance(this, this.healthImmunizationsCalendar.get(1), this.healthImmunizationsCalendar.get(2), this.healthImmunizationsCalendar.get(5));
this.healthImmunizationsDateDialog.setMaxDate(Calendar.getInstance());
this.healthImmunizationsDateDialog.setThemeDark(false);
this.healthImmunizationsDateDialog.setAccentColor(ContextCompat.getColor(this.context, 2131099650));
this.healthImmunizationsDateDialog.show(this.activity.getFragmentManager(), "Datepickerdialog");
}
@Override
public void onDateSet(DatePickerDialog datePickerDialog, int i, int i2, int i3) {
if (datePickerDialog == this.pastMedicalHistoryDateDialog) {
this.pastMedicalHistoryCalendar.set(1, i);
this.pastMedicalHistoryCalendar.set(2, i2);
this.pastMedicalHistoryCalendar.set(5, i3);
this.mPastMedicalHistoryObservedOn.setText(this.sdf.format(this.pastMedicalHistoryCalendar.getTime()));
return;
}
if (datePickerDialog == this.otherMedicalHistoryDateDialog) {
this.otherMedicalHistoryCalendar.set(1, i);
this.otherMedicalHistoryCalendar.set(2, i2);
this.otherMedicalHistoryCalendar.set(5, i3);
this.mOtherMedicalHistoryObservedOn.setText(this.sdf.format(this.otherMedicalHistoryCalendar.getTime()));
return;
}
if (datePickerDialog == this.healthIssuesDateDialog) {
this.healthIssuesCalendar.set(1, i);
this.healthIssuesCalendar.set(2, i2);
this.healthIssuesCalendar.set(5, i3);
this.mHealthIssuesObservedOn.setText(this.sdf.format(this.healthIssuesCalendar.getTime()));
return;
}
if (datePickerDialog == this.healthImmunizationsDateDialog) {
this.healthImmunizationsCalendar.set(1, i);
this.healthImmunizationsCalendar.set(2, i2);
this.healthImmunizationsCalendar.set(5, i3);
this.mHealthImmunizationsObservedOn.setText(this.sdf.format(this.healthImmunizationsCalendar.getTime()));
}
}
@Override
public void onClick(View view) {
TextView textView = this.mBMI;
if (view == textView || view == this.mMedicalHistory || view == this.mHealthImmunizations) {
setBackgroundTint(textView, 2131100860);
setBackgroundTint(this.mMedicalHistory, 2131100860);
setBackgroundTint(this.mHealthImmunizations, 2131100860);
this.mBMILL.setVisibility(8);
this.mMedicalHistoryLL.setVisibility(8);
this.mHealthImmunizationsLL.setVisibility(8);
TextView textView2 = this.mBMI;
if (view == textView2) {
setBackgroundTint(textView2, 2131099711);
this.mBMILL.setVisibility(0);
loadHealthBMI();
return;
}
TextView textView3 = this.mMedicalHistory;
if (view == textView3) {
setBackgroundTint(textView3, 2131100341);
this.mMedicalHistoryLL.setVisibility(0);
loadHealthHistory();
return;
} else {
TextView textView4 = this.mHealthImmunizations;
if (view == textView4) {
setBackgroundTint(textView4, 2131099860);
this.mHealthImmunizationsLL.setVisibility(0);
getHealthImmunizations();
return;
}
return;
}
}
if (view == this.mAddPastMedicalHistory) {
this.isEdit = false;
getMedicalHistoryMaster();
return;
}
if (view == this.mAddClinicalEvaluations) {
this.isEdit = false;
getClinicalEvaluationsMaster();
return;
}
if (view == this.mAddAllergies) {
this.isEdit = false;
getOtherMedicalHistoryMaster();
} else if (view == this.mAddHealthIssues) {
this.isEdit = false;
getHealthIssuesMaster();
} else if (view == this.mAddHealthImmunizations) {
this.isEdit = false;
getHealthImmunizationsMaster();
}
}
private void setBackgroundTint(TextView textView, int i) {
Drawable wrap = DrawableCompat.wrap(textView.getBackground());
DrawableCompat.setTint(wrap, ContextCompat.getColor(this.context, i));
textView.setBackground(wrap);
}
private void getStudentProfile() {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
this.conMgr = connectivityManager;
if (connectivityManager.getActiveNetworkInfo() != null && this.conMgr.getActiveNetworkInfo().isAvailable() && this.conMgr.getActiveNetworkInfo().isConnected()) {
getStudentDetails();
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void getStudentDetails() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).GetStudentProfile(Integer.parseInt(this.userId), Utility.getSchoolApiKey(this.context)).enqueue(new Callback<ArrayList<StudentInfoModel>>() {
public void onResponse(Call<ArrayList<StudentInfoModel>> call, Response<ArrayList<StudentInfoModel>> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
ArrayList arrayList = (ArrayList) response.body();
if (arrayList.size() > 0) {
StudentInfoModel studentInfoModel = (StudentInfoModel) arrayList.get(0);
HealthInfoFragment.this.mDOB.setText(studentInfoModel.getDateOfBirth());
HealthInfoFragment.this.mBloodGroup.setText(studentInfoModel.getBloodGroup());
}
}
public void onFailure(Call<ArrayList<StudentInfoModel>> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
public void loadHealthHistory() {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
this.conMgr = connectivityManager;
if (connectivityManager.getActiveNetworkInfo() != null && this.conMgr.getActiveNetworkInfo().isAvailable() && this.conMgr.getActiveNetworkInfo().isConnected()) {
getStudentHealthHistory();
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void getStudentHealthHistory() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).GetMedicalHistory(Integer.parseInt(this.studentEnrollmentId), Integer.parseInt(this.orgId), Utility.getSchoolApiKey(this.context)).enqueue(new Callback<HealthHistoryModel>() {
public void onResponse(Call<HealthHistoryModel> call, Response<HealthHistoryModel> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
HealthHistoryModel healthHistoryModel = (HealthHistoryModel) response.body();
ArrayList<PastMedicalHistoryModel> pastMedicalHistory = healthHistoryModel.getPastMedicalHistory();
ArrayList<ClinicalEvaluationsModel> clinicalEvaluations = healthHistoryModel.getClinicalEvaluations();
ArrayList<OtherMedicalHistoryModel> otherMedicalHistory = healthHistoryModel.getOtherMedicalHistory();
ArrayList<HealthIssuesModel> healthIssues = healthHistoryModel.getHealthIssues();
HealthInfoFragment.this.mPastMedicalHistory.setAdapter((ListAdapter) new PastMedicalHistoryAdapter(HealthInfoFragment.this.activity, pastMedicalHistory, HealthInfoFragment.this.pastMedicalHistoryDetails));
HealthInfoFragment.this.mClinicalEvaluations.setAdapter((ListAdapter) new ClinicalEvaluationsAdapter(HealthInfoFragment.this.activity, clinicalEvaluations, HealthInfoFragment.this.clinicalEvaluationsDetails));
HealthInfoFragment.this.mAllergies.setAdapter((ListAdapter) new OtherMedicalHistoryAdapter(HealthInfoFragment.this.activity, otherMedicalHistory, HealthInfoFragment.this.otherMedicalHistoryDetails));
HealthInfoFragment.this.mHealthIssues.setAdapter((ListAdapter) new HealthIssuesAdapter(HealthInfoFragment.this.activity, healthIssues, HealthInfoFragment.this.healthIssueDetails));
}
public void onFailure(Call<HealthHistoryModel> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
public void getHealthImmunizations() {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
this.conMgr = connectivityManager;
if (connectivityManager.getActiveNetworkInfo() != null && this.conMgr.getActiveNetworkInfo().isAvailable() && this.conMgr.getActiveNetworkInfo().isConnected()) {
getStudentHealthImmunizations();
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void getStudentHealthImmunizations() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).GetStudentHealthImmunizations(Integer.parseInt(this.studentEnrollmentId), Integer.parseInt(this.orgId), Utility.getSchoolApiKey(this.context)).enqueue(new Callback<ArrayList<HealthImmunizationModel>>() {
public void onResponse(Call<ArrayList<HealthImmunizationModel>> call, Response<ArrayList<HealthImmunizationModel>> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
HealthInfoFragment.this.mImmunizations.setAdapter((ListAdapter) new HealthImmunizationsAdapter(HealthInfoFragment.this.activity, (ArrayList) response.body(), HealthInfoFragment.this.healthImmunizationsDetails));
}
public void onFailure(Call<ArrayList<HealthImmunizationModel>> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
@Override
public void editPastMedicalHistory(PastMedicalHistoryModel pastMedicalHistoryModel) {
this.isEdit = true;
this.pastMedicalHistoryModel = pastMedicalHistoryModel;
getMedicalHistoryMaster();
}
@Override
public void deletePastMedicalHistory(final PastMedicalHistoryModel pastMedicalHistoryModel) {
new AlertDialog.Builder(this.activity).setTitle("Alert").setMessage("Are you sure, you want to delete?").setCancelable(false).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
HealthInfoFragment.this.pastMedicalHistoryModel = pastMedicalHistoryModel;
HealthInfoFragment.this.deletePastMedicalHistoryData();
}
}).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
}).show();
}
private void getMedicalHistoryMaster() {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
this.conMgr = connectivityManager;
if (connectivityManager.getActiveNetworkInfo() != null && this.conMgr.getActiveNetworkInfo().isAvailable() && this.conMgr.getActiveNetworkInfo().isConnected()) {
getPastMedicalHistoryMaster();
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void getPastMedicalHistoryMaster() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).GetPastMedicalHistoryMaster(Utility.getSchoolApiKey(this.context)).enqueue(new Callback<ArrayList<PastMedicalHistoryMasterModel>>() {
public void onResponse(Call<ArrayList<PastMedicalHistoryMasterModel>> call, Response<ArrayList<PastMedicalHistoryMasterModel>> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
HealthInfoFragment.this.pastMedicalHistoryMaster = (ArrayList) response.body();
ArrayAdapter arrayAdapter = new ArrayAdapter(HealthInfoFragment.this.context, 2131558613, HealthInfoFragment.this.pastMedicalHistoryMaster);
arrayAdapter.setDropDownViewResource(2131559059);
HealthInfoFragment.this.mPastMedicalHistorySpn.setAdapter((SpinnerAdapter) arrayAdapter);
if (HealthInfoFragment.this.isEdit) {
if (HealthInfoFragment.this.pastMedicalHistoryModel != null) {
String date = HealthInfoFragment.this.pastMedicalHistoryModel.getDate();
int pastMedicalHistoryId = HealthInfoFragment.this.pastMedicalHistoryModel.getPastMedicalHistoryId();
String comments = HealthInfoFragment.this.pastMedicalHistoryModel.getComments();
int i = 0;
while (true) {
if (i >= HealthInfoFragment.this.pastMedicalHistoryMaster.size()) {
break;
}
if (pastMedicalHistoryId == ((PastMedicalHistoryMasterModel) HealthInfoFragment.this.pastMedicalHistoryMaster.get(i)).getPastMedicalHistoryId()) {
HealthInfoFragment.this.mPastMedicalHistorySpn.setSelection(i);
break;
}
i++;
}
HealthInfoFragment.this.pastMedicalHistoryCalendar.setTime(new Date(date));
HealthInfoFragment.this.mPastMedicalHistoryObservedOn.setText(HealthInfoFragment.this.sdf.format(HealthInfoFragment.this.pastMedicalHistoryCalendar.getTime()));
if (comments == null || comments.length() <= 0 || comments.equalsIgnoreCase("null")) {
HealthInfoFragment.this.mPastMedicalHistoryComments.setText("");
} else {
HealthInfoFragment.this.mPastMedicalHistoryComments.setText(comments);
}
HealthInfoFragment.this.mHistoryAvailable.setChecked(HealthInfoFragment.this.pastMedicalHistoryModel.isHistoryAvailable());
HealthInfoFragment.this.mPastMedicalHistoryHeader.setText("Edit Past Medical History");
HealthInfoFragment.this.mSavePastMedicalHistory.setText("Update");
}
} else {
HealthInfoFragment.this.pastMedicalHistoryCalendar = Calendar.getInstance();
HealthInfoFragment.this.mPastMedicalHistoryObservedOn.setText(HealthInfoFragment.this.sdf.format(HealthInfoFragment.this.pastMedicalHistoryCalendar.getTime()));
HealthInfoFragment.this.mPastMedicalHistoryComments.setText("");
HealthInfoFragment.this.mHistoryAvailable.setChecked(true);
HealthInfoFragment.this.mPastMedicalHistoryHeader.setText("Add Past Medical History");
HealthInfoFragment.this.mSavePastMedicalHistory.setText("Save");
}
if (HealthInfoFragment.this.mPastMedicalHistoryDialog == null || HealthInfoFragment.this.mPastMedicalHistoryDialog.isShowing()) {
return;
}
HealthInfoFragment.this.mPastMedicalHistoryDialog.show();
}
public void onFailure(Call<ArrayList<PastMedicalHistoryMasterModel>> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
public void savePastMedicalHistoryData(String str, String str2, int i) {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
savePastMedicalHistory(str, str2, i);
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void savePastMedicalHistory(String str, String str2, int i) {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("PastMedicalHistoryID", String.valueOf(this.pastMedicalHistoryId));
hashMap.put("ObservedDate", str);
hashMap.put("Comments", str2);
hashMap.put("HistoryAvailable", String.valueOf(i));
hashMap.put("StudentEnrollmentID", this.studentEnrollmentId);
hashMap.put("OrganisationID", this.orgId);
hashMap.put("apikey", Utility.getSchoolApiKey(this.context));
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).SavePastMedicalHistory(hashMap).enqueue(new Callback<String>() {
public void onResponse(Call<String> call, Response<String> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
String str3 = (String) response.body();
AlertDialog.Builder builder = new AlertDialog.Builder(HealthInfoFragment.this.activity);
builder.setMessage(str3);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i2) {
dialogInterface.dismiss();
HealthInfoFragment.this.loadHealthHistory();
}
});
builder.show();
}
public void onFailure(Call<String> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
public void updatePastMedicalHistoryData(String str, String str2, int i) {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
updatePastMedicalHistory(str, str2, i);
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void updatePastMedicalHistory(String str, String str2, int i) {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("StudentPastMedicalHistoryID", String.valueOf(this.pastMedicalHistoryModel.getStudentPastMedicalHistoryId()));
hashMap.put("PastMedicalHistoryID", String.valueOf(this.pastMedicalHistoryId));
hashMap.put("ObservedDate", str);
hashMap.put("Comments", str2);
hashMap.put("HistoryAvailable", String.valueOf(i));
hashMap.put("apikey", Utility.getSchoolApiKey(this.context));
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).UpdatePastMedicalHistory(hashMap).enqueue(new Callback<String>() {
public void onResponse(Call<String> call, Response<String> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
String str3 = (String) response.body();
AlertDialog.Builder builder = new AlertDialog.Builder(HealthInfoFragment.this.activity);
builder.setMessage(str3);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i2) {
dialogInterface.dismiss();
HealthInfoFragment.this.loadHealthHistory();
}
});
builder.show();
}
public void onFailure(Call<String> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
public void deletePastMedicalHistoryData() {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
deletePastMedicalHistory();
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void deletePastMedicalHistory() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("StudentPastMedicalHistoryID", String.valueOf(this.pastMedicalHistoryModel.getStudentPastMedicalHistoryId()));
hashMap.put("apikey", Utility.getSchoolApiKey(this.context));
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).DeletePastMedicalHistory(hashMap).enqueue(new Callback<String>() {
public void onResponse(Call<String> call, Response<String> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
String str = (String) response.body();
AlertDialog.Builder builder = new AlertDialog.Builder(HealthInfoFragment.this.activity);
builder.setMessage(str);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
HealthInfoFragment.this.loadHealthHistory();
}
});
builder.show();
}
public void onFailure(Call<String> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
@Override
public void editClinicalEvaluations(ClinicalEvaluationsModel clinicalEvaluationsModel) {
this.isEdit = true;
this.clinicalEvaluationsModel = clinicalEvaluationsModel;
getClinicalEvaluationsMaster();
}
@Override
public void deleteClinicalEvaluations(final ClinicalEvaluationsModel clinicalEvaluationsModel) {
new AlertDialog.Builder(this.activity).setTitle("Alert").setMessage("Are you sure, you want to delete?").setCancelable(false).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
HealthInfoFragment.this.clinicalEvaluationsModel = clinicalEvaluationsModel;
HealthInfoFragment.this.deleteClinicalEvaluations();
}
}).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
}).show();
}
private void getClinicalEvaluationsMaster() {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
this.conMgr = connectivityManager;
if (connectivityManager.getActiveNetworkInfo() != null && this.conMgr.getActiveNetworkInfo().isAvailable() && this.conMgr.getActiveNetworkInfo().isConnected()) {
getStudentClinicalEvaluationsMaster();
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void getStudentClinicalEvaluationsMaster() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).GetStudentClinicalEvaluationsMaster(Utility.getSchoolApiKey(this.context)).enqueue(new Callback<ArrayList<ClinicalEvaluationMasterModel>>() {
public void onResponse(Call<ArrayList<ClinicalEvaluationMasterModel>> call, Response<ArrayList<ClinicalEvaluationMasterModel>> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
HealthInfoFragment.this.clinicalEvaluationsMaster = (ArrayList) response.body();
ArrayAdapter arrayAdapter = new ArrayAdapter(HealthInfoFragment.this.context, 2131558613, HealthInfoFragment.this.clinicalEvaluationsMaster);
arrayAdapter.setDropDownViewResource(2131559059);
HealthInfoFragment.this.mClinicalEvaluationsSpn.setAdapter((SpinnerAdapter) arrayAdapter);
if (HealthInfoFragment.this.isEdit) {
if (HealthInfoFragment.this.clinicalEvaluationsModel != null) {
int clinicalEvaluationId = HealthInfoFragment.this.clinicalEvaluationsModel.getClinicalEvaluationId();
String comments = HealthInfoFragment.this.clinicalEvaluationsModel.getComments();
int i = 0;
while (true) {
if (i >= HealthInfoFragment.this.clinicalEvaluationsMaster.size()) {
break;
}
if (clinicalEvaluationId == ((ClinicalEvaluationMasterModel) HealthInfoFragment.this.clinicalEvaluationsMaster.get(i)).getClinicalEvaluationId()) {
HealthInfoFragment.this.mClinicalEvaluationsSpn.setSelection(i);
break;
}
i++;
}
if (comments == null || comments.length() <= 0 || comments.equalsIgnoreCase("null")) {
HealthInfoFragment.this.mClinicalEvaluationsComments.setText("");
} else {
HealthInfoFragment.this.mClinicalEvaluationsComments.setText(comments);
}
HealthInfoFragment.this.mIsAbnormal.setChecked(HealthInfoFragment.this.clinicalEvaluationsModel.isAbnormal());
HealthInfoFragment.this.mClinicalEvaluationsHeader.setText("Edit Clinical Evaluations");
HealthInfoFragment.this.mSaveClinicalEvaluations.setText("Update");
}
} else {
HealthInfoFragment.this.mClinicalEvaluationsComments.setText("");
HealthInfoFragment.this.mIsAbnormal.setChecked(true);
HealthInfoFragment.this.mClinicalEvaluationsHeader.setText("Add Clinical Evaluations");
HealthInfoFragment.this.mSaveClinicalEvaluations.setText("Save");
}
if (HealthInfoFragment.this.mClinicalEvaluationsDialog == null || HealthInfoFragment.this.mClinicalEvaluationsDialog.isShowing()) {
return;
}
HealthInfoFragment.this.mClinicalEvaluationsDialog.show();
}
public void onFailure(Call<ArrayList<ClinicalEvaluationMasterModel>> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
public void saveClinicalEvaluations(String str, int i) {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
saveStudentClinicalEvaluations(str, i);
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void saveStudentClinicalEvaluations(String str, int i) {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("ClinicalEvaluationID", String.valueOf(this.clinicalEvaluationId));
hashMap.put("Comments", str);
hashMap.put("IsAbnormal", String.valueOf(i));
hashMap.put("StudentEnrollmentID", this.studentEnrollmentId);
hashMap.put("OrganisationID", this.orgId);
hashMap.put("apikey", Utility.getSchoolApiKey(this.context));
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).SaveStudentClinicalEvaluations(hashMap).enqueue(new Callback<String>() {
public void onResponse(Call<String> call, Response<String> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
String str2 = (String) response.body();
AlertDialog.Builder builder = new AlertDialog.Builder(HealthInfoFragment.this.activity);
builder.setMessage(str2);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i2) {
dialogInterface.dismiss();
HealthInfoFragment.this.loadHealthHistory();
}
});
builder.show();
}
public void onFailure(Call<String> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
public void updateClinicalEvaluations(String str, int i) {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
updateStudentClinicalEvaluations(str, i);
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void updateStudentClinicalEvaluations(String str, int i) {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("StudentClinicalEvaluationID", String.valueOf(this.clinicalEvaluationsModel.getStudentClinicalEvaluationId()));
hashMap.put("ClinicalEvaluationID", String.valueOf(this.clinicalEvaluationId));
hashMap.put("Comments", str);
hashMap.put("IsAbnormal", String.valueOf(i));
hashMap.put("apikey", Utility.getSchoolApiKey(this.context));
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).UpdateStudentClinicalEvaluations(hashMap).enqueue(new Callback<String>() {
public void onResponse(Call<String> call, Response<String> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
String str2 = (String) response.body();
AlertDialog.Builder builder = new AlertDialog.Builder(HealthInfoFragment.this.activity);
builder.setMessage(str2);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i2) {
dialogInterface.dismiss();
HealthInfoFragment.this.loadHealthHistory();
}
});
builder.show();
}
public void onFailure(Call<String> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
public void deleteClinicalEvaluations() {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
deleteStudentClinicalEvaluations();
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void deleteStudentClinicalEvaluations() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("StudentClinicalEvaluationID", String.valueOf(this.clinicalEvaluationsModel.getStudentClinicalEvaluationId()));
hashMap.put("apikey", Utility.getSchoolApiKey(this.context));
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).DeleteStudentClinicalEvaluations(hashMap).enqueue(new Callback<String>() {
public void onResponse(Call<String> call, Response<String> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
String str = (String) response.body();
AlertDialog.Builder builder = new AlertDialog.Builder(HealthInfoFragment.this.activity);
builder.setMessage(str);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
HealthInfoFragment.this.loadHealthHistory();
}
});
builder.show();
}
public void onFailure(Call<String> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
@Override
public void editOtherMedicalHistory(OtherMedicalHistoryModel otherMedicalHistoryModel) {
this.isEdit = true;
this.otherMedicalHistoryModel = otherMedicalHistoryModel;
getOtherMedicalHistoryMaster();
}
@Override
public void deleteOtherMedicalHistory(final OtherMedicalHistoryModel otherMedicalHistoryModel) {
new AlertDialog.Builder(this.activity).setTitle("Alert").setMessage("Are you sure, you want to delete?").setCancelable(false).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
HealthInfoFragment.this.otherMedicalHistoryModel = otherMedicalHistoryModel;
HealthInfoFragment.this.deleteOtherMedicalHistory();
}
}).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
}).show();
}
private void getOtherMedicalHistoryMaster() {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
this.conMgr = connectivityManager;
if (connectivityManager.getActiveNetworkInfo() != null && this.conMgr.getActiveNetworkInfo().isAvailable() && this.conMgr.getActiveNetworkInfo().isConnected()) {
getStudentOtherMedicalHistoryMaster();
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void getStudentOtherMedicalHistoryMaster() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).GetStudentOtherMedicalHistoryMaster(Utility.getSchoolApiKey(this.context)).enqueue(new Callback<ArrayList<OtherMedicalHistoryMasterModel>>() {
public void onResponse(Call<ArrayList<OtherMedicalHistoryMasterModel>> call, Response<ArrayList<OtherMedicalHistoryMasterModel>> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
HealthInfoFragment.this.otherMedicalHistoryMaster = (ArrayList) response.body();
ArrayAdapter arrayAdapter = new ArrayAdapter(HealthInfoFragment.this.context, 2131558613, HealthInfoFragment.this.otherMedicalHistoryMaster);
arrayAdapter.setDropDownViewResource(2131559059);
HealthInfoFragment.this.mOtherMedicalHistorySpn.setAdapter((SpinnerAdapter) arrayAdapter);
if (HealthInfoFragment.this.isEdit) {
if (HealthInfoFragment.this.otherMedicalHistoryModel != null) {
String date = HealthInfoFragment.this.otherMedicalHistoryModel.getDate();
int otherMedicalHistoryId = HealthInfoFragment.this.otherMedicalHistoryModel.getOtherMedicalHistoryId();
String comments = HealthInfoFragment.this.otherMedicalHistoryModel.getComments();
int i = 0;
while (true) {
if (i >= HealthInfoFragment.this.otherMedicalHistoryMaster.size()) {
break;
}
if (otherMedicalHistoryId == ((OtherMedicalHistoryMasterModel) HealthInfoFragment.this.otherMedicalHistoryMaster.get(i)).getOtherMedicalHistoryId()) {
HealthInfoFragment.this.mOtherMedicalHistorySpn.setSelection(i);
break;
}
i++;
}
HealthInfoFragment.this.otherMedicalHistoryCalendar.setTime(new Date(date));
HealthInfoFragment.this.mOtherMedicalHistoryObservedOn.setText(HealthInfoFragment.this.sdf.format(HealthInfoFragment.this.otherMedicalHistoryCalendar.getTime()));
if (comments == null || comments.length() <= 0 || comments.equalsIgnoreCase("null")) {
HealthInfoFragment.this.mOtherMedicalHistoryComments.setText("");
} else {
HealthInfoFragment.this.mOtherMedicalHistoryComments.setText(comments);
}
HealthInfoFragment.this.mOtherMedicalHistoryHeader.setText("Edit Allergies / Current Medication");
HealthInfoFragment.this.mSaveOtherMedicalHistory.setText("Update");
}
} else {
HealthInfoFragment.this.otherMedicalHistoryCalendar = Calendar.getInstance();
HealthInfoFragment.this.mOtherMedicalHistoryObservedOn.setText(HealthInfoFragment.this.sdf.format(HealthInfoFragment.this.otherMedicalHistoryCalendar.getTime()));
HealthInfoFragment.this.mOtherMedicalHistoryComments.setText("");
HealthInfoFragment.this.mOtherMedicalHistoryHeader.setText("Add Allergies / Current Medication");
HealthInfoFragment.this.mSaveOtherMedicalHistory.setText("Save");
}
if (HealthInfoFragment.this.mOtherMedicalHistoryDialog == null || HealthInfoFragment.this.mOtherMedicalHistoryDialog.isShowing()) {
return;
}
HealthInfoFragment.this.mOtherMedicalHistoryDialog.show();
}
public void onFailure(Call<ArrayList<OtherMedicalHistoryMasterModel>> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
public void saveOtherMedicalHistory(String str, String str2) {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
saveStudentOtherMedicalHistory(str, str2);
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void saveStudentOtherMedicalHistory(String str, String str2) {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("OtherMedicalHistoryID", String.valueOf(this.otherMedicalHistoryId));
hashMap.put("Date", str);
hashMap.put("Comments", str2);
hashMap.put("StudentEnrollmentID", this.studentEnrollmentId);
hashMap.put("OrganisationID", this.orgId);
hashMap.put("apikey", Utility.getSchoolApiKey(this.context));
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).SaveStudentOtherMedicalHistory(hashMap).enqueue(new Callback<String>() {
public void onResponse(Call<String> call, Response<String> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
String str3 = (String) response.body();
AlertDialog.Builder builder = new AlertDialog.Builder(HealthInfoFragment.this.activity);
builder.setMessage(str3);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
HealthInfoFragment.this.loadHealthHistory();
}
});
builder.show();
}
public void onFailure(Call<String> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
public void updateOtherMedicalHistory(String str, String str2) {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
updateStudentOtherMedicalHistory(str, str2);
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void updateStudentOtherMedicalHistory(String str, String str2) {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("StudentOtherMedicalHistoryID", String.valueOf(this.otherMedicalHistoryModel.getStudentOtherMedicalHistoryId()));
hashMap.put("OtherMedicalHistoryID", String.valueOf(this.otherMedicalHistoryId));
hashMap.put("Date", str);
hashMap.put("Comments", str2);
hashMap.put("apikey", Utility.getSchoolApiKey(this.context));
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).UpdateStudentOtherMedicalHistory(hashMap).enqueue(new Callback<String>() {
public void onResponse(Call<String> call, Response<String> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
String str3 = (String) response.body();
AlertDialog.Builder builder = new AlertDialog.Builder(HealthInfoFragment.this.activity);
builder.setMessage(str3);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
HealthInfoFragment.this.loadHealthHistory();
}
});
builder.show();
}
public void onFailure(Call<String> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
public void deleteOtherMedicalHistory() {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
deleteStudentOtherMedicalHistory();
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void deleteStudentOtherMedicalHistory() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("StudentOtherMedicalHistoryID", String.valueOf(this.otherMedicalHistoryModel.getStudentOtherMedicalHistoryId()));
hashMap.put("apikey", Utility.getSchoolApiKey(this.context));
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).DeleteStudentOtherMedicalHistory(hashMap).enqueue(new Callback<String>() {
public void onResponse(Call<String> call, Response<String> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
String str = (String) response.body();
AlertDialog.Builder builder = new AlertDialog.Builder(HealthInfoFragment.this.activity);
builder.setMessage(str);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
HealthInfoFragment.this.loadHealthHistory();
}
});
builder.show();
}
public void onFailure(Call<String> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
@Override
public void editHealthIssue(HealthIssuesModel healthIssuesModel) {
this.isEdit = true;
this.healthIssuesModel = healthIssuesModel;
getHealthIssuesMaster();
}
@Override
public void deleteHealthIssue(final HealthIssuesModel healthIssuesModel) {
new AlertDialog.Builder(this.activity).setTitle("Alert").setMessage("Are you sure, you want to delete?").setCancelable(false).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
HealthInfoFragment.this.healthIssuesModel = healthIssuesModel;
HealthInfoFragment.this.deleteHealthIssue();
}
}).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
}).show();
}
private void getHealthIssuesMaster() {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
this.conMgr = connectivityManager;
if (connectivityManager.getActiveNetworkInfo() != null && this.conMgr.getActiveNetworkInfo().isAvailable() && this.conMgr.getActiveNetworkInfo().isConnected()) {
getTypesMedicalInformation();
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void getTypesMedicalInformation() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).GetTypesMedicalInformation(Integer.parseInt(this.orgId), Utility.getSchoolApiKey(this.context)).enqueue(new Callback<ArrayList<StudentMedicalHistoryTypeMasterModel>>() {
public void onResponse(Call<ArrayList<StudentMedicalHistoryTypeMasterModel>> call, Response<ArrayList<StudentMedicalHistoryTypeMasterModel>> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
HealthInfoFragment.this.healthIssuesMaster = (ArrayList) response.body();
ArrayAdapter arrayAdapter = new ArrayAdapter(HealthInfoFragment.this.context, 2131558613, HealthInfoFragment.this.healthIssuesMaster);
arrayAdapter.setDropDownViewResource(2131559059);
HealthInfoFragment.this.mHealthIssuesSpn.setAdapter((SpinnerAdapter) arrayAdapter);
if (HealthInfoFragment.this.isEdit) {
if (HealthInfoFragment.this.healthIssuesModel != null) {
String date = HealthInfoFragment.this.healthIssuesModel.getDate();
int studentMedicalHistoryMasterId = HealthInfoFragment.this.healthIssuesModel.getStudentMedicalHistoryMasterId();
String doctorName = HealthInfoFragment.this.healthIssuesModel.getDoctorName();
String comments = HealthInfoFragment.this.healthIssuesModel.getComments();
int i = 0;
while (true) {
if (i >= HealthInfoFragment.this.healthIssuesMaster.size()) {
break;
}
if (studentMedicalHistoryMasterId == ((StudentMedicalHistoryTypeMasterModel) HealthInfoFragment.this.healthIssuesMaster.get(i)).getStudentMedicalHistoryMasterId()) {
HealthInfoFragment.this.mHealthIssuesSpn.setSelection(i);
break;
}
i++;
}
HealthInfoFragment.this.healthIssuesCalendar.setTime(new Date(date));
HealthInfoFragment.this.mHealthIssuesObservedOn.setText(HealthInfoFragment.this.sdf.format(HealthInfoFragment.this.healthIssuesCalendar.getTime()));
if (doctorName == null || doctorName.length() <= 0 || doctorName.equalsIgnoreCase("null")) {
HealthInfoFragment.this.mHealthIssuesDoctor.setText("");
} else {
HealthInfoFragment.this.mHealthIssuesDoctor.setText(doctorName);
}
if (comments == null || comments.length() <= 0 || comments.equalsIgnoreCase("null")) {
HealthInfoFragment.this.mHealthIssuesComments.setText("");
} else {
HealthInfoFragment.this.mHealthIssuesComments.setText(comments);
}
HealthInfoFragment.this.mHealthIssuesObservedOnHeader.setVisibility(8);
HealthInfoFragment.this.mHealthIssuesObservedOn.setVisibility(8);
HealthInfoFragment.this.mHealthIssuesSpn.setEnabled(false);
HealthInfoFragment.this.mHealthIssuesHeader.setText("Edit Health Issues");
HealthInfoFragment.this.mSaveHealthIssues.setText("Update");
}
} else {
HealthInfoFragment.this.healthIssuesCalendar = Calendar.getInstance();
HealthInfoFragment.this.mHealthIssuesObservedOn.setText(HealthInfoFragment.this.sdf.format(HealthInfoFragment.this.healthIssuesCalendar.getTime()));
HealthInfoFragment.this.mHealthIssuesDoctor.setText("");
HealthInfoFragment.this.mHealthIssuesComments.setText("");
HealthInfoFragment.this.mHealthIssuesSpn.setEnabled(true);
HealthInfoFragment.this.mHealthIssuesHeader.setText("Add Health Issues");
HealthInfoFragment.this.mSaveHealthIssues.setText("Save");
}
HealthInfoFragment.this.filePath = "";
HealthInfoFragment.this.mAttachedFile.setText("No File Chosen");
if (HealthInfoFragment.this.mHealthIssuesDialog == null || HealthInfoFragment.this.mHealthIssuesDialog.isShowing()) {
return;
}
HealthInfoFragment.this.mHealthIssuesDialog.show();
}
public void onFailure(Call<ArrayList<StudentMedicalHistoryTypeMasterModel>> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
public void saveHealthIssues(String str, String str2, String str3) {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
saveMedicalHistory(str, str2, str3);
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void saveMedicalHistory(String str, String str2, String str3) {
MultipartBody.Part part;
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
RequestBody create = RequestBody.create(MediaType.parse(HTTP.PLAIN_TEXT_TYPE), this.studentEnrollmentId);
RequestBody create2 = RequestBody.create(MediaType.parse(HTTP.PLAIN_TEXT_TYPE), this.orgId);
RequestBody create3 = RequestBody.create(MediaType.parse(HTTP.PLAIN_TEXT_TYPE), this.branchId);
RequestBody create4 = RequestBody.create(MediaType.parse(HTTP.PLAIN_TEXT_TYPE), this.academicYearId);
RequestBody create5 = RequestBody.create(MediaType.parse(HTTP.PLAIN_TEXT_TYPE), String.valueOf(this.healthIssueId));
RequestBody create6 = RequestBody.create(MediaType.parse(HTTP.PLAIN_TEXT_TYPE), str2);
RequestBody create7 = RequestBody.create(MediaType.parse(HTTP.PLAIN_TEXT_TYPE), str3);
RequestBody create8 = RequestBody.create(MediaType.parse(HTTP.PLAIN_TEXT_TYPE), str);
RequestBody create9 = RequestBody.create(MediaType.parse(HTTP.PLAIN_TEXT_TYPE), Utility.getSchoolApiKey(this.context));
String str4 = this.filePath;
if (str4 == null || str4.length() <= 0) {
part = null;
} else {
File file = new File(this.filePath);
part = MultipartBody.Part.createFormData("file1", file.getName(), RequestBody.create(MediaType.parse("*/*"), file));
}
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).SaveMedicalHistory(part, create5, create6, create7, create8, create, create3, create4, create2, create9).enqueue(new Callback<String>() {
public void onResponse(Call<String> call, Response<String> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
String str5 = (String) response.body();
AlertDialog.Builder builder = new AlertDialog.Builder(HealthInfoFragment.this.activity);
builder.setMessage(str5);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
if (HealthInfoFragment.this.isFromBrowse && HealthInfoFragment.this.filePath != null && HealthInfoFragment.this.filePath.length() > 0) {
FileUtils.deleteFile(HealthInfoFragment.this.context, HealthInfoFragment.this.filePath);
}
HealthInfoFragment.this.loadHealthHistory();
}
});
builder.show();
}
public void onFailure(Call<String> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
public void updateHealthIssue(String str, String str2) {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
updateMedicalHistory(str, str2);
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void updateMedicalHistory(String str, String str2) {
MultipartBody.Part part;
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
RequestBody create = RequestBody.create(MediaType.parse(HTTP.PLAIN_TEXT_TYPE), this.orgId);
RequestBody create2 = RequestBody.create(MediaType.parse(HTTP.PLAIN_TEXT_TYPE), String.valueOf(this.healthIssuesModel.getMedicalHistoryId()));
RequestBody create3 = RequestBody.create(MediaType.parse(HTTP.PLAIN_TEXT_TYPE), str);
RequestBody create4 = RequestBody.create(MediaType.parse(HTTP.PLAIN_TEXT_TYPE), str2);
RequestBody create5 = RequestBody.create(MediaType.parse(HTTP.PLAIN_TEXT_TYPE), Utility.getSchoolApiKey(this.context));
String str3 = this.filePath;
if (str3 == null || str3.length() <= 0) {
part = null;
} else {
File file = new File(this.filePath);
part = MultipartBody.Part.createFormData("file1", file.getName(), RequestBody.create(MediaType.parse("*/*"), file));
}
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).UpdateMedicalHistory(part, create2, create3, create4, create, create5).enqueue(new Callback<String>() {
public void onResponse(Call<String> call, Response<String> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
String str4 = (String) response.body();
AlertDialog.Builder builder = new AlertDialog.Builder(HealthInfoFragment.this.activity);
builder.setMessage(str4);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
if (HealthInfoFragment.this.isFromBrowse && HealthInfoFragment.this.filePath != null && HealthInfoFragment.this.filePath.length() > 0) {
FileUtils.deleteFile(HealthInfoFragment.this.context, HealthInfoFragment.this.filePath);
}
HealthInfoFragment.this.loadHealthHistory();
}
});
builder.show();
}
public void onFailure(Call<String> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
public void deleteHealthIssue() {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
deleteMedicalHistory();
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void deleteMedicalHistory() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("MedicalHistoryID", String.valueOf(this.healthIssuesModel.getMedicalHistoryId()));
hashMap.put("apikey", Utility.getSchoolApiKey(this.context));
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).DeleteMedicalHistory(hashMap).enqueue(new Callback<String>() {
public void onResponse(Call<String> call, Response<String> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
String str = (String) response.body();
AlertDialog.Builder builder = new AlertDialog.Builder(HealthInfoFragment.this.activity);
builder.setMessage(str);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
HealthInfoFragment.this.loadHealthHistory();
}
});
builder.show();
}
public void onFailure(Call<String> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
@Override
public void editHealthImmunizations(HealthImmunizationModel healthImmunizationModel) {
this.isEdit = true;
this.healthImmunizationModel = healthImmunizationModel;
getHealthImmunizationsMaster();
}
@Override
public void deleteHealthImmunizations(final HealthImmunizationModel healthImmunizationModel) {
new AlertDialog.Builder(this.activity).setTitle("Alert").setMessage("Are you sure, you want to delete?").setCancelable(false).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
HealthInfoFragment.this.healthImmunizationModel = healthImmunizationModel;
HealthInfoFragment.this.deleteHealthImmunizations();
}
}).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
}).show();
}
private void getHealthImmunizationsMaster() {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
this.conMgr = connectivityManager;
if (connectivityManager.getActiveNetworkInfo() != null && this.conMgr.getActiveNetworkInfo().isAvailable() && this.conMgr.getActiveNetworkInfo().isConnected()) {
getStudentHealthImmunizationsMaster();
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void getStudentHealthImmunizationsMaster() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).GetStudentHealthImmunizationsMaster(Utility.getSchoolApiKey(this.context)).enqueue(new Callback<ArrayList<HealthImmunizationMasterModel>>() {
public void onResponse(Call<ArrayList<HealthImmunizationMasterModel>> call, Response<ArrayList<HealthImmunizationMasterModel>> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
HealthInfoFragment.this.healthImmunizationsMaster = (ArrayList) response.body();
ArrayAdapter arrayAdapter = new ArrayAdapter(HealthInfoFragment.this.context, 2131558613, HealthInfoFragment.this.healthImmunizationsMaster);
arrayAdapter.setDropDownViewResource(2131559059);
HealthInfoFragment.this.mHealthImmunizationsSpn.setAdapter((SpinnerAdapter) arrayAdapter);
if (HealthInfoFragment.this.isEdit) {
if (HealthInfoFragment.this.healthImmunizationModel != null) {
String date = HealthInfoFragment.this.healthImmunizationModel.getDate();
int healthImmunizationId = HealthInfoFragment.this.healthImmunizationModel.getHealthImmunizationId();
String vaccineType = HealthInfoFragment.this.healthImmunizationModel.getVaccineType();
String comments = HealthInfoFragment.this.healthImmunizationModel.getComments();
int i = 0;
while (true) {
if (i >= HealthInfoFragment.this.healthImmunizationsMaster.size()) {
break;
}
if (healthImmunizationId == ((HealthImmunizationMasterModel) HealthInfoFragment.this.healthImmunizationsMaster.get(i)).getHealthImmunizationId()) {
HealthInfoFragment.this.mHealthImmunizationsSpn.setSelection(i);
break;
}
i++;
}
HealthInfoFragment.this.healthImmunizationsCalendar.setTime(new Date(date));
HealthInfoFragment.this.mHealthImmunizationsObservedOn.setText(HealthInfoFragment.this.sdf.format(HealthInfoFragment.this.healthImmunizationsCalendar.getTime()));
if (vaccineType == null || vaccineType.length() <= 0 || vaccineType.equalsIgnoreCase("null")) {
HealthInfoFragment.this.mHealthImmunizationsVaccineType.setText("");
} else {
HealthInfoFragment.this.mHealthImmunizationsVaccineType.setText(vaccineType);
}
if (comments == null || comments.length() <= 0 || comments.equalsIgnoreCase("null")) {
HealthInfoFragment.this.mHealthImmunizationsComments.setText("");
} else {
HealthInfoFragment.this.mHealthImmunizationsComments.setText(comments);
}
HealthInfoFragment.this.mHealthImmunizationsHeader.setText("Edit Health Immunization");
HealthInfoFragment.this.mSaveHealthImmunizations.setText("Update");
}
} else {
HealthInfoFragment.this.healthImmunizationsCalendar = Calendar.getInstance();
HealthInfoFragment.this.mHealthImmunizationsObservedOn.setText(HealthInfoFragment.this.sdf.format(HealthInfoFragment.this.healthImmunizationsCalendar.getTime()));
HealthInfoFragment.this.mHealthImmunizationsVaccineType.setText("");
HealthInfoFragment.this.mHealthImmunizationsComments.setText("");
HealthInfoFragment.this.mHealthImmunizationsHeader.setText("Add Health Immunization");
HealthInfoFragment.this.mSaveHealthImmunizations.setText("Save");
}
if (HealthInfoFragment.this.mHealthImmunizationsDialog == null || HealthInfoFragment.this.mHealthImmunizationsDialog.isShowing()) {
return;
}
HealthInfoFragment.this.mHealthImmunizationsDialog.show();
}
public void onFailure(Call<ArrayList<HealthImmunizationMasterModel>> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
public void saveHealthImmunizations(String str, String str2, String str3) {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
saveStudentHealthImmunizations(str, str2, str3);
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void saveStudentHealthImmunizations(String str, String str2, String str3) {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("HealthImmunizationID", String.valueOf(this.healthImmunizationsId));
hashMap.put("VaccinationDate", str2);
hashMap.put("VaccineType", str);
hashMap.put("Comments", str3);
hashMap.put("StudentEnrollmentID", this.studentEnrollmentId);
hashMap.put("OrganisationID", this.orgId);
hashMap.put("apikey", Utility.getSchoolApiKey(this.context));
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).SaveStudentHealthImmunizations(hashMap).enqueue(new Callback<String>() {
public void onResponse(Call<String> call, Response<String> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
String str4 = (String) response.body();
AlertDialog.Builder builder = new AlertDialog.Builder(HealthInfoFragment.this.activity);
builder.setMessage(str4);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
HealthInfoFragment.this.getHealthImmunizations();
}
});
builder.show();
}
public void onFailure(Call<String> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
public void updateHealthImmunizations(String str, String str2, String str3) {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
updateStudentHealthImmunizations(str, str2, str3);
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void updateStudentHealthImmunizations(String str, String str2, String str3) {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("StudentHealthImmunizationID", String.valueOf(this.healthImmunizationModel.getStudentHealthImmunizationId()));
hashMap.put("HealthImmunizationID", String.valueOf(this.healthImmunizationsId));
hashMap.put("VaccinationDate", str2);
hashMap.put("VaccineType", str);
hashMap.put("Comments", str3);
hashMap.put("apikey", Utility.getSchoolApiKey(this.context));
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).UpdateStudentHealthImmunizations(hashMap).enqueue(new Callback<String>() {
public void onResponse(Call<String> call, Response<String> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
String str4 = (String) response.body();
AlertDialog.Builder builder = new AlertDialog.Builder(HealthInfoFragment.this.activity);
builder.setMessage(str4);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
HealthInfoFragment.this.getHealthImmunizations();
}
});
builder.show();
}
public void onFailure(Call<String> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
public void deleteHealthImmunizations() {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
deleteStudentHealthImmunizations();
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void deleteStudentHealthImmunizations() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("StudentHealthImmunizationID", String.valueOf(this.healthImmunizationModel.getStudentHealthImmunizationId()));
hashMap.put("apikey", Utility.getSchoolApiKey(this.context));
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).DeleteStudentHealthImmunizations(hashMap).enqueue(new Callback<String>() {
public void onResponse(Call<String> call, Response<String> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(HealthInfoFragment.this.activity);
return;
}
String str = (String) response.body();
AlertDialog.Builder builder = new AlertDialog.Builder(HealthInfoFragment.this.activity);
builder.setMessage(str);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
HealthInfoFragment.this.getHealthImmunizations();
}
});
builder.show();
}
public void onFailure(Call<String> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
private void loadHealthBMI() {
ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
this.conMgr = connectivityManager;
if (connectivityManager.getActiveNetworkInfo() != null && this.conMgr.getActiveNetworkInfo().isAvailable() && this.conMgr.getActiveNetworkInfo().isConnected()) {
getHealthBMIDetails();
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void getHealthBMIDetails() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).getHealthBMIDetails(Integer.parseInt(this.orgId), Integer.parseInt(this.academicYearId), Integer.parseInt(this.studentEnrollmentId), Utility.getSchoolApiKey(this.context)).enqueue(new Callback<ArrayList<HealthBMIModel>>() {
public void onResponse(Call<ArrayList<HealthBMIModel>> call, Response<ArrayList<HealthBMIModel>> response) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
return;
}
ArrayList arrayList = (ArrayList) response.body();
HealthInfoFragment.this.mBMIList.setAdapter((ListAdapter) new BMIAdapter(HealthInfoFragment.this.context, arrayList));
HealthInfoFragment.this.mChestMeasurement.setAdapter((ListAdapter) new ChestMeasurementAdapter(HealthInfoFragment.this.context, arrayList));
HealthInfoFragment.this.mVision.setAdapter((ListAdapter) new VisionAdapter(HealthInfoFragment.this.context, arrayList));
HealthInfoFragment.this.mDental.setAdapter((ListAdapter) new DentalAdapter(HealthInfoFragment.this.context, arrayList));
}
public void onFailure(Call<ArrayList<HealthBMIModel>> call, Throwable th) {
if (HealthInfoFragment.this.mProgressbar != null && HealthInfoFragment.this.mProgressbar.isShowing()) {
HealthInfoFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(HealthInfoFragment.this.activity);
}
});
}
public void onActivityResult(int i, int i2, Intent intent) {
super.onActivityResult(i, i2, intent);
if (i2 != 100 || intent == null) {
return;
}
ArrayList<String> stringArrayListExtra = intent.getStringArrayListExtra("FilePaths");
if (intent.hasExtra("IsFromBrowse")) {
this.isFromBrowse = intent.getBooleanExtra("IsFromBrowse", false);
}
if (stringArrayListExtra.size() > 0) {
this.filePath = stringArrayListExtra.get(0);
}
String str = this.filePath;
if (str == null || str.length() <= 0) {
return;
}
getFileNameByPath();
}
@Override
public void onFileCaptured(ArrayList<String> arrayList) {
if (arrayList == null || arrayList.size() <= 0) {
return;
}
String str = arrayList.get(0);
this.filePath = str;
if (str == null || str.length() <= 0) {
return;
}
getFileNameByPath();
}
public void getFileNameByPath() {
String str;
String str2;
String str3;
try {
String str4 = this.filePath;
String substring = str4.substring(str4.lastIndexOf(AgentHeaderCreator.AGENT_DIVIDER) + 1);
String str5 = this.filePath;
String substring2 = str5.substring(str5.lastIndexOf(Const.FILE_EXTENSION_SEPARATOR) + 1);
this.mAttachedFile.setText(substring);
if (!substring2.equalsIgnoreCase("doc") && !substring2.equalsIgnoreCase("docx") && !substring2.equalsIgnoreCase("pdf") && !substring2.equalsIgnoreCase("png") && !substring2.equalsIgnoreCase("jpg") && !substring2.equalsIgnoreCase("jpeg") && !substring2.equalsIgnoreCase("gif") && !substring2.equalsIgnoreCase("heic") && !substring2.equalsIgnoreCase("heif")) {
if (this.isFromBrowse && (str3 = this.filePath) != null && str3.length() > 0) {
FileUtils.deleteFile(this.context, this.filePath);
}
this.filePath = "";
Toast.makeText(this.context, "Only files with extension .doc.docx,.pdf,.jpg,.png,.gif,.heic,.heif are allowed", 0).show();
this.mAttachedFile.setVisibility(8);
return;
}
int parseInt = Integer.parseInt(String.valueOf(new File(this.filePath).length() / 1024));
if (substring == null) {
if (this.isFromBrowse && (str = this.filePath) != null && str.length() > 0) {
FileUtils.deleteFile(this.context, this.filePath);
}
this.filePath = "";
this.mAttachedFile.setVisibility(8);
return;
}
if (parseInt > 10240) {
if (this.isFromBrowse && (str2 = this.filePath) != null && str2.length() > 0) {
FileUtils.deleteFile(this.context, this.filePath);
}
this.mAttachedFile.setVisibility(8);
this.filePath = "";
Toast.makeText(this.context, "File size exceeds allowed limit of 10MB", 0).show();
return;
}
this.mAttachedFile.setVisibility(0);
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(this.context, "File not supported!!", 0).show();
}
}
}