-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AC-450 Created Admission simple #696
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
080cc2b
resolving conflicts
rishabh-997 8ba965d
added sample json to check result
rishabh-997 7d7c57c
searching encounter role UUID
rishabh-997 20b1f2d
UPdated EncounterCreate.kt
rishabh-997 ade2c9f
testing
rishabh-997 4e1d210
Correctly storiing admission form on server
rishabh-997 1a76a7e
Updated tables to accomodate New UUID's
rishabh-997 ed4bb71
Created Admission form
rishabh-997 5665fcd
added checks for null condition in location
rishabh-997 7d9136f
Added EncounterRole selector while creating encounter
rishabh-997 478c490
added tests in LocationRoomDAOTest
rishabh-997 f5ffd3f
resolving conflicts
rishabh-997 8e6f710
Added new fields to encounter table definition in DBOpenHeperTest
rishabh-997 27ee001
Added tests for FormAdmissionPresente
rishabh-997 f2b12f8
Added discharge display
rishabh-997 a2235cb
Admission Form Completed
rishabh-997 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
70 changes: 70 additions & 0 deletions
70
...ient/src/main/java/org/openmrs/mobile/activities/formadmission/FormAdmissionActivity.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,70 @@ | ||
/* | ||
* 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.formadmission; | ||
|
||
import android.os.Bundle; | ||
import android.view.Menu; | ||
|
||
import androidx.appcompat.app.ActionBar; | ||
|
||
import org.openmrs.mobile.R; | ||
import org.openmrs.mobile.activities.ACBaseActivity; | ||
import org.openmrs.mobile.utilities.ApplicationConstants; | ||
|
||
public class FormAdmissionActivity extends ACBaseActivity { | ||
|
||
Long patientID; | ||
String encounterType; | ||
String formName; | ||
|
||
public static FormAdmissionFragment newInstance() { | ||
return new FormAdmissionFragment(); | ||
} | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_form_admission); | ||
ActionBar actionBar = getSupportActionBar(); | ||
|
||
if (actionBar != null) { | ||
actionBar.setElevation(0); | ||
actionBar.setDisplayHomeAsUpEnabled(true); | ||
} | ||
Bundle bundle = getIntent().getExtras(); | ||
if (bundle != null) { | ||
patientID = bundle.getLong(ApplicationConstants.BundleKeys.PATIENT_ID_BUNDLE); | ||
encounterType = (String) bundle.get(ApplicationConstants.BundleKeys.ENCOUNTERTYPE); | ||
formName = (String) bundle.get(ApplicationConstants.BundleKeys.FORM_NAME); | ||
} | ||
|
||
FormAdmissionFragment formAdmissionFragment = (FormAdmissionFragment) getSupportFragmentManager().findFragmentById(R.id.admissionFormContentFrame); | ||
if (formAdmissionFragment == null) { | ||
formAdmissionFragment = FormAdmissionFragment.newInstance(); | ||
} | ||
if (!formAdmissionFragment.isActive()) { | ||
addFragmentToActivity(getSupportFragmentManager(), | ||
formAdmissionFragment, R.id.admissionFormContentFrame); | ||
} | ||
|
||
new FormAdmissionPresenter(formAdmissionFragment, patientID, encounterType, formName, getApplicationContext()); | ||
} | ||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
super.onCreateOptionsMenu(menu); | ||
return true; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...ient/src/main/java/org/openmrs/mobile/activities/formadmission/FormAdmissionContract.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,54 @@ | ||
/* | ||
* 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.formadmission; | ||
|
||
import org.openmrs.mobile.activities.BasePresenterContract; | ||
import org.openmrs.mobile.activities.BaseView; | ||
import org.openmrs.mobile.models.Location; | ||
import org.openmrs.mobile.models.Provider; | ||
import org.openmrs.mobile.models.Resource; | ||
|
||
import java.util.List; | ||
|
||
public interface FormAdmissionContract { | ||
|
||
interface View extends BaseView<Presenter> { | ||
|
||
void updateProviderAdapter(List<Provider> providerList); | ||
|
||
void showToast(String error); | ||
|
||
void updateLocationAdapter(List<Location> locationList); | ||
|
||
void enableSubmitButton(boolean value); | ||
|
||
void quitFormEntry(); | ||
|
||
void updateEncounterRoleList(List<Resource> encounterRoleList); | ||
} | ||
|
||
interface Presenter extends BasePresenterContract { | ||
|
||
void getProviders(FormAdmissionFragment formAdmissionFragment); | ||
|
||
void updateViews(List<Provider> providerList); | ||
|
||
void getLocation(String url); | ||
|
||
void getEncounterRoles(); | ||
|
||
void createEncounter(String providerUUID, String locationUUID, String encounterRoleUUID); | ||
} | ||
} |
183 changes: 183 additions & 0 deletions
183
...ient/src/main/java/org/openmrs/mobile/activities/formadmission/FormAdmissionFragment.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,183 @@ | ||
/* | ||
* 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.formadmission; | ||
|
||
import android.annotation.SuppressLint; | ||
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 androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
|
||
import org.openmrs.mobile.R; | ||
import org.openmrs.mobile.activities.ACBaseFragment; | ||
import org.openmrs.mobile.application.OpenMRS; | ||
import org.openmrs.mobile.databinding.FragmentFormAdmissionBinding; | ||
import org.openmrs.mobile.models.Location; | ||
import org.openmrs.mobile.models.Provider; | ||
import org.openmrs.mobile.models.Resource; | ||
import org.openmrs.mobile.utilities.ToastUtil; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Calendar; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
public class FormAdmissionFragment extends ACBaseFragment<FormAdmissionContract.Presenter> implements FormAdmissionContract.View { | ||
|
||
private FragmentFormAdmissionBinding formAdmissionBinding; | ||
|
||
private String providerUUID = ""; | ||
private String locationUUID = ""; | ||
private String encounterRoleUUID = ""; | ||
|
||
public static FormAdmissionFragment newInstance() { | ||
return new FormAdmissionFragment(); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||
|
||
formAdmissionBinding = FragmentFormAdmissionBinding.inflate(inflater, container, false); | ||
View root = formAdmissionBinding.getRoot(); | ||
|
||
initFragmentFields(); | ||
mPresenter.getEncounterRoles(); | ||
mPresenter.getProviders(this); | ||
mPresenter.getLocation(OpenMRS.getInstance().getServerUrl()); | ||
|
||
return root; | ||
} | ||
|
||
private void initFragmentFields() { | ||
|
||
Date currentDate = Calendar.getInstance().getTime(); | ||
|
||
@SuppressLint("SimpleDateFormat") | ||
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy"); | ||
formAdmissionBinding.admissionDateHeader.setText(df.format(currentDate)); | ||
formAdmissionBinding.submitButton.setOnClickListener(v -> createEncounter()); | ||
} | ||
|
||
private void createEncounter() { | ||
if (providerUUID.isEmpty() || locationUUID.isEmpty() || encounterRoleUUID.isEmpty()) | ||
ToastUtil.showShortToast(getContext(), ToastUtil.ToastType.ERROR, getString(R.string.admission_fields_required)); | ||
else | ||
mPresenter.createEncounter(providerUUID, locationUUID, encounterRoleUUID); | ||
} | ||
|
||
@Override | ||
public void updateProviderAdapter(List<Provider> providerList) { | ||
String[] providers = new String[providerList.size()]; | ||
for (int i = 0; i < providerList.size(); i++) { | ||
providers[i] = providerList.get(i).getDisplay(); | ||
} | ||
|
||
ArrayAdapter<String> adapterAdmittedBy = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, providers); | ||
formAdmissionBinding.admittedBySpinner.setAdapter(adapterAdmittedBy); | ||
formAdmissionBinding.admittedBySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | ||
@Override | ||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | ||
String providerDisplay = formAdmissionBinding.admittedBySpinner.getSelectedItem().toString(); | ||
|
||
for (int i = 0; i < providerList.size(); i++) { | ||
if (providerDisplay.equals(providerList.get(i).getDisplay())) { | ||
providerUUID = providerList.get(i).getUuid(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void onNothingSelected(AdapterView<?> parent) { | ||
|
||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void updateLocationAdapter(List<Location> locationList) { | ||
String[] locations = new String[locationList.size()]; | ||
for (int i = 0; i < locationList.size(); i++) { | ||
locations[i] = locationList.get(i).getDisplay(); | ||
} | ||
ArrayAdapter<String> adapterAdmittedTo = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, locations); | ||
formAdmissionBinding.admittedToSpinner.setAdapter(adapterAdmittedTo); | ||
formAdmissionBinding.admittedToSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | ||
@Override | ||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | ||
String locationDisplay = formAdmissionBinding.admittedToSpinner.getSelectedItem().toString(); | ||
|
||
for (int i = 0; i < locationList.size(); i++) { | ||
if (locationDisplay.equals(locationList.get(i).getDisplay())) { | ||
locationUUID = locationList.get(i).getUuid(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void onNothingSelected(AdapterView<?> parent) { | ||
|
||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void updateEncounterRoleList(List<Resource> encounterRoleList) { | ||
String[] encounterRole = new String[encounterRoleList.size()]; | ||
for (int i = 0; i < encounterRoleList.size(); i++) { | ||
encounterRole[i] = encounterRoleList.get(i).getDisplay(); | ||
} | ||
ArrayAdapter<String> adapterEncounterRole = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, encounterRole); | ||
formAdmissionBinding.encounterRoleSpinner.setAdapter(adapterEncounterRole); | ||
formAdmissionBinding.encounterRoleSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | ||
@Override | ||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | ||
String encounterRoleDisplay = formAdmissionBinding.encounterRoleSpinner.getSelectedItem().toString(); | ||
|
||
for (int i = 0; i < encounterRoleList.size(); i++) { | ||
if (encounterRoleDisplay.equals(encounterRoleList.get(i).getDisplay())) { | ||
encounterRoleUUID = encounterRoleList.get(i).getUuid(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void onNothingSelected(AdapterView<?> parent) { | ||
|
||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void showToast(String errorMessage) { | ||
ToastUtil.error(errorMessage); | ||
} | ||
|
||
@Override | ||
public void enableSubmitButton(boolean value) { | ||
formAdmissionBinding.submitButton.setEnabled(value); | ||
} | ||
|
||
@Override | ||
public void quitFormEntry() { | ||
getActivity().finish(); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that users can't corrupt the database accidentally. Will be removed in the PR which will remove this error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment it @rishabh-997 it will help
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we dont give any warning, user will keep pressing icon. And the encoded string here is An error occured, Invalid or Corrupt file which is very apt