-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created layouts for allergies added models and api path resolving conflicts changed modela classes to kotlin added repository and tests AC-804 Updated string values and variable names added tab count in application constatnt removed star imports AC-804 Added allergy module base in the project
- Loading branch information
1 parent
71d4b9e
commit fd634dd
Showing
19 changed files
with
787 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
...n/java/org/openmrs/mobile/activities/patientdashboard/allergy/PatientAllergyFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* The contents of this file are subject to the OpenMRS Public License | ||
* Version 1.0 (the "License"); you may not use this file except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* http://license.openmrs.org | ||
* | ||
* Software distributed under the License is distributed on an "AS IS" | ||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing rights and limitations | ||
* under the License. | ||
* | ||
* Copyright (C) OpenMRS, LLC. All Rights Reserved. | ||
*/ | ||
|
||
package org.openmrs.mobile.activities.patientdashboard.allergy; | ||
|
||
import android.content.Context; | ||
import android.os.Bundle; | ||
import android.view.LayoutInflater; | ||
import android.view.Menu; | ||
import android.view.MenuInflater; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.recyclerview.widget.LinearLayoutManager; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.openmrs.mobile.activities.patientdashboard.PatientDashboardActivity; | ||
import org.openmrs.mobile.activities.patientdashboard.PatientDashboardContract; | ||
import org.openmrs.mobile.activities.patientdashboard.PatientDashboardFragment; | ||
import org.openmrs.mobile.databinding.FragmentPatientAllergyBinding; | ||
import org.openmrs.mobile.models.Allergy; | ||
|
||
import java.util.List; | ||
|
||
public class PatientAllergyFragment extends PatientDashboardFragment implements PatientDashboardContract.ViewPatientAllergy { | ||
private PatientDashboardActivity mPatientDashboardActivity; | ||
private FragmentPatientAllergyBinding binding; | ||
|
||
public static PatientAllergyFragment newInstance() { | ||
return new PatientAllergyFragment(); | ||
} | ||
|
||
@Override | ||
public void onAttach(@NotNull Context context) { | ||
super.onAttach(context); | ||
mPatientDashboardActivity = (PatientDashboardActivity) context; | ||
} | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
super.setPresenter(mPresenter); | ||
setHasOptionsMenu(true); | ||
} | ||
|
||
@Override | ||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
int id = item.getItemId(); | ||
return super.onOptionsItemSelected(item); | ||
} | ||
|
||
@Override | ||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||
binding = FragmentPatientAllergyBinding.inflate(inflater, container, false); | ||
((PatientDashboardAllergyPresenter) mPresenter).getAllergy(this); | ||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity()); | ||
binding.recyclerViewAllergy.setHasFixedSize(true); | ||
binding.recyclerViewAllergy.setLayoutManager(linearLayoutManager); | ||
|
||
return binding.getRoot(); | ||
} | ||
|
||
@Override | ||
public void showAllergyList(List<Allergy> allergies) { | ||
binding.progressBar.setVisibility(View.GONE); | ||
if (allergies == null) { | ||
binding.emptyAllergyList.setVisibility(View.VISIBLE); | ||
} else { | ||
if (allergies.size() == 0) { | ||
binding.emptyAllergyList.setVisibility(View.VISIBLE); | ||
} else { | ||
binding.emptyAllergyList.setVisibility(View.GONE); | ||
PatientAllergyRecyclerViewAdapter adapter = new PatientAllergyRecyclerViewAdapter(getContext(), allergies); | ||
binding.recyclerViewAllergy.setAdapter(adapter); | ||
adapter.notifyDataSetChanged(); | ||
} | ||
} | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
...openmrs/mobile/activities/patientdashboard/allergy/PatientAllergyRecyclerViewAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* The contents of this file are subject to the OpenMRS Public License | ||
* Version 1.0 (the "License"); you may not use this file except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* http://license.openmrs.org | ||
* | ||
* Software distributed under the License is distributed on an "AS IS" | ||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing rights and limitations | ||
* under the License. | ||
* | ||
* Copyright (C) OpenMRS, LLC. All Rights Reserved. | ||
*/ | ||
|
||
package org.openmrs.mobile.activities.patientdashboard.allergy; | ||
|
||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import org.openmrs.mobile.R; | ||
import org.openmrs.mobile.models.Allergy; | ||
import org.openmrs.mobile.utilities.ApplicationConstants; | ||
|
||
import java.util.List; | ||
|
||
public class PatientAllergyRecyclerViewAdapter extends RecyclerView.Adapter<PatientAllergyRecyclerViewAdapter.ViewHolder> { | ||
private Context context; | ||
private List<Allergy> list; | ||
|
||
public PatientAllergyRecyclerViewAdapter(Context context, List<Allergy> list) { | ||
this.context = context; | ||
this.list = list; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public PatientAllergyRecyclerViewAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | ||
View itemView = LayoutInflater.from(context).inflate(R.layout.list_patient_allergy, parent, false); | ||
return new ViewHolder(itemView); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(@NonNull PatientAllergyRecyclerViewAdapter.ViewHolder holder, int position) { | ||
Allergy allergy = list.get(position); | ||
holder.allergen.setText(allergy.getAllergen().getCodedAllergen().getDisplay()); | ||
if (null == allergy.getComment() || allergy.getComment().isEmpty()) { | ||
holder.comment.setText(ApplicationConstants.EMPTY_DASH_REPRESENTATION); | ||
} else { | ||
holder.comment.setText(allergy.getComment()); | ||
} | ||
|
||
if (allergy.getReactions().size() == 0) { | ||
holder.reaction.setText(ApplicationConstants.EMPTY_DASH_REPRESENTATION); | ||
} else { | ||
StringBuilder reactions = new StringBuilder(); | ||
for (int i = 0; i < allergy.getReactions().size() - 1; i++) { | ||
reactions.append(allergy.getReactions().get(i).getReaction().getDisplay()).append(ApplicationConstants.COMMA_WITH_SPACE); | ||
} | ||
reactions.append(allergy.getReactions().get(allergy.getReactions().size() - 1).getReaction().getDisplay()); | ||
holder.reaction.setText(reactions); | ||
} | ||
|
||
if (allergy.getSeverity() == null) { | ||
holder.severity.setText(ApplicationConstants.EMPTY_DASH_REPRESENTATION); | ||
} else { | ||
holder.severity.setText(allergy.getSeverity().getDisplay()); | ||
} | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return list.size(); | ||
} | ||
|
||
public class ViewHolder extends RecyclerView.ViewHolder { | ||
private TextView allergen; | ||
private TextView reaction; | ||
private TextView severity; | ||
private TextView comment; | ||
|
||
public ViewHolder(@NonNull View itemView) { | ||
super(itemView); | ||
allergen = itemView.findViewById(R.id.allergy_allergen); | ||
reaction = itemView.findViewById(R.id.allergy_reaction); | ||
severity = itemView.findViewById(R.id.allergy_severity); | ||
comment = itemView.findViewById(R.id.allergy_comment); | ||
} | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
.../openmrs/mobile/activities/patientdashboard/allergy/PatientDashboardAllergyPresenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* The contents of this file are subject to the OpenMRS Public License | ||
* Version 1.0 (the "License"); you may not use this file except in | ||
* compliance with the License. You may obtain a copy of the License at | ||
* http://license.openmrs.org | ||
* | ||
* Software distributed under the License is distributed on an "AS IS" | ||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing rights and limitations | ||
* under the License. | ||
* | ||
* Copyright (C) OpenMRS, LLC. All Rights Reserved. | ||
*/ | ||
|
||
package org.openmrs.mobile.activities.patientdashboard.allergy; | ||
|
||
import androidx.fragment.app.Fragment; | ||
|
||
import org.openmrs.mobile.activities.patientdashboard.PatientDashboardContract; | ||
import org.openmrs.mobile.activities.patientdashboard.PatientDashboardMainPresenterImpl; | ||
import org.openmrs.mobile.api.RestApi; | ||
import org.openmrs.mobile.api.RestServiceBuilder; | ||
import org.openmrs.mobile.api.repository.AllergyRepository; | ||
import org.openmrs.mobile.dao.PatientDAO; | ||
import org.openmrs.mobile.models.Allergy; | ||
import org.openmrs.mobile.models.Patient; | ||
|
||
import java.util.List; | ||
|
||
public class PatientDashboardAllergyPresenter extends PatientDashboardMainPresenterImpl implements PatientDashboardContract.PatientAllergyPresenter { | ||
private PatientDashboardContract.ViewPatientAllergy mPatientAllergyView; | ||
private String patientId; | ||
private PatientDAO patientDAO; | ||
private RestApi restApi; | ||
private AllergyRepository allergyRepository; | ||
|
||
public PatientDashboardAllergyPresenter(String patientId, PatientDashboardContract.ViewPatientAllergy mPatientAllergyView) { | ||
this.mPatientAllergyView = mPatientAllergyView; | ||
this.patientId = patientId; | ||
this.patientDAO = new PatientDAO(); | ||
this.mPatient = patientDAO.findPatientByID(patientId); | ||
allergyRepository = new AllergyRepository(); | ||
restApi = RestServiceBuilder.createService(RestApi.class); | ||
mPatientAllergyView.setPresenter(this); | ||
} | ||
|
||
public PatientDashboardAllergyPresenter(Patient patient, PatientDashboardContract.ViewPatientAllergy viewPatientAllergy, RestApi restApi) { | ||
this.mPatientAllergyView = viewPatientAllergy; | ||
this.mPatient = patient; | ||
this.restApi = restApi; | ||
this.mPatientAllergyView.setPresenter(this); | ||
allergyRepository = new AllergyRepository(); | ||
} | ||
|
||
@Override | ||
public void subscribe() { | ||
|
||
} | ||
|
||
@Override | ||
public void getAllergy(Fragment fragment) { | ||
allergyRepository.getAllergies(restApi, mPatient.getUuid()).observe(fragment, this::updateViews); | ||
} | ||
|
||
public void updateViews(List<Allergy> allergies) { | ||
mPatientAllergyView.showAllergyList(allergies); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.