-
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.
resolving conflicts removing unecessary changes retrofit network calls added admitted to part left Fetching of location done resolving travis error creating a list of ObsCreate pending created base for encounter resolving facing server issues rebasing stuff
- Loading branch information
1 parent
114b011
commit 7f0700d
Showing
17 changed files
with
629 additions
and
32 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
68 changes: 68 additions & 0 deletions
68
...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,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.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); | ||
} | ||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
super.onCreateOptionsMenu(menu); | ||
return true; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...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,49 @@ | ||
/* | ||
* 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 java.util.List; | ||
|
||
import org.openmrs.mobile.activities.BasePresenterContract; | ||
import org.openmrs.mobile.activities.BaseView; | ||
import org.openmrs.mobile.models.Location; | ||
import org.openmrs.mobile.models.Provider; | ||
|
||
public interface FormAdmissionContract { | ||
|
||
interface View extends BaseView<Presenter> { | ||
|
||
void updateProviderAdapter(List<Provider> providerList); | ||
|
||
void showToast(String error); | ||
|
||
void updateLocationAdapter(List<Location> results); | ||
|
||
void enableSubmitButton(boolean value); | ||
|
||
void quitFormEntry(); | ||
} | ||
|
||
interface Presenter extends BasePresenterContract { | ||
|
||
void getProviders(FormAdmissionFragment formAdmissionFragment); | ||
|
||
void updateViews(List<Provider> providerList); | ||
|
||
void getLocation(String url); | ||
|
||
void createEncounter(String admittedByPerson, String admittedToPerson); | ||
} | ||
} |
141 changes: 141 additions & 0 deletions
141
...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,141 @@ | ||
/* | ||
* 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 java.text.SimpleDateFormat; | ||
import java.util.Calendar; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
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.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.utilities.ToastUtil; | ||
|
||
public class FormAdmissionFragment extends ACBaseFragment<FormAdmissionContract.Presenter> implements FormAdmissionContract.View { | ||
|
||
private FragmentFormAdmissionBinding formAdmissionBinding; | ||
|
||
private String admittedByPerson = ""; | ||
private String admittedToPerson = ""; | ||
|
||
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.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(admittedByPerson.isEmpty() || admittedToPerson.isEmpty()) | ||
ToastUtil.showShortToast(getContext(), ToastUtil.ToastType.ERROR, "Please Select Required Field"); | ||
else | ||
mPresenter.createEncounter(admittedByPerson, admittedToPerson); | ||
|
||
} | ||
|
||
@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) { | ||
admittedByPerson = formAdmissionBinding.admittedBySpinner.getSelectedItem().toString(); | ||
} | ||
|
||
@Override | ||
public void onNothingSelected(AdapterView<?> parent) { | ||
|
||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void showToast(String error) { | ||
Log.i("error",error); | ||
} | ||
|
||
@Override | ||
public void updateLocationAdapter(List<Location> results) { | ||
String[] locations = new String[results.size()]; | ||
for (int i = 0; i < results.size(); i++) { | ||
locations[i] = results.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) { | ||
admittedToPerson = formAdmissionBinding.admittedToSpinner.getSelectedItem().toString(); | ||
} | ||
|
||
@Override | ||
public void onNothingSelected(AdapterView<?> parent) { | ||
|
||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void enableSubmitButton(boolean value) { | ||
formAdmissionBinding.submitButton.setEnabled(value); | ||
} | ||
|
||
@Override | ||
public void quitFormEntry() { | ||
getActivity().finish(); | ||
} | ||
|
||
} |
Oops, something went wrong.