Skip to content

Commit

Permalink
resolved conflits
Browse files Browse the repository at this point in the history
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
rishabh-997 committed Apr 13, 2020
1 parent 114b011 commit 7f0700d
Show file tree
Hide file tree
Showing 17 changed files with 629 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"formatVersion": 1,
"database": {
"version": 1,
"identityHash": "f2ba83e78fa9d0190a4a24b5be11b2de",
"identityHash": "767ea43540054e29060b41d8b2d22f2e",
"entities": [
{
"tableName": "concepts",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`uuid` TEXT NOT NULL, `display` TEXT, `id` INTEGER, `name` TEXT, `_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `datatype_uuid` TEXT, `datatype_display` TEXT, `datatype__id` INTEGER, `conceptClass_uuid` TEXT, `conceptClass_display` TEXT, `conceptClass__id` INTEGER)",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`uuid` TEXT NOT NULL, `display` TEXT, `id` INTEGER, `name` TEXT, `_id` INTEGER NOT NULL, `datatype_uuid` TEXT, `datatype_display` TEXT, `datatype__id` INTEGER, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "uuid",
Expand Down Expand Up @@ -55,31 +55,13 @@
"columnName": "datatype__id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "conceptClass.uuid",
"columnName": "conceptClass_uuid",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "conceptClass.display",
"columnName": "conceptClass_display",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "conceptClass.id",
"columnName": "conceptClass__id",
"affinity": "INTEGER",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"_id"
"id"
],
"autoGenerate": true
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
Expand Down Expand Up @@ -490,7 +472,7 @@
},
{
"tableName": "visits",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`uuid` TEXT NOT NULL, `display` TEXT, `patient_id` INTEGER NOT NULL, `visit_type` TEXT, `visit_place` TEXT, `start_date` INTEGER NOT NULL, `stop_date` TEXT, `_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`uuid` TEXT NOT NULL, `display` TEXT, `patient_id` INTEGER NOT NULL, `visit_type` TEXT, `visit_place` TEXT, `start_date` TEXT NOT NULL, `stop_date` TEXT, `_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)",
"fields": [
{
"fieldPath": "uuid",
Expand Down Expand Up @@ -525,7 +507,7 @@
{
"fieldPath": "startDate",
"columnName": "start_date",
"affinity": "INTEGER",
"affinity": "TEXT",
"notNull": true
},
{
Expand Down Expand Up @@ -554,7 +536,7 @@
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"f2ba83e78fa9d0190a4a24b5be11b2de\")"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"767ea43540054e29060b41d8b2d22f2e\")"
]
}
}
10 changes: 10 additions & 0 deletions openmrs-client/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@
android:name="android.support.PARENT_ACTIVITY"
android:value=".activities.formentrypatientlist.FormEntryPatientListActivity" />
</activity>

<activity android:name=".activities.formadmission.FormAdmissionActivity"
android:label="@string/admission"
android:theme="@style/AppThemeOrig"
android:parentActivityName=".activities.formlist.FormListActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.openmrs.mobile.activities.formlist.FormListActivity"/>
</activity>

<activity
android:name=".activities.formentrypatientlist.FormEntryPatientListActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
Expand Down
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;
}
}
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);
}
}
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();
}

}
Loading

0 comments on commit 7f0700d

Please sign in to comment.