diff --git a/platform-operate-api/src/main/java/com/lyms/hospitalapi/rcfy/RcGlxtService.java b/platform-operate-api/src/main/java/com/lyms/hospitalapi/rcfy/RcGlxtService.java index 20f9030..2063cd8 100644 --- a/platform-operate-api/src/main/java/com/lyms/hospitalapi/rcfy/RcGlxtService.java +++ b/platform-operate-api/src/main/java/com/lyms/hospitalapi/rcfy/RcGlxtService.java @@ -3,22 +3,32 @@ package com.lyms.hospitalapi.rcfy; import com.lyms.platform.biz.service.*; +import com.lyms.platform.common.enums.FmTypeEnums; +import com.lyms.platform.common.enums.RenShenJieJuEnums; +import com.lyms.platform.common.enums.YnEnums; import com.lyms.platform.common.utils.DateUtil; import com.lyms.platform.common.utils.ExceptionUtils; +import com.lyms.platform.common.utils.JsonUtil; +import com.lyms.platform.common.utils.StringUtils; import com.lyms.platform.operate.web.facade.AntenatalExaminationFacade; +import com.lyms.platform.operate.web.result.HighScoreResult; +import com.lyms.platform.operate.web.utils.CollectionUtils; import com.lyms.platform.operate.web.utils.CommonsHelper; import com.lyms.platform.permission.service.OrganizationService; import com.lyms.platform.permission.service.UsersService; -import com.lyms.platform.pojo.Patients; +import com.lyms.platform.pojo.*; +import com.lyms.platform.query.*; +import org.apache.commons.collections.MapUtils; import org.apache.commons.dbutils.QueryRunner; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; -import java.sql.Connection; -import java.sql.Date; -import java.sql.PreparedStatement; -import java.sql.SQLException; +import java.sql.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** @@ -39,9 +49,716 @@ public class RcGlxtService { @Autowired private UsersService usersService; + + @Autowired + private AntenatalExaminationService antenatalExaminationService; + + @Autowired + private BabyService babyService; + @Autowired private AntenatalExaminationFacade antenatalExaminationFacade; + + @Autowired + private MatDeliverService matDeliverService; + + + @Autowired + private SieveService sieveService; + + @Autowired + private FolicAcidService folicAcidService; + + @Autowired + private ResidentsArchiveService residentsArchiveService; + + private static Map hospitalsMap = new HashMap<>(); + static { + hospitalsMap.put("2100001785","371082007011");//荣成市人民医院 + hospitalsMap.put("2100001818","371082006011");//荣成市石岛人民医院 + hospitalsMap.put("2100001772","371082007001");//荣成市中医院 + hospitalsMap.put("2100001750","371082000011");//荣成市妇幼保健院 + } + + + /** + * + * + * 1、筛查类型、筛查类型名称,按照以下字段对应(对应你方系统如截图内容:产筛分项评价。注:组合成两个字段): + 2001 唐氏综合征(21三体) + 2002 18三体综合征 + 2003 开放性神经缺陷 + 2004 耳聋基因筛查 + + 2、筛查结果:(对应你方系统如截图内容:产筛分项评价)存在风险即为阳性,没有风险即为阴性 + + 3、筛查医疗机构代码,按照以下字段对应: + 371082007011 荣成市人民医院 + 371082006011 荣成市石岛人民医院 + 371082007001 荣成市中医院 + 371082000011 荣成市妇幼保健院 + + 4、筛查结果内容:(对应你方系统如截图内容:高危因素内容) + * 产前筛查 + * @param model + */ + public void saveRcSieveInfo(SieveResultModel model) + { + Connection conn = null; + PreparedStatement ps = null; + try { + conn = ConnTools.makeConnection(); + + ps = conn.prepareStatement("delete from PREGNANCY_EXAMINATION_INFO WHERE ID like '" + model.getId() + "%'"); + ps.executeUpdate(); + + + Patients patients = patientsService.findOnePatientById(model.getParentId()); + + // private String tszhz;// 唐氏综合症 + // private String sjgjx;// 神经管畸形 + // private String sbst;// 18-三体 + + Map map = new HashMap<>(); + if (StringUtils.isNotEmpty(model.getTszhz())) + { + map.put("tszhz",model.getTszhz()); + } + if (StringUtils.isNotEmpty(model.getSjgjx())) + { + map.put("sjgjx",model.getSjgjx()); + } + if (StringUtils.isNotEmpty(model.getSbst())) + { + map.put("sbst",model.getSbst()); + } + + if (map.size() > 0) + { + + for (String key : map.keySet()) + { + //产前筛查 + String sql = "insert into PREGNANCY_EXAMINATION_INFO(ID,NAME,ID_CARD,EXAM_DATE,SCREENING_CATE,SCREENING_CATE_NAME,IS_TOLL,SCREENING_RESULT," + + "EXAM_HOSPITAL,RESP_DOCTOR,EXAM_INFO,IS_SEND_REMIND,REFERRAL_STATUS,HIGH_RISK," + + "HANDING_SUGGESTION,REFERTO_ORG_NAME,REFERRAL_REASON,IS_SIGN_PROTOCOL,REFERRAL_CASE,REFERRAL_TRACK_DOCTOR," + + "OPERATOR,OPERAT_TIME,STATUS,CHECK_TYPE,IS_BULID_MANUAL,PREGNANCY,APPOINTMENT,CREATE_TIME,UPDATE_TIME) " + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + ps = conn.prepareStatement(sql); + ps.setString(1,model.getId()+key); + ps.setString(2,patients.getUsername()); + ps.setString(3,patients.getCardNo()); + ps.setTimestamp(4, new Timestamp(model.getCreated().getTime())); + + String type = ""; + String typeName = ""; + if ("tszhz".equals(key)) + { + type = "2001"; + typeName= "唐氏综合征(21三体)"; + } else if ("sjgjx".equals(key)) + { + type = "2003"; + typeName= "开放性神经缺陷"; + } + else if ("sbst".equals(key)) + { + type = "2002"; + typeName= "18三体综合征"; + } + ps.setString(5,type); + ps.setString(6, typeName); + ps.setString(7, null); + +// SieveQuery sieveQuery = new SieveQuery(); +// sieveQuery.setYn(YnEnums.YES.getId()); +// sieveQuery.setParentId(model.getParentId()); +// List modelList = sieveService.queryList(sieveQuery); +// String sieveResult= ""; +// if (CollectionUtils.isNotEmpty(modelList)) +// { +// Integer result = modelList.get(0).getCqResult(); +// if (result != null) +// { +// sieveResult = result == 0 ? "1" :"2"; +// } +// } + + String sieveResult= ""; + if (map.get(key) != null) + { + Integer result = Integer.parseInt(map.get(key)); + if (result != null) + { + sieveResult = result == 0 ? "2" :"1"; + } + } + + + ps.setString(8, sieveResult); + ps.setString(9, hospitalsMap.get(patients.getHospitalId())); + ps.setString(10, StringUtils.isNum(model.getPublishName()) ? CommonsHelper.getUserName(model.getPublishName(), usersService) : model.getPublishName()); + HighScoreResult highScoreResult = antenatalExaminationFacade.findLastRisk(patients.getPid(), false); + ps.setString(11, highScoreResult.gethighRiskStr()); + ps.setString(12, null); + ps.setString(13, null); + ps.setString(14, highScoreResult.gethighRiskStr()); + ps.setString(15, null); + ps.setString(16, null); + ps.setString(17, null); + ps.setString(18, null); + ps.setString(19, null); + ps.setString(20, null); + ps.setString(21, StringUtils.isNum(model.getPublishName()) ? CommonsHelper.getUserName(model.getPublishName(), usersService) : model.getPublishName()); + ps.setTimestamp(22, new Timestamp(model.getCreated().getTime())); + + String status = ""; + int week = 0; + if (patients.getLastMenses() != null && model.getCreated() != null) + { + week = DateUtil.getWeek(patients.getLastMenses(),model.getCreated()); + + //怀孕1~12周为早孕。 怀孕13周~27周为孕中,28周到40周围孕晚期,分娩后是产后,产后42天后不再属于孕期妇女 + if (week >=0 && 12 >= week) + { + status= "1"; + } + else if (week >=13 && 27 >= week) + { + status= "2"; + } + else if (week >=28 && 40 >= week) + { + status= "3"; + } + else + { + status= "4"; + } + } + ps.setString(23, status); + ps.setString(24, status); + ps.setString(25, "0"); + ps.setString(26, String.valueOf(week)); + ps.setString(27, null); + ps.setTimestamp(28, new Timestamp(model.getCreated().getTime())); + ps.setTimestamp(29, new Timestamp(model.getModified().getTime())); + + int saveRcSieveInfoCount = ps.executeUpdate(); + System.out.println("saveRcSieveInfoCount="+saveRcSieveInfoCount); + } + } + } + catch (Exception e) + { + ExceptionUtils.catchException(e,"saveRcSieveInfoCount error."); + }finally { + try { + if (ps != null) + { + ps.close(); + } + if (conn != null) + { + conn.close(); + } + } catch (SQLException e) { + } + } + } + + + /** + * 叶酸发放 + * @param model + */ + public void saveRcFolicAcidInfo(FolicAcid model) + { + Connection conn = null; + PreparedStatement ps = null; + try { + conn = ConnTools.makeConnection(); + + ps = conn.prepareStatement("delete from FOLIC_ACID_RECORD WHERE ID='" + model.getId() + "'"); + ps.executeUpdate(); + + + ResidentsArchiveQuery archiveQuery = new ResidentsArchiveQuery(); + archiveQuery.setYn(YnEnums.YES.getId()); + archiveQuery.setId(model.getParentId()); + List residentsArchiveModels = residentsArchiveService.queryResident(archiveQuery); + if (CollectionUtils.isEmpty(residentsArchiveModels)) + { + return; + } + ResidentsArchiveModel resident = residentsArchiveModels.get(0); + + //婚检 + String sql = "insert into FOLIC_ACID_RECORD(ID,CARD_NO,TIMES,NUM,PROVIDER,HOSPITAL,RECEIVER,PROVIDER_TIME,OPERATOR," + + "OPERAT_TIME,ID_CARD,NAME,STATUS,IS_SEND_REMIND,CREATE_TIME,UPDATE_TIME) " + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + ps = conn.prepareStatement(sql); + ps.setString(1, model.getId()); + ps.setString(2, resident.getVcCardNo()); + + FolicAcidQuery folicAcidQuery = new FolicAcidQuery(); + folicAcidQuery.setYn(YnEnums.YES.getId()); + folicAcidQuery.setParentId(resident.getId()); + + Integer timmes = 1; + List folicAcidList = folicAcidService.queryFolicAcidWithSort(folicAcidQuery, "drawTime", Sort.Direction.ASC); + if (CollectionUtils.isNotEmpty(folicAcidList)) + { + for (int i=0;i=0 && 12 >= week) + { + status= "1"; + } + else if (week >=13 && 27 >= week) + { + status= "2"; + } + else if (week >=28 && 40 >= week) + { + status= "3"; + } + else + { + status= "4"; + } + } + ps.setString(13, status); + ps.setString(14, null); + ps.setTimestamp(15, new Timestamp(model.getCreated().getTime())); + ps.setTimestamp(16, new Timestamp(model.getModified().getTime())); + + int saveRcFolicAcidInfo = ps.executeUpdate(); + System.out.println("saveRcFolicAcidInfo="+saveRcFolicAcidInfo); + } + catch (Exception e) + { + ExceptionUtils.catchException(e,"saveRcFolicAcidInfo error."); + }finally { + try { + if (ps != null) + { + ps.close(); + } + if (conn != null) + { + conn.close(); + } + } catch (SQLException e) { + } + } + } + + + + /** + * 婚检 + * @param model + */ + public void saveRcPremaritalCheckupInfo(PremaritalCheckup model) + { + Connection conn = null; + PreparedStatement ps = null; + try { + conn = ConnTools.makeConnection(); + + ps = conn.prepareStatement("delete from PRE_MARRIAGE_PHYSICAL WHERE ID='" + model.getId() + "'"); + ps.executeUpdate(); + + + ResidentsArchiveQuery archiveQuery = new ResidentsArchiveQuery(); + archiveQuery.setYn(YnEnums.YES.getId()); + archiveQuery.setId(model.getParentId()); + List residentsArchiveModels = residentsArchiveService.queryResident(archiveQuery); + if (CollectionUtils.isEmpty(residentsArchiveModels)) + { + return; + } + ResidentsArchiveModel resident = residentsArchiveModels.get(0); + + //婚检 + String sql = "insert into PRE_MARRIAGE_PHYSICAL(ID,NAME,ID_CARD,VAGINAL_DISCHARGE_CHARACTER,\n" + + "VAGINAL_DISCHARGE_COLOR,VAGINAL_DISCHARGE_AMOUNT," + + "VAGINAL_MEDICAL,X_RAY_RESULT,TREPONEMA_PALLIDUN," + + "GPT,HBSAG_TEST_RESULT_CODE,HIV_SCREEN_RESULT," + + "VISIT_DOCTIR,VISIT_DATE,CHECK_HOSPITAL_NAME,CHECK_HOSPITAL_ID," + + "CREATE_TIME,UPDATE_TIME,OPERATOR,OPERAT_TIME) " + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + ps = conn.prepareStatement(sql); + ps.setString(1,model.getId()); + ps.setString(2,resident.getUsername()); + ps.setString(3,resident.getCertificateNum()); + ps.setString(4,null); + ps.setString(5,null); + ps.setString(6,null); + ps.setString(7,null); + +// ps.setString(6, model.getGcFenMiWu()); +// ps.setString(7, model.getJianChaJieGuo() == 1 ? "异常":"正常"); + ps.setString(8,null); + ps.setString(9,null); + ps.setString(10,null); + ps.setString(11,null); + ps.setString(12,null); + + ps.setString(13, StringUtils.isNum(model.getHunJianDoctor()) ? CommonsHelper.getUserName(model.getHunJianDoctor(), usersService) : model.getHunJianDoctor()); + ps.setTimestamp(14, new Timestamp(model.getPremaritalUpTime().getTime())); + ps.setString(15, CommonsHelper.getHospitalName(model.getHospitalId(), organizationService)); + ps.setString(16, hospitalsMap.get(model.getHospitalId())); + + ps.setTimestamp(17, new Timestamp(model.getCreated().getTime())); + ps.setTimestamp(18, new Timestamp(model.getModified().getTime())); + ps.setString(19, StringUtils.isNum(model.getHunJianDoctor()) ? CommonsHelper.getUserName(model.getHunJianDoctor(), usersService) : model.getHunJianDoctor()); + ps.setTimestamp(20, new Timestamp(model.getCreated().getTime())); + + int saveRcPremaritalCheckupInfo = ps.executeUpdate(); + System.out.println("saveRcPremaritalCheckupCount="+saveRcPremaritalCheckupInfo); + } + catch (Exception e) + { + ExceptionUtils.catchException(e,"saveRcPremaritalCheckupInfo error."); + }finally { + try { + if (ps != null) + { + ps.close(); + } + if (conn != null) + { + conn.close(); + } + } catch (SQLException e) { + } + } + } + + + + + /** + * 产后访视 + * @param model + */ + public void saveRcMatdeliverFollowInfo(MatdeliverFollowModel model) + { + Connection conn = null; + PreparedStatement ps = null; + try { + conn = ConnTools.makeConnection(); + + ps = conn.prepareStatement("delete from PUERPERANT_VISIT_INFO WHERE ID='" + model.getId() + "'"); + ps.executeUpdate(); + + + MatDeliverQuery matDeliverQuery = new MatDeliverQuery(); + matDeliverQuery.setYn(YnEnums.YES.getId()); + matDeliverQuery.setId(model.getDeliverId()); + List maternalDeliverModelList = matDeliverService.query(matDeliverQuery); + if (CollectionUtils.isEmpty(maternalDeliverModelList)) + { + return; + } + + MaternalDeliverModel maternalDeliverModel = maternalDeliverModelList.get(0); + + Patients patients = patientsService.findOnePatientById(maternalDeliverModel.getParentId()); + + //产后访视 + String fmInfoSql = "insert into PUERPERANT_VISIT_INFO(ID,PUERPERANT_ID,PUERPERANT_NAME,PUERPERANT_ID_CARD,VISIT_DATE,VISIT_RESULT," + + "VISIT_DOCTOR,VISIT_HOSPITAL,OPERATOR,OPERAT_TIME,CREATE_TIME,UPDATE_TIME) " + + " values(?,?,?,?,?,?,?,?,?,?,?,?)"; + ps = conn.prepareStatement(fmInfoSql); + ps.setString(1,model.getId()); + ps.setString(2, maternalDeliverModel.getId()); + ps.setString(3, patients.getUsername()); + ps.setString(4, patients.getCardNo()); + ps.setTimestamp(5, model.getVisitDate() == null ? new Timestamp(model.getCreateDate().getTime()) : new Timestamp(model.getVisitDate().getTime())); + ps.setString(6, model.getVisitRemark()); + + + ps.setString(7, StringUtils.isNum(model.getVisitDoctor()) ? CommonsHelper.getUserName(model.getVisitDoctor(), usersService) : model.getVisitDoctor()); + ps.setString(8, CommonsHelper.getHospitalName(maternalDeliverModel.getFmHospital(), organizationService)); + ps.setString(9, StringUtils.isNum(model.getVisitCreateUser()) ? CommonsHelper.getUserName(model.getVisitCreateUser(), usersService) : model.getVisitCreateUser()); + + ps.setTimestamp(10, model.getVisitDate()== null ? new Timestamp(model.getCreateDate().getTime()) : new Timestamp(model.getVisitDate().getTime())); + ps.setTimestamp(11, new Timestamp(model.getCreateDate().getTime())); + ps.setTimestamp(12, new Timestamp(model.getUpdateDate().getTime())); + + int saveFollowCount = ps.executeUpdate(); + System.out.println("saveFollowCount="+saveFollowCount); + } + catch (Exception e) + { + ExceptionUtils.catchException(e,"saveRcMatdeliverFollowInfo error."); + }finally { + try { + if (ps != null) + { + ps.close(); + } + if (conn != null) + { + conn.close(); + } + } catch (SQLException e) { + } + } + } + + + public void saveRcNewBabyInfo(MaternalDeliverModel model) + { + Connection conn = null; + PreparedStatement ps = null; + try { + conn = ConnTools.makeConnection(); + + + Patients patients = patientsService.findOnePatientById(model.getParentId()); + + List babies = model.getBaby(); + if (CollectionUtils.isNotEmpty(babies)) + { + for (MaternalDeliverModel.Baby baby : babies) + { + try { + ps = conn.prepareStatement("delete from NEW_BORN_INFO WHERE ID='" + baby.getId() + "'"); + ps.executeUpdate(); + if (!"0".equals(baby.getPregnancyOut())) + { + continue; + } + //孕妇分娩信息 + String fmInfoSql = "insert into NEW_BORN_INFO(ID,PUERPERANT_ID,PUERPERANT_NAME,PUERPERANT_ID_CARD,CHILD_NAME,GENDER,BIRTH_TIME,BIRTH_HEIGHT," + + "BIRTH_GEST_WEEKS,BIRTH_WEIGHT,APGAR_SCORE,WEAKNESS,HOSPITAL,MIDWIFE_DOCTOR,PREGNANT_ADDRESS," + + "CREATE_TIME,UPDATE_TIME) " + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + ps = conn.prepareStatement(fmInfoSql); + ps.setString(1,baby.getId() == null ? StringUtils.uuid() : baby.getId()); + ps.setString(2,model.getId()); + ps.setString(3,patients.getUsername()); + ps.setString(4,patients.getCardNo()); + + String babyName = ""; + BabyModelQuery babyModelQuery = new BabyModelQuery(); + babyModelQuery.setId(baby.getId()); + List babyModels = babyService.queryBabyWithQuery(babyModelQuery); + if (CollectionUtils.isNotEmpty(babyModels)) { + babyName = babyModels.get(0).getName(); + } + + ps.setString(5,babyName); + ps.setString(6,baby.getBabyGender()==null ? null : (Integer.parseInt(baby.getBabyGender())+1)+""); + ps.setString(7,baby.getDueTime()); + ps.setString(8,baby.getBabyHeight()); + ps.setString(9,model.getDueWeek()); + ps.setString(10,baby.getBabyWeight()); + String p1Score = null; + if (baby.getApgarScore() != null) + { + Map map = JsonUtil.getMap(baby.getApgarScore()); + p1Score = map.get("pf1"); + } + ps.setString(11,p1Score == null ? null : p1Score); + ps.setString(12,null);//缺陷 + ps.setString(13, CommonsHelper.getHospitalName(model.getFmHospital(), organizationService)); + ps.setString(14, CommonsHelper.getUserName(model.getDeliverDoctor(), usersService)); + String postAddress = CommonsHelper.getResidence(patients.getProvincePostRestId(), patients.getCityPostRestId(), + patients.getAreaPostRestId(), patients.getStreetPostRestId(), patients.getAddressPostRest(), basicConfigService); + ps.setString(15, postAddress); + + ps.setTimestamp(16, new Timestamp(model.getCreated().getTime())); + ps.setTimestamp(17, new Timestamp(model.getModified().getTime())); + + int saveRcNewBabyInfoCount = ps.executeUpdate(); + System.out.println("saveRcNewBabyInfo="+saveRcNewBabyInfoCount); + }catch (Exception e) + { + ExceptionUtils.catchException(e,"saveRcNewBabyInfo error."); + continue; + } + + } + } + } + catch (Exception e) + { + ExceptionUtils.catchException(e,"saveRcNewBabyInfo error."); + }finally { + try { + if (ps != null) + { + ps.close(); + } + if (conn != null) + { + conn.close(); + } + } catch (SQLException e) { + } + } + } + + + + public void saveRcFmInfo(MaternalDeliverModel model) + { + Connection conn = null; + PreparedStatement ps = null; + try { + conn = ConnTools.makeConnection(); + + ps = conn.prepareStatement("delete from PUERPERANT_RECORD WHERE ID='" + model.getId() + "'"); + ps.executeUpdate(); + + Patients patients = patientsService.findOnePatientById(model.getParentId()); + + //孕妇分娩信息 + String fmInfoSql = "insert into PUERPERANT_RECORD(ID,PUERPERANT_NAME,PUERPERANT_ID_CARD,PREGNANT_TIMES,PUERPERANT_TIMES,BIRTH_TYPE,PREGNANCY,HIGH_RISK_FLAG" + + ",FETUS_NUMBER,REPORTER_DATE,DELIVER_DOCTOR,HOSPITAL,OPERATOR,OPERAT_TIME,CREATE_TIME,UPDATE_TIME) " + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + ps = conn.prepareStatement(fmInfoSql); + ps.setString(1,model.getId()); + ps.setString(2,patients.getUsername()); + ps.setString(3,patients.getCardNo()); + + AntExChuQuery antExChuQuery = new AntExChuQuery(); + antExChuQuery.setYn(YnEnums.YES.getId()); + antExChuQuery.setParentId(patients.getId()); + List antExChuModels = antenatalExaminationService.queryAntExChu(antExChuQuery); + String yc =null; + String cc =null; + if (CollectionUtils.isNotEmpty(antExChuModels)) + { + AntExChuModel antExChuModel = antExChuModels.get(0); + yc = antExChuModel.getPregnancyTimes() == null ? "" : String.valueOf(antExChuModel.getPregnancyTimes()); + cc = antExChuModel.getProdTime() == null ? "" : String.valueOf(antExChuModel.getProdTime()); + } + ps.setString(4, yc); + ps.setString(5, cc); + + String fmType=""; + String deliveryModeJson = model.getDeliveryMode(); + Map deliveryModeMap = JsonUtil.getMap(deliveryModeJson); + if (MapUtils.isNotEmpty(deliveryModeMap) && org.apache.commons.lang.StringUtils.isNotEmpty(deliveryModeMap.get("fmfs"))) { + for (FmTypeEnums fmTypeEnums : FmTypeEnums.values()) { + if (fmTypeEnums.getId().equals(deliveryModeMap.get("fmfs"))) { + if (fmTypeEnums.getId().equals("1")) + { + fmType = "1"; + } + else if (fmTypeEnums.getId().equals("2")) + { + fmType = "3"; + } + break; + } + } + } + + ps.setString(6,fmType); + + String status = ""; + if (patients.getLastMenses() != null && patients.getBookbuildingDate() != null) + { + int week = DateUtil.getWeek(patients.getLastMenses(),patients.getBookbuildingDate()); + + //怀孕1~12周为早孕。 怀孕13周~27周为孕中,28周到40周围孕晚期,分娩后是产后,产后42天后不再属于孕期妇女 + if (week >=0 && 12 >= week) + { + status= "1"; + } + else if (week >=13 && 27 >= week) + { + status= "2"; + } + else if (week >=28 && 40 >= week) + { + status= "3"; + } + else + { + status= "4"; + } + } + + ps.setString(7, status); + + String isRisk="否"; + if ((CollectionUtils.isNotEmpty(patients.getRiskFactorId()) && !patients.getRiskFactorId().contains("d42eec03-aa86-45b8-a4e0-78a0ff365fb6")) + || patients.getoRiskFactor() != null) + { + isRisk="是"; + } + ps.setString(8,isRisk); + ps.setString(9, model.getTireNumber() == null ? null : String.valueOf(model.getTireNumber())); + + ps.setTimestamp(10, new Timestamp(model.getCreated().getTime())); + + + ps.setString(11, StringUtils.isNum(model.getDeliverDoctor()) ? CommonsHelper.getUserName(model.getDeliverDoctor(), usersService) : model.getDeliverDoctor()); + ps.setString(12, CommonsHelper.getHospitalName(model.getFmHospital(), organizationService)); + ps.setString(13, CommonsHelper.getUserName(model.getDeliverDoctor(), usersService)); + + ps.setTimestamp(14, new Timestamp(model.getCreated().getTime())); + ps.setTimestamp(15, new Timestamp(model.getCreated().getTime())); + ps.setTimestamp(16, new Timestamp(model.getModified().getTime())); + + int saveFmCount = ps.executeUpdate(); + System.out.println("saveFmCount="+saveFmCount); + } + catch (Exception e) + { + ExceptionUtils.catchException(e,"saveRcFmInfo error."); + }finally { + try { + if (ps != null) + { + ps.close(); + } + if (conn != null) + { + conn.close(); + } + } catch (SQLException e) { + } + } + } + + public void saveRcPatientInfo(Patients patients) { Connection conn = null; @@ -50,19 +767,44 @@ public class RcGlxtService { conn = ConnTools.makeConnection(); ps = conn.prepareStatement("delete from PREGNANT_BASE_INFO WHERE ID='"+patients.getId()+"'"); - ps.executeQuery(); + ps.executeUpdate(); //孕妇基本信息 - String baseInfoSql = "insert into PREGNANT_BASE_INFO(ID,NAME,ID_CARD,CERTIFICATE_TYPE,CERTIFICATE_NO,COMPANY,COUNTRY,TELPHONE,RESIDENCE_ADDRESS,RESIDENCE_PROVINCE," + - "RESIDENCE_CITY,RESIDENCE_COUNTRY,RESIDENCE_TOWN,RESIDENCE_VILIAGE,REGISTER_ADDRESS,REGISTER_PROVINCE,REGISTER_CITY,REGISTER_COUNTRY,REGISTER_TOWN,REGISTER_VILIAGE," + - "BIRTH_DATE,CONTACT_NAME,CONTACT_TEL_NO,HUSBAND_NAME,HUSBAND_ID_CARD,HUSBAND_TEL,HUSBAND_CERTIFICATE_TYPE,HUSBAND_CERTIFICATE_NO,HUSBAND_RESIDENCE_ADDRESS,HUSBAND_COMPANY," + - "STATUS,DATA_FROM_HOSPITAL,CREATE_TIME,UPDATE_TIME,OPERATOR,OPERAT_TIME,HEALTH_RECORD) " + - " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + String baseInfoSql = "insert into PREGNANT_BASE_INFO(ID,NAME,ID_CARD,CERTIFICATE_TYPE,CERTIFICATE_NO,COMPANY,COUNTRY," + + "RESIDENCE_ADDRESS,RESIDENCE_PROVINCE, RESIDENCE_CITY,RESIDENCE_COUNTRY,RESIDENCE_TOWN,RESIDENCE_HOURCE_NO," + + "REGISTER_ADDRESS, REGISTER_PROVINCE,REGISTER_CITY,REGISTER_COUNTRY,REGISTER_TOWN,REGISTER_HOURCE_NO," + + "BIRTH_DATE,CONTACT_NAME,CONTACT_TEL_NO,HUSBAND_NAME,HUSBAND_ID_CARD,HUSBAND_TEL,HUSBAND_CERTIFICATE_TYPE," + + "HUSBAND_CERTIFICATE_NO,HUSBAND_RESIDENCE_ADDRESS,HUSBAND_COMPANY," + + "STATUS,DATA_FROM_HOSPITAL,CREATE_TIME,UPDATE_TIME,OPERATOR,OPERAT_TIME,HEALTH_RECORD,TELPHONE) " + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; ps = conn.prepareStatement(baseInfoSql); ps.setString(1,patients.getId()); ps.setString(2,patients.getUsername()); ps.setString(3,patients.getCardNo()); - ps.setString(4, CommonsHelper.getName1(patients.getPcerteTypeId(), basicConfigService)); + + String pcertType = ""; + if (StringUtils.isNotEmpty(patients.getPcerteTypeId())) + { + String name = CommonsHelper.getName1(patients.getPcerteTypeId(), basicConfigService); + if ("身份证".equals(name)) + { + pcertType = "1"; + } + else if ("护照".equals(name)) + { + pcertType = "3"; + } + else if ("军官证".equals(name)) + { + pcertType = "4"; + } + else + { + pcertType = "9"; + } + } + + ps.setString(4, pcertType); ps.setString(5,patients.getCardNo()); ps.setString(6,patients.getPworkUnit()); ps.setString(7, CommonsHelper.getName1(patients.getPcountryId(), basicConfigService)); @@ -84,50 +826,81 @@ public class RcGlxtService { ps.setString(14,addressRegister); ps.setString(15,CommonsHelper.getName1(patients.getProvinceRegisterId(), basicConfigService)); ps.setString(16,CommonsHelper.getName1(patients.getCityRegisterId(), basicConfigService)); - ps.setString(17,CommonsHelper.getName1(patients.getAreaRegisterId(), basicConfigService)); + ps.setString(17, CommonsHelper.getName1(patients.getAreaRegisterId(), basicConfigService)); ps.setString(18, CommonsHelper.getName1(patients.getStreetRegisterId(), basicConfigService)); ps.setString(19, patients.getAddressRegister()); - ps.setDate(20, new Date(patients.getBirth().getTime())); + ps.setTimestamp(20, patients.getBirth() != null ? new Timestamp(patients.getBirth().getTime()) : null); ps.setString(21, patients.getUsername()); ps.setString(22, patients.getPhone()); ps.setString(23, patients.getHusbandName()); ps.setString(24, patients.getHcertificateNum()); ps.setString(25,patients.getHusbandPhone()); - ps.setString(26,CommonsHelper.getName1(patients.getHcertificateTypeId(), basicConfigService)); + + + String hcertType = ""; + if (StringUtils.isNotEmpty(patients.getPcerteTypeId())) + { + String name = CommonsHelper.getName1(patients.getHcertificateTypeId(), basicConfigService); + if ("身份证".equals(name)) + { + hcertType = "1"; + } + else if ("护照".equals(name)) + { + hcertType = "3"; + } + else if ("军官证".equals(name)) + { + hcertType = "4"; + } + else + { + hcertType = "9"; + } + } + + + ps.setString(26,hcertType); ps.setString(27, patients.getHcertificateNum()); //户籍地址 String haddressRegister = CommonsHelper.getResidence(patients.getHprovinceRegisterId(), patients.getHcityRegisterId(), patients.getHareaRegisterId(), patients.getHstreetRegisterId(), patients.getHaddressRegister(), basicConfigService); ps.setString(28, haddressRegister); - int week = DateUtil.getWeek(patients.getLastMenses(),patients.getBookbuildingDate()); + ps.setString(29, patients.getHworkUnit()); String status = ""; - //怀孕1~12周为早孕。 怀孕13周~27周为孕中,28周到40周围孕晚期,分娩后是产后,产后42天后不再属于孕期妇女 - if (week >=0 && 12 >= week) - { - status= "1"; - } - else if (week >=13 && 27 >= week) - { - status= "2"; - } - else if (week >=28 && 40 >= week) - { - status= "3"; - } - else + if (patients.getLastMenses() != null && patients.getBookbuildingDate() != null) { - status= "4"; + int week = DateUtil.getWeek(patients.getLastMenses(),patients.getBookbuildingDate()); + + //怀孕1~12周为早孕。 怀孕13周~27周为孕中,28周到40周围孕晚期,分娩后是产后,产后42天后不再属于孕期妇女 + if (week >=0 && 12 >= week) + { + status= "1"; + } + else if (week >=13 && 27 >= week) + { + status= "2"; + } + else if (week >=28 && 40 >= week) + { + status= "3"; + } + else + { + status= "4"; + } } - ps.setString(29, status); - ps.setString(30, CommonsHelper.getHospitalName(patients.getHospitalId(), organizationService)); - ps.setDate(31, new Date(patients.getCreated().getTime())); - ps.setDate(32, new Date(patients.getModified().getTime())); - ps.setString(33, CommonsHelper.getUserName(patients.getBookbuildingDoctor(), usersService)); - ps.setDate(34, new Date(patients.getCreated().getTime())); - ps.setString(35, patients.getFileCode()); - System.out.print(baseInfoSql); + ps.setString(30, status); + ps.setString(31, CommonsHelper.getHospitalName(patients.getHospitalId(), organizationService)); + + ps.setTimestamp(32, new Timestamp(patients.getCreated().getTime())); + ps.setTimestamp(33, patients.getModified() == null ? new Timestamp(patients.getCreated().getTime()) : new Timestamp(patients.getModified().getTime())); + ps.setString(34, CommonsHelper.getUserName(patients.getBookbuildingDoctor(), usersService)); + ps.setTimestamp(35, new Timestamp(patients.getCreated().getTime())); + ps.setString(36, patients.getFileCode()); + ps.setString(37, patients.getPhone()); int saveCount = ps.executeUpdate(); System.out.println("saveCount="+saveCount); } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java index ba99882..acde84c 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java @@ -159,6 +159,8 @@ public class TestController extends BaseController { @Autowired private RcGlxtService rcGlxtService; + @Autowired + private FolicAcidService folicAcidService; @Autowired private MatDeliverFacade matDeliverFacade; @@ -2419,5 +2421,159 @@ public class TestController extends BaseController { } } + @RequestMapping(value = "/rcFmInfo", method = RequestMethod.GET) + @ResponseBody + public void rcFmInfo(@RequestParam(required = false) String hospitalId) { + + OrganizationQuery organizationQuery = new OrganizationQuery(); + organizationQuery.setYn(YnEnums.YES.getId()); + if (StringUtils.isNotEmpty(hospitalId)) { + organizationQuery.setId(Integer.parseInt(hospitalId)); + } + List organizationList = organizationService.queryOrganization(organizationQuery); + + MatDeliverQuery matDeliverQuery = new MatDeliverQuery(); + matDeliverQuery.setYn(YnEnums.YES.getId()); + if (CollectionUtils.isNotEmpty(organizationList)) { + List hids = new ArrayList<>(); + for (Organization org :organizationList) + { + hids.add(org.getId()+""); + } + matDeliverQuery.setFmHospitalList(hids); + } + List list2 = matDeliverService.query(matDeliverQuery); + + if (CollectionUtils.isNotEmpty(list2)) + { + for (MaternalDeliverModel maternalDeliverModel : list2) + { + rcGlxtService.saveRcFmInfo(maternalDeliverModel); + } + } + } + + + @RequestMapping(value = "/rcNewBabyInfo", method = RequestMethod.GET) + @ResponseBody + public void rcNewBabyInfo(@RequestParam(required = false) String hospitalId) { + + OrganizationQuery organizationQuery = new OrganizationQuery(); + organizationQuery.setYn(YnEnums.YES.getId()); + if (StringUtils.isNotEmpty(hospitalId)) { + organizationQuery.setId(Integer.parseInt(hospitalId)); + } + List organizationList = organizationService.queryOrganization(organizationQuery); + + MatDeliverQuery matDeliverQuery = new MatDeliverQuery(); + matDeliverQuery.setYn(YnEnums.YES.getId()); + if (CollectionUtils.isNotEmpty(organizationList)) { + List hids = new ArrayList<>(); + for (Organization org :organizationList) + { + hids.add(org.getId()+""); + } + matDeliverQuery.setFmHospitalList(hids); + } + List list2 = matDeliverService.query(matDeliverQuery); + + if (CollectionUtils.isNotEmpty(list2)) + { + for (MaternalDeliverModel maternalDeliverModel : list2) + { + rcGlxtService.saveRcNewBabyInfo(maternalDeliverModel); + } + } + } + + + /** + *产后访视 + * @param hospitalId + */ + @RequestMapping(value = "/rcFmFollowInfo", method = RequestMethod.GET) + @ResponseBody + public void rcFmFollowInfo(@RequestParam(required = false) String hospitalId) { + + MatDeliverFollowQuery matDeliverFollowQuery = new MatDeliverFollowQuery(); + List matdeliverFollowModels = matDeliverFollowService.query(matDeliverFollowQuery); + matDeliverFollowQuery.setVisitStatus(2); + + if (CollectionUtils.isNotEmpty(matdeliverFollowModels)) + { + for (MatdeliverFollowModel matdeliverFollowModel : matdeliverFollowModels) + { + rcGlxtService.saveRcMatdeliverFollowInfo(matdeliverFollowModel); + } + } + } + @Autowired + private PremaritalCheckupService premaritalCheckupService; + + /** + * 婚前检查 + * @param hospitalId + */ + @RequestMapping(value = "/rcPremaritalCheckup", method = RequestMethod.GET) + @ResponseBody + public void rcPremaritalCheckup(@RequestParam(required = false) String hospitalId) { + + PremaritalCheckupQuery query = new PremaritalCheckupQuery(); + query.setYn(YnEnums.YES.getId()); + query.setHospitalId(hospitalId); + query.setSexType(1); + List checkupList = premaritalCheckupService.queryPremaritalCheckup(query); + + if (CollectionUtils.isNotEmpty(checkupList)) + { + for (PremaritalCheckup premaritalCheckup : checkupList) + { + rcGlxtService.saveRcPremaritalCheckupInfo(premaritalCheckup); + } + } + } + + + /** + * 叶酸发放 + * @param hospitalId + */ + @RequestMapping(value = "/rcFolicAcidInfo", method = RequestMethod.GET) + @ResponseBody + public void rcFolicAcidInfo(@RequestParam(required = false) String hospitalId) { + + FolicAcidQuery folicAcidQuery = new FolicAcidQuery(); + folicAcidQuery.setYn(YnEnums.YES.getId()); + folicAcidQuery.setId("587621160cf248988f190469"); + + List folicAcidList = folicAcidService.queryFolicAcidWithSort(folicAcidQuery, "drawTime", Sort.Direction.ASC); + + if (CollectionUtils.isNotEmpty(folicAcidList)) + { + for (FolicAcid folicAcid : folicAcidList) + { + rcGlxtService.saveRcFolicAcidInfo(folicAcid); + } + } + } + + + @RequestMapping(value = "/rcSieveInfo", method = RequestMethod.GET) + @ResponseBody + public void rcSieveInfo(@RequestParam(required = false) String hospitalId) { + + + SieveResultQuery sieveResultQuery = new SieveResultQuery(); + sieveResultQuery.setYn(YnEnums.YES.getId()); + List list = sieveService.queryListSieveResult(sieveResultQuery); + + if (CollectionUtils.isNotEmpty(list)) + { + for (SieveResultModel sieveResultModel : list) + { + rcGlxtService.saveRcSieveInfo(sieveResultModel); + } + } + } }