SignPatientLabelInfoService.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. package com.yihu.wlyy.service.app.label;
  2. import com.yihu.wlyy.entity.doctor.profile.Doctor;
  3. import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroupInfo;
  4. import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
  5. import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
  6. import com.yihu.wlyy.entity.patient.Patient;
  7. import com.yihu.wlyy.entity.patient.PatientDisease;
  8. import com.yihu.wlyy.entity.patient.SignFamily;
  9. import com.yihu.wlyy.repository.doctor.DoctorDao;
  10. import com.yihu.wlyy.repository.doctor.DoctorPatientGroupInfoDao;
  11. import com.yihu.wlyy.repository.doctor.SignPatientLabelInfoDao;
  12. import com.yihu.wlyy.repository.patient.PatientDao;
  13. import com.yihu.wlyy.repository.patient.PatientDiseaseDao;
  14. import com.yihu.wlyy.repository.patient.SignFamilyDao;
  15. import com.yihu.wlyy.service.BaseService;
  16. import com.yihu.wlyy.util.DateUtil;
  17. import com.yihu.wlyy.util.IdCardUtil;
  18. import org.apache.commons.lang3.StringUtils;
  19. import org.json.JSONArray;
  20. import org.json.JSONObject;
  21. import org.springframework.beans.factory.annotation.Autowired;
  22. import org.springframework.jdbc.core.JdbcTemplate;
  23. import org.springframework.stereotype.Service;
  24. import org.springframework.transaction.annotation.Transactional;
  25. import java.util.*;
  26. /**
  27. * 患者标签信息服务
  28. * <p>
  29. * Created by lyr on 2016/10/9.
  30. */
  31. @Service
  32. @Transactional
  33. public class SignPatientLabelInfoService extends BaseService {
  34. @Autowired
  35. SignPatientLabelService labelService;
  36. @Autowired
  37. DoctorDao doctorDao;
  38. @Autowired
  39. PatientDao patientDao;
  40. @Autowired
  41. SignPatientLabelInfoDao labelInfoDao;
  42. @Autowired
  43. PatientDiseaseDao diseaseDao;
  44. @Autowired
  45. DoctorPatientGroupInfoDao groupInfoDao;
  46. @Autowired
  47. JdbcTemplate jdbcTemplate;
  48. @Autowired
  49. SignFamilyDao signFamilyDao;
  50. /**
  51. * 根据标签查询患者信息
  52. *
  53. * @param labelCode 标签code
  54. * @param labelType 标签类型
  55. * @param page 第几页
  56. * @param pagesize 页大小
  57. * @return
  58. */
  59. public JSONArray getPatientByLabel(String doctor, String labelCode, String labelType, Long teamCode, int page, int pagesize) throws Exception {
  60. Doctor doc = doctorDao.findByCode(doctor);
  61. if (doc == null) {
  62. throw new Exception("doctor info can not find");
  63. }
  64. Map<String, JSONObject> result = new HashMap<>();
  65. List<Map<String, Object>> signList = new ArrayList<>();
  66. int start = page * pagesize;
  67. String sql = "";
  68. Object[] args = null;
  69. if (labelCode.equals("0")) {
  70. sql = "select a.*" +
  71. " from" +
  72. " (select * from wlyy_sign_family where " + (doc.getLevel() == 2 ? " doctor" : "doctor_health") + " = ? and status > 0 and admin_team_code = ?) a" +
  73. " left join" +
  74. " (select * from wlyy_sign_patient_label_info where label_type = ? and status = 1) b" +
  75. " on a.patient = b.patient where b.patient is null limit " + start + "," + pagesize;
  76. args = new Object[]{doctor, teamCode, labelType};
  77. } else {
  78. sql = "select a.*" +
  79. " from" +
  80. " (select * from wlyy_sign_family where " + (doc.getLevel() == 2 ? " doctor" : "doctor_health") + " = ? and status > 0 and admin_team_code = ?) a" +
  81. " join" +
  82. " (select * from wlyy_sign_patient_label_info where label = ? and label_type = ? and status = 1) b" +
  83. " on a.patient = b.patient limit " + start + "," + pagesize;
  84. args = new Object[]{doctor, teamCode, labelCode, labelType};
  85. }
  86. signList = jdbcTemplate.queryForList(sql, args);
  87. if (signList != null && signList.size() > 0) {
  88. for (Map<String, Object> sign : signList) {
  89. Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
  90. if (p == null) {
  91. continue;
  92. }
  93. if (result.containsKey(p.getCode())) {
  94. JSONObject jsonP = result.get(p.getCode());
  95. if (!String.valueOf(jsonP.get("signType")).equals(String.valueOf(sign.get("type")))) {
  96. jsonP.put("signType", 3);
  97. }
  98. continue;
  99. }
  100. //List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(sign.get("patient").toString(), 1);
  101. JSONObject json = new JSONObject();
  102. // 设置患者标识
  103. json.put("code", p.getCode());
  104. // 设置患者姓名
  105. json.put("name", p.getName());
  106. // 设置患者头像
  107. json.put("photo", p.getPhoto());
  108. // 设置患者年龄
  109. json.put("age", DateUtil.getAgeByBirthday(p.getBirthday()));
  110. // 设置患者性别
  111. json.put("sex", p.getSex());
  112. // 设置签约日期
  113. json.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
  114. // 设置签约类型
  115. json.put("signType", sign.get("type") == null ? "" : sign.get("type"));
  116. // 身份证号
  117. json.put("idcard", p.getIdcard());
  118. // 患者标签
  119. //json.put("labels", labels == null ? "" : labels);
  120. result.put(p.getCode(), json);
  121. }
  122. }
  123. return result.size() > 0 ? new JSONArray(result.values()) : new JSONArray();
  124. }
  125. /**
  126. * 查询某个标签类型的所有标签居民数统计
  127. *
  128. * @param labelType 标签类型
  129. * @param teamCode 标签类型为4时,不能为空
  130. * @return
  131. */
  132. public JSONArray getPatientAmountByLabelType(String doctor, String labelType, Long teamCode) throws Exception {
  133. Doctor doc = doctorDao.findByCode(doctor);
  134. if (doc == null) {
  135. throw new Exception("doctor info can not find");
  136. }
  137. List<SignPatientLabel> labels = labelService.getLabelsByTypeAndTeam(labelType, teamCode);
  138. JSONArray result = new JSONArray();
  139. SignPatientLabel labelNo = new SignPatientLabel();
  140. labelNo.setLabelCode("0");
  141. labelNo.setLabelName("未分组");
  142. labelNo.setStatus(1);
  143. labelNo.setIsSystem(1);
  144. labelNo.setLabelType(labelType);
  145. labelNo.setSort(999999999);
  146. labels.add(labelNo);
  147. if (labels != null) {
  148. for (SignPatientLabel label : labels) {
  149. JSONObject json = new JSONObject();
  150. json.put("labelCode", label.getLabelCode());
  151. json.put("labelName", label.getLabelName());
  152. json.put("isSystem", label.getIsSystem());
  153. int amount = 0;
  154. String sql = "";
  155. Object[] args = null;
  156. if (label.getLabelCode().equals("0")) {
  157. sql = "select count(DISTINCT a.patient) count" +
  158. " from" +
  159. " (select * from wlyy_sign_family where " + (doc.getLevel() == 2 ? " doctor" : "doctor_health") + " = ? and status > 0 " +
  160. (teamCode > 0 ? "and admin_team_code = ?" : "") + ") a " +
  161. " left join" +
  162. " (select * from wlyy_sign_patient_label_info where label_type = ? and status = 1) b" +
  163. " on a.patient = b.patient where b.patient is null ";
  164. if (teamCode > 0) {
  165. args = new Object[]{doctor, teamCode, labelType};
  166. } else {
  167. args = new Object[]{doctor, labelType};
  168. }
  169. } else {
  170. sql = "select count(DISTINCT a.patient) count" +
  171. " from" +
  172. " (select * from wlyy_sign_family where " + (doc.getLevel() == 2 ? " doctor" : "doctor_health") + " = ? and status > 0 " +
  173. (teamCode > 0 ? "and admin_team_code = ?" : "") + ") a " +
  174. " join" +
  175. " (select * from wlyy_sign_patient_label_info where label = ? and label_type = ? and status = 1) b" +
  176. " on a.patient = b.patient ";
  177. if (teamCode > 0) {
  178. args = new Object[]{doctor, teamCode, label.getLabelCode(), labelType};
  179. } else {
  180. args = new Object[]{doctor, label.getLabelCode(), labelType};
  181. }
  182. }
  183. Map<String, Object> count = jdbcTemplate.queryForMap(sql, args);
  184. if (count != null && count.containsKey("count")) {
  185. amount = Integer.valueOf(String.valueOf(count.get("count")));
  186. }
  187. json.put("amount", amount);
  188. result.put(json);
  189. }
  190. }
  191. return result;
  192. }
  193. /**
  194. * 设置患者标签
  195. *
  196. * @param patient 患者名称
  197. * @param idcard 身份证号
  198. * @param patientName 患者姓名
  199. * @param health 健康情况标签
  200. * @param disease 疾病类型标签
  201. * @param custom 自定义标签
  202. * @return
  203. */
  204. public int setPatientLabels(String patient, String idcard, String patientName, String health, String disease, String custom) {
  205. Patient p = patientDao.findByCode(patient);
  206. if (p == null && (StringUtils.isEmpty(idcard) || StringUtils.isEmpty(patientName))) {
  207. return 0;
  208. } else {
  209. idcard = p.getIdcard();
  210. patientName = p.getName();
  211. }
  212. String[] diseaseArr = disease.split(",");
  213. String[] customArr = custom.split(",");
  214. // 健康情况标签
  215. int healthAmount = labelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient, "2", 1);
  216. if (StringUtils.isNotEmpty(health)) {
  217. SignPatientLabelInfo healthLabel = new SignPatientLabelInfo();
  218. SignPatientLabel label = labelService.getLabelByCodeAndType(health, "2");
  219. if (label == null) {
  220. return -1;
  221. }
  222. healthLabel.setPatient(patient);
  223. healthLabel.setPname(patientName);
  224. healthLabel.setLabelType("2");
  225. healthLabel.setLabel(health);
  226. healthLabel.setLabelName(label.getLabelName());
  227. healthLabel.setStatus(1);
  228. healthLabel.setCzrq(new Date());
  229. labelInfoDao.save(healthLabel);
  230. } else {
  231. return -2;
  232. }
  233. // 疾病类型标签
  234. int disAmount = labelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient, "3", 1);
  235. if (diseaseArr != null && diseaseArr.length > 0) {
  236. for (String diseaseLabel : diseaseArr) {
  237. if (StringUtils.isEmpty(diseaseLabel)) {
  238. continue;
  239. }
  240. SignPatientLabelInfo disLabel = new SignPatientLabelInfo();
  241. SignPatientLabel label = labelService.getLabelByCodeAndType(diseaseLabel, "3");
  242. if (label == null) {
  243. return -1;
  244. }
  245. disLabel.setPatient(patient);
  246. disLabel.setPname(patientName);
  247. disLabel.setLabelType("3");
  248. disLabel.setLabel(diseaseLabel);
  249. disLabel.setLabelName(label.getLabelName());
  250. disLabel.setStatus(1);
  251. disLabel.setCzrq(new Date());
  252. labelInfoDao.save(disLabel);
  253. }
  254. }
  255. // 自定义标签
  256. int cusAmount = labelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient, "4", 1);
  257. if (customArr != null && customArr.length > 0) {
  258. for (String customLabel : customArr) {
  259. if (StringUtils.isEmpty(customLabel)) {
  260. continue;
  261. }
  262. SignPatientLabelInfo cusLabel = new SignPatientLabelInfo();
  263. SignPatientLabel label = labelService.getLabelByCodeAndType(customLabel, "4");
  264. if (label == null) {
  265. return -1;
  266. }
  267. cusLabel.setPatient(patient);
  268. cusLabel.setPname(patientName);
  269. cusLabel.setLabelType("4");
  270. cusLabel.setLabel(customLabel);
  271. cusLabel.setLabelName(label.getLabelName());
  272. cusLabel.setStatus(1);
  273. cusLabel.setCzrq(new Date());
  274. labelInfoDao.save(cusLabel);
  275. }
  276. }
  277. // 卫计委三大分组
  278. int wjwAmount = labelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient, "1", 1);
  279. if (diseaseArr != null && diseaseArr.length > 0 && (Arrays.asList(diseaseArr).contains("1")
  280. || Arrays.asList(diseaseArr).contains("2"))) {
  281. SignPatientLabelInfo disLabel = new SignPatientLabelInfo();
  282. disLabel.setPatient(patient);
  283. disLabel.setPname(patientName);
  284. disLabel.setLabelType("1");
  285. disLabel.setLabel("2");
  286. disLabel.setLabelName("慢病人群");
  287. disLabel.setStatus(1);
  288. disLabel.setCzrq(new Date());
  289. labelInfoDao.save(disLabel);
  290. } else {
  291. int age = IdCardUtil.getAgeForIdcard(idcard);
  292. SignPatientLabelInfo disLabel = new SignPatientLabelInfo();
  293. disLabel.setPatient(patient);
  294. disLabel.setPname(patientName);
  295. disLabel.setLabelType("1");
  296. disLabel.setStatus(1);
  297. disLabel.setCzrq(new Date());
  298. if (age >= 65) {
  299. disLabel.setLabel("3");
  300. disLabel.setLabelName("65岁以上人群");
  301. } else {
  302. disLabel.setLabel("1");
  303. disLabel.setLabelName("普通人群");
  304. }
  305. labelInfoDao.save(disLabel);
  306. }
  307. return 1;
  308. }
  309. /**
  310. * 查询某个患者的某个类型的标签
  311. *
  312. * @param patient 患者code
  313. * @param labelType 标签类型
  314. * @return
  315. */
  316. public List<SignPatientLabelInfo> getPatientLabelByLabelType(String patient, String labelType) {
  317. List<SignPatientLabelInfo> labels = new ArrayList<>();
  318. if (StringUtils.isEmpty(labelType)) {
  319. labels = labelInfoDao.findByPatientAndStatus(patient, 1);
  320. } else {
  321. labels = labelInfoDao.findByPatientAndLabelTypeAndStatus(patient, labelType, 1);
  322. }
  323. return labels;
  324. }
  325. /**
  326. * 根据患者姓名或标签名称查询
  327. *
  328. * @param doctor
  329. * @param filter
  330. * @return
  331. * @throws Exception
  332. */
  333. public JSONArray searchPatientByNameOrLabel(String doctor, String filter, String labelCode, String labelType) throws Exception {
  334. Doctor doc = doctorDao.findByCode(doctor);
  335. if (doc == null) {
  336. throw new Exception("doctor info can not find");
  337. }
  338. Map<String, JSONObject> result = new HashMap<>();
  339. List<Map<String, Object>> signList = new ArrayList<>();
  340. Object[] args = null;
  341. String sql = "select a.*" +
  342. " from" +
  343. " (select * from wlyy_sign_family where " + (doc.getLevel() == 2 ? " doctor" : "doctor_health") + " = ? and status > 0) a" +
  344. " left join" +
  345. " (select * from wlyy_sign_patient_label_info where status = 1 " +
  346. (StringUtils.isNotEmpty(labelCode) ? " and label = ? " : "") +
  347. (StringUtils.isNotEmpty(labelType) ? " and label_type = ? " : "") + ") b" +
  348. " on a.patient = b.patient where a.name like ? or b.label_name like ?";
  349. if (StringUtils.isNotEmpty(labelCode)) {
  350. args = new Object[]{doctor, labelCode, labelType, "%" + filter + "%", "%" + filter + "%"};
  351. } else if (StringUtils.isEmpty(labelCode) && StringUtils.isNotEmpty(labelType)) {
  352. args = new Object[]{doctor, labelType, "%" + filter + "%", "%" + filter + "%"};
  353. } else {
  354. args = new Object[]{doctor, "%" + filter + "%", "%" + filter + "%"};
  355. }
  356. signList = jdbcTemplate.queryForList(sql, args);
  357. if (signList != null && signList.size() > 0) {
  358. for (Map<String, Object> sign : signList) {
  359. Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
  360. if (p == null) {
  361. continue;
  362. }
  363. if (result.containsKey(p.getCode())) {
  364. JSONObject jsonP = result.get(p.getCode());
  365. if (!String.valueOf(jsonP.get("signType")).equals(String.valueOf(sign.get("type")))) {
  366. jsonP.put("signType", 3);
  367. }
  368. continue;
  369. }
  370. List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(sign.get("patient").toString(), 1);
  371. JSONObject json = new JSONObject();
  372. // 设置患者标识
  373. json.put("code", p.getCode());
  374. // 设置患者姓名
  375. json.put("name", p.getName());
  376. // 设置患者头像
  377. json.put("photo", p.getPhoto());
  378. // 设置患者年龄
  379. json.put("age", DateUtil.getAgeByBirthday(p.getBirthday()));
  380. // 设置患者性别
  381. json.put("sex", p.getSex());
  382. // 设置签约日期
  383. json.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
  384. // 设置签约类型
  385. json.put("signType", sign.get("type") == null ? "" : sign.get("type"));
  386. // 身份证号
  387. json.put("idcard", p.getIdcard());
  388. // 患者标签
  389. json.put("labels", labels == null ? "" : labels);
  390. result.put(p.getCode(), json);
  391. }
  392. }
  393. return result.size() > 0 ? new JSONArray(result.values()) : new JSONArray();
  394. }
  395. /**
  396. * 添加居民到某个标签
  397. *
  398. * @param patient 患者
  399. * @param labelCode 标签code
  400. * @param labelType 标签类型
  401. * @return
  402. */
  403. public int addPatientLabel(String patient, String labelCode, String labelType) {
  404. Patient p = patientDao.findByCode(patient);
  405. if (p == null) {
  406. return -1;
  407. }
  408. SignPatientLabelInfo labelInfo = labelInfoDao.findByPatientAndLabelAndLabelTypeAndStatus(patient, labelCode, labelType, 1);
  409. if (labelInfo != null) {
  410. return -2;
  411. }
  412. SignPatientLabel label = labelService.getLabelByCodeAndType(labelCode, labelType);
  413. if (label == null) {
  414. return -3;
  415. }
  416. labelInfo = new SignPatientLabelInfo();
  417. labelInfo.setPatient(patient);
  418. labelInfo.setPname(p.getName());
  419. labelInfo.setLabel(labelCode);
  420. labelInfo.setLabelType(labelType);
  421. labelInfo.setLabelName(label.getLabelName());
  422. labelInfo.setStatus(1);
  423. labelInfo.setCzrq(new Date());
  424. labelInfoDao.save(labelInfo);
  425. return 1;
  426. }
  427. /**
  428. * 删除居民的某个标签
  429. *
  430. * @param patient 患者
  431. * @param labelCode 标签code
  432. * @param labelType 标签类型
  433. * @return
  434. */
  435. public int deletePatientLabel(String patient, String labelCode, String labelType) {
  436. SignPatientLabelInfo labelInfo = labelInfoDao.findByPatientAndLabelAndLabelTypeAndStatus(patient, labelCode, labelType, 1);
  437. if (labelInfo == null) {
  438. return -1;
  439. }
  440. labelInfoDao.delete(labelInfo);
  441. return 1;
  442. }
  443. /**
  444. * 疾病转标签
  445. *
  446. * @return
  447. */
  448. public boolean diseaseToLabel() {
  449. List<PatientDisease> diseases = diseaseDao.findByDel("1");
  450. Iterator<Patient> patients = patientDao.findAll().iterator();
  451. Map<String, String> patientNames = new HashMap<>();
  452. while (patients.hasNext()) {
  453. Patient p = patients.next();
  454. patientNames.put(p.getCode(), p.getName());
  455. }
  456. for (PatientDisease disease : diseases) {
  457. SignPatientLabelInfo labelInfo = new SignPatientLabelInfo();
  458. labelInfo.setPatient(disease.getPatient());
  459. labelInfo.setPname(patientNames.get(disease.getPatient()));
  460. labelInfo.setLabel(disease.getDisease());
  461. labelInfo.setLabelName(disease.getDiseaseName());
  462. labelInfo.setLabelType("3");
  463. labelInfo.setStatus(1);
  464. labelInfo.setCzrq(new Date());
  465. labelInfoDao.save(labelInfo);
  466. }
  467. return true;
  468. }
  469. /**
  470. * 分组转标签
  471. *
  472. * @return
  473. */
  474. public boolean groupToLabel() throws Exception {
  475. Iterator<Patient> patients = patientDao.findAll().iterator();
  476. Map<String, Patient> patientNames = new HashMap<>();
  477. Map<String, SignPatientLabelInfo> normalLabel = new HashMap<>();
  478. Map<String, SignPatientLabelInfo> manbingLabel = new HashMap<>();
  479. Map<String, SignPatientLabelInfo> sixFiveLabel = new HashMap<>();
  480. while (patients.hasNext()) {
  481. Patient p = patients.next();
  482. patientNames.put(p.getCode(), p);
  483. }
  484. List<DoctorPatientGroupInfo> groupInfos = groupInfoDao.findByGroupAndStatus("1", 1);
  485. for (DoctorPatientGroupInfo groupInfo : groupInfos) {
  486. Patient p = patientNames.get(groupInfo.getPatient());
  487. if (p == null) {
  488. continue;
  489. }
  490. SignPatientLabelInfo labelInfo = new SignPatientLabelInfo();
  491. labelInfo.setPatient(p.getCode());
  492. labelInfo.setPname(p.getName());
  493. labelInfo.setLabel("1");
  494. labelInfo.setLabelName("普通人群");
  495. labelInfo.setLabelType("1");
  496. labelInfo.setStatus(1);
  497. labelInfo.setCzrq(new Date());
  498. normalLabel.put(p.getCode(), labelInfo);
  499. }
  500. List<DoctorPatientGroupInfo> groupInfos1 = groupInfoDao.findByGroupAndStatus("2", 1);
  501. for (DoctorPatientGroupInfo groupInfo : groupInfos1) {
  502. Patient p = patientNames.get(groupInfo.getPatient());
  503. if (p == null) {
  504. continue;
  505. }
  506. SignPatientLabelInfo labelInfo = new SignPatientLabelInfo();
  507. labelInfo.setPatient(p.getCode());
  508. labelInfo.setPname(p.getName());
  509. labelInfo.setLabel("2");
  510. labelInfo.setLabelName("慢病人群");
  511. labelInfo.setLabelType("1");
  512. labelInfo.setStatus(1);
  513. labelInfo.setCzrq(new Date());
  514. manbingLabel.put(p.getCode(), labelInfo);
  515. }
  516. List<DoctorPatientGroupInfo> groupInfos2 = groupInfoDao.findByGroupAndStatus("3", 1);
  517. for (DoctorPatientGroupInfo groupInfo : groupInfos2) {
  518. Patient p = patientNames.get(groupInfo.getPatient());
  519. if (p == null) {
  520. continue;
  521. }
  522. SignPatientLabelInfo labelInfo = new SignPatientLabelInfo();
  523. labelInfo.setPatient(p.getCode());
  524. labelInfo.setPname(p.getName());
  525. labelInfo.setLabel("3");
  526. labelInfo.setLabelName("65岁以上人群");
  527. labelInfo.setLabelType("1");
  528. labelInfo.setStatus(1);
  529. labelInfo.setCzrq(new Date());
  530. sixFiveLabel.put(p.getCode(), labelInfo);
  531. }
  532. if (normalLabel.size() > 0) {
  533. for (SignPatientLabelInfo labelInfo : normalLabel.values()) {
  534. labelInfoDao.save(labelInfo);
  535. }
  536. }
  537. if (manbingLabel.size() > 0) {
  538. for (SignPatientLabelInfo labelInfo : manbingLabel.values()) {
  539. labelInfoDao.save(labelInfo);
  540. }
  541. }
  542. if (sixFiveLabel.size() > 0) {
  543. for (SignPatientLabelInfo labelInfo : sixFiveLabel.values()) {
  544. labelInfoDao.save(labelInfo);
  545. }
  546. }
  547. return true;
  548. }
  549. }