diff --git a/platform-operate-api/src/main/java/com/lyms/hospitalapi/nanhe/NhfyFmService.java b/platform-operate-api/src/main/java/com/lyms/hospitalapi/nanhe/NhfyFmService.java new file mode 100644 index 0000000..4744044 --- /dev/null +++ b/platform-operate-api/src/main/java/com/lyms/hospitalapi/nanhe/NhfyFmService.java @@ -0,0 +1,527 @@ +package com.lyms.hospitalapi.nanhe; + +import com.lyms.hospitalapi.dzfy.Fm; +import com.lyms.hospitalapi.qhdfy.FmItem; +import com.lyms.platform.biz.service.PatientsService; +import com.lyms.platform.common.enums.FmTypeEnums; +import com.lyms.platform.common.enums.RenShenJieJuEnums; +import com.lyms.platform.common.enums.TpmcTypeEnums; +import com.lyms.platform.common.enums.YnEnums; +import com.lyms.platform.common.utils.DateUtil; +import com.lyms.platform.common.utils.ExceptionUtils; +import com.lyms.platform.common.utils.StringUtils; +import com.lyms.platform.operate.web.facade.BabyBookbuildingFacade; +import com.lyms.platform.operate.web.facade.MatDeliverFacade; +import com.lyms.platform.operate.web.facade.PatientServiceFacade; +import com.lyms.platform.operate.web.request.BabyBookbuildingAddRequest; +import com.lyms.platform.operate.web.request.MatDeliverAddRequest; +import com.lyms.platform.permission.model.Users; +import com.lyms.platform.permission.model.UsersQuery; +import com.lyms.platform.permission.service.UsersService; +import com.lyms.platform.pojo.MaternalDeliverModel; +import com.lyms.platform.pojo.Patients; +import com.lyms.platform.query.PatientsQuery; +import org.apache.commons.collections.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.text.DecimalFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by Administrator on 2018/1/4. + */ +@Service("lnhFyFmService") +public class NhfyFmService implements InhFyFmService { + + @Autowired + private PatientsService patientsService; + + @Autowired + private MatDeliverFacade matDeliverFacade; + + @Autowired + private UsersService usersService; + + @Autowired + private BabyBookbuildingFacade babyBookbuildingFacade; + + @Autowired + private PatientServiceFacade patientServiceFacade; + + private static Map ONE_ENUMS = new HashMap<>(); + + private static Map babyMap = new HashMap<>(); + + private static final String HOSPITALID = "1000000115"; + static { + ONE_ENUMS.put(0, "长"); + ONE_ENUMS.put(1, "次"); + ONE_ENUMS.put(2, "三"); + ONE_ENUMS.put(3, "四"); + ONE_ENUMS.put(4, "五"); + ONE_ENUMS.put(5, "六"); + ONE_ENUMS.put(6, "七"); + + + List b1 = new ArrayList<>(); + b1.add("长女"); + b1.add("次女"); + babyMap.put("00", b1); + + List b2 = new ArrayList<>(); + b2.add("长子"); + b2.add("次子"); + babyMap.put("11", b2); + + List b3 = new ArrayList<>(); + b3.add("之子"); + b3.add("之女"); + + List b4 = new ArrayList<>(); + b4.add("之女"); + b4.add("之子"); + babyMap.put("01", b4); + babyMap.put("10", b3); + List b5 = new ArrayList<>(); + b5.add("之子"); + List b6 = new ArrayList<>(); + b6.add("之女"); + + babyMap.put("1", b5); + babyMap.put("0", b6); + } + + public void fmTimerWork() { + SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date end = new Date(new Date().getTime()-1000*60*60); + Date start = new Date(end.getTime()-1000*60*60*2); + String startStr = fmt.format(start); + String endStr = fmt.format(end); + System.out.println("start=" + startStr + "end=" + endStr); +// queryFmPatient(startStr, endStr, null); + } + + public void syncByPhone(List list) { + queryFmPatient(list); + } + + + + public void queryFmPatient(List allList) { + + saveFm sfm = new saveFm(allList); + Thread t = new Thread(sfm); + t.start(); + + } + + private List buildBabyName(List items) { + String id = ""; + if (items.size() > 2) { + int boyCount = 0; + int girlCount = 0; + List l = new ArrayList<>(); + for (int i = 0; i < items.size(); i++) { + Fm item = items.get(i); + if (org.apache.commons.lang.StringUtils.isNotEmpty(item.getBABY_SEX())) { + if ("男".equals(item.getBABY_SEX())) { + l.add(ONE_ENUMS.get(boyCount) + "子"); + boyCount++; + } else if ("女".equals(item.getBABY_SEX())) { + l.add(ONE_ENUMS.get(girlCount) + "女"); + girlCount++; + } + } + } + return l; + } else { + for (int i = 0; i < items.size(); i++) { + Fm item = items.get(i); + if (org.apache.commons.lang.StringUtils.isNotEmpty(item.getBABY_SEX())) { + if ("男".equals(item.getBABY_SEX())) + { + id += "1"; + } + else if ("女".equals(item.getBABY_SEX())) + { + id += "0"; + } + + } + } + return babyMap.get(id); + } + } + + public void buildBaby(FmItem item,Patients patInfo,Fm fm, Date dueDate, String babyName) + { + try{ + + ExceptionUtils.catchException("buildBaby===="); + + if ("死产".equals(fm.getBABY_PREGNANCY_OUT())) + { + return; + } + + UsersQuery usersQuery = new UsersQuery(); + usersQuery.setYn(YnEnums.YES.getId()); + usersQuery.setName("产科"); + usersQuery.setOrgId(new Integer(Integer.parseInt(HOSPITALID))); + List users = usersService.queryUsers(usersQuery); + + BabyBookbuildingAddRequest request = new BabyBookbuildingAddRequest(); + request.setHospitalId(HOSPITALID); + + request.setMommyName(fm.getNAME()); //母亲姓名 + Date bir = patInfo.getBirth(); + if(bir!=null){ + try { + SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); + Date birth = format.parse(bir.toString()); + format = new SimpleDateFormat("yyyy-MM-dd"); + request.setMommyBirthday(format.format(birth)); + }catch (ParseException e) + { + ExceptionUtils.catchException(e,"孕妇生日解析异常"); + } + } + + if (org.apache.commons.lang.StringUtils.isNotEmpty(fm.getIDCARD())) + { + request.setMommyCertificateTypeId("70ae1d93-2964-46bc-83fa-bec9ff605b1c"); //证件类型 (身份证号码) + request.setMommyCertificateNum(fm.getIDCARD()); //证件号 + } + else if (StringUtils.isNotEmpty(fm.getPHONE())) + { + request.setMommyCertificateTypeId("57e1dcd3f0f02e7ca519d6c6"); //证件类型 (手机号码) + request.setMommyCertificateNum(fm.getPHONE()); //证件号 + } + + request.setMommyPhone(fm.getPHONE()); + + request.setBabyName(babyName); + request.setSex("男".equals(item.getYexb()) ? 1 : 0); + + request.setBabyBirthday(DateUtil.getyyyy_MM_dd(dueDate)); //生日 + + if (StringUtils.isNotEmpty(fm.getDUE_WEEK())) { + String week = fm.getDUE_WEEK(); + + try { + request.setDueWeek(Integer.parseInt(week)); //分娩孕周 + }catch (Exception e) + { + + } + } + + String fmfs = ""; + if (fm.getDELIVERY_MODE() != null && "剖宫产".equals(fm.getDELIVERY_MODE())) + { + fmfs = FmTypeEnums.O1.getId(); + } + else + { + fmfs = FmTypeEnums.O.getId(); + } + + request.setDueType(fmfs);//分娩方式 + //request.setFetusCount(item.getDjt()); //第几胎 + //request.setDueCount(item.getCjc());//第几产 + String weight = fm.getSBABY_WEIGHT(); + String height = fm.getSBABY_HEIGHT(); + if(weight!=null){ + DecimalFormat df = new DecimalFormat("#.00"); + double w = Double.parseDouble(weight); + request.setBabyWeight(df.format(w/1000)); //体重 + } + if(height!=null){ + request.setBabyHeight(height); //身长 + } + + Map map = new HashMap<>(); + String pf1 = fm.getSBABY_APGAR_SCORE_ONE(); + String pf5 = fm.getSBABY_APGAR_SCORE_FIVE(); + String pf10 = fm.getSBABY_APGAR_SCORE_TEN(); + if(pf1!=null){ + map.put("pf1", pf1); + } + if(pf5!=null){ + map.put("pf5", pf5); + } + if(pf10!=null){ + map.put("pf10", pf10); + } + + request.setApgarScore(map); + request.setDeliverOrg(HOSPITALID); + + request.setBuildDoctor(users.get(0).getId() + ""); + request.setBuildDate(DateUtil.getyyyy_MM_dd(dueDate)); + //request.setHighRisk("是".equals(item.getSfgw()) ? 1 : 0); ////是否高危 0 非高危 1高危 + request.setMalformation((fm.getBABY_DEFORMITY() == null ? 0 : 1)); //畸形 0非畸形 1畸形 + //request.setMalformation("无".equals(item.getJx()) ? 0 : 1); //畸形 0非畸形 1畸形 + +// request.setServiceType(ServiceTypeEnums.STANDARD_SERVICE.getId()); //标准服务 +// request.setServiceStatus(ServiceStatusEnums.STANDARD_OPEN.getId()); //开通 + + /*if (patInfo != null && StringUtils.isNotEmpty(fm.getBHNUM())) + { + Map diags = dzfyHisService.queryHisBabyDiagnosis(fm.getBHNUM()); + if (diags != null && diags.size() > 0) + { + request.setBlNo(fm.getBHNUM()); + request.setBabyDiagnosis(diags.get("diagnosisItem") == null ? "" : diags.get("diagnosisItem").toString()); + } + }*/ + + //标准服务开通 + request.setSerInfos(patientServiceFacade.defaultServiceOpen()); + + babyBookbuildingFacade.addBabyBookbuilding(request, users.get(0).getId()); + + }catch (Exception e) + { + ExceptionUtils.catchException(e, "buildBaby exception"); + e.printStackTrace(); + } + } + + public class saveFm implements Runnable{ + + private List allList; + + public saveFm(List list){ + this.allList=list; + } + + public void run(){ + + SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try { + + System.out.println("fm=" + allList.toString()); + int a =0;//用来判断是否建了儿童档案,如果建了儿童档案就不保存分娩记录 + int count = 0; + List users = new ArrayList(); + + Date dueDate = null; + List babies = new ArrayList<>(); + MatDeliverAddRequest deliverAddRequest = new MatDeliverAddRequest(); + for(Fm allFm:allList){ + System.out.println(allFm.toString()); + a=0; + count=0; + if (!"活产".equals(allFm.getBABY_PREGNANCY_OUT())) + { + continue; + } + if (StringUtils.isEmpty(allFm.getPHONE()) && StringUtils.isEmpty(allFm.getIDCARD())) + { + continue; + } + + PatientsQuery query = new PatientsQuery(); + query.setYn(YnEnums.YES.getId()); + query.setType(1); //孕妇 + query.setDueStatus(0); //未终止妊娠 + String[] strs = new String[]{allFm.getPHONE(),allFm.getIDCARD()}; + query.setPc(strs); + + //查询该孕妇是否在孕产婴系统中建档 + List patientses = patientsService.queryPatient(query); + Patients patient = new Patients(); + if(CollectionUtils.isNotEmpty(patientses)){ + ExceptionUtils.catchException("patientses"+patientses); + patient = patientses.get(0); + UsersQuery usersQuery = new UsersQuery(); + usersQuery.setYn(YnEnums.YES.getId()); + usersQuery.setOrgId(new Integer(Integer.parseInt(HOSPITALID))); + usersQuery.setName("产房"); + users = usersService.queryUsers(usersQuery); + + if (CollectionUtils.isNotEmpty(users) && users.get(0).getId() != null) { + + Date dateTime = fmt.parse(allFm.getBABY_DELIVERY_TIME()); + if(dateTime!=null){ + if (!StringUtils.isNotEmpty(allFm.getBABY_DELIVERY_TIME().toString())) { + continue; + }else{ + dueDate = dateTime; + } + }else{ + continue; + } + + Map> map = new HashMap<>(); + Map map1 = new HashMap<>(); + Map map2 = new HashMap<>(); + Map map3 = new HashMap<>(); + Map totalMap = new HashMap<>(); + + Integer prod_Process_One = allFm.getPROD_PROCESS_ONE(); + Integer prod_Process_Two = allFm.getPROD_PROCESS_TWO(); + Integer prod_Process_Three = allFm.getPROD_PROCESS_THREE(); + if(prod_Process_One!=null){ + map1.put("h",String.valueOf(prod_Process_One.intValue()/60)); + map1.put("m",String.valueOf(prod_Process_One.intValue()%60)); + map.put("one", map1); + } + if(prod_Process_Two!=null){ + map2.put("h",String.valueOf(prod_Process_Two.intValue()/60)); + map2.put("m",String.valueOf(prod_Process_Two.intValue()%60)); + map.put("two",map2); + } + if(prod_Process_Three!=null){ + map3.put("h",String.valueOf(prod_Process_Three.intValue()/60)); + map3.put("m",String.valueOf(prod_Process_Three.intValue()%60)); + map.put("three",map3); + } + + /* int hProcess = Integer.parseInt(allFm.getTOTAL_PROCESS())/60;//总产程小时数 + int mProcess = Integer.parseInt(allFm.getTOTAL_PROCESS())%60;//总产程分钟数 + totalMap.put("h",String.valueOf(hProcess)); + totalMap.put("m",String.valueOf(mProcess));*/ + + deliverAddRequest.setProdprocess(map); + deliverAddRequest.setTotalprocess(totalMap); + deliverAddRequest.setDeliverDoctor(allFm.getDELIVER_DOCTOR()); + deliverAddRequest.setDueDate(DateUtil.getyyyy_MM_dd(dueDate)); + deliverAddRequest.setParentId(patient.getId()); + deliverAddRequest.setPid(patient.getPid()); + deliverAddRequest.setOperationCause("-"); + String week = ""; + if (StringUtils.isNotEmpty(allFm.getDUE_WEEK())) { + + week = allFm.getDUE_WEEK() + "周"; + if (StringUtils.isNotEmpty(allFm.getDUE_WEEK()) && StringUtils.isNotEmpty(allFm.getDUE_DAY())) + { + week += allFm.getDUE_DAY() + "天"; + } + + deliverAddRequest.setDueWeek(week); + } + + deliverAddRequest.setTireNumber(allFm.getFETUS_NUM());// 胎数(之前赋值为死值1) + Integer placenta_Num = allFm.getPLACENTA_NUM(); + if(placenta_Num!=null){ + deliverAddRequest.setPlacenta(allFm.getPLACENTA_NUM().toString());// 胎盘(之前赋值为死值1) + } + if ("完好".equals(allFm.getPERINEAL_CONDITION()) || "".equals(allFm.getPERINEAL_CONDITION())) { + deliverAddRequest.setPerinealCondition("full"); + } else if ("会阴切开".equals(allFm.getPERINEAL_CONDITION()) || "侧切".equals(allFm.getPERINEAL_CONDITION())) { + deliverAddRequest.setPerinealCondition("split"); + } + + if ("一度裂伤".equals(allFm.getPERINEAL_CONDITION())) { + deliverAddRequest.setSiLielevel(1); + } else if ("二度裂伤".equals(allFm.getPERINEAL_CONDITION())) { + deliverAddRequest.setSiLielevel(2); + } else if ("三度裂伤".equals(allFm.getPERINEAL_CONDITION())) { + deliverAddRequest.setSiLielevel(3); + } + + Integer th_Lose = allFm.getTH_LOSE_BLOOD(); + if(th_Lose!=null){ + if (StringUtils.isNotEmpty(allFm.getTH_LOSE_BLOOD().toString())) { + deliverAddRequest.settHloseBloodL(Double.parseDouble(allFm.getTH_LOSE_BLOOD().toString())); + } + } + + Map deliveryMode = new HashMap(); //分娩方式 + + String fmfs = ""; + if (allFm.getDELIVERY_MODE() != null && "手术产".equals(allFm.getDELIVERY_MODE())) + { + fmfs = FmTypeEnums.O1.getId(); + } + else + { + fmfs = FmTypeEnums.O.getId(); + } + deliveryMode.put("fmfs",fmfs); + deliverAddRequest.setDeliveryMode(deliveryMode); + //胎盘信息 + List extPlacentas = new ArrayList<>(); + MaternalDeliverModel.ExtPlacenta extPlacenta = new MaternalDeliverModel.ExtPlacenta(); + String tpmcType = ""; //胎盘娩出方式 + if ("手术产".equals(allFm.getTMCTYPE()) || "手取胎盘".equals(allFm.getTMCTYPE())) { + tpmcType = TpmcTypeEnums.O2.getId(); + } else if ("自然产出".equals(allFm.getTMCTYPE()) || "自然娩出".equals(allFm.getTMCTYPE())) { + tpmcType = TpmcTypeEnums.O.getId(); + } + extPlacenta.setTpmcType(tpmcType); + extPlacentas.add(extPlacenta); + deliverAddRequest.setExtPlacentas(extPlacentas); + + + //儿童 + MatDeliverAddRequest.Baby baby = new MatDeliverAddRequest.Baby(); + Map as = new HashMap<>(); + String pf1 = allFm.getSBABY_APGAR_SCORE_ONE(); + String pf5 = allFm.getSBABY_APGAR_SCORE_FIVE(); + String pf10 = allFm.getSBABY_APGAR_SCORE_TEN(); + if(pf1!=null){ + as.put("pf1", allFm.getSBABY_APGAR_SCORE_ONE()); + } + if(pf5!=null){ + as.put("pf5", allFm.getSBABY_APGAR_SCORE_FIVE()); + } + if(pf10!=null){ + as.put("pf10", allFm.getSBABY_APGAR_SCORE_TEN()); + } + + + baby.setApgarScore(as); + baby.setBabyGender("男".equals(allFm.getBABY_SEX()) ? "1" : "0"); + String babyHeight = allFm.getSBABY_HEIGHT(); + String babyWeight = allFm.getSBABY_WEIGHT(); + Integer baby_Asphyxiam = allFm.getBABY_ASPHYXIAM(); + if(babyHeight!=null){ + baby.setBabyHeight(allFm.getSBABY_HEIGHT());//新生儿生长 + } + if(babyWeight!=null){ + baby.setBabyWeight(allFm.getSBABY_WEIGHT());//新生儿重量 + } + if(baby_Asphyxiam!=null){ + baby.setAsphyxiaM(allFm.getBABY_ASPHYXIAM().toString()); //窒息分钟 + } + + baby.setDeformity((allFm.getBABY_DEFORMITY()==null?0:1)); //畸形 0非畸形 1畸形 + + String baby_Pregnancy_Out = allFm.getBABY_PREGNANCY_OUT(); + if(baby_Pregnancy_Out!=null && StringUtils.isNotEmpty(baby_Pregnancy_Out)){ + baby.setPregnancyOut(RenShenJieJuEnums.getIdByName(allFm.getBABY_PREGNANCY_OUT())); // 妊娠结局 + } + + baby.setDueTime(fmt.format(dueDate));//分娩时间 + babies.add(baby); + + } + } + } + + if(a==0){ + deliverAddRequest.setBabies(babies); + deliverAddRequest.setFmHospital(HOSPITALID); //设置为南和 + ExceptionUtils.catchException("deliverAddRequest===" + deliverAddRequest); + if(users!=null && users.size()>0){ + matDeliverFacade.addOrUpdateMatDeliver(deliverAddRequest, users.get(0).getId()); + } + } + + } catch (Exception e) { + ExceptionUtils.catchException(e, "sql执行异常"); + e.printStackTrace(); + } + + } + } + + + +} diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/FmController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/FmController.java index 4d23cc5..d692b46 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/FmController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/FmController.java @@ -2,6 +2,7 @@ package com.lyms.platform.operate.web.controller; import com.lyms.hospitalapi.dzfy.Fm; import com.lyms.hospitalapi.lpfy.IlpFyFmService; +import com.lyms.hospitalapi.nanhe.InhFyFmService; import com.lyms.platform.common.result.BaseResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -22,6 +23,9 @@ public class FmController { @Autowired private IlpFyFmService lpfyFmService; + @Autowired + private InhFyFmService lnhFyFmService; + @RequestMapping(method = RequestMethod.POST, value = "/saveFmData") @ResponseBody public String saveFmData(@RequestBody List models, @@ -29,9 +33,12 @@ public class FmController { if("17".equals(models.get(0).getVision())){ lpfyFmService.queryFmPatient(models); + }if("41".equals(models.get(0).getVision())){ + lnhFyFmService.queryFmPatient(models); } + return null; }