|
@@ -3,6 +3,7 @@ package com.dbs.mplus.knuh.fragment;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
+import androidx.core.content.ContextCompat;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
@@ -21,8 +22,10 @@ import android.widget.TextView;
|
|
|
|
|
|
import com.dbs.mplus.knuh.BuildConfig;
|
|
import com.dbs.mplus.knuh.BuildConfig;
|
|
import com.dbs.mplus.knuh.R;
|
|
import com.dbs.mplus.knuh.R;
|
|
|
|
+import com.dbs.mplus.knuh.activity.ConsentActivity;
|
|
import com.dbs.mplus.knuh.adapter.CategoryAdapter;
|
|
import com.dbs.mplus.knuh.adapter.CategoryAdapter;
|
|
import com.dbs.mplus.knuh.adapter.ConsentListAdapter;
|
|
import com.dbs.mplus.knuh.adapter.ConsentListAdapter;
|
|
|
|
+import com.dbs.mplus.knuh.customView.CustomAlertDialog;
|
|
import com.dbs.mplus.knuh.customView.LoadingProgress;
|
|
import com.dbs.mplus.knuh.customView.LoadingProgress;
|
|
import com.dbs.mplus.knuh.httpTask.CallBack;
|
|
import com.dbs.mplus.knuh.httpTask.CallBack;
|
|
import com.dbs.mplus.knuh.httpTask.SoapParser;
|
|
import com.dbs.mplus.knuh.httpTask.SoapParser;
|
|
@@ -42,32 +45,35 @@ public class SearchFragment extends Fragment {
|
|
|
|
|
|
private AppCompatActivity mActivity;
|
|
private AppCompatActivity mActivity;
|
|
private Context mContext;
|
|
private Context mContext;
|
|
|
|
+ private ConsentActivity instance;
|
|
|
|
|
|
private CategoryAdapter categoryAdapter;
|
|
private CategoryAdapter categoryAdapter;
|
|
- private RecyclerView searchRecyclerView;
|
|
|
|
- private LinearLayout searchClickLayout;
|
|
|
|
-
|
|
|
|
|
|
+ private ConsentListAdapter consentListAdapter;
|
|
|
|
|
|
|
|
+ private LinearLayoutManager linearLayoutManager;
|
|
|
|
+ private LinearLayout searchClickLayout;
|
|
|
|
+ private RecyclerView searchRecyclerView;
|
|
private Spinner searchDeptSpinner;
|
|
private Spinner searchDeptSpinner;
|
|
private TextView tvHospitalName;
|
|
private TextView tvHospitalName;
|
|
- private TextView etPatientId;
|
|
|
|
|
|
+ private EditText etPatientId;
|
|
|
|
+ private TextView tvEmptySearchConsent;
|
|
|
|
|
|
- private String keyWord = "";
|
|
|
|
private String categoryId = "";
|
|
private String categoryId = "";
|
|
|
|
|
|
|
|
|
|
public SearchFragment() {
|
|
public SearchFragment() {
|
|
}
|
|
}
|
|
- // 테스트
|
|
|
|
|
|
+
|
|
|
|
+ public SearchFragment(AppCompatActivity mActivity, Context mContext) {
|
|
|
|
+ this.mActivity = mActivity;
|
|
|
|
+ this.mContext = mContext;
|
|
|
|
+ this.instance = (ConsentActivity) mContext;
|
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
- mContext = getActivity();
|
|
|
|
- mActivity = (AppCompatActivity) getActivity();
|
|
|
|
-
|
|
|
|
- progress = new LoadingProgress(mActivity);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Nullable
|
|
@Nullable
|
|
@@ -76,11 +82,12 @@ public class SearchFragment extends Fragment {
|
|
|
|
|
|
View view = (View) inflater.inflate(R.layout.activity_search_fragment, container, false);
|
|
View view = (View) inflater.inflate(R.layout.activity_search_fragment, container, false);
|
|
|
|
|
|
- searchDeptSpinner = (Spinner) view.findViewById(R.id.searchDeptSpinner);
|
|
|
|
- tvHospitalName = (TextView) view.findViewById(R.id.tvHospitalName);
|
|
|
|
- etPatientId = (EditText) view.findViewById(R.id.etPatientId);
|
|
|
|
- searchRecyclerView = (RecyclerView) view.findViewById(R.id.searchRecyclerView);
|
|
|
|
- searchClickLayout = (LinearLayout) view.findViewById(R.id.searchClickLayout); // 조회 버튼
|
|
|
|
|
|
+ searchDeptSpinner = (Spinner) view.findViewById(R.id.searchDeptSpinner);
|
|
|
|
+ tvHospitalName = (TextView) view.findViewById(R.id.tvHospitalName);
|
|
|
|
+ etPatientId = (EditText) view.findViewById(R.id.etPatientId);
|
|
|
|
+ searchClickLayout = (LinearLayout) view.findViewById(R.id.searchClickLayout);
|
|
|
|
+ searchRecyclerView = (RecyclerView) view.findViewById(R.id.searchRecyclerView);
|
|
|
|
+ tvEmptySearchConsent = (TextView) view.findViewById(R.id.tvEmptySearchConsent);
|
|
|
|
|
|
getCategoryList(BuildConfig.INST_CD);
|
|
getCategoryList(BuildConfig.INST_CD);
|
|
|
|
|
|
@@ -97,14 +104,17 @@ public class SearchFragment extends Fragment {
|
|
@Override
|
|
@Override
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
if (v == searchClickLayout) {
|
|
if (v == searchClickLayout) {
|
|
- progress.show();
|
|
|
|
- keyWord = etPatientId.getText().toString();
|
|
|
|
- getConsentList(BuildConfig.INST_CD, keyWord, categoryId);
|
|
|
|
|
|
+ getConsentList(categoryId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
/** Spinner List API **/
|
|
/** Spinner List API **/
|
|
|
|
+ /**
|
|
|
|
+ * 동의서 검색 조건에 필요한 카테고리 데이터를 가져온다
|
|
|
|
+ * @author jksong
|
|
|
|
+ * @since 2020-01-28 오후 5:05
|
|
|
|
+ **/
|
|
private void getCategoryList(final String instCd) {
|
|
private void getCategoryList(final String instCd) {
|
|
CallBack callBack = new CallBack() {
|
|
CallBack callBack = new CallBack() {
|
|
@Override
|
|
@Override
|
|
@@ -113,7 +123,7 @@ public class SearchFragment extends Fragment {
|
|
if (result == null || result.toString().indexOf("null") > 0) {
|
|
if (result == null || result.toString().indexOf("null") > 0) {
|
|
stop();
|
|
stop();
|
|
} else {
|
|
} else {
|
|
- categoryArray = SoapParser.getHospitalList(result);
|
|
|
|
|
|
+ ArrayList<CategoryVO> categoryArray = SoapParser.getHospitalList(result);
|
|
setSpinnerAdapter(categoryArray);
|
|
setSpinnerAdapter(categoryArray);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -154,49 +164,78 @@ public class SearchFragment extends Fragment {
|
|
private Spinner.OnItemSelectedListener onItemSelectedListener = new Spinner.OnItemSelectedListener() {
|
|
private Spinner.OnItemSelectedListener onItemSelectedListener = new Spinner.OnItemSelectedListener() {
|
|
@Override
|
|
@Override
|
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
|
-
|
|
|
|
- CategoryVO categoryVO = categoryArray.get(position);
|
|
|
|
|
|
+ CategoryVO categoryVO = (CategoryVO) parent.getAdapter().getItem(position);
|
|
categoryId = categoryVO.getCategoryId();
|
|
categoryId = categoryVO.getCategoryId();
|
|
Log.e(TAG, "categoryId -- > " + categoryId);
|
|
Log.e(TAG, "categoryId -- > " + categoryId);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public void onNothingSelected(AdapterView<?> parent) {
|
|
public void onNothingSelected(AdapterView<?> parent) {
|
|
|
|
|
|
}
|
|
}
|
|
};
|
|
};
|
|
-
|
|
|
|
-
|
|
|
|
- /** 동의서 찾기 카테고리 리스트 **/
|
|
|
|
- private void getConsentList(final String instCd, String keyWord) {
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 동의서 찾기 리스트
|
|
|
|
+ * @author jksong
|
|
|
|
+ * @since 2020-01-28 오후 5:03
|
|
|
|
+ **/
|
|
|
|
+ private void getConsentList(String categoryId) {
|
|
CallBack callBack = new CallBack() {
|
|
CallBack callBack = new CallBack() {
|
|
@Override
|
|
@Override
|
|
- public void result(SoapObject result) {
|
|
|
|
- progress.dismiss();
|
|
|
|
- if (result == null || result.toString().indexOf("null") > 0 ) {
|
|
|
|
- } else {
|
|
|
|
- ArrayList<ConsentFormListVO> arrayList = SoapParser.getConsentList(result);
|
|
|
|
- setConsentAdapter(arrayList);
|
|
|
|
- }
|
|
|
|
|
|
+ public void result(final SoapObject result) {
|
|
|
|
+
|
|
|
|
+ mActivity.runOnUiThread(new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ Log.e(TAG, "getConsentList result -- > " + result);
|
|
|
|
+ instance.dismissProgress();
|
|
|
|
+ if (result == null || result.toString().indexOf("null") > 0 || result.toString().indexOf(ConsentConfig.RETURN_NULL) > 0) {
|
|
|
|
+ tvEmptySearchConsent.setVisibility(View.VISIBLE);
|
|
|
|
+ } else {
|
|
|
|
+ tvEmptySearchConsent.setVisibility(View.GONE);
|
|
|
|
+ ArrayList<ConsentFormListVO> arrayList = SoapParser.getConsentList(result);
|
|
|
|
+ setConsentAdapter(arrayList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|
|
@Override
|
|
@Override
|
|
public void stop() {
|
|
public void stop() {
|
|
-
|
|
|
|
}
|
|
}
|
|
@Override
|
|
@Override
|
|
public void error() {
|
|
public void error() {
|
|
|
|
|
|
}
|
|
}
|
|
};
|
|
};
|
|
- HashMap<String, String> mData = new HashMap<String, String>();
|
|
|
|
- mData.put("instCd", instCd);
|
|
|
|
- mData.put("keyWord", keyWord);
|
|
|
|
- mData.put("categoryId", categoryId);
|
|
|
|
|
|
|
|
- Util.callHttp(mContext, ConsentConfig.HOST_CONSENT, ConsentConfig.GET_CONSENT_SEARCH, mData, callBack);
|
|
|
|
|
|
+ if ((categoryId.equals("EMA_031") || categoryId.equals("EMA_032")) && etPatientId.getText().toString().trim().equals("")) {
|
|
|
|
+// categoryNotSelected
|
|
|
|
+ instance.showSingButtonDialog(mContext.getString(R.string.categoryNotSelected));
|
|
|
|
+ } else {
|
|
|
|
+ instance.showProgress();
|
|
|
|
+ HashMap<String, String> mData = new HashMap<String, String>();
|
|
|
|
+ mData.put("instCd", BuildConfig.INST_CD);
|
|
|
|
+ mData.put("keyWord", etPatientId.getText().toString().trim());
|
|
|
|
+ mData.put("categoryId", categoryId);
|
|
|
|
+
|
|
|
|
+ Util.callHttp(mContext, ConsentConfig.HOST_CONSENT, ConsentConfig.GET_CONSENT_SEARCH, mData, callBack);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void setConsentAdapter(final ArrayList<ConsentFormListVO> arrayList) {
|
|
|
|
+ if (consentListAdapter == null) {
|
|
|
|
+ linearLayoutManager = new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false);
|
|
|
|
+ searchRecyclerView.setLayoutManager(linearLayoutManager);
|
|
|
|
+ consentListAdapter = new ConsentListAdapter(mActivity, arrayList, ConsentConfig.GET_CONSENT_SEARCH);
|
|
|
|
+ searchRecyclerView.setAdapter(consentListAdapter);
|
|
|
|
+ } else {
|
|
|
|
+ consentListAdapter.arrayList = arrayList;
|
|
|
|
+ consentListAdapter.notifyDataSetChanged();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|