LeftMenu.java 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. package com.dbs.dbsec.activity.activityEvent;
  2. import android.annotation.SuppressLint;
  3. import android.app.DatePickerDialog;
  4. import android.content.Context;
  5. import android.util.Log;
  6. import android.view.View;
  7. import android.widget.AdapterView;
  8. import android.widget.DatePicker;
  9. import android.widget.RelativeLayout;
  10. import android.widget.Spinner;
  11. import android.widget.Toast;
  12. import androidx.appcompat.app.AppCompatActivity;
  13. import androidx.appcompat.widget.AppCompatRadioButton;
  14. import androidx.recyclerview.widget.LinearLayoutManager;
  15. import com.dbs.dbsec.BuildConfig;
  16. import com.dbs.dbsec.R;
  17. import com.dbs.dbsec.activity.ConsentActivity;
  18. import com.dbs.dbsec.activity.adapter.DeptSpinnerAdapter;
  19. import com.dbs.dbsec.activity.adapter.PatientListAdapter;
  20. import com.dbs.dbsec.customView.CustomRadioGroup;
  21. import com.dbs.dbsec.httpTask.CallBack;
  22. import com.dbs.dbsec.httpTask.ParseJsonData;
  23. import com.dbs.dbsec.model.DeptListVO;
  24. import com.dbs.dbsec.model.DoctorListVO;
  25. import com.dbs.dbsec.model.PatientListVO;
  26. import com.dbs.dbsec.util.Common;
  27. import com.dbs.dbsec.util.ConsentConfig;
  28. import com.raonsecure.touchen_mguard_4_0.utils.Util;
  29. import java.util.ArrayList;
  30. import java.util.HashMap;
  31. public class LeftMenu {
  32. private static final String TAG = "LeftMenu";
  33. private AppCompatActivity mActivity;
  34. private Context mContext;
  35. private ConsentActivity instance;
  36. private DeptSpinnerAdapter deptSpinnerAdapter;
  37. public PatientListAdapter patientListAdapter;
  38. private LinearLayoutManager linearLayoutManager;
  39. // private
  40. private DatePickerDialog dateDialog;
  41. private HashMap<String, String> patientSearchMap = null;
  42. public String patientState = "";
  43. public LeftMenu(Context mContext, AppCompatActivity mActivity) {
  44. this.mContext = mContext;
  45. this.mActivity = mActivity;
  46. this.instance = (ConsentActivity) mContext;
  47. this.patientSearchMap = new HashMap<String, String>();
  48. int year = Common.toDayDate()[0];
  49. int month = Integer.parseInt(Common.plusZero(Common.toDayDate()[1] - 1));
  50. int day = Integer.parseInt(Common.plusZero(Common.toDayDate()[2]));
  51. this.dateDialog = new DatePickerDialog(mContext, R.style.DatePickerDialogTheme, onDateSetListener, year, month, day);
  52. }
  53. @SuppressLint("RestrictedApi")
  54. public void setRadioGroupDraw(String indexPage) {
  55. instance.radioGroup = new CustomRadioGroup(mContext);
  56. instance.radioGroupParams = new CustomRadioGroup.LayoutParams(CustomRadioGroup.LayoutParams.WRAP_CONTENT, CustomRadioGroup.LayoutParams.WRAP_CONTENT);
  57. instance.radioGroupParams.addRule(RelativeLayout.CENTER_IN_PARENT);
  58. String radioStr1 = "";
  59. String radioStr2 = "";
  60. String radioStr3 = "";
  61. String radioStr4 = "";
  62. String radioStr5 = "";
  63. if (indexPage.equals("I")) {
  64. radioStr1 = mContext.getString(R.string.stay);
  65. radioStr2 = mContext.getString(R.string.hospitalization);
  66. radioStr3 = mContext.getString(R.string.discharge);
  67. radioStr4 = mContext.getString(R.string.noWrite);
  68. } else if (indexPage.equals("O")) {
  69. radioStr1 = mContext.getString(R.string.all);
  70. radioStr2 = mContext.getString(R.string.accept);
  71. radioStr3 = mContext.getString(R.string.waiting);
  72. radioStr4 = mContext.getString(R.string.complete);
  73. radioStr5 = mContext.getString(R.string.noWrite);
  74. } else if (indexPage.equals("E")) {
  75. radioStr1 = mContext.getString(R.string.stay);
  76. radioStr2 = mContext.getString(R.string.discharge);
  77. radioStr3 = mContext.getString(R.string.leaveClear);
  78. radioStr4 = mContext.getString(R.string.noWrite);
  79. } else if (indexPage.equals("OP")) {
  80. radioStr1 = mContext.getString(R.string.all);
  81. radioStr2 = mContext.getString(R.string.notYet);
  82. radioStr3 = mContext.getString(R.string.ready);
  83. radioStr4 = mContext.getString(R.string.ing);
  84. radioStr5 = mContext.getString(R.string.complete);
  85. } else if (indexPage.equals("SR")) {
  86. radioStr1 = mContext.getString(R.string.admission);
  87. radioStr2 = mContext.getString(R.string.outPatient);
  88. radioStr3 = mContext.getString(R.string.emergency);
  89. }
  90. if (indexPage.equals("O") || indexPage.equals("OP")) {
  91. instance.radioParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
  92. instance.radioButton1 = new AppCompatRadioButton(mContext);
  93. instance.radioButton1.setText(radioStr1);
  94. instance.radioButton1.setTextSize(14);
  95. instance.radioButton1.setLayoutParams(instance.radioParams);
  96. instance.radioGroup.addView(instance.radioButton1);
  97. instance.radioParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
  98. instance.radioParams.addRule(RelativeLayout.RIGHT_OF, instance.radioButton1.getId());
  99. instance.radioButton2 = new AppCompatRadioButton(mContext);
  100. instance.radioButton2.setText(radioStr2);
  101. instance.radioButton2.setTextSize(14);
  102. instance.radioButton2.setLayoutParams(instance.radioParams);
  103. instance.radioGroup.addView(instance.radioButton2);
  104. instance.radioParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
  105. instance.radioParams.addRule(RelativeLayout.RIGHT_OF, instance.radioButton2.getId());
  106. instance.radioButton3 = new AppCompatRadioButton(mContext);
  107. instance.radioButton3.setText(radioStr3);
  108. instance.radioButton3.setTextSize(14);
  109. instance.radioButton3.setLayoutParams(instance.radioParams);
  110. instance.radioGroup.addView(instance.radioButton3);
  111. instance.radioParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
  112. instance.radioParams.addRule(RelativeLayout.BELOW, instance.radioButton3.getId());
  113. instance.radioButton4 = new AppCompatRadioButton(mContext);
  114. instance.radioButton4.setText(radioStr4);
  115. instance.radioButton4.setTextSize(14);
  116. instance.radioButton4.setLayoutParams(instance.radioParams);
  117. instance.radioGroup.addView(instance.radioButton4);
  118. instance.radioParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
  119. instance.radioParams.addRule(RelativeLayout.BELOW, instance.radioButton2.getId());
  120. instance.radioParams.addRule(RelativeLayout.RIGHT_OF, instance.radioButton4.getId());
  121. instance.radioButton5 = new AppCompatRadioButton(mContext);
  122. instance.radioButton5.setText(radioStr5);
  123. instance.radioButton5.setTextSize(14);
  124. instance.radioButton5.setLayoutParams(instance.radioParams);
  125. instance.radioGroup.addView(instance.radioButton5);
  126. } else {
  127. instance.radioParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
  128. instance.radioButton1 = new AppCompatRadioButton(mContext);
  129. instance.radioButton1.setText(radioStr1);
  130. instance.radioButton1.setTextSize(14);
  131. instance.radioButton1.setLayoutParams(instance.radioParams);
  132. instance.radioGroup.addView(instance.radioButton1);
  133. instance.radioParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
  134. instance.radioParams.addRule(RelativeLayout.RIGHT_OF, instance.radioButton1.getId());
  135. instance.radioButton2 = new AppCompatRadioButton(mContext);
  136. instance.radioButton2.setText(radioStr2);
  137. instance.radioButton2.setTextSize(14);
  138. instance.radioButton2.setLayoutParams(instance.radioParams);
  139. instance.radioGroup.addView(instance.radioButton2);
  140. instance.radioParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
  141. instance.radioParams.addRule(RelativeLayout.RIGHT_OF, instance.radioButton2.getId());
  142. instance.radioButton3 = new AppCompatRadioButton(mContext);
  143. instance.radioButton3.setText(radioStr3);
  144. instance.radioButton3.setTextSize(14);
  145. instance.radioButton3.setLayoutParams(instance.radioParams);
  146. instance.radioGroup.addView(instance.radioButton3);
  147. if (!indexPage.equals("SR")) {
  148. instance.radioParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
  149. instance.radioParams.addRule(RelativeLayout.RIGHT_OF, instance.radioButton3.getId());
  150. instance.radioButton4 = new AppCompatRadioButton(mContext);
  151. instance.radioButton4.setText(radioStr4);
  152. instance.radioButton4.setTextSize(14);
  153. instance.radioButton4.setLayoutParams(instance.radioParams);
  154. instance.radioGroup.addView(instance.radioButton4);
  155. }
  156. }
  157. if (instance.jobKindCd.indexOf("03") == 0 || instance.indexPage.equals("SR")) {
  158. instance.radioButton1.setChecked(true);
  159. patientState = "A";
  160. } else {
  161. if (indexPage.equals("SR")) {
  162. instance.radioButton1.setChecked(true);
  163. patientState = "A";
  164. } else {
  165. if (indexPage.equals("I") || indexPage.equals("E")) {
  166. instance.radioButton4.setChecked(true);
  167. patientState = "C";
  168. } else if (indexPage.equals("O")) {
  169. instance.radioButton5.setChecked(true);
  170. patientState = "3";
  171. } else if (indexPage.equals("OP")) {
  172. instance.radioButton1.setChecked(true);
  173. patientState = "A";
  174. }
  175. }
  176. }
  177. instance.radioLayout.addView(instance.radioGroup, instance.radioGroupParams);
  178. }
  179. private DatePickerDialog.OnDateSetListener onDateSetListener = new DatePickerDialog.OnDateSetListener() {
  180. @Override
  181. public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
  182. String date = year + "/" + Common.plusZero(month + 1) + "/" + Common.plusZero(dayOfMonth);
  183. setDate(date);
  184. }
  185. };
  186. public View.OnClickListener onClickListener = new View.OnClickListener() {
  187. @Override
  188. public void onClick(View v) {
  189. if (instance.dateLayout == v) {
  190. //진료 일자 선택
  191. dateDialog.show();
  192. } else if (instance.patientSearchLayout == v) {
  193. //등록번호 검색 input 옆의 조회 버튼
  194. getPatientList();
  195. }
  196. }
  197. };
  198. public CustomRadioGroup.OnCheckedChangeListener onCheckedChangeListener = new CustomRadioGroup.OnCheckedChangeListener() {
  199. @Override
  200. public void onCheckedChanged(CustomRadioGroup group, int checkedId) {
  201. if (checkedId == instance.radioButton1.getId()) {
  202. patientState = "A";
  203. } else if (checkedId == instance.radioButton2.getId()) {
  204. patientState = "0";
  205. } else if (checkedId == instance.radioButton3.getId()) {
  206. patientState = "1";
  207. } else if (checkedId == instance.radioButton4.getId()) {
  208. if (instance.indexPage.equals("I") || instance.indexPage.equals("ER")) {
  209. patientState = "C";
  210. } else {
  211. patientState = "2";
  212. }
  213. } else if (checkedId == instance.radioButton5.getId()) {
  214. if (instance.indexPage.equals("OP") || instance.indexPage.equals("O")) {
  215. patientState = "3";
  216. } else {
  217. patientState = "C";
  218. }
  219. }
  220. Log.e(TAG, "patientState -- > " + patientState);
  221. }
  222. };
  223. private void setDate(String date) {
  224. instance.tvMainDate.setText(date);
  225. }
  226. public String getDate() {
  227. return Common.removeSlashStr(instance.tvMainDate.getText().toString().trim());
  228. }
  229. public void getWardList() {
  230. CallBack callBack = new CallBack() {
  231. @Override
  232. public void result(String result) {
  233. ArrayList<HashMap<String, String>> rts = Common.parseJSON(mContext, result);
  234. String code = rts.get(0).get("code");
  235. if (!code.equals("00")) {
  236. stop();
  237. } else {
  238. ArrayList<DeptListVO> dataAr = ParseJsonData.getInstance(mContext).getWardNDeptList(rts);
  239. setSpinnerAdapter(dataAr, ConsentConfig.GET_WARD_LIST);
  240. }
  241. }
  242. @Override
  243. public void stop() {
  244. ArrayList<DeptListVO> arrayList = new ArrayList<DeptListVO>();
  245. arrayList.add(new DeptListVO("", mContext.getString(R.string.wardListEmpty)));
  246. setSpinnerAdapter(arrayList, ConsentConfig.GET_WARD_LIST);
  247. }
  248. @Override
  249. public void error() {
  250. }
  251. };
  252. HashMap<String, String> mData = new HashMap<String, String>();
  253. mData.put("instCd", BuildConfig.INST_CD);
  254. if (Common.checkNetwork(mContext) == true) {
  255. Common.callHttp(mContext, ConsentConfig.GET_WARD_LIST, mData, callBack);
  256. } else {
  257. instance.dismissProgress();
  258. Common.networkErrorAlert(mActivity);
  259. }
  260. }
  261. public void getDeptList() {
  262. CallBack callBack = new CallBack() {
  263. @Override
  264. public void result(String result) {
  265. ArrayList<HashMap<String, String>> rts = Common.parseJSON(mContext, result);
  266. String code = rts.get(0).get("code");
  267. if (!code.equals("00")) {
  268. stop();
  269. } else {
  270. ArrayList<DeptListVO> dataAr = ParseJsonData.getInstance(mContext).getWardNDeptList(rts);
  271. setSpinnerAdapter(dataAr, ConsentConfig.GET_DEPT_LIST);
  272. }
  273. }
  274. @Override
  275. public void stop() {
  276. ArrayList<DeptListVO> arrayList = new ArrayList<DeptListVO>();
  277. arrayList.add(new DeptListVO("", mContext.getString(R.string.deptListEmpty)));
  278. setSpinnerAdapter(arrayList, ConsentConfig.GET_DEPT_LIST);
  279. }
  280. @Override
  281. public void error() {
  282. }
  283. };
  284. HashMap<String, String> mData = new HashMap<String, String>();
  285. mData.put("instCd", BuildConfig.INST_CD);
  286. mData.put("ordType", instance.indexPage);
  287. if (Common.checkNetwork(mContext) == true) {
  288. Common.callHttp(mContext, ConsentConfig.GET_DEPT_LIST, mData, callBack);
  289. } else {
  290. instance.dismissProgress();
  291. Common.networkErrorAlert(mActivity);
  292. }
  293. }
  294. private void getDoctorList(String deptCd) {
  295. CallBack callBack = new CallBack() {
  296. @Override
  297. public void result(String result) {
  298. Log.e(TAG, "result -- > " + result);
  299. ArrayList<HashMap<String, String>> rts = Common.parseJSON(mContext, result);
  300. String code = rts.get(0).get("code");
  301. if (!code.equals("00")) {
  302. stop();
  303. } else {
  304. ArrayList<DoctorListVO> dataAr = ParseJsonData.getInstance(mContext).getDoctorList(rts);
  305. setSpinnerAdapter(dataAr, ConsentConfig.GET_DOCTOR_LIST);
  306. }
  307. }
  308. @Override
  309. public void stop() {
  310. ArrayList<DoctorListVO> arrayList = new ArrayList<DoctorListVO>();
  311. arrayList.add(new DoctorListVO("", mContext.getString(R.string.doctorListEmpty), "", ""));
  312. setSpinnerAdapter(arrayList, ConsentConfig.GET_DOCTOR_LIST);
  313. }
  314. @Override
  315. public void error() {
  316. }
  317. };
  318. HashMap<String, String> mData = new HashMap<String, String>();
  319. mData.put("instCd", BuildConfig.INST_CD);
  320. mData.put("srchDd", getDate());
  321. mData.put("ordDeptCd", deptCd);
  322. if (Common.checkNetwork(mContext) == true) {
  323. Common.callHttp(mContext, ConsentConfig.GET_DOCTOR_LIST, mData, callBack);
  324. } else {
  325. instance.dismissProgress();
  326. Common.networkErrorAlert(mActivity);
  327. }
  328. }
  329. private void setSpinnerAdapter(final ArrayList arrayList, final String apiType) {
  330. mActivity.runOnUiThread(new Runnable() {
  331. @Override
  332. public void run() {
  333. deptSpinnerAdapter = new DeptSpinnerAdapter(mActivity, arrayList, apiType);
  334. if (apiType.equals(ConsentConfig.GET_WARD_LIST)) {
  335. instance.wardSpinner.setAdapter(deptSpinnerAdapter);
  336. instance.wardSpinner.setOnItemSelectedListener(onItemSelectedListener);
  337. for (int i = 0; i < arrayList.size(); i++) {
  338. DeptListVO deptListVO = (DeptListVO) arrayList.get(i);
  339. String _deptCd = deptListVO.getDeptCd();
  340. if (instance.deptCd.equals(_deptCd)) {
  341. instance.wardSpinner.setSelection(i);
  342. }
  343. }
  344. } else if (apiType.equals(ConsentConfig.GET_DEPT_LIST)) {
  345. instance.deptSpinner.setAdapter(deptSpinnerAdapter);
  346. instance.deptSpinner.setOnItemSelectedListener(onItemSelectedListener);
  347. for (int i = 0; i < arrayList.size(); i++) {
  348. DeptListVO deptListVO = (DeptListVO) arrayList.get(i);
  349. String _deptCd = deptListVO.getDeptCd();
  350. if (instance.deptCd.equals(_deptCd)) {
  351. instance.deptSpinner.setSelection(i);
  352. }
  353. }
  354. } else if (apiType.equals(ConsentConfig.GET_DOCTOR_LIST)) {
  355. instance.dismissProgress();
  356. instance.doctorSpinner.setAdapter(deptSpinnerAdapter);
  357. instance.doctorSpinner.setOnItemSelectedListener(onItemSelectedListener);
  358. for (int i = 0; i < arrayList.size(); i++) {
  359. DoctorListVO doctorListVO = (DoctorListVO) arrayList.get(i);
  360. String _doctorId = doctorListVO.getDoctorId();
  361. if (instance.userId.equals(_doctorId)) {
  362. instance.doctorSpinner.setSelection(i);
  363. }
  364. }
  365. }
  366. }
  367. });
  368. }
  369. private Spinner.OnItemSelectedListener onItemSelectedListener = new AdapterView.OnItemSelectedListener() {
  370. @Override
  371. public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
  372. DeptListVO deptListVO = null;
  373. DoctorListVO doctorListVO = null;
  374. String deptCd = "";
  375. String deptNm = "";
  376. String doctorId = "";
  377. String drKind = "";
  378. if (parent != instance.doctorSpinner) {
  379. deptListVO = (DeptListVO) parent.getAdapter().getItem(position);
  380. deptCd = deptListVO.getDeptCd();
  381. deptNm = deptListVO.getDeptNm();
  382. }
  383. if (parent == instance.wardSpinner) {
  384. patientSearchMap.put("wardCd", deptCd);
  385. } else if (parent == instance.deptSpinner) {
  386. Log.e(TAG, "deptCd -- > " + deptCd);
  387. Log.e(TAG, "deptNm -- > " + deptNm);
  388. if (!deptCd.equals("")) {
  389. instance.showProgress();
  390. getDoctorList(deptCd);
  391. } else {
  392. ArrayList<DoctorListVO> arrayList = new ArrayList<DoctorListVO>();
  393. arrayList.add(new DoctorListVO("", mContext.getString(R.string.deptListEmpty), "", ""));
  394. setSpinnerAdapter(arrayList, ConsentConfig.GET_DOCTOR_LIST);
  395. }
  396. patientSearchMap.put("ordDeptCd", deptCd);
  397. } else if (parent == instance.doctorSpinner) {
  398. doctorListVO = (DoctorListVO) parent.getAdapter().getItem(position);
  399. doctorId = doctorListVO.getDoctorId();
  400. drKind = doctorListVO.getDrKind();
  401. patientSearchMap.put("doctorId", doctorId);
  402. patientSearchMap.put("drKind", drKind);
  403. }
  404. }
  405. @Override
  406. public void onNothingSelected(AdapterView<?> parent) {
  407. }
  408. };
  409. // /**
  410. // * 로그인시 사용자 정보로 환자 리스트를 최초 처음만 조회해준다
  411. // */
  412. // public void getInitPatientList() {
  413. // CallBack callBack = new CallBack() {
  414. // @Override
  415. // public void result(String result) {
  416. // instance.dismissProgress();
  417. // Log.e(TAG, "result -- > " + result);
  418. // ArrayList<HashMap<String, String>> arrayList = Common.parseJSON(mContext, result);
  419. // String code = arrayList.get(0).get("code");
  420. //
  421. // if (!code.equals("00")) {
  422. // stop();
  423. // } else {
  424. // ArrayList<PatientListVO> dataAr = ParseJsonData.getInstance(mContext).getPatientList(arrayList);
  425. // if (dataAr.size() > 0) {
  426. // setPatientListAdapter(dataAr);
  427. // }
  428. // }
  429. // }
  430. //
  431. // @Override
  432. // public void stop() {
  433. // instance.dismissProgress();
  434. // }
  435. //
  436. // @Override
  437. // public void error() {
  438. //
  439. // }
  440. // };
  441. //
  442. // String instCd = BuildConfig.INST_CD;
  443. // String pid = "";
  444. // String srchDd = getDate();
  445. // String doctorId = Common.getStringPreference(mContext, "userInfo", "userId");
  446. // String ordDeptCd = Common.getStringPreference(mContext, "userInfo", "deptCd");
  447. // String userId = Common.getStringPreference(mContext, "userInfo", "userId");
  448. // String myPatient = "N";
  449. // String drKind = Common.getStringPreference(mContext, "userInfo", "drKind");
  450. // String patientState = this.patientState;
  451. // String wardCd = "";
  452. // String jobKindCd = Common.getStringPreference(mContext, "userInfo", "jobKindCd");
  453. // String selectFlag = instance.indexPage;
  454. // String srchYn = instance.indexPage.equals("SR") ? "Y" : "N";
  455. //
  456. // if (jobKindCd.indexOf("03") == 0) {
  457. //
  458. // } else {
  459. // if (selectFlag.equals("I")) {
  460. // wardCd = Common.getStringPreference(mContext, "userInfo", "deptCd");
  461. // }
  462. // }
  463. //
  464. // HashMap<String, String> mData = new HashMap<String, String>();
  465. // mData.put("srchDd", srchDd);
  466. // mData.put("ordDeptCd", ordDeptCd);
  467. // mData.put("doctorId", doctorId);
  468. // mData.put("pid", pid);
  469. // mData.put("patientState", patientState);
  470. // mData.put("instCd", instCd);
  471. // mData.put("wardCd", wardCd);
  472. // mData.put("userId", userId);
  473. // mData.put("myPatient", myPatient);
  474. // mData.put("jobKindCd", jobKindCd);
  475. // mData.put("drKind", drKind);
  476. // mData.put("selectFlag", selectFlag);
  477. // mData.put("srchYn", srchYn);
  478. //
  479. // if (Common.checkNetwork(mContext) == true) {
  480. // instance.showProgress();
  481. // Common.callHttp(mContext, ConsentConfig.GET_PATIENT_LIST, mData, callBack);
  482. // } else {
  483. // instance.dismissProgress();
  484. // Common.networkErrorAlert(mActivity);
  485. // }
  486. // }
  487. public void getPatientList() {
  488. boolean emptyData = false;
  489. String wardCd = patientSearchMap.get("wardCd") == null ? "" : patientSearchMap.get("wardCd");
  490. String deptCd = patientSearchMap.get("ordDeptCd") == null ? "" : patientSearchMap.get("ordDeptCd");
  491. String myPatient = instance.chkMyPatient.isChecked() == true ? "Y" : "N";
  492. String message = "";
  493. if (instance.indexPage.equals("I")) {
  494. if (wardCd.equals("") && deptCd.equals("") && instance.etPatientId.getText().toString().trim().equals("")) {
  495. emptyData = true;
  496. message = mContext.getString(R.string.inPateintSearchEmptyData);
  497. }
  498. } else if (instance.indexPage.equals("O")) {
  499. if (deptCd.equals("") && instance.etPatientId.getText().toString().trim().equals("")) {
  500. emptyData = true;
  501. message = mContext.getString(R.string.patientsearchEmptyData);
  502. }
  503. } else if (instance.indexPage.equals("SR")) {
  504. String pidStr = instance.etPatientId.getText().toString();
  505. if (pidStr.equals("")) {
  506. emptyData = true;
  507. message = mContext.getString(R.string.emptyPatientId);
  508. }
  509. }
  510. if (emptyData == true) {
  511. instance.showSingButtonDialog(message);
  512. return;
  513. }
  514. CallBack callBack = new CallBack() {
  515. private ArrayList<PatientListVO> patientArr = new ArrayList<PatientListVO>();
  516. @Override
  517. public void result(String result) {
  518. Log.e(TAG, "patientList -- > " + result);
  519. ArrayList<HashMap<String, String>> arrayList = Common.parseJSON(mContext, result);
  520. String code = arrayList.get(0).get("code");
  521. if (!code.equals("00")) {
  522. stop();
  523. } else {
  524. patientArr = ParseJsonData.getInstance(mContext).getPatientList(arrayList);
  525. setPatientListAdapter(patientArr);
  526. }
  527. }
  528. @Override
  529. public void stop() {
  530. instance.dismissProgress();
  531. if (patientListAdapter != null) {
  532. patientArr.clear();
  533. setPatientListAdapter(patientArr);
  534. }
  535. }
  536. @Override
  537. public void error() {
  538. }
  539. };
  540. String srchYn = "N";
  541. if (instance.indexPage.equals("SR")) {
  542. srchYn = "Y";
  543. }
  544. patientSearchMap.put("srchDd", getDate());
  545. patientSearchMap.put("pid", instance.etPatientId.getText().toString().trim());
  546. patientSearchMap.put("patientState", patientState);
  547. patientSearchMap.put("instCd", BuildConfig.INST_CD);
  548. patientSearchMap.put("userId", instance.userId);
  549. patientSearchMap.put("myPatient", myPatient);
  550. patientSearchMap.put("jobKindCd", instance.jobKindCd);
  551. patientSearchMap.put("selectFlag", instance.indexPage);
  552. patientSearchMap.put("srchYn", srchYn);
  553. Log.e(TAG, "patientSearchMap -- > " + patientSearchMap);
  554. if (Common.checkNetwork(mContext) == true) {
  555. instance.showProgress();
  556. Common.callHttp(mContext, ConsentConfig.GET_PATIENT_LIST, patientSearchMap, callBack);
  557. } else {
  558. instance.dismissProgress();
  559. Common.networkErrorAlert(mActivity);
  560. }
  561. }
  562. private void setPatientListAdapter(final ArrayList<PatientListVO> arrayList) {
  563. mActivity.runOnUiThread(
  564. new Runnable() {
  565. @Override
  566. public void run() {
  567. instance.dismissProgress();
  568. instance.centerMenu.clearPatientInfo();
  569. if (arrayList.size() == 0) {
  570. instance.patientEmpty.setVisibility(View.VISIBLE);
  571. } else {
  572. instance.patientEmpty.setVisibility(View.GONE);
  573. }
  574. if (patientListAdapter == null) {
  575. linearLayoutManager = new LinearLayoutManager(mActivity, LinearLayoutManager.VERTICAL, false);
  576. instance.patientRecyclerView.setLayoutManager(linearLayoutManager);
  577. patientListAdapter = new PatientListAdapter(mActivity, mContext, arrayList, instance.indexPage);
  578. instance.patientRecyclerView.setAdapter(patientListAdapter);
  579. } else {
  580. patientListAdapter.arrayList.clear();
  581. patientListAdapter.arrayList = arrayList;
  582. patientListAdapter.click = false;
  583. patientListAdapter.notifyDataSetChanged();
  584. }
  585. }
  586. });
  587. }
  588. }