diff --git a/platform-operate-api/src/main/java/com/lyms/hospitalapi/linchengfy/LcfyFmService.java b/platform-operate-api/src/main/java/com/lyms/hospitalapi/linchengfy/LcfyFmService.java index 7fc5469..c9df1b4 100644 --- a/platform-operate-api/src/main/java/com/lyms/hospitalapi/linchengfy/LcfyFmService.java +++ b/platform-operate-api/src/main/java/com/lyms/hospitalapi/linchengfy/LcfyFmService.java @@ -3,6 +3,8 @@ package com.lyms.hospitalapi.linchengfy; import com.lyms.hospitalapi.dzfy.Fm; import com.lyms.hospitalapi.qhdfy.FmItem; import com.lyms.platform.biz.service.PatientsService; +import com.lyms.platform.biz.service.PersonService; +import com.lyms.platform.biz.service.YunBookbuildingService; import com.lyms.platform.common.enums.FmTypeEnums; import com.lyms.platform.common.enums.RenShenJieJuEnums; import com.lyms.platform.common.enums.TpmcTypeEnums; @@ -20,6 +22,7 @@ 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.pojo.PersonModel; import com.lyms.platform.query.PatientsQuery; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -39,7 +42,10 @@ public class LcfyFmService implements IlcFyFmService { @Autowired private PatientsService patientsService; - + @Autowired + private YunBookbuildingService yunBookbuildingService; + @Autowired + private PersonService personService; @Autowired private MatDeliverFacade matDeliverFacade; @@ -52,11 +58,13 @@ public class LcfyFmService implements IlcFyFmService { @Autowired private PatientServiceFacade patientServiceFacade; - private static Map ONE_ENUMS = new HashMap<>(); + private static Map ONE_ENUMS = new HashMap <>(); - private static Map babyMap = new HashMap<>(); + private static Map babyMap = new HashMap <>(); + + private static final String HOSPITALID = "216"; +// private static final String HOSPITALID = "2100001296"; - private static final String HOSPITALID = "2100001296"; static { ONE_ENUMS.put(0, "长"); ONE_ENUMS.put(1, "次"); @@ -67,51 +75,50 @@ public class LcfyFmService implements IlcFyFmService { ONE_ENUMS.put(6, "七"); - List b1 = new ArrayList<>(); + List b1 = new ArrayList <>(); b1.add("长女"); b1.add("次女"); babyMap.put("00", b1); - List b2 = new ArrayList<>(); + List b2 = new ArrayList <>(); b2.add("长子"); b2.add("次子"); babyMap.put("11", b2); - List b3 = new ArrayList<>(); + List b3 = new ArrayList <>(); b3.add("之子"); b3.add("之女"); - List b4 = new ArrayList<>(); + List b4 = new ArrayList <>(); b4.add("之女"); b4.add("之子"); babyMap.put("01", b4); babyMap.put("10", b3); - List b5 = new ArrayList<>(); + List b5 = new ArrayList <>(); b5.add("之子"); - List b6 = new ArrayList<>(); + List b6 = new ArrayList <>(); b6.add("之女"); babyMap.put("1", b5); babyMap.put("0", b6); } - public void fmTimerWork() { + 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); + 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) { + public void syncByPhone(List list) { queryFmPatient(list); } - - public void queryFmPatient(List allList) { + public void queryFmPatient(List allList) { saveFm sfm = new saveFm(allList); Thread t = new Thread(sfm); @@ -119,12 +126,12 @@ public class LcfyFmService implements IlcFyFmService { } - private List buildBabyName(List items) { + private List buildBabyName(List items) { String id = ""; if (items.size() > 2) { int boyCount = 0; int girlCount = 0; - List l = new ArrayList<>(); + 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())) { @@ -142,12 +149,9 @@ public class LcfyFmService implements IlcFyFmService { 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())) - { + if ("男".equals(item.getBABY_SEX())) { id += "1"; - } - else if ("女".equals(item.getBABY_SEX())) - { + } else if ("女".equals(item.getBABY_SEX())) { id += "0"; } @@ -157,14 +161,12 @@ public class LcfyFmService implements IlcFyFmService { } } - public void buildBaby(FmItem item,Patients patInfo,Fm fm, Date dueDate, String babyName) - { - try{ + public void buildBaby(FmItem item, Patients patInfo, Fm fm, Date dueDate, String babyName) { + try { ExceptionUtils.catchException("buildBaby===="); - if ("死产".equals(fm.getBABY_PREGNANCY_OUT())) - { + if ("死产".equals(fm.getBABY_PREGNANCY_OUT())) { return; } @@ -172,32 +174,28 @@ public class LcfyFmService implements IlcFyFmService { usersQuery.setYn(YnEnums.YES.getId()); usersQuery.setName("产科"); usersQuery.setOrgId(new Integer(Integer.parseInt(HOSPITALID))); - List users = usersService.queryUsers(usersQuery); + List users = usersService.queryUsers(usersQuery); BabyBookbuildingAddRequest request = new BabyBookbuildingAddRequest(); request.setHospitalId(HOSPITALID); request.setMommyName(fm.getNAME()); //母亲姓名 Date bir = patInfo.getBirth(); - if(bir!=null){ + 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,"孕妇生日解析异常"); + } catch (ParseException e) { + ExceptionUtils.catchException(e, "孕妇生日解析异常"); } } - if (org.apache.commons.lang.StringUtils.isNotEmpty(fm.getIDCARD())) - { + 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())) - { + } else if (StringUtils.isNotEmpty(fm.getPHONE())) { request.setMommyCertificateTypeId("57e1dcd3f0f02e7ca519d6c6"); //证件类型 (手机号码) request.setMommyCertificateNum(fm.getPHONE()); //证件号 } @@ -214,19 +212,15 @@ public class LcfyFmService implements IlcFyFmService { try { request.setDueWeek(Integer.parseInt(week)); //分娩孕周 - }catch (Exception e) - { + } catch (Exception e) { } } String fmfs = ""; - if (fm.getDELIVERY_MODE() != null && "剖宫产".equals(fm.getDELIVERY_MODE())) - { + if (fm.getDELIVERY_MODE() != null && "剖宫产".equals(fm.getDELIVERY_MODE())) { fmfs = FmTypeEnums.O1.getId(); - } - else - { + } else { fmfs = FmTypeEnums.O.getId(); } @@ -235,26 +229,26 @@ public class LcfyFmService implements IlcFyFmService { //request.setDueCount(item.getCjc());//第几产 String weight = fm.getSBABY_WEIGHT(); String height = fm.getSBABY_HEIGHT(); - if(weight!=null){ + if (weight != null) { DecimalFormat df = new DecimalFormat("#.00"); double w = Double.parseDouble(weight); - request.setBabyWeight(df.format(w/1000)); //体重 + request.setBabyWeight(df.format(w / 1000)); //体重 } - if(height!=null){ + if (height != null) { request.setBabyHeight(height); //身长 } - Map map = new HashMap<>(); + 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){ + if (pf1 != null) { map.put("pf1", pf1); } - if(pf5!=null){ + if (pf5 != null) { map.put("pf5", pf5); } - if(pf10!=null){ + if (pf10 != null) { map.put("pf10", pf10); } @@ -285,106 +279,116 @@ public class LcfyFmService implements IlcFyFmService { babyBookbuildingFacade.addBabyBookbuilding(request, users.get(0).getId()); - }catch (Exception e) - { + } catch (Exception e) { ExceptionUtils.catchException(e, "buildBaby exception"); e.printStackTrace(); } } - public class saveFm implements Runnable{ + public class saveFm implements Runnable { - private List allList; + private List allList; - public saveFm(List list){ - this.allList=list; + public saveFm(List list) { + this.allList = list; } - public void run(){ + 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(); + List users = new ArrayList (); Date dueDate = null; - List babies = new ArrayList<>(); + List babies = new ArrayList <>(); MatDeliverAddRequest deliverAddRequest = new MatDeliverAddRequest(); - for(Fm allFm:allList){ - a=0; - count=0; - System.out.println("0-------------"+allFm.getBABY_PREGNANCY_OUT()); - if (!"1".equals(allFm.getBABY_PREGNANCY_OUT())) - { + Patients patient =null; + for (Fm allFm : allList) { + System.out.println("0-------------" + allFm.getBABY_PREGNANCY_OUT()); + if (!"1".equals(allFm.getBABY_PREGNANCY_OUT())) { continue; } - if (StringUtils.isEmpty(allFm.getPHONE()) && StringUtils.isEmpty(allFm.getIDCARD())) - { + 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()}; - System.out.println("1----------"+strs); + String[] strs = new String[]{allFm.getPHONE(), allFm.getIDCARD()}; query.setPc(strs); - //查询该孕妇是否在孕产婴系统中建档 - List patientses = patientsService.queryPatient(query); - System.out.println("2----------"+patientses.size()); + System.out.println("1----query--" + query.convertToQuery().convertToMongoQuery()); + List patientses = patientsService.queryPatient(query); + System.out.println("2----patientses--" + ( CollectionUtils.isNotEmpty(patientses)?patientses.size():null)); - Patients patient = new Patients(); - if(CollectionUtils.isNotEmpty(patientses)){ - ExceptionUtils.catchException("patientses"+patientses); - patient = patientses.get(0); + //获取指定医生id + try { UsersQuery usersQuery = new UsersQuery(); usersQuery.setYn(YnEnums.YES.getId()); usersQuery.setOrgId(new Integer(Integer.parseInt(HOSPITALID))); - usersQuery.setName("产科"); + usersQuery.setName("qing"); +// usersQuery.setName("产科"); users = usersService.queryUsers(usersQuery); - System.out.println("3----------"+users.size()); + } catch (NumberFormatException e) { + e.printStackTrace(); + } + System.out.println("3----users--" +( CollectionUtils.isNotEmpty(users)?users.size():null)); + if (CollectionUtils.isNotEmpty(patientses)) { + patient = patientses.get(0); + System.out.println("4----patient.getId()--" +patient.getId()); + + } else if (StringUtils.isNotEmpty(allFm.getNAME()) + && StringUtils.isNotEmpty(allFm.getBABY_DELIVERY_TIME()) + && StringUtils.isNotEmpty(allFm.getPHONE()) + && StringUtils.isNotEmpty(allFm.getIDCARD()) + && StringUtils.isNotEmpty(allFm.getNAME()) + && CollectionUtils.isNotEmpty(users) + ) { + patient = addPatients(users, allFm); + System.out.println("4.1----patient.getId()--" +patient.getId()); + } + + if (patient != null) { + System.out.println("5-----------"); if (CollectionUtils.isNotEmpty(users) && users.get(0).getId() != null) { Date dateTime = fmt.parse(allFm.getBABY_DELIVERY_TIME()); - if(dateTime!=null){ + if (dateTime != null) { if (!StringUtils.isNotEmpty(allFm.getBABY_DELIVERY_TIME().toString())) { continue; - }else{ + } else { dueDate = dateTime; } - }else{ + } else { continue; } - Map> map = new HashMap<>(); - Map map1 = new HashMap<>(); - Map map2 = new HashMap<>(); - Map map3 = new HashMap<>(); - Map totalMap = new HashMap<>(); + 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)); + 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_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); + 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;//总产程小时数 @@ -394,7 +398,7 @@ public class LcfyFmService implements IlcFyFmService { deliverAddRequest.setProdprocess(map); deliverAddRequest.setTotalprocess(totalMap); - System.out.println("4----------"+allFm.getDELIVER_DOCTOR()); + System.out.println("6----------" + allFm.getDELIVER_DOCTOR()); deliverAddRequest.setDeliverDoctor(allFm.getDELIVER_DOCTOR()); deliverAddRequest.setDueDate(DateUtil.getyyyy_MM_dd(dueDate)); @@ -405,8 +409,7 @@ public class LcfyFmService implements IlcFyFmService { if (StringUtils.isNotEmpty(allFm.getDUE_WEEK())) { week = allFm.getDUE_WEEK() + "周"; - if (StringUtils.isNotEmpty(allFm.getDUE_WEEK()) && StringUtils.isNotEmpty(allFm.getDUE_DAY())) - { + if (StringUtils.isNotEmpty(allFm.getDUE_WEEK()) && StringUtils.isNotEmpty(allFm.getDUE_DAY())) { week += allFm.getDUE_DAY() + "天"; } @@ -415,7 +418,7 @@ public class LcfyFmService implements IlcFyFmService { deliverAddRequest.setTireNumber(allFm.getFETUS_NUM());// 胎数(之前赋值为死值1) Integer placenta_Num = allFm.getPLACENTA_NUM(); - if(placenta_Num!=null){ + if (placenta_Num != null) { deliverAddRequest.setPlacenta(allFm.getPLACENTA_NUM().toString());// 胎盘(之前赋值为死值1) } if ("完好".equals(allFm.getPERINEAL_CONDITION()) || "".equals(allFm.getPERINEAL_CONDITION())) { @@ -433,7 +436,7 @@ public class LcfyFmService implements IlcFyFmService { } Integer th_Lose = allFm.getTH_LOSE_BLOOD(); - if(th_Lose!=null){ + if (th_Lose != null) { if (StringUtils.isNotEmpty(allFm.getTH_LOSE_BLOOD().toString())) { deliverAddRequest.settHloseBloodL(Double.parseDouble(allFm.getTH_LOSE_BLOOD().toString())); } @@ -442,18 +445,15 @@ public class LcfyFmService implements IlcFyFmService { Map deliveryMode = new HashMap(); //分娩方式 String fmfs = ""; - if (allFm.getDELIVERY_MODE() != null && "手术产".equals(allFm.getDELIVERY_MODE())) - { + if (allFm.getDELIVERY_MODE() != null && "手术产".equals(allFm.getDELIVERY_MODE())) { fmfs = FmTypeEnums.O1.getId(); - } - else - { + } else { fmfs = FmTypeEnums.O.getId(); } - deliveryMode.put("fmfs",fmfs); + deliveryMode.put("fmfs", fmfs); deliverAddRequest.setDeliveryMode(deliveryMode); //胎盘信息 - List extPlacentas = new ArrayList<>(); + List extPlacentas = new ArrayList <>(); MaternalDeliverModel.ExtPlacenta extPlacenta = new MaternalDeliverModel.ExtPlacenta(); String tpmcType = ""; //胎盘娩出方式 if ("手术产".equals(allFm.getTMCTYPE()) || "手取胎盘".equals(allFm.getTMCTYPE())) { @@ -468,18 +468,18 @@ public class LcfyFmService implements IlcFyFmService { //儿童 MatDeliverAddRequest.Baby baby = new MatDeliverAddRequest.Baby(); - baby.setBabyWeight(allFm.getBABY_WEIGHT()==null?null:allFm.getBABY_WEIGHT().toString()); - Map as = new HashMap<>(); + baby.setBabyWeight(allFm.getBABY_WEIGHT() == null ? null : allFm.getBABY_WEIGHT().toString()); + 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){ + if (pf1 != null) { as.put("pf1", allFm.getSBABY_APGAR_SCORE_ONE()); } - if(pf5!=null){ + if (pf5 != null) { as.put("pf5", allFm.getSBABY_APGAR_SCORE_FIVE()); } - if(pf10!=null){ + if (pf10 != null) { as.put("pf10", allFm.getSBABY_APGAR_SCORE_TEN()); } @@ -489,24 +489,24 @@ public class LcfyFmService implements IlcFyFmService { String babyHeight = allFm.getSBABY_HEIGHT(); String babyWeight = allFm.getSBABY_WEIGHT(); Integer baby_Asphyxiam = allFm.getBABY_ASPHYXIAM(); - if(babyHeight!=null){ + if (babyHeight != null) { baby.setBabyHeight(allFm.getSBABY_HEIGHT());//新生儿生长 } - if(babyWeight!=null){ + if (babyWeight != null) { baby.setBabyWeight(allFm.getSBABY_WEIGHT());//新生儿重量 } - if(baby_Asphyxiam!=null){ + if (baby_Asphyxiam != null) { baby.setAsphyxiaM(allFm.getBABY_ASPHYXIAM().toString()); //窒息分钟 } - baby.setDeformity((allFm.getBABY_DEFORMITY()==null?0:1)); //畸形 0非畸形 1畸形 + baby.setDeformity((allFm.getBABY_DEFORMITY() == null ? 0 : 1)); //畸形 0非畸形 1畸形 /* String baby_Pregnancy_Out = allFm.getBABY_PREGNANCY_OUT()=="1"?"活产":""; if(baby_Pregnancy_Out!=null && StringUtils.isNotEmpty(baby_Pregnancy_Out)){ baby.setPregnancyOut(RenShenJieJuEnums.getIdByName("活产")); // 妊娠结局 }*/ - System.out.println("5-------------"+allFm.getBABY_PREGNANCY_OUT()=="1"?"活产":""); + System.out.println("7-------------" + allFm.getBABY_PREGNANCY_OUT() == "1" ? "活产" : ""); baby.setPregnancyOut(RenShenJieJuEnums.getIdByName("活产")); // 妊娠结局 baby.setDueTime(fmt.format(dueDate));//分娩时间 @@ -516,23 +516,69 @@ public class LcfyFmService implements IlcFyFmService { } } - if(a==0){ + if (patient != null && CollectionUtils.isNotEmpty(babies)) { deliverAddRequest.setBabies(babies); deliverAddRequest.setFmHospital(HOSPITALID); //设置为临城 ExceptionUtils.catchException("deliverAddRequest===" + deliverAddRequest); - if(users!=null && users.size()>0){ + if (users != null && users.size() > 0) { matDeliverFacade.addOrUpdateMatDeliver(deliverAddRequest, users.get(0).getId()); } } } catch (Exception e) { - ExceptionUtils.catchException(e, "sql执行异常"); + ExceptionUtils.catchException(e, "执行异常"); e.printStackTrace(); } } - } + private Patients addPatients(List users, Fm allFm) { + Patients patient=new Patients();//添加产妇基本信息 + try { + PersonModel pmodel = new PersonModel(); + pmodel.setName(allFm.getNAME()); + pmodel.setBirth(DateUtil.parseYMD(allFm.getBABY_DELIVERY_TIME())); + pmodel.setPhone(allFm.getPHONE()); + pmodel.setCardNo(allFm.getIDCARD()); + pmodel.setType(3); + pmodel.setYn(YnEnums.YES.getId()); + pmodel.setModified(new Date()); + pmodel.setCreated(new Date()); + PersonModel yunModel = personService.addPerson(pmodel); + //添加产妇建档 + + Patients pat1 = new Patients(); + pat1.setUsername(allFm.getNAME()); + pat1.setPcerteTypeId(""); + pat1.setCardNo(allFm.getIDCARD()); + pat1.setBirth(DateUtil.parseYMD(allFm.getBABY_DELIVERY_TIME())); + pat1.setPhone(allFm.getPHONE()); + pat1.setFmDate(DateUtil.parseYMD(allFm.getBABY_DELIVERY_TIME())); +// pat1.setServiceStatus(request.getServiceStatus()); +// pat1.setServiceType(request.getServiceType()); + pat1.setHospitalId(HOSPITALID); + pat1.setBookbuildingDate(new Date()); + pat1.setYn(YnEnums.YES.getId()); + pat1.setBuildType(0); + pat1.setDueStatus(0); + pat1.setType(3); //1孕妇 3 产妇 + pat1.setPid(yunModel.getId()); + if (users.get(0).getId() != null) { + pat1.setBookbuildingDoctor(users.get(0).getId().toString()); + } + Date lastM = DateUtil.addDay(DateUtil.parseYMD(allFm.getBABY_DELIVERY_TIME()), -280); + pat1.setLastMenses(lastM); + pat1.setDueDate(DateUtil.parseYMD(allFm.getBABY_DELIVERY_TIME())); + pat1.setCreated(new Date()); + patient = yunBookbuildingService.addPregnantBookbuilding(pat1); + + } catch (Exception e) { + e.printStackTrace(); + } + return patient; + } + + } }