Commit 8e527ccc8608a33bdf6eeeb5bc22a9b89c4e80c8

Authored by gengxiaokai
1 parent 3ba82715b5

滦平妇幼分娩接口

Showing 3 changed files with 701 additions and 6 deletions

platform-operate-api/src/main/java/com/lyms/hospitalapi/lpfy/ConnTools.java View file @ 8e527cc
  1 +package com.lyms.hospitalapi.lpfy;
  2 +
  3 +import java.sql.Connection;
  4 +import java.sql.DriverManager;
  5 +import java.sql.SQLException;
  6 +
  7 +/**
  8 + * Created by Administrator on 2018/1/4.
  9 + */
  10 +public class ConnTools {
  11 +
  12 + private static String hisDirverClassName = "oracle.jdbc.driver.OracleDriver";
  13 + private static String hisUrl = "jdbc:oracle:thin:@192.168.1.136:1521:orcl";
  14 + private static String hisUser = "lis_cs";
  15 + private static String hisPassword = "lis_cs";
  16 +
  17 + public static Connection makeHisConnection() {
  18 + Connection conn = null;
  19 + try {
  20 + Class.forName(hisDirverClassName);
  21 + } catch (ClassNotFoundException e) {
  22 + e.printStackTrace();
  23 + }
  24 + try {
  25 + conn = DriverManager.getConnection(hisUrl, hisUser, hisPassword);
  26 + } catch (SQLException e) {
  27 + e.printStackTrace();
  28 + }
  29 + return conn;
  30 + }
  31 +
  32 +}
platform-operate-api/src/main/java/com/lyms/hospitalapi/lpfy/LpfyFmService.java View file @ 8e527cc
  1 +package com.lyms.hospitalapi.lpfy;
  2 +
  3 +import com.lyms.hospitalapi.dzfy.Fm;
  4 +import com.lyms.hospitalapi.qhdfy.FmItem;
  5 +import com.lyms.platform.biz.service.PatientsService;
  6 +import com.lyms.platform.common.enums.*;
  7 +import com.lyms.platform.common.utils.DateUtil;
  8 +import com.lyms.platform.common.utils.ExceptionUtils;
  9 +import com.lyms.platform.common.utils.StringUtils;
  10 +import com.lyms.platform.operate.web.facade.BabyBookbuildingFacade;
  11 +import com.lyms.platform.operate.web.facade.MatDeliverFacade;
  12 +import com.lyms.platform.operate.web.request.BabyBookbuildingAddRequest;
  13 +import com.lyms.platform.operate.web.request.MatDeliverAddRequest;
  14 +import com.lyms.platform.permission.model.Users;
  15 +import com.lyms.platform.permission.model.UsersQuery;
  16 +import com.lyms.platform.permission.service.UsersService;
  17 +import com.lyms.platform.pojo.MaternalDeliverModel;
  18 +import com.lyms.platform.pojo.Patients;
  19 +import com.lyms.platform.query.PatientsQuery;
  20 +import org.apache.commons.collections.CollectionUtils;
  21 +import org.apache.commons.dbutils.DbUtils;
  22 +import org.apache.commons.dbutils.QueryRunner;
  23 +import org.apache.commons.dbutils.handlers.BeanListHandler;
  24 +import org.springframework.beans.factory.annotation.Autowired;
  25 +import org.springframework.stereotype.Service;
  26 +
  27 +import java.sql.Connection;
  28 +import java.text.DecimalFormat;
  29 +import java.text.ParseException;
  30 +import java.text.SimpleDateFormat;
  31 +import java.util.*;
  32 +
  33 +/**
  34 + * Created by Administrator on 2018/1/4.
  35 + */
  36 +@Service("lpfyFmService")
  37 +public class LpfyFmService {
  38 +
  39 + @Autowired
  40 + private PatientsService patientsService;
  41 +
  42 + @Autowired
  43 + private MatDeliverFacade matDeliverFacade;
  44 +
  45 + @Autowired
  46 + private UsersService usersService;
  47 +
  48 + @Autowired
  49 + private BabyBookbuildingFacade babyBookbuildingFacade;
  50 +
  51 +
  52 +
  53 + private static Map<Integer, String> ONE_ENUMS = new HashMap<>();
  54 +
  55 + private static Map<String, List> babyMap = new HashMap<>();
  56 +
  57 + private static final String HOSPITALID = "216";
  58 + static {
  59 + ONE_ENUMS.put(0, "长");
  60 + ONE_ENUMS.put(1, "次");
  61 + ONE_ENUMS.put(2, "三");
  62 + ONE_ENUMS.put(3, "四");
  63 + ONE_ENUMS.put(4, "五");
  64 + ONE_ENUMS.put(5, "六");
  65 + ONE_ENUMS.put(6, "七");
  66 +
  67 +
  68 + List<String> b1 = new ArrayList<>();
  69 + b1.add("长女");
  70 + b1.add("次女");
  71 + babyMap.put("00", b1);
  72 +
  73 + List<String> b2 = new ArrayList<>();
  74 + b2.add("长子");
  75 + b2.add("次子");
  76 + babyMap.put("11", b2);
  77 +
  78 + List<String> b3 = new ArrayList<>();
  79 + b3.add("之子");
  80 + b3.add("之女");
  81 +
  82 + List<String> b4 = new ArrayList<>();
  83 + b4.add("之女");
  84 + b4.add("之子");
  85 + babyMap.put("01", b4);
  86 + babyMap.put("10", b3);
  87 + List<String> b5 = new ArrayList<>();
  88 + b5.add("之子");
  89 + List<String> b6 = new ArrayList<>();
  90 + b6.add("之女");
  91 +
  92 + babyMap.put("1", b5);
  93 + babyMap.put("0", b6);
  94 + }
  95 +
  96 + public void fmTimerWork() {
  97 + SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  98 + Date end = new Date(new Date().getTime()-1000*60*60);
  99 + Date start = new Date(end.getTime()-1000*60*60*2);
  100 + String startStr = fmt.format(start);
  101 + String endStr = fmt.format(end);
  102 + System.out.println("start=" + startStr + "end=" + endStr);
  103 + //queryFmPatient(startStr, endStr, null);
  104 + }
  105 +
  106 + public void syncByPhone(String startStr,String endStr,String phone) {
  107 + queryFmPatient(startStr, endStr, phone);
  108 + }
  109 +
  110 +
  111 + public void queryFmPatient(String start,String end,String phone) {
  112 +
  113 + String cloumns = " ID as ID,\n" +
  114 + " 住院编号 as BHNUM,\n" +
  115 + " 就诊卡号 as VCCARDNO,\n" +
  116 + " 手机号码 as PHONE,\n" +
  117 + " 姓名 as NAME,\n" +
  118 + " 身份证号 as IDCARD,\n" +
  119 + " CREATED as CREATED,\t\n" +
  120 + " CONVERT(char(19),婴儿产出时日,120) as BABY_DELIVERY_TIME,\n" +
  121 + " 婴儿性别 as BABY_SEX,\n" +
  122 + " 孕周 as DUE_WEEK,\n" +
  123 + // " DUE_DAY as DUE_DAY,\n" +
  124 + " 胎次 as FETUS_NUM,\n" +
  125 + " 窒息 as BABY_ASPHYXIAM,\n" +
  126 + " CONVERT(int,left(体重,len(体重)-1)) as BABY_WEIGHT,\n" +
  127 + " CONVERT(int,left(身长,len(身长)-2)) as BABY_HEIGHT,\n" +
  128 + " CONVERT(int,left(Apgar评分1,len(Apgar评分1)-1)) as BABY_APGAR_SCORE_ONE,\n" +
  129 + " CONVERT(int,left(Apgar评分5,len(Apgar评分5)-1)) as BABY_APGAR_SCORE_FIVE,\n" +
  130 + " CONVERT(int,left(Apgar评分10,len(Apgar评分10)-1)) as BABY_APGAR_SCORE_TEN,\n" +
  131 + " 妊娠结局 as BABY_PREGNANCY_OUT,\n" +
  132 + " 分娩方式 as TMCSIDE,\n" +
  133 + // " TMCTYPE as TMCTYPE,\n" +
  134 + " 产妇离开产室情况 as MATERNAL_INFO,\n" +
  135 + " 会阴切开术 as PERINEAL_CONDITION,\n" +
  136 + //" 失血量 as SH_LOSE_BLOOD,\n" +
  137 + " 失血量 as sxl,\n" +
  138 + // " TH_LOSE_BLOOD as TH_LOSE_BLOOD,\n" +
  139 + // " 接生者 as DELIVER_DOCTOR,\n" +
  140 + // " 产程第一期 as PROD_PROCESS_ONE,\n" +
  141 + " 产程第一期 as ccOne,\n" +
  142 + // " 第二期 as PROD_PROCESS_TWO,\n" +
  143 + " 第二期 as ccTwo,\n" +
  144 + // " 第三期 as PROD_PROCESS_THREE,\n" +
  145 + " 第三期 as ccThree,\n" +
  146 + //" 总计 as TOTAL_PROCESS,\n" +
  147 + " 总计 as total,\n" +
  148 + " CONVERT(int,胎盘数量) as PLACENTA_NUM,\n" +
  149 + //" DELIVER_HOSPITAL as DELIVER_HOSPITAL,\n" +
  150 + " 产妇居住地址 as ADDR,\n"+
  151 + " 接生者 as DELIVER_DOCTOR";
  152 +
  153 +
  154 + Connection conn = com.lyms.hospitalapi.lpfy.ConnTools.makeHisConnection();
  155 + QueryRunner queryRunner = new QueryRunner();
  156 + SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  157 + try {
  158 +
  159 + String sql ="select "+cloumns+" from lis_cs.v_deliveryinfo where " +
  160 + " CREATED > to_date('"+start+"', 'yyyy-mm-dd hh24:mi:ss') and CREATED <= to_date('"+end+"', 'yyyy-mm-dd hh24:mi:ss')" ;
  161 + if (phone != null)
  162 + {
  163 + sql+=" and 手机号码 = '"+phone+"'";
  164 + }
  165 + List<Fm> list = queryRunner.query(conn, sql, new BeanListHandler<Fm>(Fm.class));
  166 + ExceptionUtils.catchException("size====" + list.size());
  167 +
  168 + /*List<Fm> list=new ArrayList<Fm>();
  169 + list.add(fm1);*/
  170 + if(CollectionUtils.isNotEmpty(list)){
  171 +
  172 + for(Fm fm:list){
  173 + System.out.println("fm=" + fm.toString());
  174 + int a = 0;//用来判断是否建了儿童档案,如果建了儿童档案就不保存分娩记录
  175 + int count = 0;
  176 + List<Users> users = new ArrayList<Users>();
  177 + String id = fm.getID();//获取所有的孕妇ID,方便孕妇产下双胞胎而用
  178 +
  179 + //用来查询这个孕妇分娩的最近日期的sql
  180 + String dateSql = "select max(CONVERT(char(19),CREATED,120)) as babyDate from xlhhis..v_fmjl where " +
  181 + " ID='"+id+"'" ;
  182 +
  183 + //获取到这个孕妇的最近的分娩日期
  184 + List<Fm> dateList = queryRunner.query(conn, dateSql, new BeanListHandler<Fm>(Fm.class));
  185 + Calendar calendar = Calendar.getInstance();
  186 + calendar.setTime(fmt.parse(dateList.get(0).getBabyDate()));
  187 + calendar.add(Calendar.DAY_OF_MONTH, -1);
  188 + Date sDate = calendar.getTime();
  189 + String startDate = fmt.format(sDate);
  190 + String endDate = dateList.get(0).getBabyDate();
  191 +
  192 + //查询这个孕妇最近日期所有分娩记录的sql
  193 + String allSql = "select "+cloumns+" from xlhhis..v_fmjl where " +
  194 + " CREATED > CONVERT(char(19),'"+startDate+"',120) and CREATED <= CONVERT(char(19),'"+endDate+"',120)" +
  195 + " and ID='"+id+"'" ;
  196 +
  197 + //查出这个ID对应孕妇在这个时间段的分娩记录
  198 + List<Fm> allList = queryRunner.query(conn, allSql, new BeanListHandler<Fm>(Fm.class));
  199 +
  200 + /*List<Fm> allList = new ArrayList<Fm>();
  201 + allList.add(fm);*/
  202 +
  203 + Date dueDate = null;
  204 + List<MatDeliverAddRequest.Baby> babies = new ArrayList<>();
  205 + MatDeliverAddRequest deliverAddRequest = new MatDeliverAddRequest();
  206 + for(Fm allFm:allList){
  207 +
  208 + if ("死胎".equals(allFm.getBABY_PREGNANCY_OUT()))
  209 + {
  210 + continue;
  211 + }
  212 + if (StringUtils.isEmpty(allFm.getPHONE()) && StringUtils.isEmpty(allFm.getIDCARD()))
  213 + {
  214 + continue;
  215 + }
  216 +
  217 + //将中间字段的值整理赋值到正式字段中
  218 + int sxl = allFm.getSxl().length();
  219 + allFm.setSH_LOSE_BLOOD(Integer.parseInt(allFm.getSxl().substring(0,sxl-2)));//失血量
  220 +
  221 + String[] oneShi = allFm.getCcOne().split("时");
  222 + int one = Integer.parseInt(oneShi[0])*60;
  223 + String[] oneFen = oneShi[1].split("分");
  224 + allFm.setPROD_PROCESS_ONE(one+Integer.parseInt(oneFen[0]));//第一产程
  225 +
  226 + String[] twoShi = allFm.getCcTwo().split("时");
  227 + int two = Integer.parseInt(twoShi[0])*60;
  228 + String[] twoFen = twoShi[1].split("分");
  229 + allFm.setPROD_PROCESS_TWO(two+Integer.parseInt(twoFen[0]));//第二产程
  230 +
  231 + String[] threeShi = allFm.getCcThree().split("时");
  232 + int three = Integer.parseInt(threeShi[0])*60;
  233 + String[] threeFen = threeShi[1].split("分");
  234 + allFm.setPROD_PROCESS_THREE(three+Integer.parseInt(threeFen[0]));//第三产程
  235 +
  236 + String[] totalShi = allFm.getTotal().split("时");
  237 + int total = Integer.parseInt(totalShi[0])*60;
  238 + String[] totalFen = totalShi[1].split("分");
  239 + allFm.setTOTAL_PROCESS(String.valueOf(total+Integer.parseInt(totalFen[0])));//总产程
  240 +
  241 +
  242 + PatientsQuery query = new PatientsQuery();
  243 + query.setYn(YnEnums.YES.getId());
  244 + query.setType(1); //孕妇
  245 + query.setDueStatus(0); //未终止妊娠
  246 + String[] strs = new String[]{allFm.getPHONE(),allFm.getIDCARD()};
  247 + query.setPc(strs);
  248 +
  249 + //查询该孕妇是否在孕产婴系统中建档
  250 + List<Patients> patientses = patientsService.queryPatient(query);
  251 + Patients patient = new Patients();
  252 + if(CollectionUtils.isNotEmpty(patientses)){
  253 + ExceptionUtils.catchException("patientses"+patientses);
  254 + patient = patientses.get(0);
  255 + UsersQuery usersQuery = new UsersQuery();
  256 + usersQuery.setYn(YnEnums.YES.getId());
  257 + usersQuery.setOrgId(new Integer(Integer.parseInt(HOSPITALID)));
  258 + usersQuery.setName("产房");
  259 + users = usersService.queryUsers(usersQuery);
  260 +
  261 + if (CollectionUtils.isNotEmpty(users) && users.get(0).getId() != null) {
  262 +
  263 + Date dateTime = fmt.parse(allFm.getBABY_DELIVERY_TIME());
  264 + if(dateTime!=null){
  265 + if (!com.lyms.platform.common.utils.StringUtils.isNotEmpty(allFm.getBABY_DELIVERY_TIME().toString())) {
  266 + continue;
  267 + }else{
  268 + dueDate = dateTime;
  269 + }
  270 + }else{
  271 + continue;
  272 + }
  273 +
  274 + Map<String, Map<String,String>> map = new HashMap<>();
  275 + Map<String, String> map1 = new HashMap<>();
  276 + Map<String, String> map2 = new HashMap<>();
  277 + Map<String, String> map3 = new HashMap<>();
  278 + Map<String, String> totalMap = new HashMap<>();
  279 +
  280 + Integer prod_Process_One = allFm.getPROD_PROCESS_ONE();
  281 + Integer prod_Process_Two = allFm.getPROD_PROCESS_TWO();
  282 + Integer prod_Process_Three = allFm.getPROD_PROCESS_THREE();
  283 + if(prod_Process_One!=null){
  284 + map1.put("h",String.valueOf(prod_Process_One.intValue()/60));
  285 + map1.put("m",String.valueOf(prod_Process_One.intValue()%60));
  286 + map.put("one", map1);
  287 + }
  288 + if(prod_Process_Two!=null){
  289 + map2.put("h",String.valueOf(prod_Process_Two.intValue()/60));
  290 + map2.put("m",String.valueOf(prod_Process_Two.intValue()%60));
  291 + map.put("two",map2);
  292 + }
  293 + if(prod_Process_Three!=null){
  294 + map3.put("h",String.valueOf(prod_Process_Three.intValue()/60));
  295 + map3.put("m",String.valueOf(prod_Process_Three.intValue()%60));
  296 + map.put("three",map3);
  297 + }
  298 +
  299 + int hProcess = Integer.parseInt(allFm.getTOTAL_PROCESS())/60;//总产程小时数
  300 + int mProcess = Integer.parseInt(allFm.getTOTAL_PROCESS())%60;//总产程分钟数
  301 + totalMap.put("h",String.valueOf(hProcess));
  302 + totalMap.put("m",String.valueOf(mProcess));
  303 +
  304 + deliverAddRequest.setProdprocess(map);
  305 + deliverAddRequest.setTotalprocess(totalMap);
  306 + deliverAddRequest.setDeliverDoctor(allFm.getDELIVER_DOCTOR());
  307 + deliverAddRequest.setDueDate(DateUtil.getyyyy_MM_dd(dueDate));
  308 + deliverAddRequest.setParentId(patient.getId());
  309 + deliverAddRequest.setPid(patient.getPid());
  310 + deliverAddRequest.setOperationCause("-");
  311 + String week = "";
  312 + if (StringUtils.isNotEmpty(allFm.getDUE_WEEK())) {
  313 +
  314 + week = allFm.getDUE_WEEK() + "周";
  315 + if (StringUtils.isNotEmpty(allFm.getDUE_WEEK()) && StringUtils.isNotEmpty(allFm.getDUE_DAY()))
  316 + {
  317 + week += allFm.getDUE_DAY() + "天";
  318 + }
  319 +
  320 + deliverAddRequest.setDueWeek(week);
  321 + }
  322 +
  323 + deliverAddRequest.setTireNumber(allFm.getFETUS_NUM());// 胎数(之前赋值为死值1)
  324 + Integer placenta_Num = allFm.getPLACENTA_NUM();
  325 + if(placenta_Num!=null){
  326 + deliverAddRequest.setPlacenta(allFm.getPLACENTA_NUM().toString());// 胎盘(之前赋值为死值1)
  327 + }
  328 + if ("完好".equals(allFm.getPERINEAL_CONDITION()) || "".equals(allFm.getPERINEAL_CONDITION())) {
  329 + deliverAddRequest.setPerinealCondition("full");
  330 + } else if ("会阴切开".equals(allFm.getPERINEAL_CONDITION()) || "侧切".equals(allFm.getPERINEAL_CONDITION())) {
  331 + deliverAddRequest.setPerinealCondition("split");
  332 + }
  333 +
  334 + if ("一度裂伤".equals(allFm.getPERINEAL_CONDITION())) {
  335 + deliverAddRequest.setSiLielevel(1);
  336 + } else if ("二度裂伤".equals(allFm.getPERINEAL_CONDITION())) {
  337 + deliverAddRequest.setSiLielevel(2);
  338 + } else if ("三度裂伤".equals(allFm.getPERINEAL_CONDITION())) {
  339 + deliverAddRequest.setSiLielevel(3);
  340 + }
  341 +
  342 + Integer th_Lose = allFm.getTH_LOSE_BLOOD();
  343 + if(th_Lose!=null){
  344 + if (StringUtils.isNotEmpty(allFm.getTH_LOSE_BLOOD().toString())) {
  345 + deliverAddRequest.settHloseBloodL(Double.parseDouble(allFm.getTH_LOSE_BLOOD().toString()));
  346 + }
  347 + }
  348 +
  349 + Map deliveryMode = new HashMap(); //分娩方式
  350 +
  351 + String fmfs = "";
  352 + if (allFm.getDELIVERY_MODE() != null && "剖宫产".equals(allFm.getDELIVERY_MODE()))
  353 + {
  354 + fmfs = FmTypeEnums.O1.getId();
  355 + }
  356 + else
  357 + {
  358 + fmfs = FmTypeEnums.O.getId();
  359 + }
  360 + deliveryMode.put("fmfs",fmfs);
  361 + deliverAddRequest.setDeliveryMode(deliveryMode);
  362 + //胎盘信息
  363 + List<MaternalDeliverModel.ExtPlacenta> extPlacentas = new ArrayList<>();
  364 + MaternalDeliverModel.ExtPlacenta extPlacenta = new MaternalDeliverModel.ExtPlacenta();
  365 + String tpmcType = ""; //胎盘娩出方式
  366 + if ("手术产".equals(allFm.getTMCTYPE()) || "手取胎盘".equals(allFm.getTMCTYPE())) {
  367 + tpmcType = TpmcTypeEnums.O2.getId();
  368 + } else if ("自然产出".equals(allFm.getTMCTYPE()) || "自然娩出".equals(allFm.getTMCTYPE())) {
  369 + tpmcType = TpmcTypeEnums.O.getId();
  370 + }
  371 + extPlacenta.setTpmcType(tpmcType);
  372 + extPlacentas.add(extPlacenta);
  373 + deliverAddRequest.setExtPlacentas(extPlacentas);
  374 +
  375 +
  376 + //儿童
  377 + MatDeliverAddRequest.Baby baby = new MatDeliverAddRequest.Baby();
  378 + Map<String, String> as = new HashMap<>();
  379 + Integer pf1 = allFm.getBABY_APGAR_SCORE_ONE();
  380 + Integer pf5 = allFm.getBABY_APGAR_SCORE_FIVE();
  381 + Integer pf10 = allFm.getBABY_APGAR_SCORE_TEN();
  382 + if(pf1!=null){
  383 + as.put("pf1", allFm.getBABY_APGAR_SCORE_ONE().toString());
  384 + }
  385 + if(pf5!=null){
  386 + as.put("pf5", allFm.getBABY_APGAR_SCORE_FIVE().toString());
  387 + }
  388 + if(pf10!=null){
  389 + as.put("pf10", allFm.getBABY_APGAR_SCORE_TEN().toString());
  390 + }
  391 +
  392 +
  393 + baby.setApgarScore(as);
  394 + baby.setBabyGender("男".equals(allFm.getBABY_SEX()) ? "1" : "0");
  395 + Integer babyHeight = allFm.getBABY_HEIGHT();
  396 + Integer babyWeight = allFm.getBABY_WEIGHT();
  397 + Integer baby_Asphyxiam = allFm.getBABY_ASPHYXIAM();
  398 + if(babyHeight!=null){
  399 + baby.setBabyHeight(allFm.getBABY_HEIGHT().toString());//新生儿生长
  400 + }
  401 + if(babyWeight!=null){
  402 + baby.setBabyWeight(allFm.getBABY_WEIGHT().toString());//新生儿重量
  403 + }
  404 + if(baby_Asphyxiam!=null){
  405 + baby.setAsphyxiaM(allFm.getBABY_ASPHYXIAM().toString()); //窒息分钟
  406 + }
  407 +
  408 + baby.setDeformity((allFm.getBABY_DEFORMITY()==null?0:1)); //畸形 0非畸形 1畸形
  409 +
  410 + String baby_Pregnancy_Out = allFm.getBABY_PREGNANCY_OUT();
  411 + if(baby_Pregnancy_Out!=null && StringUtils.isNotEmpty(baby_Pregnancy_Out)){
  412 + baby.setPregnancyOut(RenShenJieJuEnums.getIdByName(allFm.getBABY_PREGNANCY_OUT())); // 妊娠结局
  413 + }
  414 +
  415 + baby.setDueTime(fmt.format(dueDate));//分娩时间
  416 + babies.add(baby);
  417 +
  418 + }
  419 + }else{
  420 + a=1;
  421 + //乐陵服务器有分娩记录,但是在这边系统没有对应孕妇 取分娩信息建档儿童数据
  422 + List<String> names = buildBabyName(allList);
  423 +
  424 + Date dateTime = fmt.parse(allFm.getBABY_DELIVERY_TIME());
  425 + if(dateTime!=null){
  426 + if (!com.lyms.platform.common.utils.StringUtils.isNotEmpty(allFm.getBABY_DELIVERY_TIME().toString())) {
  427 + continue;
  428 + }else{
  429 + dueDate = dateTime;
  430 + }
  431 + }
  432 +
  433 + //String babyName = allFm.getNAME()+("男".equals(allFm.getBABY_SEX()) ? "之子" : "之女");
  434 + String babyName = allFm.getNAME()+names.get(count).toString();
  435 + FmItem fmitem=new FmItem();
  436 + fmitem.setCcqk(allFm.getBABY_PREGNANCY_OUT());
  437 + fmitem.setYexb(allFm.getBABY_SEX());
  438 + fmitem.setRc(allFm.getDUE_WEEK());
  439 + fmitem.setFmfs(allFm.getDELIVERY_MODE());
  440 + Integer fetus_Num = allFm.getFETUS_NUM();
  441 + if(fetus_Num!=null){
  442 + fmitem.setDjt(allFm.getFETUS_NUM().toString());
  443 + }
  444 + fmitem.setCjc("");
  445 + Integer babyHeight = allFm.getBABY_HEIGHT();
  446 + Integer babyWeight = allFm.getBABY_WEIGHT();
  447 + if(babyHeight!=null){
  448 + fmitem.setSc(allFm.getBABY_HEIGHT().toString());
  449 + }
  450 + if(babyWeight!=null){
  451 + fmitem.setTz(allFm.getBABY_WEIGHT().toString());
  452 + }
  453 + Integer pf1 = allFm.getBABY_APGAR_SCORE_ONE();
  454 + Integer pf5 = allFm.getBABY_APGAR_SCORE_FIVE();
  455 + Integer pf10 = allFm.getBABY_APGAR_SCORE_TEN();
  456 + if(pf1!=null){
  457 + fmitem.setYfz(allFm.getBABY_APGAR_SCORE_ONE().toString());
  458 + }
  459 + if(pf5!=null){
  460 + fmitem.setWfz(allFm.getBABY_APGAR_SCORE_FIVE().toString());
  461 + }
  462 + if(pf10!=null){
  463 + fmitem.setSfz(allFm.getBABY_APGAR_SCORE_TEN().toString());
  464 + }
  465 + fmitem.setSfgw("");
  466 + Integer baby_Deformity = allFm.getBABY_DEFORMITY();
  467 + if(baby_Deformity!=null){
  468 + fmitem.setJx(allFm.getBABY_DEFORMITY().toString());
  469 + }
  470 + count+=1;
  471 + buildBaby(fmitem, patient,allFm, dueDate, babyName);
  472 +
  473 + }
  474 + }
  475 +
  476 + if(a==0){
  477 + deliverAddRequest.setBabies(babies);
  478 + deliverAddRequest.setFmHospital(HOSPITALID); //设置为德州妇幼
  479 + ExceptionUtils.catchException("deliverAddRequest===" + deliverAddRequest);
  480 + if(users!=null && users.size()>0){
  481 + matDeliverFacade.addOrUpdateMatDeliver(deliverAddRequest, users.get(0).getId());
  482 + }
  483 + }
  484 + }
  485 + }
  486 + DbUtils.closeQuietly(conn);
  487 + } catch (Exception e) {
  488 + ExceptionUtils.catchException(e, "sql执行异常");
  489 + e.printStackTrace();
  490 + } finally {
  491 + DbUtils.closeQuietly(conn);
  492 + }
  493 + }
  494 +
  495 + private List buildBabyName(List<Fm> items) {
  496 + String id = "";
  497 + if (items.size() > 2) {
  498 + int boyCount = 0;
  499 + int girlCount = 0;
  500 + List<String> l = new ArrayList<>();
  501 + for (int i = 0; i < items.size(); i++) {
  502 + Fm item = items.get(i);
  503 + if (org.apache.commons.lang.StringUtils.isNotEmpty(item.getBABY_SEX())) {
  504 + if ("男".equals(item.getBABY_SEX())) {
  505 + l.add(ONE_ENUMS.get(boyCount) + "子");
  506 + boyCount++;
  507 + } else if ("女".equals(item.getBABY_SEX())) {
  508 + l.add(ONE_ENUMS.get(girlCount) + "女");
  509 + girlCount++;
  510 + }
  511 + }
  512 + }
  513 + return l;
  514 + } else {
  515 + for (int i = 0; i < items.size(); i++) {
  516 + Fm item = items.get(i);
  517 + if (org.apache.commons.lang.StringUtils.isNotEmpty(item.getBABY_SEX())) {
  518 + if ("男".equals(item.getBABY_SEX()))
  519 + {
  520 + id += "1";
  521 + }
  522 + else if ("女".equals(item.getBABY_SEX()))
  523 + {
  524 + id += "0";
  525 + }
  526 +
  527 + }
  528 + }
  529 + return babyMap.get(id);
  530 + }
  531 + }
  532 +
  533 + public void buildBaby(FmItem item,Patients patInfo,Fm fm, Date dueDate, String babyName)
  534 + {
  535 + try{
  536 +
  537 + ExceptionUtils.catchException("buildBaby====");
  538 +
  539 + if ("死产".equals(fm.getBABY_PREGNANCY_OUT()))
  540 + {
  541 + return;
  542 + }
  543 +
  544 + UsersQuery usersQuery = new UsersQuery();
  545 + usersQuery.setYn(YnEnums.YES.getId());
  546 + usersQuery.setName("产房");
  547 + usersQuery.setOrgId(new Integer(Integer.parseInt(HOSPITALID)));
  548 + List<Users> users = usersService.queryUsers(usersQuery);
  549 +
  550 + BabyBookbuildingAddRequest request = new BabyBookbuildingAddRequest();
  551 + request.setHospitalId(HOSPITALID);
  552 +
  553 + request.setMommyName(fm.getNAME()); //母亲姓名
  554 + Date bir = patInfo.getBirth();
  555 + if(bir!=null){
  556 + try {
  557 + SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
  558 + Date birth = format.parse(bir.toString());
  559 + format = new SimpleDateFormat("yyyy-MM-dd");
  560 + request.setMommyBirthday(format.format(birth));
  561 + }catch (ParseException e)
  562 + {
  563 + ExceptionUtils.catchException(e,"孕妇生日解析异常");
  564 + }
  565 + }
  566 +
  567 + if (org.apache.commons.lang.StringUtils.isNotEmpty(fm.getIDCARD()))
  568 + {
  569 + request.setMommyCertificateTypeId("70ae1d93-2964-46bc-83fa-bec9ff605b1c"); //证件类型 (身份证号码)
  570 + request.setMommyCertificateNum(fm.getIDCARD()); //证件号
  571 + }
  572 + else if (StringUtils.isNotEmpty(fm.getPHONE()))
  573 + {
  574 + request.setMommyCertificateTypeId("57e1dcd3f0f02e7ca519d6c6"); //证件类型 (手机号码)
  575 + request.setMommyCertificateNum(fm.getPHONE()); //证件号
  576 + }
  577 +
  578 + request.setMommyPhone(fm.getPHONE());
  579 +
  580 + request.setBabyName(babyName);
  581 + request.setSex("男".equals(item.getYexb()) ? 1 : 0);
  582 +
  583 + request.setBabyBirthday(DateUtil.getyyyy_MM_dd(dueDate)); //生日
  584 +
  585 + if (StringUtils.isNotEmpty(fm.getDUE_WEEK())) {
  586 + String week = fm.getDUE_WEEK();
  587 +
  588 + try {
  589 + request.setDueWeek(Integer.parseInt(week)); //分娩孕周
  590 + }catch (Exception e)
  591 + {
  592 +
  593 + }
  594 + }
  595 +
  596 + String fmfs = "";
  597 + if (fm.getDELIVERY_MODE() != null && "剖宫产".equals(fm.getDELIVERY_MODE()))
  598 + {
  599 + fmfs = FmTypeEnums.O1.getId();
  600 + }
  601 + else
  602 + {
  603 + fmfs = FmTypeEnums.O.getId();
  604 + }
  605 +
  606 + request.setDueType(fmfs);//分娩方式
  607 + //request.setFetusCount(item.getDjt()); //第几胎
  608 + //request.setDueCount(item.getCjc());//第几产
  609 + Integer weight = fm.getBABY_WEIGHT();
  610 + Integer height = fm.getBABY_HEIGHT();
  611 + if(weight!=null){
  612 + DecimalFormat df = new DecimalFormat("#.00");
  613 + double w = Double.parseDouble(weight.toString());
  614 + request.setBabyWeight(df.format(w/1000)); //体重
  615 + }
  616 + if(height!=null){
  617 + request.setBabyHeight(height.toString()); //身长
  618 + }
  619 +
  620 + Map<String,String> map = new HashMap<>();
  621 + Integer pf1 = fm.getBABY_APGAR_SCORE_ONE();
  622 + Integer pf5 = fm.getBABY_APGAR_SCORE_FIVE();
  623 + Integer pf10 = fm.getBABY_APGAR_SCORE_TEN();
  624 + if(pf1!=null){
  625 + map.put("pf1", pf1.toString());
  626 + }
  627 + if(pf5!=null){
  628 + map.put("pf5", pf5.toString());
  629 + }
  630 + if(pf10!=null){
  631 + map.put("pf10", pf10.toString());
  632 + }
  633 +
  634 + request.setApgarScore(map);
  635 + request.setDeliverOrg(HOSPITALID);
  636 +
  637 + request.setBuildDoctor(users.get(0).getId() + "");
  638 + request.setBuildDate(DateUtil.getyyyy_MM_dd(dueDate));
  639 + //request.setHighRisk("是".equals(item.getSfgw()) ? 1 : 0); ////是否高危 0 非高危 1高危
  640 + request.setMalformation((fm.getBABY_DEFORMITY() == null ? 0 : 1)); //畸形 0非畸形 1畸形
  641 + //request.setMalformation("无".equals(item.getJx()) ? 0 : 1); //畸形 0非畸形 1畸形
  642 +
  643 + request.setServiceType(ServiceTypeEnums.STANDARD_SERVICE.getId()); //标准服务
  644 + request.setServiceStatus(ServiceStatusEnums.STANDARD_OPEN.getId()); //开通
  645 +
  646 + /*if (patInfo != null && StringUtils.isNotEmpty(fm.getBHNUM()))
  647 + {
  648 + Map<String,Object> diags = dzfyHisService.queryHisBabyDiagnosis(fm.getBHNUM());
  649 + if (diags != null && diags.size() > 0)
  650 + {
  651 + request.setBlNo(fm.getBHNUM());
  652 + request.setBabyDiagnosis(diags.get("diagnosisItem") == null ? "" : diags.get("diagnosisItem").toString());
  653 + }
  654 + }*/
  655 + babyBookbuildingFacade.addBabyBookbuilding(request, users.get(0).getId());
  656 +
  657 + }catch (Exception e)
  658 + {
  659 + ExceptionUtils.catchException(e, "buildBaby exception");
  660 + e.printStackTrace();
  661 + }
  662 + }
  663 +
  664 +}
platform-operate-api/src/main/java/com/lyms/hospitalapi/zcfy/ZcfyFmService.java View file @ 8e527cc
... ... @@ -4,7 +4,7 @@
4 4 * Created by Administrator on 2018/1/3.
5 5 */
6 6  
7   -import com.lyms.hospitalapi.dzfy.DzfyHisService;
  7 +
8 8 import com.lyms.hospitalapi.dzfy.Fm;
9 9 import com.lyms.hospitalapi.qhdfy.FmItem;
10 10 import com.lyms.platform.biz.service.PatientsService;
11 11  
... ... @@ -53,9 +53,8 @@
53 53 @Autowired
54 54 private BabyBookbuildingFacade babyBookbuildingFacade;
55 55  
56   - @Autowired
57   - private DzfyHisService dzfyHisService;
58 56  
  57 +
59 58 private static Map<Integer, String> ONE_ENUMS = new HashMap<>();
60 59  
61 60 private static Map<String, List> babyMap = new HashMap<>();
62 61  
... ... @@ -157,13 +156,13 @@
157 156 " 接生者 as DELIVER_DOCTOR";
158 157  
159 158  
160   - Connection conn = com.lyms.hospitalapi.llfy.ConnTools.makeHisConnection();
  159 + Connection conn = com.lyms.hospitalapi.zcfy.ConnTools.makeFmConnection();
161 160 QueryRunner queryRunner = new QueryRunner();
162 161 SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
163 162 try {
164 163  
165   - String sql ="select "+cloumns+" from xlhhis..v_fmjl where " +
166   - " CREATED > CONVERT(char(19), '"+start+"', 120) and CREATED <= CONVERT(char(19), '"+start+"', 120)" ;
  164 + String sql ="select "+cloumns+" from zcfybjy.v_deliveryinfo where " +
  165 + " CREATED > to_date('"+start+"', 'yyyy-mm-dd hh24:mi:ss') and CREATED <= to_date('"+end+"', 'yyyy-mm-dd hh24:mi:ss')" ;
167 166 if (phone != null)
168 167 {
169 168 sql+=" and 手机号码 = '"+phone+"'";