diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWxController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWxController.java new file mode 100644 index 0000000..93c8dcd --- /dev/null +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWxController.java @@ -0,0 +1,1187 @@ +package com.lyms.platform.operate.web.controller; + +import com.lyms.platform.biz.service.*; +import com.lyms.platform.common.base.BaseController; +import com.lyms.platform.common.constants.ErrorCodeConstants; +import com.lyms.platform.common.dao.operator.MongoQuery; +import com.lyms.platform.common.result.BaseObjectResponse; +import com.lyms.platform.common.result.BaseResponse; +import com.lyms.platform.common.result.CommonResult; +import com.lyms.platform.common.utils.*; +import com.lyms.platform.operate.web.facade.*; +import com.lyms.platform.operate.web.request.AntExAddRequest; +import com.lyms.platform.operate.web.request.AntExQueryRequest; +import com.lyms.platform.operate.web.request.AntenatalExaminationQueryRequest; +import com.lyms.platform.operate.web.request.PatientQueryRequest; +import com.lyms.platform.operate.web.service.PatientWeightService; +import com.lyms.platform.operate.web.utils.CollectionUtils; +import com.lyms.platform.operate.web.utils.FunvCommonUtil; +import com.lyms.platform.permission.model.PatientService; +import com.lyms.platform.permission.model.PatientServiceQuery; +import com.lyms.platform.permission.service.CouponService; +import com.lyms.platform.permission.service.PatientServiceService; +import com.lyms.platform.pojo.*; +import com.lyms.platform.query.AntExChuQuery; +import com.lyms.platform.query.LisCrisisItemQuery; +import com.lyms.platform.query.PatientsQuery; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Sort; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.IOException; +import java.io.OutputStream; +import java.util.*; + +/** + * 邢台威县 + */ +@Controller +@RequestMapping +public class PatientWxController extends BaseController { + @Autowired + private PatientsService patientsService; + @Autowired + private PatientWeightService patientWeightService1; + @Autowired + private PatientWeightService2 patientWeightService; + @Autowired + private BloodPressureService bloodPressureService; + @Autowired + private AntenatalExaminationService antExService; + @Autowired + private BasicConfigService basicConfigService; + @Autowired + private AntenatalExaminationFacade antenatalExaminationFacade; + @Autowired + private ViewFacade viewFacade; + @Autowired + private StopPregnancyFacade stopPregnancyFacade; + @Autowired + private LisCrisisItemService lisCrisisItemService; + @Autowired + private PatientFacade patientFacade; + @Autowired + private CouponService couponService; + /* @Autowired + private AppointmentService appointmentService;*/ + @Autowired + private PatientServiceService patientServiceService; + public static final String MEMBER_BABY_URL= PropertiesUtils.getPropertyValue("member_baby_url"); + + final static Integer userId=2100006857;//默认为客服ID + final static String hospitalId="2100002421";//大同医院ID + final static String Authorization="1d$l*Y8lslp4dJLTsbm7LkM90"; + + + /** + * 大同his获取孕妇小程序预建档信息——末次月经、血压、体重、既往史、个人史、家族史、传染病史、手术史数据 + * @param idCard + * @param name + * @param phone + * @return + */ + /*@RequestMapping(method = RequestMethod.GET, value = "/getDTPatient/Bookbuilding") + @ResponseBody + public BaseResponse getPatients(@RequestHeader("Authorization")String authorization, String idCard, String name, String phone){ + BaseResponse baseResponse=new BaseResponse(); + + if (!authorization.contains(Authorization)){ + return baseResponse.setErrormsg("权限异常").setErrorcode(-1); + } + + PatientsQuery patientsQuery =new PatientsQuery(); + patientsQuery.setYn(1); + patientsQuery.setHospitalId(hospitalId); + if (StringUtils.isNotEmpty(idCard)){ + patientsQuery.setCardNo(idCard); + }else { + if (StringUtils.isNotEmpty(name)&&StringUtils.isNotEmpty(phone)){ + patientsQuery.setName(name); + patientsQuery.setPhone(phone); + }else { + return baseResponse.setErrormsg("参数异常").setErrorcode(-1); + } + } + List patientsList= patientsService.queryPatient(patientsQuery); + Map params=new HashMap<>(); + if (CollectionUtils.isNotEmpty(patientsList)){ + //处理预建档信息 末次月经、血压、体重、既往史、个人史、家族史、传染病史、手术史数据 + Patients patients= patientsList.get(0); + String id=patients.getId(); + params.put("lastMenses",patients.getLastMenses()); + PatientWeightQuery patientWeightQuery=new PatientWeightQuery(); + patientWeightQuery.setYn(1); + patientWeightQuery.setParentId(id); + MongoQuery mongoQuery=patientWeightQuery.convertToQuery().addOrder(Sort.Direction.DESC, "id"); + List patientWeightList= patientWeightService.queryPatientWeight(mongoQuery.convertToMongoQuery()); + if (CollectionUtils.isNotEmpty(patientWeightList)){ + //体重 + params.put("yqweight",patientWeightList.get(0).getNowWeight()); + } + BloodPressureQuery bloodPressureQuery=new BloodPressureQuery(); + bloodPressureQuery.setParentId(id); + bloodPressureQuery.setYn(1); + List list= bloodPressureService.getList(bloodPressureQuery); + if (CollectionUtils.isNotEmpty(list)){ + BloodPressure bloodPressure= list.get(0); + //血压 + params.put("bp", bloodPressure.getSsy() + "/" + bloodPressure.getSzy() + "mmHg"); + } + AntExChuQuery antExChuQuery=new AntExChuQuery(); + antExChuQuery.setYn(1); + antExChuQuery.setParentId(id); + List antExChuModelList= antExService.queryAntExChu(antExChuQuery); + if (CollectionUtils.isNotEmpty(antExChuModelList)){ + AntExChuModel data= antExChuModelList.get(0); + //既往史 + String pastHistory = ""; + if (org.apache.commons.lang.StringUtils.isNotEmpty(data.getPastHistory())) { + Map map1 = JsonUtil.jkstr2Obj(data.getPastHistory(), Map.class); + pastHistory = FunvCommonUtil.replace(map1, new StringBuilder(), basicConfigService); + } + params.put("pastHistory", pastHistory); + //家族史 + String familyHistory = ""; + if (org.apache.commons.lang.StringUtils.isNotEmpty(data.getFamilyHistory())) { + Map map1 = JsonUtil.jkstr2Obj(data.getFamilyHistory(), Map.class); + familyHistory = FunvCommonUtil.replace(map1, new StringBuilder(), basicConfigService); + } + params.put("familyHistory", familyHistory); + //个人史 + String personalHistory = ""; + if (org.apache.commons.lang.StringUtils.isNotEmpty(data.getPersonalHistory())) { + Map map1 = JsonUtil.jkstr2Obj(data.getPersonalHistory(), Map.class); + personalHistory = FunvCommonUtil.replace(map1, new StringBuilder(), basicConfigService); + } + params.put("personalHistory", personalHistory); + //妇科手术史 + String fksxHistory = ""; + if (org.apache.commons.lang.StringUtils.isNotEmpty(data.getFksxHistory())) { + Map map1 = JsonUtil.jkstr2Obj(data.getFksxHistory(), Map.class); + fksxHistory = FunvCommonUtil.replace(map1, new StringBuilder(), basicConfigService); + } + params.put("fksxHistory", fksxHistory); + //传染病史 + String infectDiseases=""; + if (org.apache.commons.lang.StringUtils.isNotEmpty(data.getInfectDiseases())) { + Map map1 = JsonUtil.jkstr2Obj(data.getInfectDiseases(), Map.class); + infectDiseases=FunvCommonUtil.reslove(map1, new StringBuilder()); + } + params.put("infectDiseases", infectDiseases); + + } + }else { + return new BaseResponse().setErrormsg("当前用户未有建档信息").setErrorcode(41001); + } + baseResponse.setObject(params); + return baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); + }*/ + + /** + * 建档基础信息大同 + * @param idCard + * @param name + * @param phone + * @return + */ + @RequestMapping(method = RequestMethod.GET, value = "/wx/antexmanage") + @ResponseBody + public BaseResponse queryAntenatalExamination(@RequestHeader("Authorization")String authorization, String idCard, String name, String phone, String vcCardNo){ + if (!authorization.contains(Authorization)){ + return new BaseResponse().setErrormsg("权限异常").setErrorcode(-1); + } + String cardNo=idCard; + if (!StringUtils.isNotEmpty(idCard)){ + if (StringUtils.isNotEmpty(name)&&StringUtils.isNotEmpty(phone)){ + PatientsQuery patientsQuery =new PatientsQuery(); + patientsQuery.setYn(1); + patientsQuery.setHospitalId(hospitalId); + patientsQuery.setName(name); + patientsQuery.setPhone(phone); + List patientsList= patientsService.queryPatient(patientsQuery); + if (CollectionUtils.isNotEmpty(patientsList)){ + cardNo=patientsList.get(0).getCardNo(); + }else { + return new BaseResponse().setErrormsg("当前用户未有建档信息").setErrorcode(41001); + } + } + + if (StringUtils.isEmpty(cardNo)&&StringUtils.isEmpty(vcCardNo)){ + return new BaseResponse().setErrormsg("参数异常").setErrorcode(-1); + } + + } + AntenatalExaminationQueryRequest queryRequest=new AntenatalExaminationQueryRequest(); + queryRequest.setCardNo(cardNo); + queryRequest.setVcCardNo(vcCardNo); + return antenatalExaminationFacade.queryAntenatalExamination(queryRequest,userId); + } + + /** + * 高危威县 + * @param patientId + * @return + */ + @RequestMapping(method = RequestMethod.GET, value = "/wx/getLastRisk") + @ResponseBody + public BaseResponse getLastRisk(@RequestHeader("Authorization")String authorization, String patientId) { + if (!authorization.contains(Authorization)){ + return new BaseResponse().setErrormsg("权限异常").setErrorcode(-1); + } + return antenatalExaminationFacade.getLastRisk(patientId, null); + } + + /** + * 检查报表 + * + * @param antex + * @return + */ + @RequestMapping(value = "/wx/checkReport", method = RequestMethod.GET) + @ResponseBody + public BaseResponse checkReport(@RequestHeader("Authorization")String authorization, @RequestParam(required = false) List antex, @RequestParam(required = false) String antexc) { + if (!authorization.contains(Authorization)){ + return new BaseResponse().setErrormsg("权限异常").setErrorcode(-1); + } + return viewFacade.checkReport(antex, antexc, userId); + } + + /** + * 查询复诊接口 + * + * @param id + * @return + */ + @RequestMapping(value = "/wx/findAntenatalExaminationData", method = RequestMethod.GET) + @ResponseBody + public BaseObjectResponse findAntenatalExaminationData(@RequestHeader("Authorization")String authorization, @RequestParam("id") String id) { + if (!authorization.contains(Authorization)){ + return new BaseObjectResponse().setErrormsg("权限异常").setErrorcode(-1); + } + return viewFacade.findAntenatalExamination(id); + } + + + /** + * 返回该医院可选择的录入人 + * 默认为客服号 + * @return + */ + @RequestMapping(method = RequestMethod.GET, value = "/wx/queryInPerson") + @ResponseBody + public BaseResponse queryInPerson(@RequestHeader("Authorization")String authorization) { + if (!authorization.contains(Authorization)){ + return new BaseResponse().setErrormsg("权限异常").setErrorcode(-1); + } + return stopPregnancyFacade.queryInPerson(userId); + } + + /** + * 返回该医院可选择的录入人 + * 默认为客服号 + * @return + */ + @RequestMapping(method = RequestMethod.GET, value = "/wx/queryInPerson2") + @ResponseBody + public BaseResponse queryInPerson2(@RequestHeader("Authorization")String authorization) { + if (!authorization.contains(Authorization)){ + return new BaseResponse().setErrormsg("权限异常").setErrorcode(-1); + } + return stopPregnancyFacade.queryInPerson2(userId); + } + + /** + * 危急列表 + * @param response + * @param page + * @param limit + * @param cardNo + * @param phone + + */ + @RequestMapping(value = "/dt/lisCrisisItems", method = RequestMethod.GET) + public void getEmergenceTreatments(HttpServletResponse response, + @RequestHeader("Authorization")String authorization, + @RequestParam("page") int page, + @RequestParam("limit") int limit, + @RequestParam(value = "cardNo", required = false) String cardNo, + @RequestParam(value = "phone", required = false) String phone, + @RequestParam(value = "name", required = false) String name) + { + if (!authorization.contains(Authorization)){ + ResultUtils.buildParameterErrorResultAndWrite(response, "权限异常"); + return ; + } + LisCrisisItemQuery query = new LisCrisisItemQuery(); + query.setPage(page); + query.setLimit(limit); + query.setNeed("y"); + Boolean b=false; + if (StringUtils.isNotEmpty(cardNo)){ + query.setCardNo(cardNo); + b=true; + } + if (StringUtils.isNotEmpty(phone)&&StringUtils.isNotEmpty(name)){ + query.setPhone(phone); + query.setName(name); + b=true; + } + if (!b){ + ResultUtils.buildParameterErrorResultAndWrite(response, "参数异常"); + return; + } + query.setHospitalId(hospitalId); + + + List lisCrisisItemList = lisCrisisItemService.query(query, Sort.Direction.DESC, "publishTime"); + List list = new ArrayList<>(); + + if (org.apache.commons.collections.CollectionUtils.isNotEmpty(lisCrisisItemList)) { + for (LisCrisisItem data : lisCrisisItemList) { + Map map = new HashMap<>(); + map.put("id", data.getId()); + map.put("hospitalId", data.getHospitalId()); + map.put("name", data.getName()); + map.put("age", data.getAge()); + map.put("itemCode", data.getItemCode()); + map.put("itemName", data.getItemName()); + map.put("classify", data.getClassify()); + map.put("classifyName", data.getClassifyName()); + map.put("flag", data.getFlag()); + map.put("ref", data.getRef()); + map.put("result", data.getResult()); + map.put("unit", data.getUnit()); + map.put("applyDoctorCode", data.getApplyDoctorCode()); + map.put("applyDoctorName", data.getApplyDoctorName()); + map.put("publishTime", DateUtil.getyyyy_MM_dd(data.getPublishTime())); + map.put("status", data.getStatus()); + map.put("statusName", data.getStatusName()); + + map.put("patientName", data.getPatientName()); + map.put("cardNo", data.getCardNo()); + map.put("phone", data.getPhone()); + map.put("serviceType", data.getServiceType()); + map.put("serviceStatus", data.getServiceStatus()); + map.put("lastMenses", data.getLastMenses() == null ? 0 : data.getLastMenses().getTime()); + + if (data.getWeek() >= 42) { + map.put("week", "已分娩"); + } else { + map.put("week", data.getWeek() + "周"); + } + map.put("pId", data.getPid()); + map.put("pid", data.getPid()); + map.put("patientId", data.getPatientId()); + + list.add(map); + } + } + CommonResult result = new CommonResult(); + result.setList(list); + result.setPageInfo(query.getPageInfo()); + + ResultUtils.buildSuccessResultAndWrite(response, result); + } + + @RequestMapping(value = "/dt/findp2", method = RequestMethod.GET) + @ResponseBody + public BaseResponse getPatent2(@Valid PatientQueryRequest request, + @RequestHeader("Authorization")String authorization) { + if (!authorization.contains(Authorization)){ + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + return patientFacade.findPatient2(request, userId); + } + + @RequestMapping(method = RequestMethod.GET, value = "/dt/getGongGaoCurve") + @ResponseBody + public BaseResponse getGongGaoLine(@RequestParam(required = true) String patientId, @RequestHeader("Authorization")String authorization) { + if (!authorization.contains(Authorization)){ + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + return antenatalExaminationFacade.getGongGaoLine(patientId, userId); + } + + @RequestMapping(method = RequestMethod.GET, value = "/wx/antex") + @ResponseBody + public BaseResponse findOneAntById(@RequestHeader("Authorization")String authorization, @Valid AntExQueryRequest antExQueryRequest) { + if (!authorization.contains(Authorization)){ + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + antExQueryRequest.setUserId(userId); + return antenatalExaminationFacade.findOneAntExById(antExQueryRequest); + } + + @RequestMapping(method = RequestMethod.POST, value = "/wx/antexmanage") + @ResponseBody + public BaseResponse addOneAntenatalExamination(@RequestHeader("Authorization")String authorization, @Valid @RequestBody AntExAddRequest antExAddRequest) { + if (!authorization.contains(Authorization)){ + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + BaseResponse baseResponse = antenatalExaminationFacade.addOneAntEx(antExAddRequest, userId); + baseResponse.setObject(couponService.getPatientsInfoByCode(antExAddRequest.getCouponCode())); + return baseResponse; + } + + /** + * 获取体重列表; + * @param authorization + * @param id + * @return + */ + @ResponseBody + @RequestMapping(value = "/dt/patient/weight/info/{id}", method = RequestMethod.GET) + public BaseResponse info(@RequestHeader("Authorization")String authorization, @PathVariable String id) { + if (!authorization.contains(Authorization)){ + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + return patientWeightService1.info(id); + } + + /** + * 添加体重管理 + * @param patientWeight + * @return + */ + /* @ResponseBody + @RequestMapping(value = "/dt/patient/weight",method = RequestMethod.POST) + public BaseResponse addOrUpdate(@RequestHeader("Authorization")String authorization, PatientWeight patientWeight) { + if (!authorization.contains(Authorization)){ + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + return patientWeightService1.addOrUpdate(userId, patientWeight); + }*/ + /*@Autowired + private PregnancyReportFacade pregnancyReportFacade;*/ + + /** + * 获取患者体重报告 + * @return + */ + /*@RequestMapping(method = RequestMethod.GET, value = "/dt/getPatientReport") + @ResponseBody + public BaseResponse getPatientReport(@RequestParam(required = false) String name, + @RequestParam(required = false) Integer week, + @RequestParam(required = false) Integer weightType, + @RequestHeader("Authorization")String authorization){ + if (!authorization.contains(Authorization)){ + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + PregnancyReportQuery pregnancyReportQuery=new PregnancyReportQuery(); + pregnancyReportQuery.setWeek(week); + pregnancyReportQuery.setWeightType(weightType); + pregnancyReportQuery.setName(name); + return pregnancyReportFacade.getPatientReport(pregnancyReportQuery,userId); + }*/ + /* @Autowired + private PregnancyReportMattersServiceFacade pregnancyReportMattersServiceFacade; + *//** + * 获取模版列表 + * @return + *//* + @RequestMapping(method = RequestMethod.GET, value = "/dt/matters/getList") + @ResponseBody + public BaseResponse getMattersList( + @RequestHeader("Authorization")String authorization, + @RequestParam(required = false) Integer week, + @RequestParam(required = false) Integer riskType, + @RequestParam Integer type, + @RequestParam(required = false) String name, + @RequestParam("page") Integer page, + @RequestParam("limit") Integer limit + ){ + if (!authorization.contains(Authorization)){ + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + PregnancyReportMattersQuery postpartumReportQuery=new PregnancyReportMattersQuery(); + postpartumReportQuery.setWeek(week); + postpartumReportQuery.setType(type); + postpartumReportQuery.setRiskType(riskType); + postpartumReportQuery.setPage(page); + postpartumReportQuery.setLimit(limit); + postpartumReportQuery.setName(name); + return pregnancyReportMattersServiceFacade.getList(postpartumReportQuery,userId); + } + + *//** + * 获取高危饮食原则模版详情 + * @return + *//* + @RequestMapping(method = RequestMethod.GET, value = "/dt/matters/getRisk") + @ResponseBody + public BaseResponse getReportByRisk(@RequestHeader("Authorization")String authorization, @RequestParam Integer week, @RequestParam Integer type, + @RequestParam String riskFactorId){ + if (!authorization.contains(Authorization)){ + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + BaseResponse baseResponse= new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); + PregnancyReportMattersQuery postpartumReportQuery=new PregnancyReportMattersQuery(); + postpartumReportQuery.setWeek(week); + postpartumReportQuery.setType(type); + postpartumReportQuery.setRiskFactorId(StringUtils.covertToList(riskFactorId, String.class)); + baseResponse.setObject(pregnancyReportMattersServiceFacade.getReportByRisk(postpartumReportQuery,userId)); + return baseResponse; + } + *//** + * 获取模版详情 + * @return + *//* + @RequestMapping(method = RequestMethod.GET, value = "/dt/matters/getInfo") + @ResponseBody + public BaseResponse getMattersList(@RequestHeader("Authorization")String authorization, String id){ + if (!authorization.contains(Authorization)){ + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + BaseResponse baseResponse= new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); + baseResponse.setObject(pregnancyReportMattersServiceFacade.getPregnancyReport(id)); + return baseResponse; + }*/ + + /** + * 查询初诊接口 + * + * @param id + * @return + */ + @RequestMapping(value = "/wx/findAntExChuData", method = RequestMethod.GET) + @ResponseBody + public BaseObjectResponse findAntExChuData(@RequestParam("id") String id, + @RequestHeader("Authorization")String authorization) { + if (!authorization.contains(Authorization)){ + return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + BaseObjectResponse br = viewFacade.findAntExChu(id); + return br; + } + + /* @Autowired + private LisFacade lisFacade; + + @RequestMapping(method = RequestMethod.GET, value = "/dt/getLisAndRisData") + @ResponseBody + public BaseResponse getLisAndRisData(@RequestHeader("Authorization")String authorization, + @RequestParam(required = false) String vcCardNo, + @RequestParam(required = false) String sINCard, + @RequestParam("sortType") Integer sortType, + @RequestParam(required = false) String phone, + @RequestParam(required = false) String cardNo, + @RequestParam(required = false) String userName, + @RequestParam(defaultValue = "1") Integer perType//默认孕妇 + ) { + if (!authorization.contains(Authorization)){ + return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + return lisFacade.getLisAndRisData(vcCardNo,sINCard, phone,cardNo, sortType,perType, userName,userId); + } + + *//** + * 增加产检高危手册(大同) + * @param antExHighRiskModel + * @return + *//* + @RequestMapping(method = RequestMethod.POST, value = "/dt/addAntexHighRisk") + @ResponseBody + public BaseResponse addAntexHighRisk(@RequestHeader("Authorization")String authorization, @RequestBody AntExHighRiskModel antExHighRiskModel){ + if (!authorization.contains(Authorization)){ + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + return antenatalExaminationFacade.addAntexHighRisk(antExHighRiskModel,userId); + } + + *//** + * 查询产检高危手册(大同) + * @param parentId + * @return + *//* + @RequestMapping(method = RequestMethod.GET, value = "/dt/queryAntexHighRisk") + @ResponseBody + public BaseResponse queryAntexHighRisk(@RequestHeader("Authorization")String authorization, @RequestParam String parentId){ + if (!authorization.contains(Authorization)){ + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + return antenatalExaminationFacade.queryAntexHighRisk(parentId,userId); + } + + @RequestMapping(method = RequestMethod.POST, value = "/dt/addPatientNipt") + @ResponseBody + public BaseResponse addPatientNipt(@RequestHeader("Authorization")String authorization, @RequestBody PatientNiptDTO patientNiptDTO){ + if (!authorization.contains(Authorization)){ + return new BaseResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + return antenatalExaminationFacade.addPatientNipt(patientNiptDTO,userId); + }*/ + //大同需要特殊处理的护士名称 + private static final String doctors="孙慧洁,曹琴,温燕芳,牛冬燕,王改然,杜文瑞,习亚美,卫娜,施春花,胡雪娇,田保来"; + + /** + * 预约挂号列表查询 + * @param authorization + * @param doctor + * @param startTime + * @param endTime + * @param name + * @return + */ + /*@RequestMapping(method = RequestMethod.GET, value = "/dt/appointment") + @ResponseBody + public BaseResponse getAppointment(@RequestHeader("Authorization")String authorization, + @RequestParam String doctor, + @RequestParam String startTime, + @RequestParam String endTime, + @RequestParam(required = false) Integer isBuild, + @RequestParam(required = false) Integer expire, + @RequestParam(required = false) String name, + @RequestParam(required = false) String doctorName, + @RequestParam(required = false) Integer page, + @RequestParam(required = false) Integer limit + + ) { + if (!authorization.contains(Authorization)){ + return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + BaseResponse baseResponse=new BaseResponse(); + startTime=startTime+" 00:00:00"; + endTime=endTime+" 23:59:59"; + String dept=null; + String need=null; + if (doctors.contains(doctor)){ + doctor=doctorName; + dept="产科"; + if (isBuild==null && expire==null){ + need="true"; + } + } + AppointmentQuery appointmentQuery=new AppointmentQuery(); + appointmentQuery.setDoctor(doctor); + appointmentQuery.setStartTime(startTime); + appointmentQuery.setEndTime(endTime); + appointmentQuery.setDept(dept); + appointmentQuery.setName(name); + appointmentQuery.setNeed(need); + appointmentQuery.setLimit(limit); + appointmentQuery.setPage(page); + List modelList= appointmentService.queryAppointment(appointmentQuery); + Date date=new Date(); + if (CollectionUtils.isNotEmpty(modelList)){ + Map params=new HashMap(); + boolean b=true; + if (expire!=null || isBuild!=null){ + b=false; + } + List checkList=new ArrayList<>(); + PatientsQuery patientsQuery =new PatientsQuery(); + patientsQuery.setYn(1); + patientsQuery.setHospitalId(hospitalId); + for (int i = 0,j=modelList.size(); i < j; i++) { + AppointmentModel appointmentModel= modelList.get(i); + if (StringUtils.isNotEmpty(appointmentModel.getDoctor())){ + String idCard=appointmentModel.getIdCard(); + String phone=appointmentModel.getPhone(); + String username=appointmentModel.getName(); + if (StringUtils.isNotEmpty(idCard)){ + patientsQuery.setName(null); + patientsQuery.setPhone(null); + patientsQuery.setCardNo(idCard); + }else { + if (StringUtils.isNotEmpty(username)&&StringUtils.isNotEmpty(phone)){ + patientsQuery.setCardNo(null); + patientsQuery.setName(username); + patientsQuery.setPhone(phone); + }else { + appointmentModel.setIsBuild(0); + appointmentModel.setExpire(1); + appointmentQuery.setIdCard(idCard); + appointmentModel.setAppointmentNum(appointmentService.queryAppointmentCount(appointmentQuery)); + } + } + if (appointmentModel.getIsBuild()==null){ + List patientsList= patientsService.queryPatient(patientsQuery); + if (CollectionUtils.isNotEmpty(patientsList)){ + appointmentModel.setIsBuild(1); + Patients patients= patientsList.get(0); + appointmentModel.setBookbuildingDate(patients.getBookbuildingDate()); + PatientServiceQuery patientQuery = new PatientServiceQuery(); + patientQuery.setParentid(patients.getId()); + patientQuery.setSerType(1); + List patientServices = patientServiceService.queryPatientService(patientQuery); + if (CollectionUtils.isNotEmpty(patientServices)){ + Date serEndTime= patientServices.get(0).getSerEndTime(); + Date serStartTime=patientServices.get(0).getUpdateDate(); + appointmentModel.setSerEndTime(serEndTime); + appointmentModel.setSerStartTime(serStartTime); + if (serEndTime.compareTo(date)>0){ + appointmentModel.setExpire(0); + }else { + appointmentModel.setExpire(1); + } + }else { + appointmentModel.setExpire(1); + } + + if (org.apache.commons.lang.StringUtils.isNotEmpty(patients.getRiskLevelId()) && !"[]".equals(patients.getRiskLevelId())) { + List level = new ArrayList(); + try { + List list = JsonUtil.patientRiskLevelIdToList(patients.getRiskLevelId()); + for (String str : list) { + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(str); + if (null != basicConfig) { + Map map = new HashMap(); + basicConfig.replenRisk(map); + if (!level.contains(map)){ + level.add(map); + } + } + } + } catch (Exception e) { + ExceptionUtils.catchException(e, "patients.getRiskLevelId error."); + } + appointmentModel.setrlevel(level); + } + }else { + appointmentModel.setIsBuild(0); + appointmentModel.setExpire(1); + if (appointmentModel.getAppointmentNum()==null || appointmentModel.getAppointmentNum()==0){ + appointmentQuery.setIdCard(idCard); + appointmentModel.setAppointmentNum(appointmentService.queryAppointmentCount(appointmentQuery)); + } + } + } + if (isBuild!=null){ + if (expire!=null){ + if (appointmentModel.getIsBuild()==isBuild&&appointmentModel.getExpire()==expire){ + checkList.add(appointmentModel); + } + }else { + if (appointmentModel.getIsBuild()==isBuild){ + checkList.add(appointmentModel); + } + } + }else { + if (expire!=null){ + if (appointmentModel.getExpire()==expire){ + checkList.add(appointmentModel); + } + } + } + } + + } + + if (b){ + params.put("data",modelList); + }else { + params.put("data",checkList); + } + if (StringUtils.isNotEmpty(need)){ + params.put("pageInfo",appointmentQuery.getPageInfo()); + } + baseResponse.setObject(params); + } + baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); + return baseResponse; + } + + *//** + * 预约统计管理科室统计列表 + * @param authorization + * @param doctor + * @param startTime + * @param endTime + * @return + *//* + @RequestMapping(method = RequestMethod.GET, value = "/dt/appointment/dept/statistics") + @ResponseBody + public BaseResponse appointmentDeptStatistics(@RequestHeader("Authorization")String authorization, + @RequestParam String doctor, + @RequestParam String startTime, + @RequestParam String endTime){ + if (!authorization.contains(Authorization)){ + return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + BaseResponse baseResponse=new BaseResponse(); + startTime=startTime+" 00:00:00"; + endTime=endTime+" 23:59:59"; + String dept=null; + //只有护士长和主任可以看统计(目前) + if (doctor.equals("田保来")||doctor.equals("孙慧洁")){ + dept="产科"; + }else { + return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + AppointmentQuery appointmentQuery=new AppointmentQuery(); + appointmentQuery.setStartTime(startTime); + appointmentQuery.setEndTime(endTime); + appointmentQuery.setDept(dept); + List modelList= appointmentService.queryAppointment(appointmentQuery); + if (CollectionUtils.isNotEmpty(modelList)){ + Map params=new HashMap(); + PatientsQuery patientsQuery =new PatientsQuery(); + patientsQuery.setYn(1); + patientsQuery.setHospitalId(hospitalId); + for (int i = 0,j=modelList.size(); i < j; i++) { + AppointmentModel appointmentModel= modelList.get(i); + String depts=appointmentModel.getDept(); + if (StringUtils.isNotEmpty(depts)){ + AppointmentData appointmentData= params.get(depts); + if (appointmentData==null){ + appointmentData=new AppointmentData(); + } + appointmentData.setDept(depts); + String idCard=appointmentModel.getIdCard(); + String phone=appointmentModel.getPhone(); + String username=appointmentModel.getName(); + if (StringUtils.isNotEmpty(idCard)){ + patientsQuery.setName(null); + patientsQuery.setPhone(null); + patientsQuery.setCardNo(idCard); + }else { + if (StringUtils.isNotEmpty(username)&&StringUtils.isNotEmpty(phone)){ + patientsQuery.setCardNo(null); + patientsQuery.setName(username); + patientsQuery.setPhone(phone); + }else { + appointmentModel.setIsBuild(0); + //未建档 + appointmentData.setUnBuildNum(appointmentData.getUnBuildNum()!=null?appointmentData.getUnBuildNum()+1:1); + } + } + if (appointmentModel.getIsBuild()==null){ + List patientsList= patientsService.queryPatient(patientsQuery); + if (CollectionUtils.isNotEmpty(patientsList)){ + //已经建档 + //新建档人数等于当天建档人数 + appointmentData.setBuildNum(appointmentData.getBuildNum()!=null?appointmentData.getBuildNum()+1:1); + Patients patients= patientsList.get(0); + if (DateUtil.isBetween(patients.getCreated(),DateUtil.parseYMDHMS(startTime),DateUtil.parseYMDHMS(endTime))){ + appointmentData.setNewBuildNum(appointmentData.getNewBuildNum()!=null?appointmentData.getNewBuildNum()+1:1); + } + }else { + //未建档 + appointmentData.setUnBuildNum(appointmentData.getUnBuildNum()!=null?appointmentData.getUnBuildNum()+1:1); + } + } + appointmentData.setAppointmentNum(appointmentData.getAppointmentNum()!=null?appointmentData.getAppointmentNum()+1:1); + params.put(depts,appointmentData); + } + } + // 使用TreeMap进行排序 + Map sortedMap = new TreeMap<>(new ChineseComparator()); + sortedMap.putAll(params); + baseResponse.setObject(sortedMap); + } + baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); + return baseResponse; + } + // 自定义Comparator,用于按照定义好的顺序排序 + static class ChineseComparator implements Comparator { + @Override + public int compare(String s1, String s2) { + try { + return getPinyin(s1).compareTo(getPinyin(s2)); + }catch (Exception e){ + System.out.println(s1+" "+s2); + } + return 0; + } + + } + private static Integer getPinyin(String s) { + Map map = new HashMap<>(); + map.put("产后康复门诊", 10); + map.put("产科七病区", 7); + map.put("产科三病区", 3); + map.put("产科二病区", 2); + map.put("产科五病区", 5); + map.put("产科六病区", 6); + map.put("产科门诊", 1); + return map.get(s); + } + + *//** + * 预约统计管理列表 + * @param authorization + * @param doctor + * @param startTime + * @param endTime + * @return + *//* + @RequestMapping(method = RequestMethod.GET, value = "/dt/appointment/statistics") + @ResponseBody + public BaseResponse appointmentStatistics(@RequestHeader("Authorization")String authorization, + @RequestParam String doctor, + @RequestParam String startTime, + @RequestParam String endTime, + @RequestParam(required = false) String deptName + ){ + if (!authorization.contains(Authorization)){ + return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + BaseResponse baseResponse=new BaseResponse(); + startTime=startTime+" 00:00:00"; + endTime=endTime+" 23:59:59"; + String dept=null; + //只有护士长和主任可以看统计(目前) + if (doctor.equals("田保来")||doctor.equals("孙慧洁")){ + if (StringUtils.isEmpty(deptName)){ + dept="产科"; + } + }else { + return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + AppointmentQuery appointmentQuery=new AppointmentQuery(); + appointmentQuery.setStartTime(startTime); + appointmentQuery.setEndTime(endTime); + appointmentQuery.setDept(dept); + appointmentQuery.setDeptName(deptName); + List modelList= appointmentService.queryAppointment(appointmentQuery); + if (CollectionUtils.isNotEmpty(modelList)){ + Map params=new HashMap(); + PatientsQuery patientsQuery =new PatientsQuery(); + patientsQuery.setYn(1); + patientsQuery.setHospitalId(hospitalId); + for (int i = 0,j=modelList.size(); i < j; i++) { + AppointmentModel appointmentModel= modelList.get(i); + String doctorName=StringUtils.isNotEmpty(appointmentModel.getDoctor())?appointmentModel.getDoctor():"-"; + AppointmentData appointmentData= params.get(doctorName); + if (appointmentData==null){ + appointmentData=new AppointmentData(); + } + appointmentData.setDoctor(doctorName); + if (StringUtils.isEmpty(appointmentData.getDept())){ + appointmentData.setDept(appointmentModel.getDept()); + } + String idCard=appointmentModel.getIdCard(); + String phone=appointmentModel.getPhone(); + String username=appointmentModel.getName(); + if (StringUtils.isNotEmpty(idCard)){ + patientsQuery.setName(null); + patientsQuery.setPhone(null); + patientsQuery.setCardNo(idCard); + }else { + if (StringUtils.isNotEmpty(username)&&StringUtils.isNotEmpty(phone)){ + patientsQuery.setCardNo(null); + patientsQuery.setName(username); + patientsQuery.setPhone(phone); + }else { + appointmentModel.setIsBuild(0); + //未建档 + appointmentData.setUnBuildNum(appointmentData.getUnBuildNum()!=null?appointmentData.getUnBuildNum()+1:1); + } + } + if (appointmentModel.getIsBuild()==null){ + List patientsList= patientsService.queryPatient(patientsQuery); + if (CollectionUtils.isNotEmpty(patientsList)){ + //已经建档 + //新建档人数等于当天建档人数 + Patients patients= patientsList.get(0); + if (DateUtil.isBetween(patients.getCreated(),DateUtil.parseYMDHMS(startTime),DateUtil.parseYMDHMS(endTime))){ + appointmentData.setNewBuildNum(appointmentData.getNewBuildNum()!=null?appointmentData.getNewBuildNum()+1:1); + } + appointmentData.setBuildNum(appointmentData.getBuildNum()!=null?appointmentData.getBuildNum()+1:1); + }else { + //未建档 + appointmentData.setUnBuildNum(appointmentData.getUnBuildNum()!=null?appointmentData.getUnBuildNum()+1:1); + } + } + appointmentData.setAppointmentNum(appointmentData.getAppointmentNum()!=null?appointmentData.getAppointmentNum()+1:1); + params.put(doctorName,appointmentData); + } + baseResponse.setObject(params); + } + baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); + return baseResponse; + } + + *//** + * 统计数据导出 + *//* + @RequestMapping(method = RequestMethod.POST, value = "/dt/appointment/statistics/export") + @ResponseBody + public void statisticsExport(@RequestHeader("Authorization")String authorization, + @RequestBody AppointmentExport appointmentExport, + HttpServletResponse response){ + if (authorization.contains(Authorization)){ + String doctor= appointmentExport.getDoctor(); + String dept=null; + if (doctor.equals("田保来")||doctor.equals("孙慧洁")){ + dept="产科"; + }else { + return; + } + try { + Map cnames = new LinkedHashMap <>(); + cnames.put("dept", "科室"); + cnames.put("appointmentSumNum", "科室预约就诊总人数"); + cnames.put("buildSumNum", "科室建立电子档案总人数"); + cnames.put("newBuildSumNum", "科室新建档总人数"); + cnames.put("unBuildSumNum", "科室未档总人数"); + cnames.put("buildSumRate", "科室已建档总比率");//已建档/总 + cnames.put("newBuildSumRate", "科室新建档总比率");//新建/(总-已建档+新建档) + cnames.put("doctor", "医生"); + cnames.put("appointmentNum", "预约就诊人数"); + cnames.put("buildNum", "建立电子档案人数"); + cnames.put("newBuildNum", "新建档人数"); + cnames.put("unBuildNum", "未档总人数"); + cnames.put("buildRate", "已建档比率"); + cnames.put("newBuildRate", "新建档比率"); + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", "attachment;fileName=" + "科室建档统计.xls"); + OutputStream out = response.getOutputStream(); + Map> params= appointmentExport.getParams(); + AppointmentQuery appointmentQuery=new AppointmentQuery(); + String startTime=appointmentExport.getStartTime()+" 00:00:00"; + String endTime=appointmentExport.getEndTime()+" 23:59:59"; + appointmentQuery.setStartTime(startTime); + appointmentQuery.setEndTime(endTime); + appointmentQuery.setDept(dept); + List modelList= appointmentService.queryAppointment(appointmentQuery); + if (CollectionUtils.isNotEmpty(modelList)&&!params.isEmpty()){ + Map>> data=new HashMap(); + Map> params1=new HashMap(); + PatientsQuery patientsQuery =new PatientsQuery(); + patientsQuery.setYn(1); + patientsQuery.setHospitalId(hospitalId); + for (int i = 0,j=modelList.size(); i < j; i++) { + AppointmentModel appointmentModel= modelList.get(i); + String doctorName=StringUtils.isNotEmpty(appointmentModel.getDoctor())?appointmentModel.getDoctor():"-"; + String depts=appointmentModel.getDept(); + Map appointmentData= params1.get(doctorName+","+depts); + if (appointmentData==null){ + appointmentData=new HashMap<>(); + } + appointmentData.put("doctor",doctorName); + appointmentData.put("dept",depts); + String idCard=appointmentModel.getIdCard(); + String phone=appointmentModel.getPhone(); + String username=appointmentModel.getName(); + if (StringUtils.isNotEmpty(idCard)){ + patientsQuery.setName(null); + patientsQuery.setPhone(null); + patientsQuery.setCardNo(idCard); + }else { + if (StringUtils.isNotEmpty(username)&&StringUtils.isNotEmpty(phone)){ + patientsQuery.setCardNo(null); + patientsQuery.setName(username); + patientsQuery.setPhone(phone); + }else { + appointmentModel.setIsBuild(0); + //未建档 + appointmentData.put("unBuildNum",appointmentData.get("unBuildNum")!=null?Integer.valueOf(String.valueOf(appointmentData.get("unBuildNum")))+1:1); + } + } + if (appointmentModel.getIsBuild()==null){ + List patientsList= patientsService.queryPatient(patientsQuery); + if (CollectionUtils.isNotEmpty(patientsList)){ + //已经建档 + //新建档人数等于当天建档人数 + appointmentData.put("buildNum",appointmentData.get("buildNum")!=null?Integer.valueOf(String.valueOf(appointmentData.get("buildNum")))+1:1); + Patients patients= patientsList.get(0); + if (DateUtil.isBetween(patients.getCreated(),DateUtil.parseYMDHMS(startTime),DateUtil.parseYMDHMS(endTime))){ + appointmentData.put("newBuildNum",appointmentData.get("newBuildNum")!=null?Integer.valueOf(String.valueOf(appointmentData.get("newBuildNum")))+1:1); + } + }else { + //未建档 + appointmentData.put("unBuildNum",appointmentData.get("unBuildNum")!=null?Integer.valueOf(String.valueOf(appointmentData.get("unBuildNum")))+1:1); + } + } + appointmentData.put("appointmentNum",appointmentData.get("appointmentNum")!=null?Integer.valueOf(String.valueOf(appointmentData.get("appointmentNum")))+1:1); + params1.put(doctorName+","+depts,appointmentData); + + } + for (Map.Entry> entry: params1.entrySet()) { + Map value= entry.getValue(); + // System.out.println(value); + String deptName= String.valueOf(value.get("dept")); + if (StringUtils.isNotEmpty(deptName)){ + List> data1 =data.get(deptName); + if (CollectionUtils.isEmpty(data1)){ + data1=new ArrayList<>(); + } + data1.add(value); + data.put(deptName,data1); + } + } + ExcelUtil.toExcelRegion(out,params ,data, cnames); + } + } catch (IOException e) { + ExceptionUtils.catchException(e, e.getMessage()); + } + } + } + + *//** + * 挂号信息同步 + * @param authorization + * @param doctor + * @param date + * @return + *//* + @RequestMapping(method = RequestMethod.GET, value = "/dt/sync/appointment") + @ResponseBody + public BaseResponse syncAppointmentList(@RequestHeader("Authorization")String authorization, + @RequestParam(required = true) String doctor, + @RequestParam(required = true) String date){ + if (!authorization.contains(Authorization)){ + return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + Map params=new HashMap<>(); + if (doctors.contains(doctor)){ + doctor="孙慧洁"; + } + params.put("doctor",doctor); + params.put("ksrq",date); + params.put("jsrq",date); + HttpClientUtil.doGet("http://192.168.5.23:9090/dtdyrm/getdtAppointment" ,params,"utf-8",null); + return new BaseResponse(); + } + @Autowired + private IdtdyrmFmService idtdyrmFmService; + //导出 + @ResponseBody + @RequestMapping(value = "/dt/appointment/export", method = RequestMethod.GET) + public void reportFmRecord(@RequestHeader("Authorization")String authorization, + @RequestParam String doctor, + @RequestParam String startTime, + @RequestParam String endTime, + @RequestParam(required = false) String name, + @RequestParam(required = false) String doctorName, + HttpServletResponse response) { + if (!authorization.contains(Authorization)){ + throw new RuntimeException("权限异常"); + } + if (doctors.contains(doctor)){ + doctor="孙慧洁"; + } + idtdyrmFmService.reportAppointmentList(response,doctor,startTime,endTime,name,doctorName); + } + + + + @RequestMapping(method = RequestMethod.GET, value = "/pc/pregnancy") + @ResponseBody + public String getPregnancyList( String page, + String limit, + String phone, + String days, + String type, + String categoryId){ + + Map params=new HashMap<>(); + params.put("page",page); + params.put("limit",limit); + params.put("phone",phone); + params.put("days",days); + String str; + if ("4312".equals(categoryId) ){ + str= HttpClientUtil.doGet(MEMBER_BABY_URL+"/wx/pc/riskGuide" ,params,"utf-8",null); + }else { + params.put("categoryId",categoryId); + params.put("type",type); + str= HttpClientUtil.doGet(MEMBER_BABY_URL+"/wx/pc/articles/precise" ,params,"utf-8",null); + } + return str; + }*/ +}