Commit 69fafdb939b32ec970404c1a559bb6563586b284

Authored by yangfei
1 parent 0ddc7846ad

听力诊断模块

Showing 1 changed file with 192 additions and 48 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/HearDiagnManageController.java View file @ 69fafdb
... ... @@ -162,7 +162,7 @@
162 162 //获取当前登录用户ID
163 163 LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
164 164 if (loginState == null) {
165   - return;
  165 + return ;
166 166 }
167 167 //当前登录人医院Id
168 168 String hospitalId = autoMatchFacade.getHospitalId(loginState.getId());
... ... @@ -176,6 +176,7 @@
176 176 //加入院组
177 177 hospitalIds.addAll(hospiIds);
178 178 query.setCheckHospitalIds((String[]) hospitalIds.toArray(new String[hospitalIds.size()]));
  179 +
179 180 if (hdReq.getDiagnDoctorId() != null) {//诊断医生
180 181 query.setDiagnDoctorId(hdReq.getDiagnDoctorId());
181 182 }
182 183  
183 184  
184 185  
185 186  
186 187  
... ... @@ -187,26 +188,48 @@
187 188 if (hdReq.getConfirmEndTime() != null) {//确诊结束时间
188 189 query.setConfirmEndTime(hdReq.getConfirmEndTime());
189 190 }
  191 +
  192 + BabyPatientExtendEarBabyQuery babyQuery = new BabyPatientExtendEarBabyQuery();
  193 + babyQuery.setQueryNo(hdReq.getKeyWord());
  194 + babyQuery.setBirthStart(hdReq.getBirthStartTime());
  195 + babyQuery.setBirthEnd(hdReq.getBirthEndTime());
  196 + babyQuery.setHospitalId(hospitalId);
  197 + List<BabyPatientExtendEarBaby> models = earBabyService.queryBabyPatientExtendEarBaby(babyQuery);
  198 +
  199 + List<String> babyIds = new ArrayList<>();
  200 + if (CollectionUtils.isEmpty(models) && (StringUtils.isNotEmpty(hdReq.getKeyWord()) || hdReq.getBirthStartTime() != null || hdReq.getBirthEndTime() != null)) {
  201 + return ;
  202 + }
  203 +
  204 + if (CollectionUtils.isNotEmpty(models)) {
  205 + for (BabyPatientExtendEarBaby pa : models) {
  206 + babyIds.add(pa.getBabyPatientId());
  207 + }
  208 + query.setBabyIds(babyIds.toArray(new String[babyIds.size()]));
  209 + }
  210 +
  211 +
190 212 //设置确诊
191 213 query.setIsconfirm(1);
192   - if (hdReq.getConfirmDegree() != null) {//模糊查询确诊结果
  214 + query.setIfdel(0);
  215 + if (hdReq.getConfirmResult() != null) {//模糊查询确诊结果
193 216 List<String> cfList = new ArrayList<>();
194   - if (hdReq.getConfirmDegree() == 1) {//轻度
  217 + if (hdReq.getConfirmResult() == 1) {//轻度
195 218 cfList.add(",1,");
196 219 cfList.add(",2,");
197 220 cfList.add(",3,");
198   - } else if (hdReq.getConfirmDegree() == 2) {//中度
  221 + } else if (hdReq.getConfirmResult() == 2) {//中度
199 222 cfList.add(",4,");
200 223 cfList.add(",5,");
201 224 cfList.add(",6,");
202   - } else if (hdReq.getConfirmDegree() == 3) {//重度
  225 + } else if (hdReq.getConfirmResult() == 3) {//重度
203 226 cfList.add(",7,");
204 227 cfList.add(",8,");
205 228 cfList.add(",9,");
206 229 cfList.add(",10,");
207 230 cfList.add(",11,");
208 231 cfList.add(",12,");
209   - } else if (hdReq.getConfirmDegree() == 4) {//极重度
  232 + } else if (hdReq.getConfirmResult() == 4) {//极重度
210 233 cfList.add(",13,");
211 234 cfList.add(",14,");
212 235 cfList.add(",15,");
213 236  
... ... @@ -250,11 +273,16 @@
250 273 String title = HighRiskEnum.getTitle(Integer.parseInt(hf[b]));
251 274 map.put(Integer.parseInt(hf[b]), title);
252 275 // highRiskEnums.add(map);
253   - hrSb.append(title + ",");
  276 + hrSb.append(title + "");
254 277 }
255 278 }
256   - // hea.setHighRiskEnums(highRiskEnums);
257   - hea.setHighRiskEnums(hrSb.toString());
  279 + String hfString = null;
  280 + if (hrSb.toString().endsWith("、")) {
  281 + hfString = hrSb.substring(0, hrSb.length() - 1);
  282 + } else {
  283 + hfString = hrSb.toString();
  284 + }
  285 + hea.setHighRiskEnums(hfString);
258 286 }
259 287 //确诊结果
260 288 if (hd.getConfirmResult() != null) {
261 289  
... ... @@ -266,11 +294,16 @@
266 294 String title = ConfirmedEnums.getTitle(Integer.parseInt(cr[b]));
267 295 map.put(Integer.parseInt(cr[b]), title);
268 296 // hdEnums.add(map);
269   - hdSb.append(title + "");
  297 + hdSb.append(title + "");
270 298 }
271 299 }
272   - // hea.setDiagnResult(hdEnums);
273   - hea.setDiagnResult(hdSb.toString());
  300 + String hfString = null;
  301 + if (hdSb.toString().endsWith("、")) {
  302 + hfString = hdSb.substring(0, hdSb.length() - 1);
  303 + } else {
  304 + hfString = hdSb.toString();
  305 + }
  306 + hea.setDiagnResult(hfString);
274 307 }
275 308 hdList.add(hea);
276 309 }
... ... @@ -396,7 +429,6 @@
396 429 }
397 430 query.setSort("diagnose_time");
398 431 query.setNeed("1");
399   -
400 432 List<BabyPatientExtendEarHearingDiagnose> hearingDiagnoseList = hearingDiagnoseService.getHdAndScreen(query);
401 433  
402 434 List<HearingDiagnoseListResult> hdList = new ArrayList<>();
403 435  
404 436  
... ... @@ -643,13 +675,31 @@
643 675 if (loginState == null) {
644 676 return;
645 677 }
646   -//当前登录人医院Id
  678 + //当前登录人医院Id
647 679 String hospitalId = autoMatchFacade.getHospitalId(loginState.getId());
648 680  
649 681 List<String> babyIds = new ArrayList<>();
650 682  
651 683  
  684 + BabyPatientExtendEarBabyQuery babyQuery = new BabyPatientExtendEarBabyQuery();
  685 + babyQuery.setQueryNo(model.getKeyWord());
  686 + babyQuery.setBirthStart(model.getBirthStartTime());
  687 + babyQuery.setBirthEnd(model.getBirthEndTime());
  688 + babyQuery.setHospitalId(hospitalId);
  689 + List<BabyPatientExtendEarBaby> models = earBabyService.queryBabyPatientExtendEarBaby(babyQuery);
  690 +
  691 + if (CollectionUtils.isEmpty(models) && (StringUtils.isNotEmpty(model.getKeyWord()) || model.getBirthStartTime() != null || model.getBirthEndTime() != null)) {
  692 + return;
  693 + }
  694 +
652 695 BabyPatientExtendEarScreenQuery screenQuery = new BabyPatientExtendEarScreenQuery();
  696 + if (CollectionUtils.isNotEmpty(models)) {
  697 + for (BabyPatientExtendEarBaby pa : models) {
  698 + babyIds.add(pa.getBabyPatientId());
  699 + }
  700 + screenQuery.setBabyIds(babyIds.toArray(new String[babyIds.size()]));
  701 + }
  702 +
653 703 //听筛开始时间
654 704 if (model.getSecrStartTime() != null) {
655 705 screenQuery.setScreenStartDate(model.getSecrStartTime());
656 706  
... ... @@ -667,7 +717,9 @@
667 717 List hospiIds = earFacade.getOrgHospitalIds(hospitalId);
668 718 List<String> hospitalIds = new ArrayList<String>();
669 719 hospitalIds.addAll(hospiIds);
  720 + //加入院组
670 721 screenQuery.setCheckHospitalIds((String[]) hospitalIds.toArray(new String[hospitalIds.size()]));
  722 +
671 723 //查询全部数据
672 724 List<BabyPatientExtendEarScreen> earScreens = screenService.dubiousScreen(screenQuery);
673 725  
... ... @@ -772,7 +824,7 @@
772 824  
773 825  
774 826 /**
775   - * 导出听力可疑儿童列表(听力筛查表,当前医院的复诊未通过的数据)
  827 + * 导出全部童列表(听力筛查表,当前医院的复诊未通过的数据)
776 828 *
777 829 * @param request
778 830 * @return
779 831  
780 832  
781 833  
782 834  
783 835  
784 836  
785 837  
786 838  
787 839  
... ... @@ -786,55 +838,147 @@
786 838 if (loginState == null) {
787 839 return;
788 840 }
789   -//当前登录人医院Id
  841 + //当前登录人医院Id
790 842 String hospitalId = autoMatchFacade.getHospitalId(loginState.getId());
  843 +
  844 + BabyPatientExtendEarBabyQuery babyQuery = new BabyPatientExtendEarBabyQuery();
  845 +
  846 + Date currentDate = DateUtil.formatDate(new Date());
  847 + if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(model.getBirth()) && model.getMonthAgeStart() != null && model.getMonthAgeEnd() != null) {
  848 +
  849 + Date start = DateUtil.addMonth(currentDate, -model.getMonthAgeStart());
  850 + String birthStr = model.getBirth();
  851 + String[] dates = birthStr.split(" - ");
  852 +
  853 + if (DateUtil.parseYMD(dates[1]).getTime() < start.getTime()) {
  854 + babyQuery.setBirthEnd(DateUtil.parseYMD(dates[1]));
  855 + } else {
  856 + babyQuery.setBirthEnd(start);
  857 + }
  858 +
  859 + Date end = DateUtil.addDay(DateUtil.addMonth(currentDate, -model.getMonthAgeEnd() - 1), 1);
  860 +
  861 + if (DateUtil.parseYMD(dates[0]).getTime() < end.getTime()) {
  862 + babyQuery.setBirthStart(end);
  863 + } else {
  864 + babyQuery.setBirthStart(DateUtil.parseYMD(dates[0]));
  865 + }
  866 + } else if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(model.getBirth()) && model.getMonthAgeStart() != null) {
  867 +
  868 + Date start = DateUtil.addMonth(currentDate, -model.getMonthAgeStart());
  869 + String birthStr = model.getBirth();
  870 + String[] dates = birthStr.split(" - ");
  871 +
  872 + if (DateUtil.parseYMD(dates[1]).getTime() < start.getTime()) {
  873 + babyQuery.setBirthEnd(DateUtil.parseYMD(dates[1]));
  874 + } else {
  875 + babyQuery.setBirthEnd(start);
  876 + }
  877 +
  878 + babyQuery.setBirthStart(DateUtil.parseYMD(dates[0]));
  879 +
  880 + } else if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(model.getBirth())) {
  881 + String birthStr = model.getBirth();
  882 + String[] dates = birthStr.split(" - ");
  883 + babyQuery.setBirthStart(DateUtil.parseYMD(dates[0]));
  884 + babyQuery.setBirthEnd(new Date(DateUtil.parseYMD(dates[1]).getTime() + 24 * 60 * 60 * 1000 - 1));
  885 + } else if (model.getMonthAgeStart() != null && model.getMonthAgeEnd() != null) {
  886 + Date start = DateUtil.addMonth(currentDate, -model.getMonthAgeStart());
  887 + babyQuery.setBirthEnd(start);
  888 +
  889 + Date end = DateUtil.addDay(DateUtil.addMonth(currentDate, -model.getMonthAgeEnd() - 1), 1);
  890 + babyQuery.setBirthStart(end);
  891 + } else if (model.getMonthAgeStart() != null) {
  892 + Date start = DateUtil.addMonth(currentDate, -model.getMonthAgeStart());
  893 + babyQuery.setBirthEnd(start);
  894 + } else if (model.getMonthAgeEnd() != null) {
  895 + Date end = DateUtil.addDay(DateUtil.addMonth(currentDate, -model.getMonthAgeEnd() - 1), 1);
  896 + babyQuery.setBirthStart(end);
  897 + }
  898 +
  899 +
  900 + babyQuery.setHospitalId(hospitalId);
  901 + babyQuery.setNoEnable("0");
  902 +
  903 + List<String> babyIds = new ArrayList<>();
  904 +
  905 + //如果查询号不为空,根据查询号查询儿童档案表,获取儿童档案Id
  906 + if (StringUtils.isNotEmpty(model.getKeyWord())) {//关键字:姓名、联系方式、就诊卡 查询babyId
  907 + babyQuery.setQueryNo(model.getKeyWord());
  908 + // babyQuery.setHospitalId(hospitalId);
  909 + }
  910 +
  911 + List<BabyPatientExtendEarBaby> babyModels = earBabyService.queryBabyPatientExtendEarBaby(babyQuery);
  912 +
  913 + for (BabyPatientExtendEarBaby babyModel : babyModels) {
  914 + babyIds.add(babyModel.getBabyPatientId());
  915 + }
  916 +
  917 + //查询儿童听筛记录
791 918 BabyPatientExtendEarScreenQuery screenQuery = new BabyPatientExtendEarScreenQuery();
792 919 //检测医生ID
793 920 if (model.getDiagnDoctorId() != null) {
794 921 screenQuery.setCheckDoctorId(model.getDiagnDoctorId());
795 922 }
796 923 // screenQuery.setCheckHospitalId(hospitalId);
  924 + List<String> hospitalIds = new ArrayList<String>();
797 925 //当前登录人医院Id
798 926 List hospiIds = earFacade.getOrgHospitalIds(hospitalId);
799   - List<String> hospitalIds = new ArrayList<String>();
800 927 hospitalIds.addAll(hospiIds);
801 928 screenQuery.setCheckHospitalIds((String[]) hospitalIds.toArray(new String[hospitalIds.size()]));
802   - List<BabyPatientExtendEarScreen> earScreens = screenService.notAuscultationBabyPatientExtendEarScreen(screenQuery);
  929 + screenQuery.setStatus(0);
  930 +
  931 + //根据儿童条件查询如果为空
  932 + if (CollectionUtils.isEmpty(babyIds) && (model.getMonthAgeStart() != null || model.getMonthAgeEnd() != null || StringUtils.isNotEmpty(model.getKeyWord()) || model.getBirthStartTime() != null || model.getBirthEndTime() != null)) {
  933 + return ;
  934 + }
  935 +
803 936 //查询全部数据
804   - List<HearDiagnManageListResult> hdmResult = new ArrayList<>();
  937 + List<BabyPatientExtendEarScreen> earScreens = screenService.queryBabyPatientExtendEarScreen(screenQuery);
  938 + Map<String, BabyPatientExtendEarScreen> screenMap = new HashMap<>();
805 939 if (CollectionUtils.isNotEmpty(earScreens)) {
806 940 for (BabyPatientExtendEarScreen es : earScreens) {
  941 + screenMap.put(es.getBabyId(), es);
  942 + }
  943 + }
  944 +
  945 + //听筛医生不为空
  946 + if (CollectionUtils.isEmpty(earScreens)&&model.getDiagnDoctorId() != null) {
  947 + return;
  948 + }
  949 +
  950 +
  951 +
  952 + //要返回的数据
  953 + List<HearDiagnManageListResult> hdmResult = new ArrayList<>();
  954 + if (CollectionUtils.isNotEmpty(babyModels)) {
  955 + for (BabyPatientExtendEarBaby ear : babyModels) {
807 956 HearDiagnManageListResult hdm = new HearDiagnManageListResult();
808   - hdm.setId(es.getId());
809   - String docotorId = es.getCheckDoctorId();
810   - Users users = usersService.getUsers(Integer.parseInt(docotorId == null ? "0" : docotorId));
811   - if (users != null) {
812   - hdm.setDoctorName(users.getName() == null ? "-" : users.getName());
  957 + hdm.setBabyName(ear.getName());
  958 + hdm.setBabyId(ear.getBabyPatientId());
  959 + hdm.setMommyName(com.lyms.platform.common.utils.StringUtils.emptyDeal(ear.getMname()));
  960 + hdm.setMommnyPhone(com.lyms.platform.common.utils.StringUtils.emptyDeal(ear.getMphone()));
  961 + hdm.setMommnyEncryptPhone(com.lyms.platform.common.utils.StringUtils.encryPhone(ear.getMphone()));
  962 + hdm.setMonthAge(DateUtil.getBabyMonthAge(ear.getBirth(), new Date()));
  963 + hdm.setBirthday(com.lyms.platform.common.utils.StringUtils.emptyDeal(DateUtil.getyyyy_MM_dd(ear.getBirth())));
  964 + hdm.setSex(com.lyms.platform.common.utils.StringUtils.emptyDeal(SexEnum.getTextById(ear.getSex())));
  965 + BabyPatientExtendEarScreen es = screenMap.get(ear.getBabyPatientId());
  966 +
  967 + if(es==null){
  968 + if (model.getDiagnDoctorId() != null) {//筛查医生查询条件不为空,没找到则跳过
  969 + continue;
  970 + }
813 971 }
814   - hdm.setSecrTime(DateUtil.getyyyy_MM_dd(es.getScreenDate()));
815   - BabyModel babyModel = babyService.getOneBabyById(es.getBabyId());
816   - if (babyModel != null) {
817   - hdm.setBabyName(babyModel.getName());
818   - hdm.setBabyId(es.getBabyId());
819   - hdm.setMommyName(com.lyms.platform.common.utils.StringUtils.emptyDeal(babyModel.getMname()));
820   - hdm.setMommnyPhone(com.lyms.platform.common.utils.StringUtils.emptyDeal(babyModel.getMphone()));
821   - hdm.setMommnyEncryptPhone(com.lyms.platform.common.utils.StringUtils.encryPhone(babyModel.getMphone()));
822   - hdm.setMonthAge(DateUtil.getBabyMonthAge(babyModel.getBirth(), new Date()));
823   - hdm.setBirthday(com.lyms.platform.common.utils.StringUtils.emptyDeal(DateUtil.getyyyy_MM_dd(babyModel.getBirth())));
824   - hdm.setSex(com.lyms.platform.common.utils.StringUtils.emptyDeal(SexEnum.getTextById(babyModel.getSex())));
  972 +
  973 + if (es != null) {
  974 + hdm.setId(es.getId());
  975 + String docotorId = es.getCheckDoctorId();
  976 + Users users = usersService.getUsers(Integer.parseInt(docotorId == null ? "0" : docotorId));
  977 + if (users != null) {
  978 + hdm.setDoctorName(users.getName() == null ? "-" : users.getName());
  979 + }
  980 + hdm.setSecrTime(DateUtil.getyyyy_MM_dd(es.getScreenDate()));
825 981 }
826   - String babyId = es.getBabyId();
827   - BabyPatientExtendEarHearingDiagnoseQuery hdQuery = new BabyPatientExtendEarHearingDiagnoseQuery();
828   - hdQuery.setBabyId(babyId);
829   - //根据babyId查询听力诊断,如果有数据则已诊断
830   - int count = hearingDiagnoseService.queryBabyPatientExtendEarHearingDiagnoseCount(hdQuery);
831   - hdm.setSecrType("复诊");
832   - hdm.setSecrResult("未通过");
833   - if (count > 0) {//儿童在医院里做过听力诊断记录,标记为已诊断
834   - hdm.setStatus("已诊断");
835   - } else {
836   - hdm.setStatus("未诊断");
837   - }
838 982 hdmResult.add(hdm);
839 983 }
840 984  
... ... @@ -885,7 +1029,7 @@
885 1029 if (loginState == null) {
886 1030 return new BaseResponse().setErrorcode(ErrorCodeConstants.TOKEN_EXPIRE).setErrormsg("请重新登录");
887 1031 }
888   -//当前登录人医院Id
  1032 + //当前登录人医院Id
889 1033 String hospitalId = autoMatchFacade.getHospitalId(loginState.getId());
890 1034  
891 1035 BabyPatientExtendEarBabyQuery babyQuery = new BabyPatientExtendEarBabyQuery();