PageRenderTime 60ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 2ms

/hospsys/hospsys/insurance/core/javasrc/com/hospital/HospitalServiceImpl.java

https://bitbucket.org/dkhaliunaa/mal-emneleg
Java | 6998 lines | 5771 code | 1049 blank | 178 comment | 2910 complexity | 6d19225d2d1870b83585b46340c2c348 MD5 | raw file
  1. package com.hospital;
  2. import com.auth.HospService;
  3. import com.enumclass.ErrorType;
  4. import com.google.gson.internal.LinkedTreeMap;
  5. import com.hospital.app.*;
  6. import com.model.FavoritePages;
  7. import com.model.Role;
  8. import com.model.User;
  9. import com.model.hos.*;
  10. import com.mongodb.BasicDBObject;
  11. import com.rpc.RpcHandler;
  12. import org.bson.types.ObjectId;
  13. import java.math.BigDecimal;
  14. import java.text.SimpleDateFormat;
  15. import java.time.format.DateTimeFormatter;
  16. import java.util.*;
  17. public class HospitalServiceImpl extends HospService implements HospitalService {
  18. private CheckUserRoleControl roleControl = null;
  19. private ErrorEntity errorEntity = null;
  20. private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
  21. public HospitalServiceImpl() {
  22. handler = new RpcHandler<>(this, HospitalService.class);
  23. }
  24. @Override
  25. public BasicDBObject checkSession(String sessionId) {
  26. BasicDBObject basicDBObject = new BasicDBObject();
  27. User loginUser = getUserInfo(sessionId);
  28. basicDBObject.put("session", true);
  29. if (loginUser == null) {
  30. basicDBObject.put("session", false);
  31. }
  32. return basicDBObject;
  33. }
  34. @Override
  35. public List<BasicDBObject> getRoles(String sessionId) {
  36. User user = sessionUser.get(sessionId);
  37. if (user == null) return null;
  38. try {
  39. //Check Role
  40. roleControl = new CheckUserRoleControl(super.conn);
  41. if (roleControl == null) {
  42. return null;
  43. }
  44. return roleControl.getUserAccessMenuList(user);
  45. //End Check Role
  46. } catch (Exception ex) {
  47. ex.printStackTrace();
  48. } finally {
  49. }
  50. return null;
  51. }
  52. @Override
  53. public List<NewsEntity> getNewsData(LinkedTreeMap criteria, String sessionId, String menuid) throws Exception {
  54. System.out.println("Hospital Service Implament ::: get news data");
  55. try {
  56. INewsService newsService = new NewsServiceImpl(super.conn);
  57. User user = sessionUser.get(sessionId);
  58. NewsEntity newsEntity = new NewsEntity();
  59. Iterator it = criteria.entrySet().iterator();
  60. while (it.hasNext()) {
  61. Map.Entry pairs = (Map.Entry) it.next();
  62. try {
  63. if (pairs.getKey().equals(newsEntity.ID)) {
  64. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  65. newsEntity.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  66. } else if (pairs.getKey().equals(newsEntity.TITLE)) {
  67. newsEntity.setTitle(String.valueOf(pairs.getValue()));
  68. } else if (pairs.getKey().equals(newsEntity.CONTENT)) {
  69. newsEntity.setContent(String.valueOf(pairs.getValue()));
  70. }
  71. } catch (NullPointerException ex) {
  72. ex.printStackTrace();
  73. } catch (Exception ex) {
  74. ex.printStackTrace();
  75. }
  76. }//end while
  77. Date utilDate = new Date();
  78. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  79. try {
  80. newsEntity.setCreby(user.getUsername());
  81. } catch (Exception e) {
  82. newsEntity.setCreby("");
  83. }
  84. if (newsEntity != null) {
  85. return newsService.getListData(newsEntity);
  86. }
  87. } catch (Exception ex) {
  88. ex.printStackTrace();
  89. } finally {
  90. }
  91. return null;
  92. }
  93. @Override
  94. public ErrorEntity setNewsData(LinkedTreeMap criteria, String sessionId, String menuid) throws Exception {
  95. System.out.println("Hospital Service Implament ::: set news data");
  96. try {
  97. String command = "EDT";
  98. INewsService newsService = new NewsServiceImpl(super.conn);
  99. User user = sessionUser.get(sessionId);
  100. NewsEntity newsEntity = new NewsEntity();
  101. Iterator it = criteria.entrySet().iterator();
  102. while (it.hasNext()) {
  103. Map.Entry pairs = (Map.Entry) it.next();
  104. try {
  105. if (pairs.getKey().equals(newsEntity.ID)) {
  106. String tmpId = "";
  107. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty()) {
  108. if (pairs.getValue().toString().contains(".")) {
  109. tmpId = pairs.getValue().toString().substring(0, pairs.getValue().toString().indexOf("."));
  110. }
  111. newsEntity.setId(Long.parseLong(String.valueOf(tmpId)));
  112. }
  113. } else if (pairs.getKey().equals(newsEntity.TITLE)) {
  114. newsEntity.setTitle(String.valueOf(pairs.getValue()));
  115. } else if (pairs.getKey().equals(newsEntity.CONTENT)) {
  116. newsEntity.setContent(String.valueOf(pairs.getValue()));
  117. } else if (pairs.getKey().toString().equalsIgnoreCase("command")) {
  118. command = String.valueOf(pairs.getValue());
  119. }
  120. } catch (NullPointerException ex) {
  121. ex.printStackTrace();
  122. } catch (Exception ex) {
  123. ex.printStackTrace();
  124. }
  125. }//end while
  126. if (command.equalsIgnoreCase("INS")) {
  127. newsEntity.setDelflg("N");
  128. newsEntity.setActflg("Y");
  129. try {
  130. newsEntity.setCreby(user.getUsername());
  131. newsEntity.setModby(user.getUsername());
  132. } catch (NullPointerException e) {
  133. newsEntity.setCreby("");
  134. newsEntity.setModby("");
  135. }
  136. Date utilDate = new Date();
  137. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  138. newsEntity.setCreat(sqlDate);
  139. newsEntity.setModAt(sqlDate);
  140. errorEntity = newsService.insertNewData(newsEntity);
  141. } else if (command.equalsIgnoreCase("EDT") ||
  142. command.equalsIgnoreCase("DEL") ||
  143. command.equalsIgnoreCase("ACT")) {
  144. int quality = 2;
  145. if (command.equalsIgnoreCase("DEL")) {
  146. newsEntity.setDelflg("Y");
  147. quality = 3;
  148. } else if (command.equalsIgnoreCase("ACT")) {
  149. newsEntity.setActflg("N");
  150. }
  151. errorEntity = newsService.updateData(newsEntity);
  152. }
  153. } catch (Exception ex) {
  154. ex.printStackTrace();
  155. } finally {
  156. }
  157. return errorEntity;
  158. }
  159. @Override
  160. public List<Form08Entity> getForm08Data(LinkedTreeMap criteria, String sessionId, String menuid) throws Exception {
  161. System.out.println("Hospital Service Implament ::: get form 08 data");
  162. try {
  163. IForm08Service form08Service = new Form08ServiceImpl(super.conn);
  164. User user = sessionUser.get(sessionId);
  165. Form08Entity form08Entity = new Form08Entity();
  166. Iterator it = criteria.entrySet().iterator();
  167. //Check Role
  168. roleControl = new CheckUserRoleControl(super.conn);
  169. if (roleControl == null) {
  170. return null;
  171. }
  172. menuid = menuid.replaceAll("#", "");
  173. if (!roleControl.checkRole(user, menuid, 1)) {
  174. return null;
  175. }
  176. //End Check Role
  177. while (it.hasNext()) {
  178. Map.Entry pairs = (Map.Entry) it.next();
  179. try {
  180. if (pairs.getKey().equals(form08Entity.ID)) {
  181. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  182. form08Entity.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  183. } else if (pairs.getKey().equals(form08Entity.AIMAG)) {
  184. form08Entity.setAimag(String.valueOf(pairs.getValue()));
  185. } else if (pairs.getKey().equals(form08Entity.SUM)) {
  186. form08Entity.setSum(String.valueOf(pairs.getValue()));
  187. } else if (pairs.getKey().equals(form08Entity.MALTURUL)) {
  188. form08Entity.setMalTurul(String.valueOf(pairs.getValue()));
  189. } else if (pairs.getKey().equals(form08Entity.ARGA_HEMJEE_NER)) {
  190. form08Entity.setArgaHemjeeNer(String.valueOf(pairs.getValue()));
  191. } else if (pairs.getKey().equals(form08Entity.NER)) {
  192. form08Entity.setNer(String.valueOf(pairs.getValue()));
  193. } else if (pairs.getKey().equals(form08Entity.ZARTSUULSAN_HEMJEE)) {
  194. form08Entity.setZartsuulsanHemjee(String.valueOf(pairs.getValue()));
  195. } else if (pairs.getKey().equals(form08Entity.TOLOVLOGOO)) {
  196. form08Entity.setTolovlogoo(String.valueOf(pairs.getValue()));
  197. } else if (pairs.getKey().equals(form08Entity.GUITSETGEL)) {
  198. form08Entity.setGuitsetgel(String.valueOf(pairs.getValue()));
  199. } else if (pairs.getKey().equals(form08Entity.HUVI)) {
  200. form08Entity.setHuvi(String.valueOf(pairs.getValue()));
  201. } else if (pairs.getKey().equals(form08Entity.OLGOSON_TUN)) {
  202. try {
  203. form08Entity.setOLGOSON_TUN(Long.valueOf(pairs.getValue().toString()));
  204. } catch (NumberFormatException e) {
  205. form08Entity.setOLGOSON_TUN(Long.parseLong("0"));
  206. }
  207. } else if (pairs.getKey().equals(form08Entity.HEREGLESEN_TUN)) {
  208. try {
  209. form08Entity.setHEREGLESEN_TUN(Long.valueOf(pairs.getValue().toString()));
  210. } catch (NumberFormatException e) {
  211. form08Entity.setHEREGLESEN_TUN(Long.parseLong("0"));
  212. }
  213. } else if (pairs.getKey().equals(form08Entity.USTGASAN_TUN)) {
  214. try {
  215. form08Entity.setUSTGASAN_TUN(Long.valueOf(pairs.getValue().toString()));
  216. } catch (NumberFormatException e) {
  217. form08Entity.setUSTGASAN_TUN(Long.parseLong("0"));
  218. }
  219. } else if (pairs.getKey().equals(form08Entity.NUUTSULSEN_TUN)) {
  220. try {
  221. form08Entity.setNUUTSULSEN_TUN(Long.valueOf(pairs.getValue().toString()));
  222. } catch (NumberFormatException e) {
  223. form08Entity.setNUUTSULSEN_TUN(Long.parseLong("0"));
  224. }
  225. } else if (pairs.getKey().equals(form08Entity.RECORD_DATE)) {
  226. String dv = String.valueOf(pairs.getValue());
  227. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  228. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  229. form08Entity.setRecordDate(sqlDate);
  230. } else if (pairs.getKey().equals(form08Entity.SEARCH_RECORD_DATE)) {
  231. String dv = String.valueOf(pairs.getValue());
  232. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  233. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  234. form08Entity.setSearchRecordDate(sqlDate);
  235. }
  236. } catch (NullPointerException ex) {
  237. ex.printStackTrace();
  238. } catch (Exception ex) {
  239. ex.printStackTrace();
  240. }
  241. }//end while
  242. Date utilDate = new Date();
  243. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  244. if (form08Entity.getRecordDate() == null) form08Entity.setRecordDate(sqlDate);
  245. if (form08Entity.getSearchRecordDate() == null) form08Entity.setSearchRecordDate(sqlDate);
  246. if (user.getRoleCode() != null && !user.getRoleCode().equalsIgnoreCase("SUPERADMIN")
  247. && !user.getRoleCode().equalsIgnoreCase("ADMIN")) {
  248. form08Entity.setCreby(user.getUsername());
  249. }
  250. if (form08Entity != null && form08Entity.getRecordDate() != null && form08Entity.getSearchRecordDate() != null) {
  251. return form08Service.getListData(form08Entity);
  252. }
  253. } catch (Exception ex) {
  254. ex.printStackTrace();
  255. } finally {
  256. }
  257. return null;
  258. }
  259. @Override
  260. public ErrorEntity setForm08Data(LinkedTreeMap criteria, String sessionId, String menuid) throws Exception {
  261. System.out.println("Hospital Service Implament ::: get form 08 data");
  262. try {
  263. String command = "EDT";
  264. IForm08Service form08Service = new Form08ServiceImpl(super.conn);
  265. //Begin Check Role Step 1
  266. roleControl = new CheckUserRoleControl(super.conn);
  267. if (roleControl == null) {
  268. errorEntity = new ErrorEntity(ErrorType.ERROR, Long.valueOf(1002)); // Ерөнхий алдаа : Эрх нь хүрэлцэхгүй үед өгөх
  269. return errorEntity;
  270. }
  271. //End Check Role Step 1
  272. menuid = menuid.replaceAll("#", "");
  273. User user = sessionUser.get(sessionId);
  274. Form08Entity form08Entity = new Form08Entity();
  275. Iterator it = criteria.entrySet().iterator();
  276. while (it.hasNext()) {
  277. Map.Entry pairs = (Map.Entry) it.next();
  278. try {
  279. if (pairs.getKey().equals(form08Entity.ID)) {
  280. String tmpId = "";
  281. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty()) {
  282. if (pairs.getValue().toString().contains(".")) {
  283. tmpId = pairs.getValue().toString().substring(0, pairs.getValue().toString().indexOf("."));
  284. }
  285. form08Entity.setId(Long.parseLong(String.valueOf(tmpId)));
  286. }
  287. } else if (pairs.getKey().equals(form08Entity.ARGA_HEMJEE_NER)) {
  288. form08Entity.setArgaHemjeeNer(String.valueOf(pairs.getValue()));
  289. } else if (pairs.getKey().equals(form08Entity.AIMAG)) {
  290. form08Entity.setAimag(String.valueOf(pairs.getValue()));
  291. } else if (pairs.getKey().equals(form08Entity.SUM)) {
  292. form08Entity.setSum(String.valueOf(pairs.getValue()));
  293. } else if (pairs.getKey().equals(form08Entity.NER)) {
  294. form08Entity.setNer(String.valueOf(pairs.getValue()));
  295. } else if (pairs.getKey().equals(form08Entity.ZARTSUULSAN_HEMJEE)) {
  296. form08Entity.setZartsuulsanHemjee(String.valueOf(pairs.getValue()));
  297. } else if (pairs.getKey().equals(form08Entity.MALTURUL)) {
  298. form08Entity.setMalTurul(String.valueOf(pairs.getValue()));
  299. } else if (pairs.getKey().equals(form08Entity.TOLOVLOGOO)) {
  300. form08Entity.setTolovlogoo(String.valueOf(pairs.getValue()));
  301. } else if (pairs.getKey().equals(form08Entity.GUITSETGEL)) {
  302. form08Entity.setGuitsetgel(String.valueOf(pairs.getValue()));
  303. } else if (pairs.getKey().equals(form08Entity.HUVI)) {
  304. form08Entity.setHuvi(String.valueOf(pairs.getValue()));
  305. } else if (pairs.getKey().equals(form08Entity.OLGOSON_TUN)) {
  306. try {
  307. form08Entity.setOLGOSON_TUN(Long.valueOf(pairs.getValue().toString()));
  308. } catch (NumberFormatException e) {
  309. form08Entity.setOLGOSON_TUN(Long.parseLong("0"));
  310. }
  311. } else if (pairs.getKey().equals(form08Entity.HEREGLESEN_TUN)) {
  312. try {
  313. form08Entity.setHEREGLESEN_TUN(Long.valueOf(pairs.getValue().toString()));
  314. } catch (NumberFormatException e) {
  315. form08Entity.setHEREGLESEN_TUN(Long.parseLong("0"));
  316. }
  317. } else if (pairs.getKey().equals(form08Entity.USTGASAN_TUN)) {
  318. try {
  319. form08Entity.setUSTGASAN_TUN(Long.valueOf(pairs.getValue().toString()));
  320. } catch (NumberFormatException e) {
  321. form08Entity.setUSTGASAN_TUN(Long.parseLong("0"));
  322. }
  323. } else if (pairs.getKey().equals(form08Entity.NUUTSULSEN_TUN)) {
  324. try {
  325. form08Entity.setNUUTSULSEN_TUN(Long.valueOf(pairs.getValue().toString()));
  326. } catch (NumberFormatException e) {
  327. form08Entity.setNUUTSULSEN_TUN(Long.parseLong("0"));
  328. }
  329. } else if (pairs.getKey().toString().equalsIgnoreCase("command")) {
  330. command = String.valueOf(pairs.getValue());
  331. } else if (pairs.getKey().equals(form08Entity.RECORD_DATE)) {
  332. String dv = String.valueOf(pairs.getValue());
  333. if (!dv.isEmpty() && dv.length() >= 8) {
  334. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  335. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  336. form08Entity.setRecordDate(sqlDate);
  337. }
  338. }
  339. } catch (NullPointerException ex) {
  340. ex.printStackTrace();
  341. } catch (Exception ex) {
  342. ex.printStackTrace();
  343. }
  344. }//end while
  345. if (command.equalsIgnoreCase("INS")) {
  346. form08Entity.setDelflg("N");
  347. form08Entity.setActflg("Y");
  348. if (user != null && (user.getRoleCode().equalsIgnoreCase("SUPERADMIN")
  349. || user.getRoleCode().equalsIgnoreCase("ADMIN"))) {
  350. //Aimag songoh shaardlagagui
  351. } else {
  352. form08Entity.setAimag(user.getCity());
  353. }
  354. //form08Entity.setSum(user.getSum());
  355. form08Entity.setCreby(user.getUsername());
  356. Date utilDate = new Date();
  357. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  358. form08Entity.setCreat(sqlDate);
  359. if (form08Entity.getRecordDate() == null) form08Entity.setCreat(sqlDate);
  360. //Begin Check Role Step 2
  361. if (roleControl.checkRole(user, menuid, 2)) {
  362. errorEntity = form08Service.insertNewData(form08Entity);
  363. } else {
  364. errorEntity = new ErrorEntity(ErrorType.ERROR, Long.valueOf(1002)); // Ерөнхий алдаа : Эрх нь хүрэлцэхгүй үед өгөх
  365. }
  366. //End Check Role Step 2
  367. } else if (command.equalsIgnoreCase("EDT") ||
  368. command.equalsIgnoreCase("DEL") ||
  369. command.equalsIgnoreCase("ACT")) {
  370. int quality = 2;
  371. if (command.equalsIgnoreCase("DEL")) {
  372. form08Entity.setDelflg("Y");
  373. quality = 3;
  374. } else if (command.equalsIgnoreCase("ACT")) {
  375. form08Entity.setActflg("N");
  376. }
  377. //Begin Check Role Step 2
  378. if (roleControl.checkRole(user, menuid, quality)) {
  379. errorEntity = form08Service.updateData(form08Entity);
  380. } else {
  381. errorEntity = new ErrorEntity(ErrorType.ERROR, Long.valueOf(1002)); // Ерөнхий алдаа : Эрх нь хүрэлцэхгүй үед өгөх
  382. }
  383. //End Check Role Step 2
  384. }
  385. } catch (Exception ex) {
  386. ex.printStackTrace();
  387. } finally {
  388. }
  389. return errorEntity;
  390. }
  391. // Begin-form09
  392. @Override
  393. public List<Form09Entity> getForm09Data(LinkedTreeMap criteria, String sessionId) throws Exception {
  394. System.out.println("Hospital Service Implament ::: get form 09 data");
  395. try {
  396. IForm09Service form09Service = new Form09ServiceImpl(super.conn);
  397. User user = sessionUser.get(sessionId);
  398. Form09Entity form09Entity = new Form09Entity();
  399. Iterator it = criteria.entrySet().iterator();
  400. while (it.hasNext()) {
  401. Map.Entry pairs = (Map.Entry) it.next();
  402. try {
  403. if (pairs.getKey().equals(form09Entity.ID)) {
  404. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  405. form09Entity.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  406. } else if (pairs.getKey().equals(form09Entity.AIMAG)) {
  407. form09Entity.setAimag(String.valueOf(pairs.getValue()));
  408. } else if (pairs.getKey().equals(form09Entity.SUM)) {
  409. form09Entity.setSum(form09Entity.SUM);
  410. } else if (pairs.getKey().equals(form09Entity.MALTURUL)) {
  411. form09Entity.setMalTurul(String.valueOf(pairs.getValue()));
  412. } else if (pairs.getKey().equals(form09Entity.TARILGANER)) {
  413. form09Entity.setTarilgaNer(String.valueOf(pairs.getValue()));
  414. } else if (pairs.getKey().equals(form09Entity.NER)) {
  415. form09Entity.setNer(String.valueOf(pairs.getValue()));
  416. } else if (pairs.getKey().equals(form09Entity.ZARTSUULSANHEMJEE)) {
  417. form09Entity.setZartsuulsanHemjee(String.valueOf(pairs.getValue()));
  418. } else if (pairs.getKey().equals(form09Entity.TOLOVLOGOO)) {
  419. form09Entity.setTolovlogoo(String.valueOf(pairs.getValue()));
  420. } else if (pairs.getKey().equals(form09Entity.GUITSETGEL)) {
  421. form09Entity.setGuitsetgel(String.valueOf(pairs.getValue()));
  422. } else if (pairs.getKey().equals(form09Entity.HUVI)) {
  423. form09Entity.setHuvi(String.valueOf(pairs.getValue()));
  424. } else if (pairs.getKey().equals(form09Entity.OLGOSON_TUN)) {
  425. try {
  426. form09Entity.setOLGOSON_TUN(Long.valueOf(pairs.getValue().toString()));
  427. } catch (NumberFormatException e) {
  428. form09Entity.setOLGOSON_TUN(Long.parseLong("0"));
  429. }
  430. } else if (pairs.getKey().equals(form09Entity.HEREGLESEN_TUN)) {
  431. try {
  432. form09Entity.setHEREGLESEN_TUN(Long.valueOf(pairs.getValue().toString()));
  433. } catch (NumberFormatException e) {
  434. form09Entity.setHEREGLESEN_TUN(Long.parseLong("0"));
  435. }
  436. } else if (pairs.getKey().equals(form09Entity.USTGASAN_TUN)) {
  437. try {
  438. form09Entity.setUSTGASAN_TUN(Long.valueOf(pairs.getValue().toString()));
  439. } catch (NumberFormatException e) {
  440. form09Entity.setUSTGASAN_TUN(Long.parseLong("0"));
  441. }
  442. } else if (pairs.getKey().equals(form09Entity.NUUTSULSEN_TUN)) {
  443. try {
  444. form09Entity.setNUUTSULSEN_TUN(Long.valueOf(pairs.getValue().toString()));
  445. } catch (NumberFormatException e) {
  446. form09Entity.setNUUTSULSEN_TUN(Long.parseLong("0"));
  447. }
  448. } else if (pairs.getKey().equals(form09Entity.RECORD_DATE)) {
  449. String dv = String.valueOf(pairs.getValue());
  450. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  451. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  452. form09Entity.setRecordDate(sqlDate);
  453. } else if (pairs.getKey().equals(form09Entity.SEARCH_RECORD_DATE)) {
  454. String dv = String.valueOf(pairs.getValue());
  455. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  456. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  457. form09Entity.setSearchRecordDate(sqlDate);
  458. }
  459. } catch (NullPointerException ex) {
  460. ex.printStackTrace();
  461. } catch (Exception ex) {
  462. ex.printStackTrace();
  463. }
  464. }//end while
  465. if (user.getRoleCode() != null && !user.getRoleCode().equalsIgnoreCase("SUPERADMIN")
  466. && !user.getRoleCode().equalsIgnoreCase("ADMIN")) {
  467. form09Entity.setCreby(user.getUsername());
  468. }
  469. return form09Service.getListData(form09Entity);
  470. } catch (Exception ex) {
  471. ex.printStackTrace();
  472. } finally {
  473. }
  474. return null;
  475. }
  476. @Override
  477. public ErrorEntity setForm09Data(LinkedTreeMap criteria, String sessionId) throws Exception {
  478. System.out.println("Hospital Service Implament ::: get form 09 data");
  479. try {
  480. String command = "EDT";
  481. IForm09Service form09Service = new Form09ServiceImpl(super.conn);
  482. User user = sessionUser.get(sessionId);
  483. Form09Entity form09Entity = new Form09Entity();
  484. Iterator it = criteria.entrySet().iterator();
  485. while (it.hasNext()) {
  486. Map.Entry pairs = (Map.Entry) it.next();
  487. try {
  488. if (pairs.getKey().equals(form09Entity.ID)) {
  489. String tmpId = "";
  490. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty()) {
  491. if (pairs.getValue().toString().contains(".")) {
  492. tmpId = pairs.getValue().toString().substring(0, pairs.getValue().toString().indexOf("."));
  493. }
  494. form09Entity.setId(Long.parseLong(String.valueOf(tmpId)));
  495. }
  496. } else if (pairs.getKey().equals(form09Entity.TARILGANER)) {
  497. form09Entity.setTarilgaNer(String.valueOf(pairs.getValue()));
  498. } else if (pairs.getKey().equals(form09Entity.NER)) {
  499. form09Entity.setNer(String.valueOf(pairs.getValue()));
  500. } else if (pairs.getKey().equals(form09Entity.ZARTSUULSANHEMJEE)) {
  501. form09Entity.setZartsuulsanHemjee(String.valueOf(pairs.getValue()));
  502. } else if (pairs.getKey().equals(form09Entity.MALTURUL)) {
  503. form09Entity.setMalTurul(String.valueOf(pairs.getValue()));
  504. } else if (pairs.getKey().equals(form09Entity.TOLOVLOGOO)) {
  505. form09Entity.setTolovlogoo(String.valueOf(pairs.getValue()));
  506. } else if (pairs.getKey().equals(form09Entity.GUITSETGEL)) {
  507. form09Entity.setGuitsetgel(String.valueOf(pairs.getValue()));
  508. } else if (pairs.getKey().equals(form09Entity.HUVI)) {
  509. form09Entity.setHuvi(String.valueOf(pairs.getValue()));
  510. } else if (pairs.getKey().equals(form09Entity.OLGOSON_TUN)) {
  511. try {
  512. form09Entity.setOLGOSON_TUN(Long.valueOf(pairs.getValue().toString()));
  513. } catch (NumberFormatException e) {
  514. form09Entity.setOLGOSON_TUN(Long.parseLong("0"));
  515. }
  516. } else if (pairs.getKey().equals(form09Entity.HEREGLESEN_TUN)) {
  517. try {
  518. form09Entity.setHEREGLESEN_TUN(Long.valueOf(pairs.getValue().toString()));
  519. } catch (NumberFormatException e) {
  520. form09Entity.setHEREGLESEN_TUN(Long.parseLong("0"));
  521. }
  522. } else if (pairs.getKey().equals(form09Entity.USTGASAN_TUN)) {
  523. try {
  524. form09Entity.setUSTGASAN_TUN(Long.valueOf(pairs.getValue().toString()));
  525. } catch (NumberFormatException e) {
  526. form09Entity.setUSTGASAN_TUN(Long.parseLong("0"));
  527. }
  528. } else if (pairs.getKey().equals(form09Entity.NUUTSULSEN_TUN)) {
  529. try {
  530. form09Entity.setNUUTSULSEN_TUN(Long.valueOf(pairs.getValue().toString()));
  531. } catch (NumberFormatException e) {
  532. form09Entity.setNUUTSULSEN_TUN(Long.parseLong("0"));
  533. }
  534. } else if (pairs.getKey().toString().equalsIgnoreCase("command")) {
  535. command = String.valueOf(pairs.getValue());
  536. } else if (pairs.getKey().equals(form09Entity.RECORD_DATE)) {
  537. String dv = String.valueOf(pairs.getValue());
  538. if (!dv.isEmpty() && dv.length() >= 8) {
  539. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  540. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  541. form09Entity.setRecordDate(sqlDate);
  542. }
  543. }
  544. } catch (NullPointerException ex) {
  545. ex.printStackTrace();
  546. } catch (Exception ex) {
  547. ex.printStackTrace();
  548. }
  549. }//end while
  550. if (command.equalsIgnoreCase("INS")) {
  551. form09Entity.setDelflg("N");
  552. form09Entity.setActflg("Y");
  553. form09Entity.setAimag(user.getCity());
  554. form09Entity.setSum(user.getSum());
  555. form09Entity.setCreby(user.getUsername());
  556. Date utilDate = new Date();
  557. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  558. form09Entity.setCreat(sqlDate);
  559. if (form09Entity.getRecordDate() == null) form09Entity.setCreat(sqlDate);
  560. errorEntity = form09Service.insertNewData(form09Entity);
  561. } else if (command.equalsIgnoreCase("EDT") ||
  562. command.equalsIgnoreCase("DEL") ||
  563. command.equalsIgnoreCase("ACT")) {
  564. if (command.equalsIgnoreCase("DEL")) {
  565. form09Entity.setDelflg("Y");
  566. } else if (command.equalsIgnoreCase("ACT")) {
  567. form09Entity.setActflg("N");
  568. }
  569. errorEntity = form09Service.updateData(form09Entity);
  570. }
  571. } catch (Exception ex) {
  572. ex.printStackTrace();
  573. } finally {
  574. }
  575. return errorEntity;
  576. }
  577. // end-form09
  578. @Override
  579. public List<Form11Entity> getForm11Data(LinkedTreeMap criteria, String sessionId) throws Exception {
  580. System.out.println("Hospital Service Implament ::: get form 11 data");
  581. try {
  582. IForm11Service form11Service = new Form11ServiceImpl(super.conn);
  583. User user = sessionUser.get(sessionId);
  584. Form11Entity form11Entity = new Form11Entity();
  585. Iterator it = criteria.entrySet().iterator();
  586. while (it.hasNext()) {
  587. Map.Entry pairs = (Map.Entry) it.next();
  588. try {
  589. if (pairs.getKey().equals(form11Entity.ID)) {
  590. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty()) {
  591. form11Entity.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  592. }
  593. } else if (pairs.getKey().equals(form11Entity.AIMAG)) {
  594. form11Entity.setAimag(String.valueOf(pairs.getValue()));
  595. } else if (pairs.getKey().equals(form11Entity.SUM)) {
  596. form11Entity.setSum(String.valueOf(pairs.getValue()));
  597. } else if (pairs.getKey().equals(form11Entity.BAGCODE)) {
  598. form11Entity.setBagCode(String.valueOf(pairs.getValue()));
  599. } else if (pairs.getKey().equals(form11Entity.MALTURUL)) {
  600. form11Entity.setMalTurul(String.valueOf(pairs.getValue()));
  601. } else if (pairs.getKey().equals(form11Entity.DEEJIINTURUL)) {
  602. form11Entity.setDeejiinTurul(String.valueOf(pairs.getValue()));
  603. } else if (pairs.getKey().equals(form11Entity.SUMBAGNER)) {
  604. form11Entity.setSumBagNer(String.valueOf(pairs.getValue()));
  605. } else if (pairs.getKey().equals(form11Entity.TOOTOLGOI)) {
  606. try {
  607. form11Entity.setTooTolgoi(Long.parseLong(String.valueOf(pairs.getValue())));
  608. } catch (Exception e) {
  609. form11Entity.setTooTolgoi(Long.parseLong(String.valueOf("0")));
  610. }
  611. } else if (pairs.getKey().equals(form11Entity.HAANASHINJILSEN)) {
  612. form11Entity.setHaanaShinjilsen(String.valueOf(pairs.getValue()));
  613. } else if (pairs.getKey().equals(form11Entity.SHINJILSENARGA)) {
  614. form11Entity.setShinjilsenArga(String.valueOf(pairs.getValue()));
  615. } else if (pairs.getKey().equals(form11Entity.ERUUL)) {
  616. try {
  617. form11Entity.setEruul(Long.parseLong(String.valueOf(pairs.getValue())));
  618. } catch (Exception e) {
  619. form11Entity.setEruul(Long.parseLong(String.valueOf("0")));
  620. }
  621. } else if (pairs.getKey().equals(form11Entity.UVCHTEI)) {
  622. try {
  623. form11Entity.setUvchtei(Long.parseLong(String.valueOf(pairs.getValue())));
  624. } catch (Exception e) {
  625. form11Entity.setUvchtei(Long.parseLong(String.valueOf("0")));
  626. }
  627. } else if (pairs.getKey().equals(form11Entity.ONOSH)) {
  628. try {
  629. form11Entity.setOnosh(Long.parseLong(String.valueOf(pairs.getValue())));
  630. } catch (Exception e) {
  631. form11Entity.setOnosh(Long.parseLong(String.valueOf("0")));
  632. }
  633. } else if (pairs.getKey().equals(form11Entity.RECORD_DATE)) {
  634. String dv = String.valueOf(pairs.getValue());
  635. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  636. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  637. form11Entity.setRecordDate(sqlDate);
  638. } else if (pairs.getKey().equals(form11Entity.SEARCH_RECORD_DATE)) {
  639. String dv = String.valueOf(pairs.getValue());
  640. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  641. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  642. form11Entity.setSearchRecordDate(sqlDate);
  643. }
  644. } catch (NullPointerException ex) {
  645. ex.printStackTrace();
  646. } catch (Exception ex) {
  647. ex.printStackTrace();
  648. }
  649. }//end while
  650. if (user.getRoleCode() != null && !user.getRoleCode().equalsIgnoreCase("SUPERADMIN")
  651. && !user.getRoleCode().equalsIgnoreCase("ADMIN")) {
  652. form11Entity.setCreby(user.getUsername());
  653. }
  654. if (form11Entity != null && form11Entity.getRecordDate() != null && form11Entity.getSearchRecordDate() != null) {
  655. return form11Service.getListData(form11Entity);
  656. }
  657. } catch (Exception ex) {
  658. ex.printStackTrace();
  659. } finally {
  660. }
  661. return null;
  662. }
  663. @Override
  664. public ErrorEntity setForm11Data(LinkedTreeMap criteria, String sessionId) throws Exception {
  665. System.out.println("Hospital Service Implament ::: get form 11 data");
  666. try {
  667. String command = "EDT";
  668. IForm11Service form11Service = new Form11ServiceImpl(super.conn);
  669. User user = sessionUser.get(sessionId);
  670. Form11Entity form11Entity = new Form11Entity();
  671. Iterator it = criteria.entrySet().iterator();
  672. while (it.hasNext()) {
  673. Map.Entry pairs = (Map.Entry) it.next();
  674. try {
  675. if (pairs.getKey().equals(form11Entity.ID)) {
  676. String tmpId = "";
  677. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty()) {
  678. if (pairs.getValue().toString().contains(".")) {
  679. tmpId = pairs.getValue().toString().substring(0, pairs.getValue().toString().indexOf("."));
  680. }
  681. form11Entity.setId(Long.parseLong(String.valueOf(tmpId)));
  682. }
  683. } else if (pairs.getKey().equals(form11Entity.DEEJIINTURUL)) {
  684. form11Entity.setDeejiinTurul(String.valueOf(pairs.getValue()));
  685. } else if (pairs.getKey().equals(form11Entity.AIMAG)) {
  686. form11Entity.setAimag(String.valueOf(pairs.getValue()));
  687. } else if (pairs.getKey().equals(form11Entity.SUMBAGNER)) {
  688. form11Entity.setSumBagNer(String.valueOf(pairs.getValue()));
  689. } else if (pairs.getKey().equals(form11Entity.SUM)) {
  690. form11Entity.setSum(String.valueOf(pairs.getValue()));
  691. } else if (pairs.getKey().equals(form11Entity.BAGCODE)) {
  692. form11Entity.setBagCode(String.valueOf(pairs.getValue()));
  693. } else if (pairs.getKey().equals(form11Entity.MALTURUL)) {
  694. form11Entity.setMalTurul(String.valueOf(pairs.getValue()));
  695. } else if (pairs.getKey().equals(form11Entity.TOOTOLGOI)) {
  696. form11Entity.setTooTolgoi(Long.parseLong(String.valueOf(pairs.getValue())));
  697. } else if (pairs.getKey().equals(form11Entity.HAANASHINJILSEN)) {
  698. form11Entity.setHaanaShinjilsen(String.valueOf(pairs.getValue()));
  699. } else if (pairs.getKey().equals(form11Entity.SHINJILSENARGA)) {
  700. form11Entity.setShinjilsenArga(String.valueOf(pairs.getValue()));
  701. } else if (pairs.getKey().equals(form11Entity.ERUUL)) {
  702. form11Entity.setEruul(Long.parseLong(String.valueOf(pairs.getValue())));
  703. } else if (pairs.getKey().equals(form11Entity.UVCHTEI)) {
  704. form11Entity.setUvchtei(Long.parseLong(String.valueOf(pairs.getValue())));
  705. } else if (pairs.getKey().equals(form11Entity.ONOSH)) {
  706. form11Entity.setOnosh(Long.parseLong(String.valueOf(pairs.getValue())));
  707. } else if (pairs.getKey().equals(form11Entity.RECORD_DATE)) {
  708. String dv = String.valueOf(pairs.getValue());
  709. if (!dv.isEmpty() && dv.length() >= 8) {
  710. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  711. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  712. form11Entity.setRecordDate(sqlDate);
  713. }
  714. } else if (pairs.getKey().toString().equalsIgnoreCase("command")) {
  715. command = String.valueOf(pairs.getValue());
  716. }
  717. } catch (NullPointerException ex) {
  718. ex.printStackTrace();
  719. } catch (Exception ex) {
  720. ex.printStackTrace();
  721. }
  722. }//end while
  723. Date utilDate = new Date();
  724. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  725. form11Entity.setModby(user.getUsername());
  726. form11Entity.setModAt(sqlDate);
  727. if (command.equalsIgnoreCase("INS")) {
  728. form11Entity.setDelflg("N");
  729. form11Entity.setActflg("Y");
  730. if (user != null && (user.getRoleCode().equalsIgnoreCase("SUPERADMIN")
  731. || user.getRoleCode().equalsIgnoreCase("ADMIN"))) {
  732. //Aimag songoh shaardlagagui
  733. } else {
  734. form11Entity.setAimag(user.getCity());
  735. }
  736. //form11Entity.setSum(user.getSum());
  737. form11Entity.setCreby(user.getUsername());
  738. form11Entity.setCreat(sqlDate);
  739. if (form11Entity.getRecordDate() == null) form11Entity.setCreat(sqlDate);
  740. errorEntity = form11Service.insertNewData(form11Entity);
  741. } else if (command.equalsIgnoreCase("EDT") ||
  742. command.equalsIgnoreCase("DEL") ||
  743. command.equalsIgnoreCase("ACT")) {
  744. if (command.equalsIgnoreCase("DEL")) {
  745. form11Entity.setDelflg("Y");
  746. } else if (command.equalsIgnoreCase("ACT")) {
  747. form11Entity.setActflg("N");
  748. }
  749. errorEntity = form11Service.updateData(form11Entity);
  750. }
  751. } catch (Exception ex) {
  752. ex.printStackTrace();
  753. } finally {
  754. }
  755. return errorEntity;
  756. }
  757. // Begin-form14
  758. @Override
  759. public List<Form14Entity> getForm14Data(LinkedTreeMap criteria, String sessionId) throws Exception {
  760. System.out.println("Hospital Service Implament ::: get form 14 data");
  761. try {
  762. IForm14Service form14Service = new Form14ServiceImpl(super.conn);
  763. User user = sessionUser.get(sessionId);
  764. Form14Entity form14Entity = new Form14Entity();
  765. Iterator it = criteria.entrySet().iterator();
  766. while (it.hasNext()) {
  767. Map.Entry pairs = (Map.Entry) it.next();
  768. try {
  769. if (pairs.getKey().equals(form14Entity.ID)) {
  770. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  771. form14Entity.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  772. } else if (pairs.getKey().equals(form14Entity.AIMAG)) {
  773. form14Entity.setAimag(String.valueOf(pairs.getValue()));
  774. } else if (pairs.getKey().equals(form14Entity.SUM)) {
  775. form14Entity.setSum(String.valueOf(pairs.getValue()));
  776. } else if (pairs.getKey().equals(form14Entity.SHALGAHGAZAR)) {
  777. form14Entity.setShalgahGazar(String.valueOf(pairs.getValue()));
  778. } else if (pairs.getKey().equals(form14Entity.UZLEGTOO)) {
  779. try {
  780. form14Entity.setUzlegToo(Long.valueOf(pairs.getValue().toString()));
  781. } catch (NumberFormatException e) {
  782. form14Entity.setUzlegToo(Long.valueOf("0"));
  783. }
  784. } else if (pairs.getKey().equals(form14Entity.BAIGUULLAGATOO)) {
  785. try {
  786. form14Entity.setBaiguullagaToo(Long.valueOf(pairs.getValue().toString()));
  787. } catch (NumberFormatException e) {
  788. form14Entity.setBaiguullagaToo(Long.valueOf("0"));
  789. }
  790. } else if (pairs.getKey().equals(form14Entity.AJAHUINNEGJTOO)) {
  791. try {
  792. form14Entity.setAjAhuinNegjToo(Long.valueOf(pairs.getValue().toString()));
  793. } catch (NumberFormatException e) {
  794. form14Entity.setAjAhuinNegjToo(Long.valueOf("0"));
  795. }
  796. } else if (pairs.getKey().equals(form14Entity.IRGEDTOO)) {
  797. try {
  798. form14Entity.setIrgedToo(Long.valueOf(pairs.getValue().toString()));
  799. } catch (NumberFormatException e) {
  800. form14Entity.setIrgedToo(Long.valueOf("0"));
  801. }
  802. } else if (pairs.getKey().equals(form14Entity.HUULIINBAIGSHILJSEN)) {
  803. try {
  804. form14Entity.setHuuliinBaigShiljsen(Long.valueOf(pairs.getValue().toString()));
  805. } catch (NumberFormatException e) {
  806. form14Entity.setHuuliinBaigShiljsen(Long.valueOf("0"));
  807. }
  808. } else if (pairs.getKey().equals(form14Entity.ZAHIRGAAHARITOO)) {
  809. try {
  810. form14Entity.setZahirgaaHariToo(Long.valueOf(pairs.getValue().toString()));
  811. } catch (NumberFormatException e) {
  812. form14Entity.setZahirgaaHariToo(Long.valueOf("0"));
  813. }
  814. } else if (pairs.getKey().equals(form14Entity.TORGUULIHEMJEE)) {
  815. try {
  816. form14Entity.setTorguuliHemjee(BigDecimal.valueOf(Long.parseLong(pairs.getValue().toString())));
  817. } catch (NumberFormatException e) {
  818. form14Entity.setTorguuliHemjee(BigDecimal.valueOf(Long.parseLong("0")));
  819. }
  820. } else if (pairs.getKey().equals(form14Entity.TOLBOR)) {
  821. try {
  822. form14Entity.setTolbor(BigDecimal.valueOf(Long.parseLong(pairs.getValue().toString())));
  823. } catch (NumberFormatException e) {
  824. form14Entity.setTolbor(BigDecimal.valueOf(Long.parseLong("0")));
  825. }
  826. } else if (pairs.getKey().equals(form14Entity.TORGUULIAR)) {
  827. try {
  828. form14Entity.setTorguuliar(BigDecimal.valueOf(Long.parseLong(pairs.getValue().toString())));
  829. } catch (NumberFormatException e) {
  830. form14Entity.setTorguuliar(BigDecimal.valueOf(Long.parseLong("0")));
  831. }
  832. } else if (pairs.getKey().equals(form14Entity.TOLBOROOR)) {
  833. try {
  834. form14Entity.setTolboroor(BigDecimal.valueOf(Long.parseLong(pairs.getValue().toString())));
  835. } catch (NumberFormatException e) {
  836. form14Entity.setTolboroor(BigDecimal.valueOf(Long.parseLong("0")));
  837. }
  838. } else if (pairs.getKey().equals(form14Entity.RECORD_DATE)) {
  839. String dv = String.valueOf(pairs.getValue());
  840. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  841. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  842. form14Entity.setRecordDate(sqlDate);
  843. } else if (pairs.getKey().equals(form14Entity.SEARCH_RECORD_DATE)) {
  844. String dv = String.valueOf(pairs.getValue());
  845. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  846. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  847. form14Entity.setSearchRecordDate(sqlDate);
  848. }
  849. } catch (NullPointerException ex) {
  850. ex.printStackTrace();
  851. } catch (Exception ex) {
  852. ex.printStackTrace();
  853. }
  854. }//end while
  855. return form14Service.getListData(form14Entity);
  856. } catch (Exception ex) {
  857. ex.printStackTrace();
  858. } finally {
  859. }
  860. return null;
  861. }
  862. @Override
  863. public ErrorEntity setForm14Data(LinkedTreeMap criteria, String sessionId) throws Exception {
  864. System.out.println("Hospital Service Implament ::: get form 14 data");
  865. try {
  866. String command = "EDT";
  867. IForm14Service form14Service = new Form14ServiceImpl(super.conn);
  868. User user = sessionUser.get(sessionId);
  869. Form14Entity form14Entity = new Form14Entity();
  870. Iterator it = criteria.entrySet().iterator();
  871. while (it.hasNext()) {
  872. Map.Entry pairs = (Map.Entry) it.next();
  873. try {
  874. if (pairs.getKey().equals(form14Entity.ID)) {
  875. String tmpId = "";
  876. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty()) {
  877. if (pairs.getValue().toString().contains(".")) {
  878. tmpId = pairs.getValue().toString().substring(0, pairs.getValue().toString().indexOf("."));
  879. }
  880. form14Entity.setId(Long.parseLong(String.valueOf(tmpId)));
  881. }
  882. } else if (pairs.getKey().equals(form14Entity.SHALGAHGAZAR)) {
  883. form14Entity.setShalgahGazar(String.valueOf(pairs.getValue()));
  884. } else if (pairs.getKey().equals(form14Entity.UZLEGTOO)) {
  885. try {
  886. form14Entity.setUzlegToo(Long.valueOf(pairs.getValue().toString()));
  887. } catch (NumberFormatException e) {
  888. form14Entity.setUzlegToo(Long.valueOf("0"));
  889. }
  890. } else if (pairs.getKey().equals(form14Entity.BAIGUULLAGATOO)) {
  891. try {
  892. form14Entity.setBaiguullagaToo(Long.valueOf(pairs.getValue().toString()));
  893. } catch (NumberFormatException e) {
  894. form14Entity.setBaiguullagaToo(Long.valueOf("0"));
  895. }
  896. } else if (pairs.getKey().equals(form14Entity.AJAHUINNEGJTOO)) {
  897. try {
  898. form14Entity.setAjAhuinNegjToo(Long.valueOf(pairs.getValue().toString()));
  899. } catch (NumberFormatException e) {
  900. form14Entity.setAjAhuinNegjToo(Long.valueOf("0"));
  901. }
  902. } else if (pairs.getKey().equals(form14Entity.IRGEDTOO)) {
  903. try {
  904. form14Entity.setIrgedToo(Long.valueOf(pairs.getValue().toString()));
  905. } catch (NumberFormatException e) {
  906. form14Entity.setIrgedToo(Long.valueOf("0"));
  907. }
  908. } else if (pairs.getKey().equals(form14Entity.HUULIINBAIGSHILJSEN)) {
  909. try {
  910. form14Entity.setHuuliinBaigShiljsen(Long.valueOf(pairs.getValue().toString()));
  911. } catch (NumberFormatException e) {
  912. form14Entity.setHuuliinBaigShiljsen(Long.valueOf("0"));
  913. }
  914. } else if (pairs.getKey().equals(form14Entity.ZAHIRGAAHARITOO)) {
  915. try {
  916. form14Entity.setZahirgaaHariToo(Long.valueOf(pairs.getValue().toString()));
  917. } catch (NumberFormatException e) {
  918. form14Entity.setZahirgaaHariToo(Long.valueOf("0"));
  919. }
  920. } else if (pairs.getKey().equals(form14Entity.TORGUULIHEMJEE)) {
  921. try {
  922. form14Entity.setTorguuliHemjee(BigDecimal.valueOf(Long.parseLong(pairs.getValue().toString())));
  923. } catch (NumberFormatException e) {
  924. form14Entity.setTorguuliHemjee(BigDecimal.valueOf(Long.parseLong("0")));
  925. }
  926. } else if (pairs.getKey().equals(form14Entity.TOLBOR)) {
  927. try {
  928. form14Entity.setTolbor(BigDecimal.valueOf(Long.parseLong(pairs.getValue().toString())));
  929. } catch (NumberFormatException e) {
  930. form14Entity.setTolbor(BigDecimal.valueOf(Long.parseLong("0")));
  931. }
  932. } else if (pairs.getKey().equals(form14Entity.TORGUULIAR)) {
  933. try {
  934. form14Entity.setTorguuliar(BigDecimal.valueOf(Long.parseLong(pairs.getValue().toString())));
  935. } catch (NumberFormatException e) {
  936. form14Entity.setTorguuliar(BigDecimal.valueOf(Long.parseLong("0")));
  937. }
  938. } else if (pairs.getKey().equals(form14Entity.TOLBOROOR)) {
  939. try {
  940. form14Entity.setTolboroor(BigDecimal.valueOf(Long.parseLong(pairs.getValue().toString())));
  941. } catch (NumberFormatException e) {
  942. form14Entity.setTolboroor(BigDecimal.valueOf(Long.parseLong("0")));
  943. }
  944. } else if (pairs.getKey().toString().equalsIgnoreCase("command")) {
  945. command = String.valueOf(pairs.getValue());
  946. } else if (pairs.getKey().equals(form14Entity.RECORD_DATE)) {
  947. String dv = String.valueOf(pairs.getValue());
  948. if (!dv.isEmpty() && dv.length() >= 8) {
  949. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  950. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  951. form14Entity.setRecordDate(sqlDate);
  952. }
  953. }
  954. } catch (NullPointerException ex) {
  955. ex.printStackTrace();
  956. } catch (Exception ex) {
  957. ex.printStackTrace();
  958. }
  959. }//end while
  960. if (command.equalsIgnoreCase("INS")) {
  961. form14Entity.setDelflg("N");
  962. form14Entity.setActflg("Y");
  963. form14Entity.setAimag(user.getCity());
  964. form14Entity.setSum(user.getSum());
  965. form14Entity.setCreby(user.getUsername());
  966. Date utilDate = new Date();
  967. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  968. form14Entity.setCreat(sqlDate);
  969. if (form14Entity.getRecordDate() == null) form14Entity.setCreat(sqlDate);
  970. errorEntity = form14Service.insertNewData(form14Entity);
  971. } else if (command.equalsIgnoreCase("EDT") ||
  972. command.equalsIgnoreCase("DEL") ||
  973. command.equalsIgnoreCase("ACT")) {
  974. if (command.equalsIgnoreCase("DEL")) {
  975. form14Entity.setDelflg("Y");
  976. } else if (command.equalsIgnoreCase("ACT")) {
  977. form14Entity.setActflg("N");
  978. }
  979. errorEntity = form14Service.updateData(form14Entity);
  980. }
  981. } catch (Exception ex) {
  982. ex.printStackTrace();
  983. } finally {
  984. }
  985. return errorEntity;
  986. }
  987. // end-form14
  988. @Override
  989. public List<Form46Entity> getForm46Data(LinkedTreeMap criteria, String sessionId) throws Exception {
  990. System.out.println("Hospital Service Implament ::: get form 46 data");
  991. try {
  992. IForm46Service form46Service = new Form46ServiceImpl(super.conn);
  993. User user = sessionUser.get(sessionId);
  994. Form46Entity entity = new Form46Entity();
  995. Iterator it = criteria.entrySet().iterator();
  996. while (it.hasNext()) {
  997. Map.Entry pairs = (Map.Entry) it.next();
  998. try {
  999. if (pairs.getKey().equals(entity.ID)) {
  1000. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  1001. entity.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  1002. } else if (pairs.getKey().equals(entity.AIMAG)) {
  1003. entity.setAimag(String.valueOf(pairs.getValue()));
  1004. } else if (pairs.getKey().equals(entity.SUM)) {
  1005. entity.setSum(String.valueOf(pairs.getValue()));
  1006. } else if (pairs.getKey().equals(entity.BAGHOROONER)) {
  1007. entity.setBagHorooNer(String.valueOf(pairs.getValue()));
  1008. } else if (pairs.getKey().equals(entity.UHERNIITTOO)) {
  1009. entity.setUherNiitToo(String.valueOf(pairs.getValue()));
  1010. } else if (pairs.getKey().equals(entity.TUGALTOO)) {
  1011. try {
  1012. entity.setTugalToo(Long.parseLong(String.valueOf(pairs.getValue())));
  1013. } catch (Exception e) {
  1014. entity.setTugalToo(Long.parseLong(String.valueOf("0")));
  1015. }
  1016. } else if (pairs.getKey().equals(entity.BUSADTOO)) {
  1017. try {
  1018. entity.setBusadToo(Long.parseLong(String.valueOf(pairs.getValue())));
  1019. } catch (Exception e) {
  1020. entity.setBusadToo(Long.parseLong(String.valueOf("0")));
  1021. }
  1022. } else if (pairs.getKey().equals(entity.GUURTAINIITTOO)) {
  1023. entity.setGuurtaiNiitToo(String.valueOf(pairs.getValue()));
  1024. } else if (pairs.getKey().equals(entity.GUURTAITUGALTOO)) {
  1025. try {
  1026. entity.setGuurtaiBusadToo(Long.parseLong(String.valueOf(pairs.getValue())));
  1027. } catch (Exception e) {
  1028. entity.setGuurtaiBusadToo(Long.parseLong(String.valueOf("0")));
  1029. }
  1030. } else if (pairs.getKey().equals(entity.GUURTAIBUSADTOO)) {
  1031. try {
  1032. entity.setGuurtaiBusadToo(Long.parseLong(String.valueOf(pairs.getValue())));
  1033. } catch (Exception e) {
  1034. entity.setGuurtaiBusadToo(Long.parseLong(String.valueOf("0")));
  1035. }
  1036. } else if (pairs.getKey().equals(entity.DUNDAJHUVI)) {
  1037. entity.setDundajHuvi(String.valueOf(pairs.getValue()));
  1038. } else if (pairs.getKey().equals(entity.TUGALHUVI)) {
  1039. entity.setTugalHuvi(String.valueOf(pairs.getValue()));
  1040. } else if (pairs.getKey().equals(entity.BUSADHUVI)) {
  1041. entity.setBusadHuvi(String.valueOf(pairs.getValue()));
  1042. } else if (pairs.getKey().equals(entity.RECORD_DATE)) {
  1043. String dv = String.valueOf(pairs.getValue());
  1044. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  1045. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  1046. entity.setRecordDate(sqlDate);
  1047. } else if (pairs.getKey().equals(entity.SEARCH_RECORD_DATE)) {
  1048. String dv = String.valueOf(pairs.getValue());
  1049. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  1050. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  1051. entity.setSearchRecordDate(sqlDate);
  1052. }
  1053. } catch (NullPointerException ex) {
  1054. ex.printStackTrace();
  1055. } catch (Exception ex) {
  1056. ex.printStackTrace();
  1057. }
  1058. }//end while
  1059. if (user.getRoleCode() != null && !user.getRoleCode().equalsIgnoreCase("SUPERADMIN")
  1060. && !user.getRoleCode().equalsIgnoreCase("ADMIN")) {
  1061. entity.setCreby(user.getUsername());
  1062. }
  1063. return form46Service.getListData(entity);
  1064. } catch (Exception ex) {
  1065. ex.printStackTrace();
  1066. } finally {
  1067. }
  1068. return null;
  1069. }
  1070. @Override
  1071. public ErrorEntity setForm46Data(LinkedTreeMap criteria, String sessionId) throws Exception {
  1072. System.out.println("Hospital Service Implament ::: get form 46 data");
  1073. try {
  1074. String command = "EDT";
  1075. IForm46Service form46Service = new Form46ServiceImpl(super.conn);
  1076. User user = sessionUser.get(sessionId);
  1077. Form46Entity entity = new Form46Entity();
  1078. Iterator it = criteria.entrySet().iterator();
  1079. while (it.hasNext()) {
  1080. Map.Entry pairs = (Map.Entry) it.next();
  1081. try {
  1082. if (pairs.getKey().equals(entity.ID)) {
  1083. String tmpId = "";
  1084. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty()) {
  1085. if (pairs.getValue().toString().contains(".")) {
  1086. tmpId = pairs.getValue().toString().substring(0, pairs.getValue().toString().indexOf("."));
  1087. }
  1088. entity.setId(Long.parseLong(String.valueOf(tmpId)));
  1089. }
  1090. } else if (pairs.getKey().equals(entity.AIMAG)) {
  1091. entity.setAimag(String.valueOf(pairs.getValue()));
  1092. } else if (pairs.getKey().equals(entity.SUM)) {
  1093. entity.setSum(String.valueOf(pairs.getValue()));
  1094. } else if (pairs.getKey().equals(entity.BAGHOROONER)) {
  1095. entity.setBagHorooNer(String.valueOf(pairs.getValue()));
  1096. } else if (pairs.getKey().equals(entity.UHERNIITTOO)) {
  1097. entity.setUherNiitToo(String.valueOf(pairs.getValue()));
  1098. } else if (pairs.getKey().equals(entity.TUGALTOO)) {
  1099. try {
  1100. entity.setTugalToo(Long.parseLong(String.valueOf(pairs.getValue())));
  1101. } catch (Exception e) {
  1102. entity.setTugalToo(Long.parseLong(String.valueOf("0")));
  1103. }
  1104. } else if (pairs.getKey().equals(entity.BUSADTOO)) {
  1105. try {
  1106. entity.setBusadToo(Long.parseLong(String.valueOf(pairs.getValue())));
  1107. } catch (Exception e) {
  1108. entity.setBusadToo(Long.parseLong(String.valueOf("0")));
  1109. }
  1110. } else if (pairs.getKey().equals(entity.GUURTAINIITTOO)) {
  1111. entity.setGuurtaiNiitToo(String.valueOf(pairs.getValue()));
  1112. } else if (pairs.getKey().equals(entity.GUURTAITUGALTOO)) {
  1113. try {
  1114. entity.setGuurtaiTugalToo(Long.parseLong(String.valueOf(pairs.getValue())));
  1115. } catch (Exception e) {
  1116. entity.setGuurtaiTugalToo(Long.parseLong(String.valueOf("0")));
  1117. }
  1118. } else if (pairs.getKey().equals(entity.GUURTAIBUSADTOO)) {
  1119. try {
  1120. entity.setGuurtaiBusadToo(Long.parseLong(String.valueOf(pairs.getValue())));
  1121. } catch (Exception e) {
  1122. entity.setGuurtaiBusadToo(Long.parseLong(String.valueOf("0")));
  1123. }
  1124. } else if (pairs.getKey().equals(entity.DUNDAJHUVI)) {
  1125. entity.setDundajHuvi(String.valueOf(pairs.getValue()));
  1126. } else if (pairs.getKey().equals(entity.TUGALHUVI)) {
  1127. entity.setTugalHuvi(String.valueOf(pairs.getValue()));
  1128. } else if (pairs.getKey().equals(entity.BUSADHUVI)) {
  1129. entity.setBusadHuvi(String.valueOf(pairs.getValue()));
  1130. } else if (pairs.getKey().toString().equalsIgnoreCase("command")) {
  1131. command = String.valueOf(pairs.getValue());
  1132. } else if (pairs.getKey().equals(entity.RECORD_DATE)) {
  1133. String dv = String.valueOf(pairs.getValue());
  1134. if (!dv.isEmpty() && dv.length() >= 8) {
  1135. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  1136. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  1137. entity.setRecordDate(sqlDate);
  1138. }
  1139. }
  1140. } catch (NullPointerException ex) {
  1141. ex.printStackTrace();
  1142. } catch (Exception ex) {
  1143. ex.printStackTrace();
  1144. }
  1145. }//end while
  1146. if (command.equalsIgnoreCase("INS")) {
  1147. entity.setDelflg("N");
  1148. entity.setActflg("Y");
  1149. if (user != null && (user.getRoleCode().equalsIgnoreCase("SUPERADMIN")
  1150. || user.getRoleCode().equalsIgnoreCase("ADMIN"))) {
  1151. //Aimag songoh shaardlagagui
  1152. } else {
  1153. entity.setAimag(user.getCity());
  1154. }
  1155. //entity.setSum(user.getSum());
  1156. entity.setCreby(user.getUsername());
  1157. Date utilDate = new Date();
  1158. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  1159. entity.setCreat(sqlDate);
  1160. if (entity.getRecordDate() == null) entity.setCreat(sqlDate);
  1161. errorEntity = form46Service.insertNewData(entity);
  1162. } else if (command.equalsIgnoreCase("EDT") ||
  1163. command.equalsIgnoreCase("DEL") ||
  1164. command.equalsIgnoreCase("ACT")) {
  1165. if (command.equalsIgnoreCase("DEL")) {
  1166. entity.setDelflg("Y");
  1167. } else if (command.equalsIgnoreCase("ACT")) {
  1168. entity.setActflg("N");
  1169. }
  1170. errorEntity = form46Service.updateData(entity);
  1171. }
  1172. } catch (Exception ex) {
  1173. ex.printStackTrace();
  1174. } finally {
  1175. }
  1176. return errorEntity;
  1177. }
  1178. //Begin-form43
  1179. @Override
  1180. public List<Form43Entity> getForm43Data(LinkedTreeMap criteria, String sessionId) throws Exception {
  1181. System.out.println("Hospital Service Implament ::: get form 43 data");
  1182. try {
  1183. IForm43Service form43Service = new Form43ServiceImpl(super.conn);
  1184. User user = sessionUser.get(sessionId);
  1185. Form43Entity form43Entity = new Form43Entity();
  1186. Iterator it = criteria.entrySet().iterator();
  1187. while (it.hasNext()) {
  1188. Map.Entry pairs = (Map.Entry) it.next();
  1189. try {
  1190. if (pairs.getKey().equals(form43Entity.ID)) {
  1191. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  1192. form43Entity.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  1193. } else if (pairs.getKey().equals(form43Entity.AIMAG)) {
  1194. form43Entity.setAimag(String.valueOf(pairs.getValue()));
  1195. } else if (pairs.getKey().equals(form43Entity.SUM)) {
  1196. form43Entity.setSum(String.valueOf(pairs.getValue()));
  1197. } else if (pairs.getKey().equals(form43Entity.AJAHUINNEGJ)) {
  1198. form43Entity.setAjahuinNegj(String.valueOf(pairs.getValue()));
  1199. } else {
  1200. if (pairs.getKey().equals(form43Entity.TUSGAIZOVSHOOROL)) {
  1201. String dv = String.valueOf(pairs.getValue());
  1202. try {
  1203. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  1204. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  1205. form43Entity.setTusgaiZovshoorol(sqlDate);
  1206. } catch (Exception ex) {
  1207. DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
  1208. Date now = new Date();
  1209. form43Entity.setTusgaiZovshoorol(new java.sql.Date(now.getTime()));
  1210. }
  1211. } else if (pairs.getKey().equals(form43Entity.EMBELDMELNER)) {
  1212. form43Entity.setEmBeldmelNer(String.valueOf(pairs.getValue()));
  1213. } else if (pairs.getKey().equals(form43Entity.HEMJIHNEGJ)) {
  1214. form43Entity.setHemjihNegj(String.valueOf(pairs.getValue()));
  1215. } else if (pairs.getKey().equals(form43Entity.PARMAKOP)) {
  1216. try {
  1217. form43Entity.setParmakop(Long.parseLong(String.valueOf(pairs.getValue())));
  1218. } catch (Exception e) {
  1219. form43Entity.setParmakop(Long.parseLong(String.valueOf("0")));
  1220. }
  1221. } else if (pairs.getKey().equals(form43Entity.UILDVERLESENTOO)) {
  1222. try {
  1223. form43Entity.setUildverlesenToo(Long.valueOf(pairs.getValue().toString()));
  1224. } catch (NumberFormatException e) {
  1225. form43Entity.setUildverlesenToo(Long.valueOf("0"));
  1226. }
  1227. } else if (pairs.getKey().equals(form43Entity.NEGJUNE)) {
  1228. try {
  1229. form43Entity.setNegjUne(String.valueOf(pairs.getValue()));
  1230. } catch (NumberFormatException e) {
  1231. form43Entity.setNegjUne(String.valueOf("0"));
  1232. }
  1233. } else if (pairs.getKey().equals(form43Entity.NIITUNE)) {
  1234. try {
  1235. form43Entity.setNiitUne(String.valueOf(pairs.getValue()));
  1236. } catch (NullPointerException e) {
  1237. form43Entity.setNiitUne(String.valueOf("0"));
  1238. }
  1239. } else if (pairs.getKey().equals(form43Entity.RECORD_DATE)) {
  1240. String dv = String.valueOf(pairs.getValue());
  1241. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  1242. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  1243. form43Entity.setRecordDate(sqlDate);
  1244. } else if (pairs.getKey().equals(form43Entity.SEARCH_RECORD_DATE)) {
  1245. String dv = String.valueOf(pairs.getValue());
  1246. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  1247. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  1248. form43Entity.setSearchRecordDate(sqlDate);
  1249. }
  1250. }
  1251. } catch (NullPointerException ex) {
  1252. ex.printStackTrace();
  1253. } catch (Exception ex) {
  1254. ex.printStackTrace();
  1255. }
  1256. }//end while
  1257. return form43Service.getListData(form43Entity);
  1258. } catch (Exception ex) {
  1259. ex.printStackTrace();
  1260. } finally {
  1261. }
  1262. return null;
  1263. }
  1264. @Override
  1265. public ErrorEntity setForm43Data(LinkedTreeMap criteria, String sessionId) throws Exception {
  1266. System.out.println("Hospital Service Implament ::: get form 43 data");
  1267. try {
  1268. String command = "EDT";
  1269. IForm43Service form43Service = new Form43ServiceImpl(super.conn);
  1270. User user = sessionUser.get(sessionId);
  1271. Form43Entity form43Entity = new Form43Entity();
  1272. Iterator it = criteria.entrySet().iterator();
  1273. while (it.hasNext()) {
  1274. Map.Entry pairs = (Map.Entry) it.next();
  1275. try {
  1276. if (pairs.getKey().equals(form43Entity.ID)) {
  1277. String tmpId = "";
  1278. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty()) {
  1279. if (pairs.getValue().toString().contains(".")) {
  1280. tmpId = pairs.getValue().toString().substring(0, pairs.getValue().toString().indexOf("."));
  1281. }
  1282. form43Entity.setId(Long.parseLong(String.valueOf(tmpId)));
  1283. }
  1284. } else if (pairs.getKey().equals(form43Entity.AJAHUINNEGJ)) {
  1285. form43Entity.setAjahuinNegj(String.valueOf(pairs.getValue()));
  1286. } else if (pairs.getKey().equals(form43Entity.TUSGAIZOVSHOOROL)) {
  1287. String dv = String.valueOf(pairs.getValue());
  1288. if (!dv.isEmpty() && dv.length() >= 8) {
  1289. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  1290. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  1291. form43Entity.setTusgaiZovshoorol(sqlDate);
  1292. }
  1293. } else if (pairs.getKey().equals(form43Entity.EMBELDMELNER)) {
  1294. form43Entity.setEmBeldmelNer(String.valueOf(pairs.getValue()));
  1295. } else if (pairs.getKey().equals(form43Entity.HEMJIHNEGJ)) {
  1296. form43Entity.setHemjihNegj(String.valueOf(pairs.getValue()));
  1297. } else if (pairs.getKey().equals(form43Entity.PARMAKOP)) {
  1298. try {
  1299. form43Entity.setParmakop(Long.parseLong(String.valueOf(pairs.getValue())));
  1300. } catch (Exception e) {
  1301. form43Entity.setParmakop(Long.parseLong(String.valueOf("0")));
  1302. }
  1303. } else if (pairs.getKey().equals(form43Entity.UILDVERLESENTOO)) {
  1304. try {
  1305. form43Entity.setUildverlesenToo(Long.valueOf(pairs.getValue().toString()));
  1306. } catch (NumberFormatException e) {
  1307. form43Entity.setUildverlesenToo(Long.valueOf("0"));
  1308. }
  1309. } else if (pairs.getKey().equals(form43Entity.NEGJUNE)) {
  1310. try {
  1311. form43Entity.setNegjUne(String.valueOf(pairs.getValue()));
  1312. } catch (NumberFormatException e) {
  1313. form43Entity.setNegjUne(String.valueOf("0"));
  1314. }
  1315. } else if (pairs.getKey().equals(form43Entity.NIITUNE)) {
  1316. try {
  1317. form43Entity.setNiitUne(String.valueOf(pairs.getValue()));
  1318. } catch (NullPointerException e) {
  1319. form43Entity.setNiitUne(String.valueOf("0"));
  1320. }
  1321. } else if (pairs.getKey().equals(form43Entity.RECORD_DATE)) {
  1322. String dv = String.valueOf(pairs.getValue());
  1323. if (!dv.isEmpty() && dv.length() >= 8) {
  1324. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  1325. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  1326. form43Entity.setRecordDate(sqlDate);
  1327. }
  1328. } else if (pairs.getKey().toString().equalsIgnoreCase("command")) {
  1329. command = String.valueOf(pairs.getValue());
  1330. }
  1331. } catch (NullPointerException ex) {
  1332. ex.printStackTrace();
  1333. } catch (Exception ex) {
  1334. ex.printStackTrace();
  1335. }
  1336. }//end while
  1337. Date utilDate = new Date();
  1338. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  1339. form43Entity.setModby(user.getUsername());
  1340. form43Entity.setModAt(sqlDate);
  1341. if (command.equalsIgnoreCase("INS")) {
  1342. form43Entity.setDelflg("N");
  1343. form43Entity.setActflg("Y");
  1344. form43Entity.setAimag(user.getCity());
  1345. form43Entity.setSum(user.getSum());
  1346. form43Entity.setCreby(user.getUsername());
  1347. form43Entity.setCreat(sqlDate);
  1348. if (form43Entity.getRecordDate() == null) form43Entity.setCreat(sqlDate);
  1349. errorEntity = form43Service.insertNewData(form43Entity);
  1350. } else if (command.equalsIgnoreCase("EDT") ||
  1351. command.equalsIgnoreCase("DEL") ||
  1352. command.equalsIgnoreCase("ACT")) {
  1353. if (command.equalsIgnoreCase("DEL")) {
  1354. form43Entity.setDelflg("Y");
  1355. } else if (command.equalsIgnoreCase("ACT")) {
  1356. form43Entity.setActflg("N");
  1357. }
  1358. errorEntity = form43Service.updateData(form43Entity);
  1359. }
  1360. } catch (Exception ex) {
  1361. ex.printStackTrace();
  1362. } finally {
  1363. }
  1364. return errorEntity;
  1365. }
  1366. //end-form43
  1367. //Begin City Form
  1368. @Override
  1369. public List<City> getCityData(LinkedTreeMap criteria, String sessionId) throws Exception {
  1370. System.out.println("Hospital Service ::: get city data");
  1371. try {
  1372. ICityService cityService = new CityServiceImpl(super.conn);
  1373. User user = sessionUser.get(sessionId);
  1374. City city = new City();
  1375. Iterator it = criteria.entrySet().iterator();
  1376. while (it.hasNext()) {
  1377. Map.Entry pairs = (Map.Entry) it.next();
  1378. try {
  1379. if (pairs.getKey().equals(city.ID)) {
  1380. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  1381. city.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  1382. } else if (pairs.getKey().equals(city.CODE)) {
  1383. city.setCode(String.valueOf(pairs.getValue()));
  1384. } else if (pairs.getKey().equals(city.COUNTRYCODE)) {
  1385. city.setCountrycode(String.valueOf(pairs.getValue()));
  1386. } else if (pairs.getKey().equals(city.CITYNAME)) {
  1387. city.setCityname(String.valueOf(pairs.getValue()));
  1388. } else if (pairs.getKey().equals(city.CITYDESC)) {
  1389. city.setCitydesc(String.valueOf(pairs.getValue()));
  1390. } else if (pairs.getKey().equals(city.CITYNAME_EN)) {
  1391. city.setCitynameEn(String.valueOf(pairs.getValue()));
  1392. } else if (pairs.getKey().equals(city.DELFLG)) {
  1393. city.setDelflg(String.valueOf(pairs.getValue()));
  1394. } else if (pairs.getKey().equals(city.ACTFLG)) {
  1395. city.setActflg(String.valueOf(pairs.getValue()));
  1396. }
  1397. } catch (NullPointerException ex) {
  1398. ex.printStackTrace();
  1399. } catch (Exception ex) {
  1400. ex.printStackTrace();
  1401. }
  1402. }//end while
  1403. city.setDelflg("N");
  1404. return cityService.selectAll(city);
  1405. } catch (Exception ex) {
  1406. ex.printStackTrace();
  1407. } finally {
  1408. }
  1409. return null;
  1410. }
  1411. @Override
  1412. public ErrorEntity setCityData(LinkedTreeMap insdata, String sessionId) throws Exception {
  1413. System.out.println("Hospital Service Implament ::: set city data");
  1414. try {
  1415. String command = "EDT";
  1416. ICityService cityService = new CityServiceImpl(super.conn);
  1417. User user = sessionUser.get(sessionId);
  1418. City city = new City();
  1419. Iterator it = insdata.entrySet().iterator();
  1420. while (it.hasNext()) {
  1421. Map.Entry pairs = (Map.Entry) it.next();
  1422. try {
  1423. if (pairs.getKey().equals(city.ID)) {
  1424. String tmpId = "";
  1425. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty()) {
  1426. if (pairs.getValue().toString().contains(".")) {
  1427. tmpId = pairs.getValue().toString().substring(0, pairs.getValue().toString().indexOf("."));
  1428. }
  1429. city.setId(Long.parseLong(String.valueOf(tmpId)));
  1430. }
  1431. } else if (pairs.getKey().equals(city.CODE)) {
  1432. city.setCode(String.valueOf(pairs.getValue()));
  1433. } else if (pairs.getKey().equals(city.COUNTRYCODE)) {
  1434. city.setCountrycode(String.valueOf(pairs.getValue()));
  1435. } else if (pairs.getKey().equals(city.CITYNAME)) {
  1436. city.setCityname(String.valueOf(pairs.getValue()));
  1437. } else if (pairs.getKey().equals(city.CITYDESC)) {
  1438. city.setCitydesc(String.valueOf(pairs.getValue()));
  1439. } else if (pairs.getKey().equals(city.CITYNAME_EN)) {
  1440. city.setCitynameEn(String.valueOf(pairs.getValue()));
  1441. } else if (pairs.getKey().equals(city.DELFLG)) {
  1442. city.setDelflg(String.valueOf(pairs.getValue()));
  1443. } else if (pairs.getKey().equals(city.ACTFLG)) {
  1444. city.setActflg(String.valueOf(pairs.getValue()));
  1445. } else if (pairs.getKey().equals(city.LATITUDE)) {
  1446. city.setLatitude(String.valueOf(pairs.getValue()));
  1447. } else if (pairs.getKey().equals(city.LONGITUDE)) {
  1448. city.setLongitude(String.valueOf(pairs.getValue()));
  1449. } else if (pairs.getKey().toString().equalsIgnoreCase("command")) {
  1450. command = String.valueOf(pairs.getValue());
  1451. }
  1452. } catch (NullPointerException ex) {
  1453. ex.printStackTrace();
  1454. } catch (Exception ex) {
  1455. ex.printStackTrace();
  1456. }
  1457. }//end while
  1458. if (command.equalsIgnoreCase("INS")) {
  1459. city.setDelflg("N");
  1460. city.setActflg("Y");
  1461. city.setCountrycode("UB");
  1462. city.setCreby(user.getUsername());
  1463. Date utilDate = new Date();
  1464. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  1465. city.setCreat(sqlDate);
  1466. errorEntity = cityService.insertData(city);
  1467. } else if (command.equalsIgnoreCase("EDT") ||
  1468. command.equalsIgnoreCase("DEL") ||
  1469. command.equalsIgnoreCase("ACT")) {
  1470. city.setModby(user.getUsername());
  1471. Date utilDate = new Date();
  1472. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  1473. city.setModAt(sqlDate);
  1474. if (command.equalsIgnoreCase("DEL")) {
  1475. city.setDelflg("Y");
  1476. }
  1477. errorEntity = cityService.updateData(city);
  1478. }
  1479. } catch (Exception ex) {
  1480. ex.printStackTrace();
  1481. } finally {
  1482. if (errorEntity == null) {
  1483. errorEntity = new ErrorEntity(ErrorType.ERROR, Long.valueOf(1000));
  1484. }
  1485. }
  1486. return errorEntity;
  1487. }
  1488. //End City Form
  1489. //Begin Sum Form
  1490. @Override
  1491. public List<Sum> getSumData(LinkedTreeMap criteria, String sessionId) throws Exception {
  1492. System.out.println("Hospital Service ::: get sum data");
  1493. try {
  1494. ISumService sumService = new SumServiceImpl(super.conn);
  1495. User user = sessionUser.get(sessionId);
  1496. Sum sum = new Sum();
  1497. Iterator it = criteria.entrySet().iterator();
  1498. while (it.hasNext()) {
  1499. Map.Entry pairs = (Map.Entry) it.next();
  1500. try {
  1501. if (pairs.getKey().equals(sum.ID)) {
  1502. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  1503. sum.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  1504. } else if (pairs.getKey().equals(sum.SUMCODE)) {
  1505. sum.setSumcode(String.valueOf(pairs.getValue()));
  1506. } else if (pairs.getKey().equals(sum.CITYCODE)) {
  1507. sum.setCitycode(String.valueOf(pairs.getValue()));
  1508. } else if (pairs.getKey().equals(sum.SUMNAME)) {
  1509. sum.setSumname(String.valueOf(pairs.getValue()));
  1510. } else if (pairs.getKey().equals(sum.SUMDESC)) {
  1511. sum.setSumdesc(String.valueOf(pairs.getValue()));
  1512. } else if (pairs.getKey().equals(sum.SUMNAME_EN)) {
  1513. sum.setSumname_en(String.valueOf(pairs.getValue()));
  1514. } else if (pairs.getKey().equals(sum.DELFLG)) {
  1515. sum.setDelFlg(String.valueOf(pairs.getValue()));
  1516. } else if (pairs.getKey().equals(sum.ACTFLG)) {
  1517. sum.setActFlg(String.valueOf(pairs.getValue()));
  1518. }
  1519. } catch (NullPointerException ex) {
  1520. ex.printStackTrace();
  1521. } catch (Exception ex) {
  1522. ex.printStackTrace();
  1523. }
  1524. }//end while
  1525. if (sum.getCitycode() != null && sum.getCitycode().equalsIgnoreCase("CURRENT")) {
  1526. sum.setCitycode(user.getCity());
  1527. }
  1528. sum.setDelFlg("N");
  1529. return sumService.selectAll(sum);
  1530. } catch (Exception ex) {
  1531. ex.printStackTrace();
  1532. } finally {
  1533. }
  1534. return null;
  1535. }
  1536. @Override
  1537. public ErrorEntity setSumData(LinkedTreeMap insdata, String sessionId) throws Exception {
  1538. System.out.println("Hospital Service Implament ::: set sum data");
  1539. try {
  1540. String command = "EDT";
  1541. ISumService sumService = new SumServiceImpl(super.conn);
  1542. User user = sessionUser.get(sessionId);
  1543. Sum sum = new Sum();
  1544. Iterator it = insdata.entrySet().iterator();
  1545. while (it.hasNext()) {
  1546. Map.Entry pairs = (Map.Entry) it.next();
  1547. try {
  1548. if (pairs.getKey().equals(sum.ID)) {
  1549. String tmpId = "";
  1550. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty()) {
  1551. if (pairs.getValue().toString().contains(".")) {
  1552. tmpId = pairs.getValue().toString().substring(0, pairs.getValue().toString().indexOf("."));
  1553. }
  1554. sum.setId(Long.parseLong(String.valueOf(tmpId)));
  1555. }
  1556. } else if (pairs.getKey().equals(sum.SUMCODE)) {
  1557. sum.setSumcode(String.valueOf(pairs.getValue()));
  1558. } else if (pairs.getKey().equals(sum.CITYCODE)) {
  1559. sum.setCitycode(String.valueOf(pairs.getValue()));
  1560. } else if (pairs.getKey().equals(sum.SUMNAME)) {
  1561. sum.setSumname(String.valueOf(pairs.getValue()));
  1562. } else if (pairs.getKey().equals(sum.SUMDESC)) {
  1563. sum.setSumdesc(String.valueOf(pairs.getValue()));
  1564. } else if (pairs.getKey().equals(sum.SUMNAME_EN)) {
  1565. sum.setSumname_en(String.valueOf(pairs.getValue()));
  1566. } else if (pairs.getKey().equals(sum.DELFLG)) {
  1567. sum.setDelFlg(String.valueOf(pairs.getValue()));
  1568. } else if (pairs.getKey().equals(sum.ACTFLG)) {
  1569. sum.setActFlg(String.valueOf(pairs.getValue()));
  1570. } else if (pairs.getKey().equals(sum.LATITUDE)) {
  1571. sum.setLatitude(String.valueOf(pairs.getValue()));
  1572. } else if (pairs.getKey().equals(sum.LONGITUDE)) {
  1573. sum.setLongitude(String.valueOf(pairs.getValue()));
  1574. } else if (pairs.getKey().toString().equalsIgnoreCase("command")) {
  1575. command = String.valueOf(pairs.getValue());
  1576. }
  1577. } catch (NullPointerException ex) {
  1578. ex.printStackTrace();
  1579. } catch (Exception ex) {
  1580. ex.printStackTrace();
  1581. }
  1582. }//end while
  1583. if (command.equalsIgnoreCase("INS")) {
  1584. sum.setDelFlg("N");
  1585. sum.setActFlg("Y");
  1586. sum.setCreBy(user.getUsername());
  1587. Date utilDate = new Date();
  1588. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  1589. sum.setCreAt(sqlDate);
  1590. sum.setModBy(user.getUsername());
  1591. sum.setModAt(sqlDate);
  1592. errorEntity = sumService.insertData(sum);
  1593. } else if (command.equalsIgnoreCase("EDT") ||
  1594. command.equalsIgnoreCase("DEL") ||
  1595. command.equalsIgnoreCase("ACT")) {
  1596. sum.setModBy(user.getUsername());
  1597. Date utilDate = new Date();
  1598. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  1599. sum.setModAt(sqlDate);
  1600. if (command.equalsIgnoreCase("DEL")) {
  1601. sum.setDelFlg("Y");
  1602. }
  1603. errorEntity = sumService.updateData(sum);
  1604. }
  1605. } catch (Exception ex) {
  1606. ex.printStackTrace();
  1607. } finally {
  1608. if (errorEntity == null) {
  1609. errorEntity = new ErrorEntity(ErrorType.ERROR, Long.valueOf(1000));
  1610. }
  1611. }
  1612. return errorEntity;
  1613. }
  1614. //End Sum form
  1615. //Begin User form
  1616. @Override
  1617. public List<User> getUserData(LinkedTreeMap criteria, String sessionId) throws Exception {
  1618. System.out.println("Hospital Service ::: get user data");
  1619. try {
  1620. IUserService userService = new UserServiceImpl(super.conn);
  1621. User user = sessionUser.get(sessionId);
  1622. User seluser = new User();
  1623. Iterator it = criteria.entrySet().iterator();
  1624. while (it.hasNext()) {
  1625. Map.Entry pairs = (Map.Entry) it.next();
  1626. try {
  1627. if (pairs.getKey().equals(seluser.ID)) {
  1628. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  1629. seluser.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  1630. } else if (pairs.getKey().equals(seluser.USERNAME)) {
  1631. seluser.setUsername(String.valueOf(pairs.getValue()));
  1632. } else if (pairs.getKey().equals(seluser.ROLECODE)) {
  1633. seluser.setRoleCode(String.valueOf(pairs.getValue()));
  1634. } else if (pairs.getKey().equals(seluser.FIRSTNAME)) {
  1635. seluser.setFirstName(String.valueOf(pairs.getValue()));
  1636. } else if (pairs.getKey().equals(seluser.LASTNAME)) {
  1637. seluser.setLastName(String.valueOf(pairs.getValue()));
  1638. } else if (pairs.getKey().equals(seluser.GENDER)) {
  1639. seluser.setGender(String.valueOf(pairs.getValue()));
  1640. } else if (pairs.getKey().equals(seluser.REGID)) {
  1641. seluser.setRegId(String.valueOf(pairs.getValue()));
  1642. } else if (pairs.getKey().equals(seluser.CITY)) {
  1643. seluser.setCity(String.valueOf(pairs.getValue()));
  1644. } else if (pairs.getKey().equals(seluser.SUM)) {
  1645. seluser.setSum(String.valueOf(pairs.getValue()));
  1646. } else if (pairs.getKey().equals(seluser.CREBY)) {
  1647. seluser.setCreBy(String.valueOf(pairs.getValue()));
  1648. } else if (pairs.getKey().equals(seluser.MODBY)) {
  1649. seluser.setModBy(String.valueOf(pairs.getValue()));
  1650. } else if (pairs.getKey().equals(seluser.DELFLG)) {
  1651. seluser.setDelFlg(String.valueOf(pairs.getValue()));
  1652. } else if (pairs.getKey().equals(seluser.ACTFLG)) {
  1653. seluser.setActFlg(String.valueOf(pairs.getValue()));
  1654. } else if (pairs.getKey().equals(seluser.CHAT_ID)) {
  1655. seluser.setChatId(String.valueOf(pairs.getValue()));
  1656. }
  1657. } catch (NullPointerException ex) {
  1658. ex.printStackTrace();
  1659. } catch (Exception ex) {
  1660. ex.printStackTrace();
  1661. }
  1662. }//end while
  1663. seluser.setDelFlg("N");
  1664. return userService.getUserList(seluser);
  1665. } catch (Exception ex) {
  1666. ex.printStackTrace();
  1667. } finally {
  1668. }
  1669. return null;
  1670. }
  1671. @Override
  1672. public ErrorEntity setUserData(LinkedTreeMap insdata, String sessionId) throws Exception {
  1673. System.out.println("Hospital Service ::: set user data");
  1674. try {
  1675. String command = "EDT";
  1676. IUserService userService = new UserServiceImpl(super.conn);
  1677. User user = sessionUser.get(sessionId);
  1678. User seluser = new User();
  1679. Iterator it = insdata.entrySet().iterator();
  1680. while (it.hasNext()) {
  1681. Map.Entry pairs = (Map.Entry) it.next();
  1682. try {
  1683. if (pairs.getKey().equals(seluser.ID)) {
  1684. String tmpId = "";
  1685. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty()) {
  1686. if (pairs.getValue().toString().contains(".")) {
  1687. tmpId = pairs.getValue().toString().substring(0, pairs.getValue().toString().indexOf("."));
  1688. }
  1689. seluser.setId(Long.parseLong(String.valueOf(tmpId)));
  1690. }
  1691. } else if (pairs.getKey().equals(seluser.USERNAME)) {
  1692. seluser.setUsername(String.valueOf(pairs.getValue()));
  1693. } else if (pairs.getKey().equals(seluser.ROLECODE)) {
  1694. seluser.setRoleCode(String.valueOf(pairs.getValue()));
  1695. } else if (pairs.getKey().equals(seluser.FIRSTNAME)) {
  1696. seluser.setFirstName(String.valueOf(pairs.getValue()));
  1697. } else if (pairs.getKey().equals(seluser.LASTNAME)) {
  1698. seluser.setLastName(String.valueOf(pairs.getValue()));
  1699. } else if (pairs.getKey().equals(seluser.GENDER)) {
  1700. seluser.setGender(String.valueOf(pairs.getValue()));
  1701. } else if (pairs.getKey().equals(seluser.REGID)) {
  1702. seluser.setRegId(String.valueOf(pairs.getValue()));
  1703. } else if (pairs.getKey().equals(seluser.CITY)) {
  1704. seluser.setCity(String.valueOf(pairs.getValue()));
  1705. } else if (pairs.getKey().equals(seluser.SUM)) {
  1706. seluser.setSum(String.valueOf(pairs.getValue()));
  1707. } else if (pairs.getKey().equals(seluser.CREBY)) {
  1708. seluser.setCreBy(String.valueOf(pairs.getValue()));
  1709. } else if (pairs.getKey().equals(seluser.MODBY)) {
  1710. seluser.setModBy(String.valueOf(pairs.getValue()));
  1711. } else if (pairs.getKey().equals(seluser.DELFLG)) {
  1712. seluser.setDelFlg(String.valueOf(pairs.getValue()));
  1713. } else if (pairs.getKey().equals(seluser.ACTFLG)) {
  1714. seluser.setActFlg(String.valueOf(pairs.getValue()));
  1715. } else if (pairs.getKey().equals(seluser.PASSWORD)) {
  1716. seluser.setPassword(String.valueOf(pairs.getValue()));
  1717. } else if (pairs.getKey().toString().equalsIgnoreCase("command")) {
  1718. command = String.valueOf(pairs.getValue());
  1719. }
  1720. } catch (NullPointerException ex) {
  1721. ex.printStackTrace();
  1722. } catch (Exception ex) {
  1723. ex.printStackTrace();
  1724. }
  1725. }//end while
  1726. seluser.setModBy(user.getUsername());
  1727. Date utilDate = new Date();
  1728. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  1729. seluser.setModAt(sqlDate);
  1730. if (command.equalsIgnoreCase("INS")) {
  1731. seluser.setDelFlg("N");
  1732. seluser.setActFlg("Y");
  1733. seluser.setCreBy(user.getUsername());
  1734. seluser.setCreAt(sqlDate);
  1735. String chatid = new ObjectId().toString();
  1736. seluser.setChatId(chatid);
  1737. errorEntity = userService.insertUser(seluser);
  1738. } else if (command.equalsIgnoreCase("EDT") ||
  1739. command.equalsIgnoreCase("DEL")) {
  1740. if (command.equalsIgnoreCase("DEL")) {
  1741. seluser.setDelFlg("Y");
  1742. }
  1743. errorEntity = userService.updateUserData(seluser);
  1744. }
  1745. } catch (Exception ex) {
  1746. ex.printStackTrace();
  1747. } finally {
  1748. if (errorEntity == null) {
  1749. errorEntity = new ErrorEntity(ErrorType.ERROR, Long.valueOf(1000));
  1750. }
  1751. }
  1752. return errorEntity;
  1753. }
  1754. //End User form
  1755. //Begin Bag Horoo form
  1756. @Override
  1757. public List<BagHorooEntity> getBagHorooData(LinkedTreeMap criteria, String sessionId) throws Exception {
  1758. System.out.println("Hospital Service ::: get bag horoo data");
  1759. try {
  1760. IBagHorooService bagService = new BagHorooServiceImpl(super.conn);
  1761. User user = sessionUser.get(sessionId);
  1762. BagHorooEntity bagHorooEntity = new BagHorooEntity();
  1763. Iterator it = criteria.entrySet().iterator();
  1764. while (it.hasNext()) {
  1765. Map.Entry pairs = (Map.Entry) it.next();
  1766. try {
  1767. if (pairs.getKey().equals(bagHorooEntity.ID)) {
  1768. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  1769. bagHorooEntity.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  1770. } else if (pairs.getKey().equals(bagHorooEntity.SUM_CODE)) {
  1771. bagHorooEntity.setSumcode(String.valueOf(pairs.getValue()));
  1772. } else if (pairs.getKey().equals(bagHorooEntity.HOROO_CODE)) {
  1773. bagHorooEntity.setHoroocode(String.valueOf(pairs.getValue()));
  1774. } else if (pairs.getKey().equals(bagHorooEntity.HOROO_NAME)) {
  1775. bagHorooEntity.setHorooname(String.valueOf(pairs.getValue()));
  1776. } else if (pairs.getKey().equals(bagHorooEntity.HOROO_DESC)) {
  1777. bagHorooEntity.setHoroodesc(String.valueOf(pairs.getValue()));
  1778. } else if (pairs.getKey().equals(bagHorooEntity.HOROO_NAME_EN)) {
  1779. bagHorooEntity.setHorooname_en(String.valueOf(pairs.getValue()));
  1780. } else if (pairs.getKey().equals(bagHorooEntity.DELFLG)) {
  1781. bagHorooEntity.setDelflg(String.valueOf(pairs.getValue()));
  1782. } else if (pairs.getKey().equals(bagHorooEntity.ACTFLG)) {
  1783. bagHorooEntity.setActflg(String.valueOf(pairs.getValue()));
  1784. }
  1785. } catch (NullPointerException ex) {
  1786. ex.printStackTrace();
  1787. } catch (Exception ex) {
  1788. ex.printStackTrace();
  1789. }
  1790. }//end while
  1791. bagHorooEntity.setDelflg("N");
  1792. return bagService.selectAll(bagHorooEntity);
  1793. } catch (Exception ex) {
  1794. ex.printStackTrace();
  1795. } finally {
  1796. }
  1797. return null;
  1798. }
  1799. //End bag horoo form
  1800. @Override
  1801. public List<BasicDBObject> getComboVals(String type, String langid, String sessionId) throws Exception {
  1802. IComboService comboService = new ComboServiceImpl(conn);
  1803. return comboService.getComboVals(type, langid);
  1804. }
  1805. //End bag horoo form
  1806. @Override
  1807. public List<BasicDBObject> getShalgahGazarVals(String type, String langid, String sessionId) throws Exception {
  1808. IComboService comboService = new ComboServiceImpl(conn);
  1809. return comboService.getShalgahGazarVals(type, langid);
  1810. }
  1811. @Override
  1812. public List<MenuEntity> getMenuList(LinkedTreeMap criteria, String sessionId) throws Exception {
  1813. System.out.println("Hospital Service ::: get menu list data");
  1814. try {
  1815. IMenuService service = new MenuServiceImpl(super.conn);
  1816. User user = sessionUser.get(sessionId);
  1817. MenuEntity entity = new MenuEntity();
  1818. Iterator it = criteria.entrySet().iterator();
  1819. while (it.hasNext()) {
  1820. Map.Entry pairs = (Map.Entry) it.next();
  1821. try {
  1822. if (pairs.getKey().equals(entity.ID)) {
  1823. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  1824. entity.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  1825. } else if (pairs.getKey().equals(entity.MENUID)) {
  1826. entity.setMenuid(String.valueOf(pairs.getValue()));
  1827. } else if (pairs.getKey().equals(entity.MENUNAMEMN)) {
  1828. entity.setMenunamemn(String.valueOf(pairs.getValue()));
  1829. } else if (pairs.getKey().equals(entity.MENUNAMEEN)) {
  1830. entity.setMenunameen(String.valueOf(pairs.getValue()));
  1831. } else if (pairs.getKey().equals(entity.MENUDESC)) {
  1832. entity.setMenudesc(String.valueOf(pairs.getValue()));
  1833. }
  1834. } catch (NullPointerException ex) {
  1835. ex.printStackTrace();
  1836. } catch (Exception ex) {
  1837. ex.printStackTrace();
  1838. }
  1839. }//end while
  1840. entity.setDelflg("N");
  1841. entity.setActflg("Y");
  1842. return service.selectAll(entity);
  1843. } catch (Exception ex) {
  1844. ex.printStackTrace();
  1845. } finally {
  1846. }
  1847. return null;
  1848. }
  1849. @Override
  1850. public List<Role> getRoleList(LinkedTreeMap criteria, String sessionId) throws Exception {
  1851. System.out.println("Hospital Service ::: get role list data");
  1852. try {
  1853. IRoleService service = new RoleServiceImpl(super.conn);
  1854. User user = sessionUser.get(sessionId);
  1855. Role entity = new Role();
  1856. Iterator it = criteria.entrySet().iterator();
  1857. while (it.hasNext()) {
  1858. Map.Entry pairs = (Map.Entry) it.next();
  1859. try {
  1860. if (pairs.getKey().equals(entity.ID)) {
  1861. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  1862. entity.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  1863. } else if (pairs.getKey().equals(entity.CODE)) {
  1864. entity.setCode(String.valueOf(pairs.getValue()));
  1865. } else if (pairs.getKey().equals(entity.NAME)) {
  1866. entity.setName(String.valueOf(pairs.getValue()));
  1867. } else if (pairs.getKey().equals(entity.PARENT)) {
  1868. entity.setParent(String.valueOf(pairs.getValue()));
  1869. } else if (pairs.getKey().equals(entity.DESC)) {
  1870. entity.setDesc(String.valueOf(pairs.getValue()));
  1871. }
  1872. } catch (NullPointerException ex) {
  1873. ex.printStackTrace();
  1874. } catch (Exception ex) {
  1875. ex.printStackTrace();
  1876. }
  1877. }//end while
  1878. return service.selectAll(entity);
  1879. } catch (Exception ex) {
  1880. ex.printStackTrace();
  1881. } finally {
  1882. }
  1883. return null;
  1884. }
  1885. @Override
  1886. public ErrorEntity setMenuRole(LinkedTreeMap insdata, String sessionId) throws Exception {
  1887. System.out.println("Hospital Service ::: register role menu data");
  1888. try {
  1889. String command = "EDT";
  1890. IMenuRolesService service = new MenuRolesServiceImpl(super.conn);
  1891. User user = sessionUser.get(sessionId);
  1892. MenuRoles menuRoles = new MenuRoles();
  1893. Iterator it = insdata.entrySet().iterator();
  1894. List<LinkedTreeMap> menuList = null;
  1895. while (it.hasNext()) {
  1896. Map.Entry pairs = (Map.Entry) it.next();
  1897. try {
  1898. if (pairs.getKey().equals(menuRoles.ID)) {
  1899. String tmpId = "";
  1900. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty()) {
  1901. if (pairs.getValue().toString().contains(".")) {
  1902. tmpId = pairs.getValue().toString().substring(0, pairs.getValue().toString().indexOf("."));
  1903. }
  1904. menuRoles.setId(Long.parseLong(String.valueOf(tmpId)));
  1905. }
  1906. } else if (pairs.getKey().equals(menuRoles.ROLECODE)) {
  1907. menuRoles.setRolecode(String.valueOf(pairs.getValue()));
  1908. } else if (pairs.getKey().equals("menulist")) {
  1909. menuList = (List<LinkedTreeMap>) pairs.getValue();
  1910. } else if (pairs.getKey().toString().equalsIgnoreCase("command")) {
  1911. command = String.valueOf(pairs.getValue());
  1912. }
  1913. } catch (NullPointerException ex) {
  1914. ex.printStackTrace();
  1915. } catch (Exception ex) {
  1916. ex.printStackTrace();
  1917. }
  1918. }//end while
  1919. menuRoles.setCreBy(user.getUsername());
  1920. Date utilDate = new Date();
  1921. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  1922. menuRoles.setCreAt(sqlDate);
  1923. if (command.equalsIgnoreCase("INS")) {
  1924. menuRoles.setDelflg("N");
  1925. menuRoles.setCreBy(user.getUsername());
  1926. menuRoles.setCreAt(sqlDate);
  1927. for (LinkedTreeMap regmenu : menuList) {
  1928. Iterator itm = regmenu.entrySet().iterator();
  1929. String provMenuId = menuRoles.getMenuId();
  1930. while (itm.hasNext()) {
  1931. Map.Entry pairs = (Map.Entry) itm.next();
  1932. if (pairs != null && pairs.getKey().equals("menuId")) {
  1933. menuRoles.setMenuId(String.valueOf(pairs.getValue()));
  1934. }
  1935. }
  1936. if (provMenuId != null && menuRoles.getMenuId() != null && !provMenuId.equalsIgnoreCase(menuRoles.getMenuId())) {
  1937. errorEntity = service.insertData(menuRoles);
  1938. }
  1939. }//end of for loop
  1940. } else if (command.equalsIgnoreCase("EDT") ||
  1941. command.equalsIgnoreCase("DEL")) {
  1942. if (command.equalsIgnoreCase("DEL")) {
  1943. menuRoles.setDelflg("Y");
  1944. }
  1945. errorEntity = service.updateData(menuRoles);
  1946. }
  1947. } catch (Exception ex) {
  1948. ex.printStackTrace();
  1949. } finally {
  1950. if (errorEntity == null) {
  1951. errorEntity = new ErrorEntity(ErrorType.ERROR, Long.valueOf(1000));
  1952. }
  1953. }
  1954. return errorEntity;
  1955. }
  1956. @Override
  1957. public List<MenuRoles> getMenuRole(LinkedTreeMap criteria, String sessionId) throws Exception {
  1958. System.out.println("Hospital Service ::: get menu role list data");
  1959. try {
  1960. IMenuRolesService service = new MenuRolesServiceImpl(super.conn);
  1961. User user = sessionUser.get(sessionId);
  1962. MenuRoles entity = new MenuRoles();
  1963. Iterator it = criteria.entrySet().iterator();
  1964. while (it.hasNext()) {
  1965. Map.Entry pairs = (Map.Entry) it.next();
  1966. try {
  1967. if (pairs.getKey().equals(entity.ID)) {
  1968. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  1969. entity.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  1970. } else if (pairs.getKey().equals(entity.ROLECODE)) {
  1971. entity.setRolecode(String.valueOf(pairs.getValue()));
  1972. } else if (pairs.getKey().equals(entity.MENUID)) {
  1973. entity.setMenuId(String.valueOf(pairs.getValue()));
  1974. }
  1975. } catch (NullPointerException ex) {
  1976. ex.printStackTrace();
  1977. } catch (Exception ex) {
  1978. ex.printStackTrace();
  1979. }
  1980. }//end while
  1981. entity.setDelflg("N");
  1982. return service.selectAll(entity);
  1983. } catch (Exception ex) {
  1984. ex.printStackTrace();
  1985. } finally {
  1986. }
  1987. return null;
  1988. }//end of function
  1989. @Override
  1990. public BasicDBObject getForm08ColumnChartData(LinkedTreeMap criteria, String sessionId, String menuid) throws Exception {
  1991. System.out.println("Hospital Service Implament ::: get form 08 data");
  1992. try {
  1993. IForm08Service form08Service = new Form08ServiceImpl(super.conn);
  1994. User user = sessionUser.get(sessionId);
  1995. Form08Entity form08Entity = new Form08Entity();
  1996. Iterator it = criteria.entrySet().iterator();
  1997. //Check Role
  1998. /*roleControl = new CheckUserRoleControl(super.conn);
  1999. if (roleControl == null) {
  2000. return null;
  2001. }
  2002. menuid = menuid.replaceAll("#", "");
  2003. if (!roleControl.checkRole(user, menuid, 1)){
  2004. return null;
  2005. }*/
  2006. //End Check Role
  2007. while (it.hasNext()) {
  2008. Map.Entry pairs = (Map.Entry) it.next();
  2009. try {
  2010. if (pairs.getKey().equals(form08Entity.ID)) {
  2011. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  2012. form08Entity.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  2013. } else if (pairs.getKey().equals(form08Entity.AIMAG)) {
  2014. form08Entity.setAimag(String.valueOf(pairs.getValue()));
  2015. } else if (pairs.getKey().equals(form08Entity.SUM)) {
  2016. form08Entity.setSum(String.valueOf(pairs.getValue()));
  2017. } else if (pairs.getKey().equals(form08Entity.MALTURUL)) {
  2018. form08Entity.setMalTurul(String.valueOf(pairs.getValue()));
  2019. } else if (pairs.getKey().equals(form08Entity.ARGA_HEMJEE_NER)) {
  2020. form08Entity.setArgaHemjeeNer(String.valueOf(pairs.getValue()));
  2021. } else if (pairs.getKey().equals(form08Entity.NER)) {
  2022. form08Entity.setNer(String.valueOf(pairs.getValue()));
  2023. } else if (pairs.getKey().equals(form08Entity.ZARTSUULSAN_HEMJEE)) {
  2024. form08Entity.setZartsuulsanHemjee(String.valueOf(pairs.getValue()));
  2025. } else if (pairs.getKey().equals(form08Entity.TOLOVLOGOO)) {
  2026. form08Entity.setTolovlogoo(String.valueOf(pairs.getValue()));
  2027. } else if (pairs.getKey().equals(form08Entity.GUITSETGEL)) {
  2028. form08Entity.setGuitsetgel(String.valueOf(pairs.getValue()));
  2029. } else if (pairs.getKey().equals(form08Entity.HUVI)) {
  2030. form08Entity.setHuvi(String.valueOf(pairs.getValue()));
  2031. } else if (pairs.getKey().equals(form08Entity.RECORD_DATE)) {
  2032. String dv = String.valueOf(pairs.getValue());
  2033. if (dv != null && !dv.isEmpty()) {
  2034. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  2035. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  2036. form08Entity.setRecordDate(sqlDate);
  2037. }
  2038. } else if (pairs.getKey().equals(form08Entity.SEARCH_RECORD_DATE)) {
  2039. String dv = String.valueOf(pairs.getValue());
  2040. if (dv != null && !dv.isEmpty()) {
  2041. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  2042. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  2043. form08Entity.setSearchRecordDate(sqlDate);
  2044. }
  2045. }
  2046. } catch (NullPointerException ex) {
  2047. ex.printStackTrace();
  2048. } catch (Exception ex) {
  2049. ex.printStackTrace();
  2050. }
  2051. }//end while
  2052. if (user.getRoleCode() != null && !user.getRoleCode().equalsIgnoreCase("SUPERADMIN")
  2053. && !user.getRoleCode().equalsIgnoreCase("ADMIN")) {
  2054. form08Entity.setCreby(user.getUsername());
  2055. }
  2056. //if(form08Entity.getSum() == null)form08Entity.setSum(user.getSum());
  2057. if (user.getRoleCode() != null && !user.getRoleCode().equalsIgnoreCase("SUPERADMIN")
  2058. && !user.getRoleCode().equalsIgnoreCase("ADMIN")) {
  2059. form08Entity.setCreby(user.getUsername());
  2060. }
  2061. form08Entity.setDelflg("N");
  2062. form08Entity.setActflg("Y");
  2063. if (form08Entity != null && form08Entity.getRecordDate() != null && form08Entity.getSearchRecordDate() != null) {
  2064. return form08Service.getColumnChartData(form08Entity);
  2065. }
  2066. } catch (Exception ex) {
  2067. ex.printStackTrace();
  2068. } finally {
  2069. }
  2070. return null;
  2071. }//end of function
  2072. @Override
  2073. public List<BasicDBObject> getForm08PieChartData(LinkedTreeMap criteria, String sessionId, String menuid) throws Exception {
  2074. System.out.println("Hospital Service Implament ::: get form 08 data");
  2075. try {
  2076. IForm08Service form08Service = new Form08ServiceImpl(super.conn);
  2077. User user = sessionUser.get(sessionId);
  2078. Form08Entity form08Entity = new Form08Entity();
  2079. Iterator it = criteria.entrySet().iterator();
  2080. //Check Role
  2081. /*roleControl = new CheckUserRoleControl(super.conn);
  2082. if (roleControl == null) {
  2083. return null;
  2084. }
  2085. menuid = menuid.replaceAll("#", "");
  2086. if (!roleControl.checkRole(user, menuid, 1)){
  2087. return null;
  2088. }*/
  2089. //End Check Role
  2090. while (it.hasNext()) {
  2091. Map.Entry pairs = (Map.Entry) it.next();
  2092. try {
  2093. if (pairs.getKey().equals(form08Entity.ID)) {
  2094. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  2095. form08Entity.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  2096. } else if (pairs.getKey().equals(form08Entity.AIMAG)) {
  2097. form08Entity.setAimag(String.valueOf(pairs.getValue()));
  2098. } else if (pairs.getKey().equals(form08Entity.SUM)) {
  2099. form08Entity.setSum(String.valueOf(pairs.getValue()));
  2100. } else if (pairs.getKey().equals(form08Entity.MALTURUL)) {
  2101. form08Entity.setMalTurul(String.valueOf(pairs.getValue()));
  2102. } else if (pairs.getKey().equals(form08Entity.ARGA_HEMJEE_NER)) {
  2103. form08Entity.setArgaHemjeeNer(String.valueOf(pairs.getValue()));
  2104. } else if (pairs.getKey().equals(form08Entity.NER)) {
  2105. form08Entity.setNer(String.valueOf(pairs.getValue()));
  2106. } else if (pairs.getKey().equals(form08Entity.ZARTSUULSAN_HEMJEE)) {
  2107. form08Entity.setZartsuulsanHemjee(String.valueOf(pairs.getValue()));
  2108. } else if (pairs.getKey().equals(form08Entity.TOLOVLOGOO)) {
  2109. form08Entity.setTolovlogoo(String.valueOf(pairs.getValue()));
  2110. } else if (pairs.getKey().equals(form08Entity.GUITSETGEL)) {
  2111. form08Entity.setGuitsetgel(String.valueOf(pairs.getValue()));
  2112. } else if (pairs.getKey().equals(form08Entity.HUVI)) {
  2113. form08Entity.setHuvi(String.valueOf(pairs.getValue()));
  2114. } else if (pairs.getKey().equals(form08Entity.RECORD_DATE)) {
  2115. String dv = String.valueOf(pairs.getValue());
  2116. if (dv != null && !dv.isEmpty()) {
  2117. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  2118. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  2119. form08Entity.setRecordDate(sqlDate);
  2120. }
  2121. } else if (pairs.getKey().equals(form08Entity.SEARCH_RECORD_DATE)) {
  2122. String dv = String.valueOf(pairs.getValue());
  2123. if (dv != null && !dv.isEmpty()) {
  2124. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  2125. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  2126. form08Entity.setSearchRecordDate(sqlDate);
  2127. }
  2128. }
  2129. } catch (NullPointerException ex) {
  2130. ex.printStackTrace();
  2131. } catch (Exception ex) {
  2132. ex.printStackTrace();
  2133. }
  2134. }//end while
  2135. if (form08Entity.getAimag() == null) form08Entity.setAimag(user.getCity());
  2136. //if(form08Entity.getSum() == null)form08Entity.setSum(user.getSum());
  2137. if (user.getRoleCode() != null && !user.getRoleCode().equalsIgnoreCase("SUPERADMIN")
  2138. && !user.getRoleCode().equalsIgnoreCase("ADMIN")) {
  2139. form08Entity.setCreby(user.getUsername());
  2140. }
  2141. form08Entity.setDelflg("N");
  2142. form08Entity.setActflg("Y");
  2143. if (form08Entity != null && form08Entity.getRecordDate() != null && form08Entity.getSearchRecordDate() != null) {
  2144. return form08Service.getPieChartData(form08Entity);
  2145. }
  2146. } catch (Exception ex) {
  2147. ex.printStackTrace();
  2148. } finally {
  2149. }
  2150. return null;
  2151. }
  2152. @Override
  2153. public List<Form08HavsraltEntity> getForm08HavsraltData(LinkedTreeMap criteria, String sessionId, String menuid) throws Exception {
  2154. System.out.println("Hospital Service Implament ::: get form 08 havsralt data");
  2155. try {
  2156. IForm08HavsraltService form08Service = new Form08HavsraltServiceImpl(super.conn);
  2157. User user = sessionUser.get(sessionId);
  2158. Form08HavsraltEntity entity = new Form08HavsraltEntity();
  2159. Iterator it = criteria.entrySet().iterator();
  2160. //Check Role
  2161. /*roleControl = new CheckUserRoleControl(super.conn);
  2162. if (roleControl == null) {
  2163. return null;
  2164. }
  2165. menuid = menuid.replaceAll("#", "");
  2166. if (!roleControl.checkRole(user, menuid, 1)){
  2167. return null;
  2168. }*/
  2169. //End Check Role
  2170. while (it.hasNext()) {
  2171. Map.Entry pairs = (Map.Entry) it.next();
  2172. try {
  2173. if (!pairs.getValue().toString().isEmpty()) {
  2174. if (pairs.getKey().equals(entity.ID)) {
  2175. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  2176. entity.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  2177. } else if (pairs.getKey().equals(entity.CITYCODE)) {
  2178. entity.setCitycode(String.valueOf(pairs.getValue()));
  2179. } else if (pairs.getKey().equals(entity.SUMCODE)) {
  2180. entity.setSumcode(String.valueOf(pairs.getValue()));
  2181. } else if (pairs.getKey().equals(entity.BAGCODE)) {
  2182. entity.setBagcode(String.valueOf(pairs.getValue()));
  2183. } else if (pairs.getKey().equals(entity.GAZARNER)) {
  2184. entity.setGazarner(String.valueOf(pairs.getValue()));
  2185. } else if (pairs.getKey().equals(entity.URTRAG)) {
  2186. entity.setUrtrag(String.valueOf(pairs.getValue()));
  2187. } else if (pairs.getKey().equals(entity.ORGOROG)) {
  2188. entity.setOrgorog(String.valueOf(pairs.getValue()));
  2189. } else if (pairs.getKey().equals(entity.GOLOMTTOO)) {
  2190. entity.setGolomttoo(Integer.parseInt(String.valueOf(pairs.getValue())));
  2191. } else if (pairs.getKey().equals(entity.OVCHIN_NER)) {
  2192. entity.setOvchin_ner(String.valueOf(pairs.getValue()));
  2193. } else if (pairs.getKey().equals(entity.MAL_TURUL)) {
  2194. entity.setMal_turul(String.valueOf(pairs.getValue()));
  2195. } else if (pairs.getKey().equals(entity.UVCHILSON)) {
  2196. entity.setUvchilson(Integer.parseInt(String.valueOf(pairs.getValue())));
  2197. } else if (pairs.getKey().equals(entity.UHSEN)) {
  2198. entity.setUhsen(Integer.parseInt(String.valueOf(pairs.getValue())));
  2199. } else if (pairs.getKey().equals(entity.EDGERSEN)) {
  2200. entity.setEdgersen(Integer.parseInt(String.valueOf(pairs.getValue())));
  2201. } else if (pairs.getKey().equals(entity.USTGASAN)) {
  2202. entity.setUstgasan(Integer.parseInt(String.valueOf(pairs.getValue())));
  2203. } else if (pairs.getKey().equals(entity.NYDLUULSAN)) {
  2204. entity.setNydluulsan(Integer.parseInt(String.valueOf(pairs.getValue())));
  2205. } else if (pairs.getKey().equals(entity.LAB_NER)) {
  2206. entity.setLab_ner(String.valueOf(pairs.getValue()));
  2207. } else if (pairs.getKey().equals(entity.SHINJILGEE_ARGA)) {
  2208. entity.setShinjilgee_arga(String.valueOf(pairs.getValue()));
  2209. } else if (pairs.getKey().equals(entity.RECORD_DATE)) {
  2210. String dv = String.valueOf(pairs.getValue());
  2211. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  2212. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  2213. entity.setRecordDate(sqlDate);
  2214. } else if (pairs.getKey().equals(entity.SEARCH_RECORD_DATE)) {
  2215. String dv = String.valueOf(pairs.getValue());
  2216. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  2217. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  2218. entity.setSearchRecordDate(sqlDate);
  2219. }
  2220. }
  2221. } catch (NullPointerException ex) {
  2222. ex.printStackTrace();
  2223. } catch (Exception ex) {
  2224. ex.printStackTrace();
  2225. }
  2226. }//end while
  2227. Date utilDate = new Date();
  2228. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  2229. if (entity.getRecordDate() == null) entity.setRecordDate(sqlDate);
  2230. if (entity.getSearchRecordDate() == null) entity.setSearchRecordDate(sqlDate);
  2231. entity.setDelflg("N");
  2232. if (user.getRoleCode() != null && !user.getRoleCode().equalsIgnoreCase("SUPERADMIN")
  2233. && !user.getRoleCode().equalsIgnoreCase("ADMIN")) {
  2234. entity.setCreby(user.getUsername());
  2235. }
  2236. if (entity != null && entity.getRecordDate() != null && entity.getSearchRecordDate() != null) {
  2237. return form08Service.getListData(entity);
  2238. }
  2239. } catch (Exception ex) {
  2240. ex.printStackTrace();
  2241. } finally {
  2242. }
  2243. return null;
  2244. }
  2245. @Override
  2246. public ErrorEntity setForm08HavsraltData(LinkedTreeMap criteria, String sessionId, String menuid) throws Exception {
  2247. System.out.println("Hospital Service Implament ::: get form 08 havsralt data");
  2248. try {
  2249. String command = "EDT";
  2250. IForm08HavsraltService service = new Form08HavsraltServiceImpl(super.conn);
  2251. User user = sessionUser.get(sessionId);
  2252. Form08HavsraltEntity entity = new Form08HavsraltEntity();
  2253. //Begin Check Role Step 1
  2254. roleControl = new CheckUserRoleControl(super.conn);
  2255. if (roleControl == null) {
  2256. errorEntity = new ErrorEntity(ErrorType.ERROR, Long.valueOf(1002)); // Ерөнхий алдаа : Эрх нь хүрэлцэхгүй үед өгөх
  2257. return errorEntity;
  2258. }
  2259. //End Check Role Step 1
  2260. menuid = menuid.replaceAll("#", "");
  2261. Iterator it = criteria.entrySet().iterator();
  2262. while (it.hasNext()) {
  2263. Map.Entry pairs = (Map.Entry) it.next();
  2264. try {
  2265. if (pairs.getKey().equals(entity.ID)) {
  2266. String tmpId = "";
  2267. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty()) {
  2268. if (pairs.getValue().toString().contains(".")) {
  2269. tmpId = pairs.getValue().toString().substring(0, pairs.getValue().toString().indexOf("."));
  2270. }
  2271. entity.setId(Long.parseLong(String.valueOf(tmpId)));
  2272. }
  2273. } else if (pairs.getKey().equals(entity.CITYCODE)) {
  2274. entity.setCitycode(String.valueOf(pairs.getValue()));
  2275. } else if (pairs.getKey().equals(entity.SUMCODE)) {
  2276. entity.setSumcode(String.valueOf(pairs.getValue()));
  2277. } else if (pairs.getKey().equals(entity.BAGCODE)) {
  2278. entity.setBagcode(String.valueOf(pairs.getValue()));
  2279. } else if (pairs.getKey().equals(entity.GAZARNER)) {
  2280. entity.setGazarner(String.valueOf(pairs.getValue()));
  2281. } else if (pairs.getKey().equals(entity.URTRAG)) {
  2282. entity.setUrtrag(String.valueOf(pairs.getValue()));
  2283. } else if (pairs.getKey().equals(entity.ORGOROG)) {
  2284. entity.setOrgorog(String.valueOf(pairs.getValue()));
  2285. } else if (pairs.getKey().equals(entity.GOLOMTTOO)) {
  2286. entity.setGolomttoo(stringToInteger(String.valueOf(pairs.getValue())));
  2287. } else if (pairs.getKey().equals(entity.OVCHIN_NER)) {
  2288. entity.setOvchin_ner(String.valueOf(pairs.getValue()));
  2289. } else if (pairs.getKey().equals(entity.MAL_TURUL)) {
  2290. entity.setMal_turul(String.valueOf(pairs.getValue()));
  2291. } else if (pairs.getKey().equals(entity.UVCHILSON)) {
  2292. entity.setUvchilson(stringToInteger(String.valueOf(pairs.getValue())));
  2293. } else if (pairs.getKey().equals(entity.UHSEN)) {
  2294. entity.setUhsen(stringToInteger(String.valueOf(pairs.getValue())));
  2295. } else if (pairs.getKey().equals(entity.EDGERSEN)) {
  2296. entity.setEdgersen(stringToInteger(String.valueOf(pairs.getValue())));
  2297. } else if (pairs.getKey().equals(entity.USTGASAN)) {
  2298. entity.setUstgasan(stringToInteger(String.valueOf(pairs.getValue())));
  2299. } else if (pairs.getKey().equals(entity.NYDLUULSAN)) {
  2300. entity.setNydluulsan(stringToInteger(String.valueOf(pairs.getValue())));
  2301. } else if (pairs.getKey().equals(entity.LAB_NER)) {
  2302. entity.setLab_ner(String.valueOf(pairs.getValue()));
  2303. } else if (pairs.getKey().equals(entity.SHINJILGEE_ARGA)) {
  2304. entity.setShinjilgee_arga(String.valueOf(pairs.getValue()));
  2305. } else if (pairs.getKey().equals(entity.RECORD_DATE)) {
  2306. String dv = String.valueOf(pairs.getValue());
  2307. if (!dv.isEmpty() && dv.length() >= 8) {
  2308. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  2309. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  2310. entity.setRecordDate(sqlDate);
  2311. }
  2312. } else if (pairs.getKey().toString().equalsIgnoreCase("command")) {
  2313. command = String.valueOf(pairs.getValue());
  2314. }
  2315. } catch (NullPointerException ex) {
  2316. ex.printStackTrace();
  2317. } catch (Exception ex) {
  2318. ex.printStackTrace();
  2319. }
  2320. }//end while
  2321. if (command.equalsIgnoreCase("INS")) {
  2322. entity.setDelflg("N");
  2323. if (user != null && (user.getRoleCode().equalsIgnoreCase("SUPERADMIN")
  2324. || user.getRoleCode().equalsIgnoreCase("ADMIN"))) {
  2325. //Aimag songoh shaardlagagui
  2326. } else {
  2327. entity.setCitycode(user.getCity());
  2328. }
  2329. //entity.setSumcode(user.getSum());
  2330. entity.setCreby(user.getUsername());
  2331. Date utilDate = new Date();
  2332. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  2333. entity.setCreat(sqlDate);
  2334. if (entity.getRecordDate() == null) entity.setCreat(sqlDate);
  2335. //Begin Check Role Step 2
  2336. if (roleControl.checkRole(user, menuid, 2)) {
  2337. errorEntity = service.insertNewData(entity);
  2338. } else {
  2339. errorEntity = new ErrorEntity(ErrorType.ERROR, Long.valueOf(1002)); // Ерөнхий алдаа : Эрх нь хүрэлцэхгүй үед өгөх
  2340. }
  2341. //End Check Role Step 2
  2342. } else if (command.equalsIgnoreCase("EDT") ||
  2343. command.equalsIgnoreCase("DEL") ||
  2344. command.equalsIgnoreCase("ACT")) {
  2345. int quality = 2;
  2346. if (command.equalsIgnoreCase("DEL")) {
  2347. entity.setDelflg("Y");
  2348. quality = 3;
  2349. }
  2350. //Begin Check Role Step 2
  2351. if (roleControl.checkRole(user, menuid, quality)) {
  2352. errorEntity = service.updateData(entity);
  2353. } else {
  2354. errorEntity = new ErrorEntity(ErrorType.ERROR, Long.valueOf(1002)); // Ерөнхий алдаа : Эрх нь хүрэлцэхгүй үед өгөх
  2355. }
  2356. //End Check Role Step 2
  2357. }
  2358. } catch (Exception ex) {
  2359. ex.printStackTrace();
  2360. } finally {
  2361. }
  2362. return errorEntity;
  2363. }//
  2364. // begin-form09hav
  2365. @Override
  2366. public List<Form09HavsraltEntity> getForm09HavsraltData(LinkedTreeMap criteria, String sessionId, String menuid) throws Exception {
  2367. System.out.println("Hospital Service Implament ::: get form 09 havsralt data");
  2368. try {
  2369. IForm09HavsraltService form09Service = new Form09HavsraltServiceImpl(super.conn);
  2370. User user = sessionUser.get(sessionId);
  2371. Form09HavsraltEntity entity = new Form09HavsraltEntity();
  2372. Iterator it = criteria.entrySet().iterator();
  2373. // //Check Role
  2374. // roleControl = new CheckUserRoleControl(super.conn);
  2375. //
  2376. // if (roleControl == null) {
  2377. // return null;
  2378. // }
  2379. //
  2380. // menuid = menuid.replaceAll("#", "");
  2381. //
  2382. // if (!roleControl.checkRole(user, menuid, 1)){
  2383. // return null;
  2384. // }
  2385. // //End Check Role
  2386. while (it.hasNext()) {
  2387. Map.Entry pairs = (Map.Entry) it.next();
  2388. try {
  2389. if (!pairs.getValue().toString().isEmpty()) {
  2390. if (pairs.getKey().equals(entity.ID)) {
  2391. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  2392. entity.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  2393. } else if (pairs.getKey().equals(entity.CITYCODE)) {
  2394. entity.setCitycode(String.valueOf(pairs.getValue()));
  2395. } else if (pairs.getKey().equals(entity.SUMCODE)) {
  2396. entity.setSumcode(String.valueOf(pairs.getValue()));
  2397. } else if (pairs.getKey().equals(entity.BAGCODE)) {
  2398. entity.setBagcode(String.valueOf(pairs.getValue()));
  2399. } else if (pairs.getKey().equals(entity.GAZARNER)) {
  2400. entity.setGazarner(String.valueOf(pairs.getValue()));
  2401. } else if (pairs.getKey().equals(entity.URTRAG)) {
  2402. entity.setUrtrag(String.valueOf(pairs.getValue()));
  2403. } else if (pairs.getKey().equals(entity.ORGOROG)) {
  2404. entity.setOrgorog(String.valueOf(pairs.getValue()));
  2405. } else if (pairs.getKey().equals(entity.GOLOMTTOO)) {
  2406. entity.setGolomttoo(Integer.parseInt(String.valueOf(pairs.getValue())));
  2407. } else if (pairs.getKey().equals(entity.OVCHIN_NER)) {
  2408. entity.setOvchin_ner(String.valueOf(pairs.getValue()));
  2409. } else if (pairs.getKey().equals(entity.MAL_TURUL)) {
  2410. entity.setMal_turul(String.valueOf(pairs.getValue()));
  2411. } else if (pairs.getKey().equals(entity.UVCHILSON)) {
  2412. entity.setUvchilson(Integer.parseInt(String.valueOf(pairs.getValue())));
  2413. } else if (pairs.getKey().equals(entity.UHSEN)) {
  2414. entity.setUhsen(Integer.parseInt(String.valueOf(pairs.getValue())));
  2415. } else if (pairs.getKey().equals(entity.EDGERSEN)) {
  2416. entity.setEdgersen(Integer.parseInt(String.valueOf(pairs.getValue())));
  2417. } else if (pairs.getKey().equals(entity.RECORD_DATE)) {
  2418. String dv = String.valueOf(pairs.getValue());
  2419. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  2420. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  2421. entity.setRecordDate(sqlDate);
  2422. } else if (pairs.getKey().equals(entity.SEARCH_RECORD_DATE)) {
  2423. String dv = String.valueOf(pairs.getValue());
  2424. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  2425. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  2426. entity.setSearchRecordDate(sqlDate);
  2427. }
  2428. }
  2429. } catch (NullPointerException ex) {
  2430. ex.printStackTrace();
  2431. } catch (Exception ex) {
  2432. ex.printStackTrace();
  2433. }
  2434. }//end while
  2435. Date utilDate = new Date();
  2436. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  2437. if (entity.getRecordDate() == null) entity.setRecordDate(sqlDate);
  2438. if (entity.getSearchRecordDate() == null) entity.setSearchRecordDate(sqlDate);
  2439. entity.setDelflg("N");
  2440. if (user.getRoleCode() != null && !user.getRoleCode().equalsIgnoreCase("SUPERADMIN")
  2441. && !user.getRoleCode().equalsIgnoreCase("ADMIN")) {
  2442. entity.setCreby(user.getUsername());
  2443. }
  2444. if (entity != null && entity.getRecordDate() != null && entity.getSearchRecordDate() != null) {
  2445. return form09Service.getListData(entity);
  2446. }
  2447. } catch (Exception ex) {
  2448. ex.printStackTrace();
  2449. } finally {
  2450. }
  2451. return null;
  2452. }
  2453. @Override
  2454. public ErrorEntity setForm09HavsraltData(LinkedTreeMap criteria, String sessionId, String menuid) throws Exception {
  2455. System.out.println("Hospital Service Implament ::: get form 09 havsralt data");
  2456. try {
  2457. String command = "EDT";
  2458. IForm09HavsraltService service = new Form09HavsraltServiceImpl(super.conn);
  2459. User user = sessionUser.get(sessionId);
  2460. Form09HavsraltEntity entity = new Form09HavsraltEntity();
  2461. // //Begin Check Role Step 1
  2462. // roleControl = new CheckUserRoleControl(super.conn);
  2463. //
  2464. // if (roleControl == null) {
  2465. // errorEntity = new ErrorEntity(ErrorType.ERROR, Long.valueOf(1002)); // Ерөнхий алдаа : Эрх нь хүрэлцэхгүй үед өгөх
  2466. // return errorEntity;
  2467. // }
  2468. // //End Check Role Step 1
  2469. // menuid = menuid.replaceAll("#", "");
  2470. Iterator it = criteria.entrySet().iterator();
  2471. while (it.hasNext()) {
  2472. Map.Entry pairs = (Map.Entry) it.next();
  2473. try {
  2474. if (pairs.getKey().equals(entity.ID)) {
  2475. String tmpId = "";
  2476. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty()) {
  2477. if (pairs.getValue().toString().contains(".")) {
  2478. tmpId = pairs.getValue().toString().substring(0, pairs.getValue().toString().indexOf("."));
  2479. }
  2480. entity.setId(Long.parseLong(String.valueOf(tmpId)));
  2481. }
  2482. } else if (pairs.getKey().equals(entity.CITYCODE)) {
  2483. entity.setCitycode(String.valueOf(pairs.getValue()));
  2484. } else if (pairs.getKey().equals(entity.SUMCODE)) {
  2485. entity.setSumcode(String.valueOf(pairs.getValue()));
  2486. } else if (pairs.getKey().equals(entity.BAGCODE)) {
  2487. entity.setBagcode(String.valueOf(pairs.getValue()));
  2488. } else if (pairs.getKey().equals(entity.GAZARNER)) {
  2489. entity.setGazarner(String.valueOf(pairs.getValue()));
  2490. } else if (pairs.getKey().equals(entity.URTRAG)) {
  2491. entity.setUrtrag(String.valueOf(pairs.getValue()));
  2492. } else if (pairs.getKey().equals(entity.ORGOROG)) {
  2493. entity.setOrgorog(String.valueOf(pairs.getValue()));
  2494. } else if (pairs.getKey().equals(entity.GOLOMTTOO)) {
  2495. entity.setGolomttoo(stringToInteger(String.valueOf(pairs.getValue())));
  2496. } else if (pairs.getKey().equals(entity.OVCHIN_NER)) {
  2497. entity.setOvchin_ner(String.valueOf(pairs.getValue()));
  2498. } else if (pairs.getKey().equals(entity.MAL_TURUL)) {
  2499. entity.setMal_turul(String.valueOf(pairs.getValue()));
  2500. } else if (pairs.getKey().equals(entity.UVCHILSON)) {
  2501. entity.setUvchilson(stringToInteger(String.valueOf(pairs.getValue())));
  2502. } else if (pairs.getKey().equals(entity.UHSEN)) {
  2503. entity.setUhsen(stringToInteger(String.valueOf(pairs.getValue())));
  2504. } else if (pairs.getKey().equals(entity.EDGERSEN)) {
  2505. entity.setEdgersen(stringToInteger(String.valueOf(pairs.getValue())));
  2506. } else if (pairs.getKey().equals(entity.RECORD_DATE)) {
  2507. String dv = String.valueOf(pairs.getValue());
  2508. if (!dv.isEmpty() && dv.length() >= 8) {
  2509. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  2510. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  2511. entity.setRecordDate(sqlDate);
  2512. }
  2513. } else if (pairs.getKey().toString().equalsIgnoreCase("command")) {
  2514. command = String.valueOf(pairs.getValue());
  2515. }
  2516. } catch (NullPointerException ex) {
  2517. ex.printStackTrace();
  2518. } catch (Exception ex) {
  2519. ex.printStackTrace();
  2520. }
  2521. }//end while
  2522. if (command.equalsIgnoreCase("INS")) {
  2523. entity.setDelflg("N");
  2524. if (user != null && (user.getRoleCode().equalsIgnoreCase("SUPERADMIN")
  2525. || user.getRoleCode().equalsIgnoreCase("ADMIN"))) {
  2526. //Aimag songoh shaardlagagui
  2527. } else {
  2528. entity.setCitycode(user.getCity());
  2529. }
  2530. //entity.setSumcode(user.getSum());
  2531. entity.setCreby(user.getUsername());
  2532. Date utilDate = new Date();
  2533. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  2534. entity.setCreat(sqlDate);
  2535. if (entity.getRecordDate() == null) entity.setCreat(sqlDate);
  2536. errorEntity = service.insertNewData(entity);
  2537. // //Begin Check Role Step 2
  2538. // if (roleControl.checkRole(user, menuid, 2)){
  2539. //
  2540. // }else {
  2541. // errorEntity = new ErrorEntity(ErrorType.ERROR, Long.valueOf(1002)); // Ерөнхий алдаа : Эрх нь хүрэлцэхгүй үед өгөх
  2542. // }
  2543. // //End Check Role Step 2
  2544. } else if (command.equalsIgnoreCase("EDT") ||
  2545. command.equalsIgnoreCase("DEL") ||
  2546. command.equalsIgnoreCase("ACT")) {
  2547. int quality = 2;
  2548. if (command.equalsIgnoreCase("DEL")) {
  2549. entity.setDelflg("Y");
  2550. quality = 3;
  2551. }
  2552. errorEntity = service.updateData(entity);
  2553. // //Begin Check Role Step 2
  2554. // if (roleControl.checkRole(user, menuid, quality)){
  2555. // errorEntity = service.updateData(entity);
  2556. // }else {
  2557. // errorEntity = new ErrorEntity(ErrorType.ERROR, Long.valueOf(1002)); // Ерөнхий алдаа : Эрх нь хүрэлцэхгүй үед өгөх
  2558. // }
  2559. // //End Check Role Step 2
  2560. }
  2561. } catch (Exception ex) {
  2562. ex.printStackTrace();
  2563. } finally {
  2564. }
  2565. return errorEntity;
  2566. }//
  2567. //end-form09hav
  2568. @Override
  2569. public ErrorEntity writeFavoriteMenuLog(String sessionId, String menuid) throws Exception {
  2570. System.out.println("Hospital Service Implament ::: write favorite page");
  2571. try {
  2572. FavoritePageControl service = new FavoritePageControl(super.conn);
  2573. User user = sessionUser.get(sessionId);
  2574. menuid = menuid.replaceAll("#", "");
  2575. service.writeLog(user.getUsername(), menuid);
  2576. } catch (Exception ex) {
  2577. ex.printStackTrace();
  2578. } finally {
  2579. }
  2580. return errorEntity;
  2581. }
  2582. @Override
  2583. public List<FavoritePages> getFavoriteMenuList(String sessionId) throws Exception {
  2584. System.out.println("Hospital Service Implament ::: write favorite page");
  2585. try {
  2586. FavoritePageControl service = new FavoritePageControl(super.conn);
  2587. User user = sessionUser.get(sessionId);
  2588. FavoritePages favoritePages = new FavoritePages();
  2589. favoritePages.setCreate_by(user.getUsername());
  2590. return service.getFavoritePages(favoritePages);
  2591. } catch (Exception ex) {
  2592. ex.printStackTrace();
  2593. } finally {
  2594. }
  2595. return null;
  2596. }
  2597. @Override
  2598. public List<Form13aEntity> getForm13aData(LinkedTreeMap criteria, String sessionId, String menuid) throws Exception {
  2599. System.out.println("Hospital Service Implament ::: get form 08 havsralt data");
  2600. try {
  2601. IForm13aService service = new Form13aServiceImpl(super.conn);
  2602. User user = sessionUser.get(sessionId);
  2603. Form13aEntity entity = new Form13aEntity();
  2604. Iterator it = criteria.entrySet().iterator();
  2605. //Check Role
  2606. roleControl = new CheckUserRoleControl(super.conn);
  2607. if (roleControl == null) {
  2608. return null;
  2609. }
  2610. menuid = menuid.replaceAll("#", "");
  2611. if (!roleControl.checkRole(user, menuid, 1)) {
  2612. return null;
  2613. }
  2614. //End Check Role
  2615. while (it.hasNext()) {
  2616. Map.Entry pairs = (Map.Entry) it.next();
  2617. try {
  2618. if (!pairs.getValue().toString().isEmpty()) {
  2619. if (pairs.getKey().equals(entity.ID)) {
  2620. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  2621. entity.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  2622. } else if (pairs.getKey().equals(entity.CITYCODE)) {
  2623. entity.setCitycode(String.valueOf(pairs.getValue()));
  2624. } else if (pairs.getKey().equals(entity.SUMCODE)) {
  2625. entity.setSumcode(String.valueOf(pairs.getValue()));
  2626. } else if (pairs.getKey().equals(entity.BAG_CODE)) {
  2627. entity.setBag_code(String.valueOf(pairs.getValue()));
  2628. } else if (pairs.getKey().equals(entity.UZLEG_HIIH)) {
  2629. entity.setUzleg_hiih(String.valueOf(pairs.getValue()));
  2630. } else if (pairs.getKey().equals(entity.HEMJIH_NEGJ)) {
  2631. entity.setHemjih_negj(String.valueOf(pairs.getValue()));
  2632. } else if (pairs.getKey().equals(entity.TOO_HEMJEE)) {
  2633. entity.setToo_hemjee(String.valueOf(pairs.getValue()));
  2634. } else if (pairs.getKey().equals(entity.DEEJIIN_TOO)) {
  2635. entity.setDeejiin_too(String.valueOf(pairs.getValue()));
  2636. } else if (pairs.getKey().equals(entity.SHINJILGEE_HIISEN)) {
  2637. entity.setShinjilgee_hiisen(String.valueOf(pairs.getValue()));
  2638. } else if (pairs.getKey().equals(entity.SHINJILSEN_ARGA)) {
  2639. entity.setShinjilsen_arga(String.valueOf(pairs.getValue()));
  2640. } else if (pairs.getKey().equals(entity.HERGTSEEND_TOHIRSON)) {
  2641. entity.setHergtseend_tohirson(Double.parseDouble(String.valueOf(pairs.getValue())));
  2642. } else if (pairs.getKey().equals(entity.USTGASAN)) {
  2643. entity.setUstgasan(Double.parseDouble(String.valueOf(pairs.getValue())));
  2644. } else if (pairs.getKey().equals(entity.HALDBARGUIJUULELT)) {
  2645. entity.setHaldbarguijuulelt(Double.parseDouble(String.valueOf(pairs.getValue())));
  2646. } else if (pairs.getKey().equals(entity.BRUTSELLYOZ)) {
  2647. entity.setBrutsellyoz(String.valueOf(pairs.getValue()));
  2648. } else if (pairs.getKey().equals(entity.MASTIT)) {
  2649. entity.setMastit(String.valueOf(pairs.getValue()));
  2650. } else if (pairs.getKey().equals(entity.TRIXINELL)) {
  2651. entity.setTrixinell(String.valueOf(pairs.getValue()));
  2652. } else if (pairs.getKey().equals(entity.FINNOZ)) {
  2653. entity.setFinnoz(String.valueOf(pairs.getValue()));
  2654. } else if (pairs.getKey().equals(entity.SURIYEE)) {
  2655. entity.setSuriyee(String.valueOf(pairs.getValue()));
  2656. } else if (pairs.getKey().equals(entity.BOOM)) {
  2657. entity.setBoom(String.valueOf(pairs.getValue()));
  2658. } else if (pairs.getKey().equals(entity.BUSAD)) {
  2659. entity.setBusad(String.valueOf(pairs.getValue()));
  2660. } else if (pairs.getKey().equals(entity.BUGD)) {
  2661. entity.setBugd(String.valueOf(pairs.getValue()));
  2662. } else if (pairs.getKey().equals(entity.DEL_FLG)) {
  2663. entity.setDel_flg(String.valueOf(pairs.getValue()));
  2664. } else if (pairs.getKey().equals(entity.CRE_BY)) {
  2665. entity.setCre_by(String.valueOf(pairs.getValue()));
  2666. } else if (pairs.getKey().equals(entity.NO_DATA)) {
  2667. entity.setNo_data(String.valueOf(pairs.getValue()));
  2668. } else if (pairs.getKey().equals(entity.RECORD_DATE)) {
  2669. String dv = String.valueOf(pairs.getValue());
  2670. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  2671. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  2672. entity.setRecordDate(sqlDate);
  2673. } else if (pairs.getKey().equals(entity.SEARCH_RECORD_DATE)) {
  2674. String dv = String.valueOf(pairs.getValue());
  2675. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  2676. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  2677. entity.setSearchRecordDate(sqlDate);
  2678. }
  2679. }
  2680. } catch (NullPointerException ex) {
  2681. ex.printStackTrace();
  2682. } catch (Exception ex) {
  2683. ex.printStackTrace();
  2684. }
  2685. }//end while
  2686. Date utilDate = new Date();
  2687. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  2688. if (entity.getRecordDate() == null) entity.setRecordDate(sqlDate);
  2689. if (entity.getSearchRecordDate() == null) entity.setSearchRecordDate(sqlDate);
  2690. if (user.getRoleCode() != null && !user.getRoleCode().equalsIgnoreCase("SUPERADMIN")
  2691. && !user.getRoleCode().equalsIgnoreCase("ADMIN")) {
  2692. entity.setCre_by(user.getUsername());
  2693. }
  2694. if (entity != null && entity.getRecordDate() != null && entity.getSearchRecordDate() != null) {
  2695. return service.getListData(entity);
  2696. }
  2697. } catch (Exception ex) {
  2698. ex.printStackTrace();
  2699. } finally {
  2700. }
  2701. return null;
  2702. }
  2703. @Override
  2704. public ErrorEntity setForm13aData(LinkedTreeMap criteria, String sessionId, String menuid) throws Exception {
  2705. System.out.println("Hospital Service Implament ::: setForm13aData havsralt data");
  2706. try {
  2707. String command = "EDT";
  2708. IForm13aService service = new Form13aServiceImpl(super.conn);
  2709. User user = sessionUser.get(sessionId);
  2710. Form13aEntity entity = new Form13aEntity();
  2711. //Begin Check Role Step 1
  2712. roleControl = new CheckUserRoleControl(super.conn);
  2713. if (roleControl == null) {
  2714. errorEntity = new ErrorEntity(ErrorType.ERROR, Long.valueOf(1002)); // Ерөнхий алдаа : Эрх нь хүрэлцэхгүй үед өгөх
  2715. return errorEntity;
  2716. }
  2717. //End Check Role Step 1
  2718. menuid = menuid.replaceAll("#", "");
  2719. Iterator it = criteria.entrySet().iterator();
  2720. while (it.hasNext()) {
  2721. Map.Entry pairs = (Map.Entry) it.next();
  2722. try {
  2723. if (pairs.getKey().equals(entity.ID)) {
  2724. String tmpId = "";
  2725. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty()) {
  2726. if (pairs.getValue().toString().contains(".")) {
  2727. tmpId = pairs.getValue().toString().substring(0, pairs.getValue().toString().indexOf("."));
  2728. }
  2729. entity.setId(Long.parseLong(String.valueOf(tmpId)));
  2730. }
  2731. } else if (pairs.getKey().equals(entity.CITYCODE)) {
  2732. entity.setCitycode(String.valueOf(pairs.getValue()));
  2733. } else if (pairs.getKey().equals(entity.SUMCODE)) {
  2734. entity.setSumcode(String.valueOf(pairs.getValue()));
  2735. } else if (pairs.getKey().equals(entity.BAG_CODE)) {
  2736. entity.setBag_code(String.valueOf(pairs.getValue()));
  2737. } else if (pairs.getKey().equals(entity.UZLEG_HIIH)) {
  2738. entity.setUzleg_hiih(String.valueOf(pairs.getValue()));
  2739. } else if (pairs.getKey().equals(entity.HEMJIH_NEGJ)) {
  2740. entity.setHemjih_negj(String.valueOf(pairs.getValue()));
  2741. } else if (pairs.getKey().equals(entity.TOO_HEMJEE)) {
  2742. entity.setToo_hemjee(String.valueOf(pairs.getValue()));
  2743. } else if (pairs.getKey().equals(entity.DEEJIIN_TOO)) {
  2744. entity.setDeejiin_too(String.valueOf(pairs.getValue()));
  2745. } else if (pairs.getKey().equals(entity.SHINJILGEE_HIISEN)) {
  2746. entity.setShinjilgee_hiisen(String.valueOf(pairs.getValue()));
  2747. } else if (pairs.getKey().equals(entity.SHINJILSEN_ARGA)) {
  2748. entity.setShinjilsen_arga(String.valueOf(pairs.getValue()));
  2749. } else if (pairs.getKey().equals(entity.HERGTSEEND_TOHIRSON)) {
  2750. try {
  2751. entity.setHergtseend_tohirson(Double.valueOf(Double.parseDouble(pairs.getValue().toString())));
  2752. } catch (NumberFormatException e) {
  2753. entity.setHergtseend_tohirson(Double.valueOf(Long.parseLong("0")));
  2754. }
  2755. } else if (pairs.getKey().equals(entity.USTGASAN)) {
  2756. try {
  2757. entity.setUstgasan(Double.valueOf(Double.parseDouble(pairs.getValue().toString())));
  2758. } catch (NumberFormatException e) {
  2759. entity.setUstgasan(Double.valueOf(Long.parseLong("0")));
  2760. }
  2761. } else if (pairs.getKey().equals(entity.HALDBARGUIJUULELT)) {
  2762. try {
  2763. entity.setHaldbarguijuulelt(Double.valueOf(Double.parseDouble(pairs.getValue().toString())));
  2764. } catch (NumberFormatException e) {
  2765. entity.setHaldbarguijuulelt(Double.valueOf(Long.parseLong("0")));
  2766. }
  2767. } else if (pairs.getKey().equals(entity.BRUTSELLYOZ)) {
  2768. entity.setBrutsellyoz(String.valueOf(pairs.getValue()));
  2769. } else if (pairs.getKey().equals(entity.MASTIT)) {
  2770. entity.setMastit(String.valueOf(pairs.getValue()));
  2771. } else if (pairs.getKey().equals(entity.TRIXINELL)) {
  2772. entity.setTrixinell(String.valueOf(pairs.getValue()));
  2773. } else if (pairs.getKey().equals(entity.FINNOZ)) {
  2774. entity.setFinnoz(String.valueOf(pairs.getValue()));
  2775. } else if (pairs.getKey().equals(entity.SURIYEE)) {
  2776. entity.setSuriyee(String.valueOf(pairs.getValue()));
  2777. } else if (pairs.getKey().equals(entity.BOOM)) {
  2778. entity.setBoom(String.valueOf(pairs.getValue()));
  2779. } else if (pairs.getKey().equals(entity.BUSAD)) {
  2780. entity.setBusad(String.valueOf(pairs.getValue()));
  2781. } else if (pairs.getKey().equals(entity.BUGD)) {
  2782. entity.setBugd(String.valueOf(pairs.getValue()));
  2783. } else if (pairs.getKey().equals(entity.DEL_FLG)) {
  2784. entity.setDel_flg(String.valueOf(pairs.getValue()));
  2785. } else if (pairs.getKey().equals(entity.CRE_BY)) {
  2786. entity.setCre_by(String.valueOf(pairs.getValue()));
  2787. } else if (pairs.getKey().equals(entity.NO_DATA)) {
  2788. entity.setNo_data(String.valueOf(pairs.getValue()));
  2789. } else if (pairs.getKey().equals(entity.RECORD_DATE)) {
  2790. String dv = String.valueOf(pairs.getValue());
  2791. if (!dv.isEmpty() && dv.length() >= 8) {
  2792. if (String.valueOf(pairs.getValue()).length() <= 10) dv += " 00:00:00";
  2793. java.sql.Date sqlDate = new java.sql.Date(dateFormat.parse(dv).getTime());
  2794. entity.setRecordDate(sqlDate);
  2795. }
  2796. } else if (pairs.getKey().toString().equalsIgnoreCase("command")) {
  2797. command = String.valueOf(pairs.getValue());
  2798. }
  2799. } catch (NullPointerException ex) {
  2800. ex.printStackTrace();
  2801. } catch (Exception ex) {
  2802. ex.printStackTrace();
  2803. }
  2804. }//end while
  2805. Date utilDate = new Date();
  2806. java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
  2807. entity.setMod_at(sqlDate);
  2808. entity.setMod_by(user.getUsername());
  2809. if (command.equalsIgnoreCase("INS")) {
  2810. entity.setDel_flg("N");
  2811. entity.setCitycode(user.getCity());
  2812. entity.setSumcode(user.getSum());
  2813. entity.setCre_by(user.getUsername());
  2814. entity.setCre_at(sqlDate);
  2815. if (entity.getRecordDate() == null) entity.setRecordDate(sqlDate);
  2816. //Begin Check Role Step 2
  2817. if (roleControl.checkRole(user, menuid, 2)) {
  2818. errorEntity = service.insertNewData(entity);
  2819. } else {
  2820. errorEntity = new ErrorEntity(ErrorType.ERROR, Long.valueOf(1002)); // Ерөнхий алдаа : Эрх нь хүрэлцэхгүй үед өгөх
  2821. }
  2822. //End Check Role Step 2
  2823. } else if (command.equalsIgnoreCase("EDT") ||
  2824. command.equalsIgnoreCase("DEL") ||
  2825. command.equalsIgnoreCase("ACT")) {
  2826. int quality = 2;
  2827. if (command.equalsIgnoreCase("DEL")) {
  2828. entity.setDel_flg("Y");
  2829. quality = 3;
  2830. }
  2831. //Begin Check Role Step 2
  2832. if (roleControl.checkRole(user, menuid, quality)) {
  2833. errorEntity = service.updateData(entity);
  2834. } else {
  2835. errorEntity = new ErrorEntity(ErrorType.ERROR, Long.valueOf(1002)); // Ерөнхий алдаа : Эрх нь хүрэлцэхгүй үед өгөх
  2836. }
  2837. //End Check Role Step 2
  2838. }
  2839. } catch (Exception ex) {
  2840. ex.printStackTrace();
  2841. } finally {
  2842. }
  2843. return errorEntity;
  2844. }
  2845. @Override
  2846. public List<User> getAllUserList(LinkedTreeMap credata, String sessionId) throws Exception {
  2847. System.out.println("Hospital Service ::: get all user list");
  2848. try {
  2849. IUserService userService = new UserServiceImpl(super.conn);
  2850. User user = sessionUser.get(sessionId);
  2851. User seluser = new User();
  2852. Iterator it = credata.entrySet().iterator();
  2853. while (it.hasNext()) {
  2854. Map.Entry pairs = (Map.Entry) it.next();
  2855. try {
  2856. if (pairs.getKey().equals(seluser.ID)) {
  2857. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  2858. seluser.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  2859. } else if (pairs.getKey().equals(seluser.USERNAME)) {
  2860. seluser.setUsername(String.valueOf(pairs.getValue()));
  2861. } else if (pairs.getKey().equals(seluser.ROLECODE)) {
  2862. seluser.setRoleCode(String.valueOf(pairs.getValue()));
  2863. } else if (pairs.getKey().equals(seluser.FIRSTNAME)) {
  2864. seluser.setFirstName(String.valueOf(pairs.getValue()));
  2865. } else if (pairs.getKey().equals(seluser.LASTNAME)) {
  2866. seluser.setLastName(String.valueOf(pairs.getValue()));
  2867. } else if (pairs.getKey().equals(seluser.GENDER)) {
  2868. seluser.setGender(String.valueOf(pairs.getValue()));
  2869. } else if (pairs.getKey().equals(seluser.REGID)) {
  2870. seluser.setRegId(String.valueOf(pairs.getValue()));
  2871. } else if (pairs.getKey().equals(seluser.CITY)) {
  2872. seluser.setCity(String.valueOf(pairs.getValue()));
  2873. } else if (pairs.getKey().equals(seluser.SUM)) {
  2874. seluser.setSum(String.valueOf(pairs.getValue()));
  2875. } else if (pairs.getKey().equals(seluser.CREBY)) {
  2876. seluser.setCreBy(String.valueOf(pairs.getValue()));
  2877. } else if (pairs.getKey().equals(seluser.MODBY)) {
  2878. seluser.setModBy(String.valueOf(pairs.getValue()));
  2879. } else if (pairs.getKey().equals(seluser.DELFLG)) {
  2880. seluser.setDelFlg(String.valueOf(pairs.getValue()));
  2881. } else if (pairs.getKey().equals(seluser.ACTFLG)) {
  2882. seluser.setActFlg(String.valueOf(pairs.getValue()));
  2883. }
  2884. } catch (NullPointerException ex) {
  2885. ex.printStackTrace();
  2886. } catch (Exception ex) {
  2887. ex.printStackTrace();
  2888. }
  2889. }//end while
  2890. seluser.setDelFlg("N");
  2891. List<User> arrUserList = new ArrayList<>();
  2892. List<User> listUser = userService.getUserList(seluser);
  2893. if (listUser != null) {
  2894. for (User us : listUser) {
  2895. boolean isme = false;
  2896. User tmp = new User();
  2897. tmp.put("status", "offline");
  2898. tmp.setChatId(us.getChatId());
  2899. tmp.setUsername(us.getUsername());
  2900. tmp.setFirstName(us.getFirstName());
  2901. tmp.setLastName(us.getLastName());
  2902. tmp.setCityName(us.getCityName());
  2903. tmp.setCityNameEn(us.getCityNameEn());
  2904. tmp.setSumName(us.getSumName());
  2905. tmp.setSumNameEn(us.getSumNameEn());
  2906. for (Map.Entry<String, User> entry : sessionUser.entrySet()) {
  2907. String key = entry.getKey();
  2908. User su = entry.getValue();
  2909. if (su.getUsername().equalsIgnoreCase(tmp.getUsername())) {
  2910. if (key.equalsIgnoreCase(sessionId)) {
  2911. isme = true;
  2912. }
  2913. tmp.put("status", "online");
  2914. }
  2915. }//end of for
  2916. if (isme) continue;
  2917. arrUserList.add(tmp);
  2918. }
  2919. }
  2920. return arrUserList;
  2921. } catch (Exception ex) {
  2922. ex.printStackTrace();
  2923. } finally {
  2924. }
  2925. return null;
  2926. }
  2927. /*
  2928. *
  2929. * CHART
  2930. * */
  2931. public List<BasicDBObject> getForm08HavsraltPieChartData(LinkedTreeMap criteria, String sessionId, String menuid) throws Exception {
  2932. System.out.println("Hospital Service Implament ::: get form 08 havsralt data");
  2933. try {
  2934. IForm08HavsraltService service = new Form08HavsraltServiceImpl(super.conn);
  2935. User user = sessionUser.get(sessionId);
  2936. Form08HavsraltEntity entity = new Form08HavsraltEntity();
  2937. Iterator it = criteria.entrySet().iterator();
  2938. while (it.hasNext()) {
  2939. Map.Entry pairs = (Map.Entry) it.next();
  2940. try {
  2941. if (!pairs.getValue().toString().isEmpty()) {
  2942. if (pairs.getKey().equals(entity.ID)) {
  2943. if (pairs.getValue() != null && !pairs.getValue().toString().isEmpty())
  2944. entity.setId(Long.parseLong(String.valueOf(pairs.getValue())));
  2945. } else if (pairs.getKey().equals(entity.CITYCODE)) {
  2946. entity.setCitycode(String.valueOf(pairs.getValue()));
  2947. } else if (pairs.getKey().equals(entity.SUMCODE)) {
  2948. entity.setSumcode(String.valueOf(pairs.getValue()));
  2949. } else if (pairs.getKey().equals(entity.BAGCODE)) {
  2950. entity.setBagcode(String.valueOf(pairs.getValue()));
  2951. } else if (pairs.getKey().equals(entity.GAZARNER)) {
  2952. entity.setGazarner(String.valueOf(pairs.getValue()));
  2953. } else if (pairs.getKey().equals(entity.URTRAG)) {
  2954. entity.setUrtrag(String.valueOf(pairs.getValue()));
  2955. } else if (pairs.getKey().equals(entity.ORGOROG)) {
  2956. entity.setOrgorog(String.valueOf(pairs.getValue()));
  2957. } else if (pairs.getKey().equals(entity.GOLOMTTOO)) {
  2958. entity.setGolomttoo(Integer.parseInt(String.valueOf(pairs.getValue())));
  2959. } else if (pairs.getKey().equals(entity.OVCHIN_NER)) {
  2960. entity.setOvchin_ner(String.valueOf(pairs.getValue()));
  2961. } else if (pairs.getKey().equals(entity.MAL_TURUL)) {
  2962. entity.setMal_turul(String.valueOf(pairs.getValue()));
  2963. } else if (pairs.getKey().equals(entity.UVCHILSON)) {
  2964. enti