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