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