This commit is contained in:
2023-09-06 21:08:04 +05:30
parent a1d29c6091
commit 4fe7e7f2df
10 changed files with 159 additions and 60 deletions

View File

@@ -2,6 +2,7 @@ package com.ssb.simplitend.caregiverdashboard.activities;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import android.os.Bundle;
import android.widget.Toast;
@@ -26,6 +27,8 @@ public class PatientProfileShowerActivity extends AppCompatActivity {
public static final String WHICH_FRAGMENT = "which_f";
private Fragment current_fragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

View File

@@ -236,10 +236,13 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
viewModel.updatePatientAddress(careGiverData.patientId, body,
"Bearer " + AppUtil.getCgToken(this),
this);
}else {
Toast.makeText(this, "Couldn't load address.", Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
// do nothing as we couldn't load the location from the lat lng
Toast.makeText(this, "Couldn't load address.", Toast.LENGTH_SHORT).show();
}
}

View File

@@ -41,7 +41,6 @@ public class MedicalInfoFragment extends Fragment implements ProfileContracts.Ge
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
binding = MedicalIntoFragmentBinding.inflate(inflater, container, false);
medicalInfoViewModel = new ViewModelProvider(requireActivity()).get(MedicalInfoViewModel.class);
initViews();

View File

@@ -27,6 +27,7 @@ import com.ssb.simplitend.apputils.AppUtil;
import com.ssb.simplitend.databinding.AddReminderFragmentBinding;
import com.ssb.simplitend.patientprofile.ProfileContracts;
import com.ssb.simplitend.patientprofile.medreminder.mvvm.ReminderViewModel;
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.DosageType;
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.FreqNMedTypeResult;
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.Frequency;
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.MedicationType;
@@ -69,6 +70,8 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
private ArrayList<Frequency> frequencyList;
private ArrayList<MedicationType> medicationTypeList;
private ArrayList<DosageType> dosageTypeList;
public AddReminderFragment() {
// required empty const.
}
@@ -140,6 +143,10 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
});
binding.dosageDrop.setOnClickListener(v -> {
binding.dosageSpinner.show();
});
}
private void adReminder() {
@@ -157,9 +164,11 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
try {
reminderResult.medication_frequency_xid = String.valueOf(frequencyList.get(binding.frequencySpinner.getSelectedIndex()).id);
reminderResult.medication_type_xid = String.valueOf(medicationTypeList.get(binding.medicationsSpinner.getSelectedIndex()).id);
reminderResult.dosage_unit = String.valueOf(dosageTypeList.get(binding.dosageSpinner.getSelectedIndex()).id);
} catch (Exception e) {
reminderResult.medication_frequency_xid = String.valueOf(frequencyList.get(0).id);
reminderResult.medication_type_xid = String.valueOf(medicationTypeList.get(0).id);
reminderResult.dosage_unit = String.valueOf(dosageTypeList.get(0).id);
}
// saving the actual format of time i.e. HH:mm:ss as hint
@@ -234,8 +243,8 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
datePickerDialog.getDatePicker().setMinDate(System.currentTimeMillis());
frequencyList = new ArrayList<>();
medicationTypeList = new ArrayList<>();
dosageTypeList = new ArrayList<>();
// scrolling instruction edit text
binding.instructions.setOnTouchListener((v, event) -> {
@@ -257,6 +266,10 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
binding.medicationsSpinner.setIsFocusable(true);
binding.medicationsSpinner.setLifecycleOwner(this);
binding.dosageSpinner.setDismissWhenNotifiedItemSelected(true);
binding.dosageSpinner.setIsFocusable(true);
binding.dosageSpinner.setLifecycleOwner(this);
binding.frequencySpinner.setOnSpinnerItemSelectedListener((OnSpinnerItemSelectedListener<String>) (i, s, i1, item) -> {
AppUtil.closeKeyboard(requireActivity());
binding.frequencySpinner.setError(null);
@@ -435,6 +448,13 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
}
}
for (int i = 0; i < dosageTypeList.size(); i++) {
if (String.valueOf(dosageTypeList.get(i).id).equals(reminder.dosage_unit)) {
binding.dosageSpinner.selectItemByIndex(i);
break;
}
}
// week day selection
setSelectionState(0, week_state[0] = reminder.sun.equals("1"));
setSelectionState(1, week_state[1] = reminder.mon.equals("1"));
@@ -649,6 +669,7 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
public void onFreqNMedTypeLoaded(FreqNMedTypeResult result) {
frequencyList.addAll(result.frequencies);
medicationTypeList.addAll(result.medicationTypes);
dosageTypeList.addAll(result.dosageUnits);
ArrayList<String> frequencies = new ArrayList<>();
for (Frequency frequency : frequencyList) {
@@ -657,7 +678,9 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
binding.frequencySpinner.setItems(frequencies);
// default selection to one
if (frequencies.size() > 1) binding.frequencySpinner.selectItemByIndex(0);
if (frequencies.size() > 1) {
binding.frequencySpinner.selectItemByIndex(0);
}
ArrayList<String> medicationTypes = new ArrayList<>();
for (MedicationType type : medicationTypeList) {
@@ -665,6 +688,17 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
}
binding.medicationsSpinner.setItems(medicationTypes);
ArrayList<String> dosageTypes = new ArrayList<>();
for (DosageType dosageType: dosageTypeList){
dosageTypes.add(dosageType.title);
}
binding.dosageSpinner.setItems(dosageTypes);
try {
binding.dosageSpinner.selectItemByIndex(0);
}catch (Exception e){
// do nothing
}
// checking if intent to EDIT or ADD reminder
Bundle bundle = getArguments();
if (bundle != null) {

View File

@@ -60,7 +60,6 @@ public class ReminderFragment extends Fragment implements RecyclerTouchListener.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
binding = RemindersFragmentBinding.inflate(inflater, container, false);
reminderViewModel = new ViewModelProvider(requireActivity()).get(ReminderViewModel.class);
initViews();
@@ -116,7 +115,7 @@ public class ReminderFragment extends Fragment implements RecyclerTouchListener.
getParentFragmentManager().beginTransaction()
.replace(R.id.fcv_profile_shower, AddReminderFragment.class, null)
.addToBackStack("add_reminder")
.commitAllowingStateLoss();
.commit();
} catch (Exception ex) {
// user may be out of context
}
@@ -180,7 +179,6 @@ public class ReminderFragment extends Fragment implements RecyclerTouchListener.
setDayOfWeekViews();
setDayOfWeek(reminderViewModel.selected_dow = 0);
loadReminderList(weekDayViewsList.get(reminderViewModel.selected_dow).day_of_week);
}
@@ -432,7 +430,7 @@ public class ReminderFragment extends Fragment implements RecyclerTouchListener.
try {
getParentFragmentManager().beginTransaction()
.add(R.id.fcv_profile_shower, AddReminderFragment.class, bundle)
.replace(R.id.fcv_profile_shower, AddReminderFragment.class, bundle)
.addToBackStack("add_reminder")
.commitAllowingStateLoss();
} catch (Exception ex) {

View File

@@ -0,0 +1,10 @@
package com.ssb.simplitend.patientprofile.medreminder.mvvm.models;
public class DosageType{
public int id;
public String title;
public String value;
public String created_at;
public String updated_at;
public String deleted_at;
}

View File

@@ -5,4 +5,5 @@ import java.util.ArrayList;
public class FreqNMedTypeResult{
public ArrayList<Frequency> frequencies;
public ArrayList<MedicationType> medicationTypes;
public ArrayList<DosageType> dosageUnits;
}

View File

@@ -60,7 +60,6 @@ public class RoutineFragment extends Fragment implements RoutineAdapter.ClickLis
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
binding = RoutineFragmentBinding.inflate(inflater, container, false);
routineViewModel = new ViewModelProvider(requireActivity()).get(RoutineViewModel.class);
initViews();
@@ -397,7 +396,6 @@ public class RoutineFragment extends Fragment implements RoutineAdapter.ClickLis
Bundle bundle = new Bundle();
bundle.putSerializable(ROUTINE_KEY, routine);
try {
Navigation.findNavController(binding.getRoot()).navigate(R.id.action_routineFragment_to_addRoutineFragment, bundle);
} catch (Exception e) {
@@ -406,7 +404,7 @@ public class RoutineFragment extends Fragment implements RoutineAdapter.ClickLis
try {
getParentFragmentManager().beginTransaction()
.add(R.id.fcv_profile_shower, AddRoutineFragment.class, bundle)
.replace(R.id.fcv_profile_shower, AddRoutineFragment.class, bundle)
.addToBackStack("add_reminder")
.commitAllowingStateLoss();
} catch (Exception ex) {