From 1c4619a9f392fa99d027871e6136e1a8ebb3241a Mon Sep 17 00:00:00 2001 From: shiyang <316555390@qq.com> Date: Wed, 8 Jun 2022 14:41:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B0=91=E7=94=9F=E5=B7=A5=E7=A8=8B=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=8E=A5=E5=8F=A3-=E5=88=86=E5=A8=A9=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=EF=BC=88=E4=B8=BB=EF=BC=89C301?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/lyms/platform/common/utils/DateUtil.java | 142 ++++++ .../controller/LivelihoodProjectsController.java | 24 + .../web/facade/LivelihoodProjectsFacade.java | 545 ++++++++++++++++----- 3 files changed, 599 insertions(+), 112 deletions(-) diff --git a/platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java b/platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java index 5d66a05..63c9d76 100644 --- a/platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java +++ b/platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java @@ -1734,6 +1734,148 @@ public class DateUtil { return doubleValue; } + /** + * 身份证-获取出生日期 + * + * @return 返回字符串类型 + */ + public static String getBirthFromIdCard(String idCard) { + if (idCard.length() != 18 && idCard.length() != 15) { + return null; + } + if (idCard.length() == 18) { + String year = idCard.substring(6).substring(0, 4);// 得到年份 + String month = idCard.substring(10).substring(0, 2);// 得到月份 + String day = idCard.substring(12).substring(0, 2);// 得到日 + return (year + "-" + month + "-" + day); + } else if (idCard.length() == 15) { + String year = "19" + idCard.substring(6, 8);// 年份 + String month = idCard.substring(8, 10);// 月份 + String day = idCard.substring(10, 12);// 得到日 + return (year + "-" + month + "-" + day); + } + return null; + } + + /** + * 身份证-获取出生日期 + * + * @return 返回日期格式 + */ + public static Date getBirthDayFromIdCard(String idCard) throws ParseException { + Date birth = null; + if (idCard.length() == 18) { + String year = idCard.substring(6).substring(0, 4);// 得到年份 + String month = idCard.substring(10).substring(0, 2);// 得到月份 + String day = idCard.substring(12).substring(0, 2);// 得到日 + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + birth = format.parse(year + "-" + month + "-" + day); + } else if (idCard.length() == 15) { + String year = "19" + idCard.substring(6, 8);// 年份 + String month = idCard.substring(8, 10);// 月份 + String day = idCard.substring(10, 12);// 得到日 + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + birth = format.parse(year + "-" + month + "-" + day); + } + return birth; + } + + /** + * 身份证-获取性别 + * 9=未说明的性别,0=女性,1=男性 + * @return int + */ + public static int getSexFromIdCard(String idCard) { + int sex = 9; + // 身份证号码为空 + if (idCard == "" || idCard.length() <= 0){ + return sex; + } + if (idCard.length() == 18) { + if (Integer.parseInt(idCard.substring(16).substring(0, 1)) % 2 == 0) {// 判断性别 + sex = 0; // 女 + } else { + sex = 1; // 男 + } + } else if (idCard.length() == 15) { + String usex = idCard.substring(14, 15);// 用户的性别 + if (Integer.parseInt(usex) % 2 == 0) { + sex = 0; // 女 + } else { + sex = 1; // 男 + } + } + return sex; + } + + /** + * 根据身份证的号码算出当前身份证持有者的年龄 + * + * @param + * @throws Exception + * @return 0 (身份证号码为空/异常) + */ + public static int getAgeForIdcard(String idcard) { + try { + int age = 0; + if (StringUtils.isEmpty(idcard)) { + return age; + } + + String birth = ""; + if (idcard.length() == 18) { + birth = idcard.substring(6, 14); + } else if (idcard.length() == 15) { + birth = "19" + idcard.substring(6, 12); + } + + int year = Integer.valueOf(birth.substring(0, 4)); + int month = Integer.valueOf(birth.substring(4, 6)); + int day = Integer.valueOf(birth.substring(6)); + Calendar cal = Calendar.getInstance(); + age = cal.get(Calendar.YEAR) - year; + //周岁计算 + if (cal.get(Calendar.MONTH) < (month - 1) || (cal.get(Calendar.MONTH) == (month - 1) && cal.get(Calendar.DATE) < day)) { + age--; + } + return age; + } catch (Exception e) { + e.getMessage(); + } + return 0; + } + + /** + * 15 位身份证号码转 18 位 + *

+ * 15位身份证号码:第7、8位为出生年份(两位数),第9、10位为出生月份,第11、12位代表出生日期,第15位代表性别,奇数为男,偶数为女。 + * 18位身份证号码:第7、8、9、10位为出生年份(四位数),第11、第12位为出生月份,第13、14位代表出生日期,第17位代表性别,奇数为男,偶数为女。 + */ + public static StringBuffer IdCardMethod15To18(String idCard) { + //将字符串转化为buffer进行操作 + StringBuffer stringBuffer = new StringBuffer(idCard); + //身份证最后一位校验码,X代表10(顺序固定) + char[] checkIndex = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'}; + int sum = 0; + //在第6位插入年份的前两位19 + stringBuffer.insert(6, "19"); + for (int i = 0; i < stringBuffer.length(); i++) { + char c = stringBuffer.charAt(i); + //前17位数字 + int ai = Integer.valueOf(String.valueOf(c)); + //前17位每位对应的系数(7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 ) + int wi = ((int) Math.pow(2, stringBuffer.length() - i)) % 11; + //总和(每位数字乘以系数再相加) + sum = sum + ai * wi; + } + //总和除以11求余 + int indexOf = sum % 11; + //根据余数作为下表在校验码数组里取值 + stringBuffer.append(checkIndex[indexOf]); + return stringBuffer; + } + + public static void main(String[] args) { Date startDate = DateUtil.parseYMDHMS(DateUtil.getyyyy_MM_dd( DateUtil.addDay(new Date(), -3)) + " 00:00:00"); diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/LivelihoodProjectsController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/LivelihoodProjectsController.java index 0ee7480..9f575c0 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/LivelihoodProjectsController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/LivelihoodProjectsController.java @@ -88,4 +88,28 @@ public class LivelihoodProjectsController extends BaseController { @RequestParam(required = false) String endDate) { return livelihoodProjectsFacade.getMsgcC201(startDate,endDate); } + /** + * 孕分娩记录(主)C301 + * @param startDate + * @param endDate + * @return + */ + @RequestMapping(value = "/getMsgcC301", method = RequestMethod.GET) + @ResponseBody + public BaseObjectResponse getMsgcC301(@RequestParam(required = false) String startDate, + @RequestParam(required = false) String endDate) { + return livelihoodProjectsFacade.getMsgcC301(startDate,endDate); + } + /** + * 新生儿信息(从)C401 + * @param startDate + * @param endDate + * @return + */ + @RequestMapping(value = "/getMsgcC401", method = RequestMethod.GET) + @ResponseBody + public BaseObjectResponse getMsgcC401(@RequestParam(required = false) String startDate, + @RequestParam(required = false) String endDate) { + return livelihoodProjectsFacade.getMsgcC401(startDate,endDate); + } } \ No newline at end of file diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/LivelihoodProjectsFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/LivelihoodProjectsFacade.java index 255d859..324e9d0 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/LivelihoodProjectsFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/LivelihoodProjectsFacade.java @@ -11,10 +11,12 @@ import com.lyms.platform.common.enums.CdGwPcountryEnums; import com.lyms.platform.common.enums.YnEnums; import com.lyms.platform.common.result.BaseObjectResponse; import com.lyms.platform.common.utils.DateUtil; +import com.lyms.platform.common.utils.JsonUtil; import com.lyms.platform.common.utils.SystemConfig; import com.lyms.platform.operate.web.result.BasicConfigResult; import com.lyms.platform.operate.web.utils.CollectionUtils; import com.lyms.platform.operate.web.utils.CommonsHelper; +import com.lyms.platform.permission.dao.master.CouponMapper; import com.lyms.platform.permission.model.Users; import com.lyms.platform.permission.service.OrganizationService; import com.lyms.platform.permission.service.UsersService; @@ -23,9 +25,11 @@ import com.lyms.platform.query.BabyModelQuery; import com.lyms.platform.query.PatientsQuery; import com.lyms.platform.query.ResidentsArchiveQuery; import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.math.NumberUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Query; import org.springframework.stereotype.Component; @@ -53,6 +57,10 @@ public class LivelihoodProjectsFacade { private BabyBookbuildingService babyBookbuildingService; @Autowired private PatientsService patientsService; + @Autowired + private MongoTemplate mongoTemplate; + @Autowired + private CouponMapper couponMapper; public BaseObjectResponse getMsgcC101(String startDate, String endDate) { @@ -78,9 +86,9 @@ public class LivelihoodProjectsFacade { //id map.put("id",model.getId()); //档案编号 - map.put("file_number",""); + map.put("file_number","/"); //纸质档案编号 - map.put("file_number_paper",""); + map.put("file_number_paper","/"); //证件类型(lyms_basicconfig表中查"parentId": "c914bb2e-1825-4036-8a41-fe617c90d405") String credentials_type_code="99"; if(StringUtils.isNotEmpty(model.getCertificateTypeId())){ @@ -101,37 +109,49 @@ public class LivelihoodProjectsFacade { } map.put("credentials_type_code",credentials_type_code); //其他身份证件名称 - map.put("other_credentials_type",""); + map.put("other_credentials_type","/"); //证件号码 - map.put("credentials_number",StringUtils.isNotEmpty(model.getCertificateNum())?model.getCertificateNum():""); + map.put("credentials_number",StringUtils.isNotEmpty(model.getCertificateNum())?model.getCertificateNum():"/"); //出生日期 - map.put("birthday",null!=model.getBirthday()?DateUtil.getyyyy_MM_dd_hms(model.getBirthday()):null); + String birthday=DateUtil.getyyyy_MM_dd_hms(model.getBirthday()); + if(StringUtils.isEmpty(birthday)){ + if(StringUtils.isNotEmpty(model.getCertificateNum())){ + //用身份证获取 + birthday=DateUtil.getBirthFromIdCard(model.getCertificateNum()); + if(StringUtils.isEmpty(birthday)){ + birthday=DateUtil.getyyyy_MM_dd_hms(new Date()); + } + }else { + birthday=DateUtil.getyyyy_MM_dd_hms(new Date()); + } + } + map.put("birthday",birthday); //姓名 - map.put("name",StringUtils.isNotEmpty(model.getUsername())?model.getUsername():""); + map.put("name",StringUtils.isNotEmpty(model.getUsername())?model.getUsername():"/"); //姓名简拼 - map.put("en_name",""); + map.put("en_name","/"); //所属民族 String nation_code= CdGwNationEnums.getId(getBasicConfig(model.getNationId())); map.put("nation_code",StringUtils.isNotEmpty(nation_code)?nation_code:"99"); //性别 map.put("gender_code","2"); //工作单位 - map.put("work_unit",StringUtils.isNotEmpty(model.getWorkUnit())?model.getWorkUnit():""); + map.put("work_unit",StringUtils.isNotEmpty(model.getWorkUnit())?model.getWorkUnit():"/"); //固定电话 - map.put("tel",""); + map.put("tel","/"); //手机号 - map.put("phone",StringUtils.isNotEmpty(model.getPhone())?model.getPhone():""); + map.put("phone",StringUtils.isNotEmpty(model.getPhone())?model.getPhone():"/"); //联系人姓名 - map.put("contact_name",""); + map.put("contact_name","/"); //联系人电话 - map.put("contact_phone",""); + map.put("contact_phone","/"); //是否常驻 - map.put("is_permanent_code",""); + map.put("is_permanent_code","/"); //流动情况 - map.put("permanent_type_code",""); + map.put("permanent_type_code","/"); //户籍类型(lyms_basicconfig表中查"parentId": "57624ba30cf23d4631523e9d") - String address_type_code="1"; + String address_type_code="2"; if(StringUtils.isNotEmpty(model.getCensusTypeId())){ switch (model.getCensusTypeId()){ case "57624bf90cf23d4631523e9e": @@ -146,23 +166,30 @@ public class LivelihoodProjectsFacade { } map.put("census_register_type_code",address_type_code); //居住类型 - map.put("address_type_code",""); + map.put("address_type_code","/"); //户籍区划编码 - map.put("residence_district_id",""); + map.put("residence_district_id","/"); //户籍地址区划详情 - map.put("residence_district_detail",""); + map.put("residence_district_detail","/"); //户籍地址 - map.put("residence_address",""); + map.put("residence_address","/"); //身份证住址 - map.put("id_card_address",""); + map.put("id_card_address","/"); //年龄 - map.put("age",null!=model.getAge()?model.getAge():null); - //身高(cm)?????? - map.put("height",null); + Integer age=model.getAge(); + if(null==model.getAge()){ + if(StringUtils.isNotEmpty(model.getCertificateNum())){ + //用身份证获取 + age=DateUtil.getAgeForIdcard(model.getCertificateNum()); + } + } + map.put("age",age); + //身高(cm)系统中不能获取 没有就传最小取值 + map.put("height",20); //血型 - map.put("blood_type_code",""); + map.put("blood_type_code","/"); //RH阴性 - map.put("blood_type_rh_code",""); + map.put("blood_type_rh_code","/"); //文化程度(lyms_basicconfig表中查"parentId": "8046934b-ebe8-4037-98b6-a9ec47996700") String edu_attainment_code="10"; if(StringUtils.isNotEmpty(model.getLevelTypeId())){ @@ -215,7 +242,7 @@ public class LivelihoodProjectsFacade { } map.put("edu_attainment_code",edu_attainment_code); //职业 - map.put("profession_code",""); + map.put("profession_code","/"); //婚姻状况(lyms_basicconfig表中查"parentId": "0ab3e86b-dfdb-47eb-a58b-a2f2d978b69f") String marital_status_code="5"; if(StringUtils.isNotEmpty(model.getMarriageId())){ @@ -232,9 +259,9 @@ public class LivelihoodProjectsFacade { } map.put("marital_status_code",marital_status_code); //责任医生 - map.put("doctor_name",""); + map.put("doctor_name","/"); //建档人 - String create_doctor=""; + String create_doctor="/"; if(StringUtils.isNotEmpty(model.getBuildDoctor())) { Users user = usersService.getUsers(Integer.parseInt(model.getBuildDoctor())); if (null!=user && StringUtils.isNotEmpty(user.getName())) { @@ -243,17 +270,17 @@ public class LivelihoodProjectsFacade { } map.put("create_doctor",create_doctor); //建档日期 - map.put("this_date",null!=model.getBuildDay()?DateUtil.getyyyy_MM_dd_hms(model.getBuildDay()):null); + map.put("this_date",null!=model.getBuildDay()?DateUtil.getyyyy_MM_dd_hms(model.getBuildDay()):DateUtil.getyyyy_MM_dd_hms(new Date())); //出生人口编码 - map.put("childbirth_code",""); + map.put("childbirth_code","/"); //是否孕妇 - map.put("is_gravida",""); + map.put("is_gravida","/"); //是否产妇 - map.put("is_puerpera",""); + map.put("is_puerpera","/"); //系统录入时间 - map.put("entering_time",null!=model.getCreated()?DateUtil.getyyyy_MM_dd_hms(model.getCreated()):new Date()); + map.put("entering_time",null!=model.getCreated()?DateUtil.getyyyy_MM_dd_hms(model.getCreated()):DateUtil.getyyyy_MM_dd_hms(new Date())); //所属机构编码 - String organ_id=""; + String organ_id="/"; if(StringUtils.isNotEmpty(model.getHospitalId())){ organ_id =organizationService.getPlatHosNewCode(model.getHospitalId()); } @@ -268,9 +295,9 @@ public class LivelihoodProjectsFacade { } map.put("district_nation_code", organizationService.getAreaCode(areaName)); //母亲姓名简拼 - map.put("mother_en_name",""); + map.put("mother_en_name","/"); //数据上传时间 -// map.put("import_time",""); +// map.put("import_time",null); //修改时间 map.put("last_modified_time",null); //删除状态,0正常,1删除 @@ -319,32 +346,53 @@ public class LivelihoodProjectsFacade { //id map.put("id",model.getId()); //档案编号 - map.put("babyModels", ""); + map.put("babyModels", "/"); //纸质档案编号 - map.put("file_number_paper", ""); + map.put("file_number_paper", "/"); //证件类型 - map.put("credentials_type_code", ""); + map.put("credentials_type_code", "/"); //其他证件名称 - map.put("other_credentials_type", ""); + map.put("other_credentials_type", "/"); //证件号码 - map.put("credentials_number", StringUtils.isNotEmpty(model.getCardNo())?model.getCardNo():""); + map.put("credentials_number", StringUtils.isNotEmpty(model.getCardNo())?model.getCardNo():"/"); //出生日期 - map.put("birthday", null!=model.getBirth()?DateUtil.getyyyy_MM_dd_hms(model.getBirth()):null); + String birthday=DateUtil.getyyyy_MM_dd_hms(model.getBirth()); + if(StringUtils.isEmpty(birthday)){ + if(StringUtils.isNotEmpty(model.getCardNo())){ + //用身份证获取 + birthday=DateUtil.getBirthFromIdCard(model.getCardNo()); + if(StringUtils.isEmpty(birthday)){ + birthday=DateUtil.getyyyy_MM_dd_hms(new Date()); + } + }else { + birthday=DateUtil.getyyyy_MM_dd_hms(new Date()); + } + } + map.put("birthday", birthday); //姓名 - map.put("name", StringUtils.isNotEmpty(model.getName())?model.getName():""); + map.put("name", StringUtils.isNotEmpty(model.getName())?model.getName():"/"); //姓名简拼 - map.put("en_name", ""); + map.put("en_name", "/"); //所属民族 String nation_code= CdGwNationEnums.getId(getBasicConfig(model.getBnationId())); map.put("nation_code",StringUtils.isNotEmpty(nation_code)?nation_code:"99"); //性别 - map.put("gender_code", null!=model.getSex()?(model.getSex()==1?"1":"2"):"9"); + String gender_code="9"; + if(null!=model.getSex()){ + gender_code=model.getSex()==1?"1":"2"; + }else { + if(StringUtils.isNotEmpty(model.getCardNo())){ + gender_code=String.valueOf(DateUtil.getSexFromIdCard(model.getCardNo())); + gender_code=gender_code.equals("1")?"1":gender_code.equals("0")?"2":"9"; + } + } + map.put("gender_code", gender_code); //接种条码 - map.put("vaccination_code", ""); + map.put("vaccination_code", "/"); //固话 - map.put("tel", ""); + map.put("tel", "/"); //手机号 - String phone=""; + String phone="/"; if(StringUtils.isNotEmpty(model.getMphone())){ phone=model.getMphone(); } @@ -353,41 +401,50 @@ public class LivelihoodProjectsFacade { } map.put("phone", phone); //是否常住 - map.put("is_permanent_code", ""); + map.put("is_permanent_code", "/"); //流动情况 - map.put("permanent_type_code", ""); - //户籍类型??? - map.put("census_register_type_code", ""); + map.put("permanent_type_code", "/"); + //户籍类型 系统中不能获取,默认2 + map.put("census_register_type_code", "2"); //居住类型 - map.put("address_type_code", ""); + map.put("address_type_code", "/"); //户籍地址区划Id - map.put("residence_district_id", ""); + map.put("residence_district_id", "/"); //户籍地址区划详情 - map.put("residence_district_detail", ""); + map.put("residence_district_detail", "/"); //户籍地址 - map.put("residence_address", ""); + map.put("residence_address", "/"); //身份证住址 - map.put("id_card_address", ""); + map.put("id_card_address", "/"); //年龄 - map.put("age", null!=model.getBirth()?DateUtil.getAge(model.getBirth()):null); - //身高(cm) - Integer babyHeight=null; + Integer age=0; + if(null!=model.getBirth()){ + age=DateUtil.getAge(model.getBirth()); + }else { + if(StringUtils.isNotEmpty(model.getCardNo())){ + //用身份证获取 + age=DateUtil.getAgeForIdcard(model.getCardNo()); + } + } + map.put("age", age); + //身高(cm) 默认取 最小值 + Integer babyHeight=20; if(StringUtils.isNotEmpty(model.getBabyHeight())){ babyHeight=Integer.parseInt(String.valueOf(Math.round(Double.parseDouble(model.getBabyHeight())))); } map.put("height", babyHeight); - //体重(g) - Integer babyWeight=null; + //体重(g) 默认取 最小值 + Integer babyWeight=200; if(StringUtils.isNotEmpty(model.getBabyWeight())){ babyWeight=Integer.parseInt(String.valueOf(Math.round(Double.parseDouble(model.getBabyWeight())))); } map.put("weight", babyWeight); //血型 - map.put("blood_type_code", ""); + map.put("blood_type_code", "/"); //RH阴性 - map.put("blood_type_rh_code", ""); + map.put("blood_type_rh_code", "/"); //责任医生 - String create_doctor=""; + String create_doctor="/"; if(StringUtils.isNotEmpty(model.getBuildDoctor())) { if ("a9e5507f-e7da-4ec6-b8db-9a1e4d1b7c29".equals(model.getBuildDoctor())) { create_doctor="产科病房"; @@ -402,9 +459,9 @@ public class LivelihoodProjectsFacade { //建档人 map.put("create_doctor",create_doctor); //建档日期 - map.put("this_date", null!=model.getBuildDate()?DateUtil.getyyyy_MM_dd_hms(model.getBuildDate()):null); + map.put("this_date", null!=model.getBuildDate()?DateUtil.getyyyy_MM_dd_hms(model.getBuildDate()):DateUtil.getyyyy_MM_dd_hms(new Date())); //母亲姓名 - map.put("mother_name", StringUtils.isNotEmpty(model.getMname())?model.getMname():""); + map.put("mother_name", StringUtils.isNotEmpty(model.getMname())?model.getMname():"/"); //母亲证件类型(lyms_basicconfig表中查"parentId": "c914bb2e-1825-4036-8a41-fe617c90d405") String mother_credentials_type_code="99"; if(StringUtils.isNotEmpty(model.getMcertTypeId())){ @@ -425,21 +482,21 @@ public class LivelihoodProjectsFacade { } map.put("mother_credentials_type_code", mother_credentials_type_code); //母亲其他证件名称 - map.put("mother_other_credentials_type", ""); + map.put("mother_other_credentials_type", "/"); //母亲证件号码 - map.put("mother_credentials_number", StringUtils.isNotEmpty(model.getMcertNo())?model.getMcertNo():""); + map.put("mother_credentials_number", StringUtils.isNotEmpty(model.getMcertNo())?model.getMcertNo():"/"); //出生人口编码 - map.put("childbirth_code", ""); + map.put("childbirth_code", "/"); //录入系统时间 - map.put("entering_time", null!=model.getCreated()?DateUtil.getyyyy_MM_dd_hms(model.getCreated()):null); + map.put("entering_time", null!=model.getCreated()?DateUtil.getyyyy_MM_dd_hms(model.getCreated()):DateUtil.getyyyy_MM_dd_hms(new Date())); //所属机构编码 - String organ_id=""; + String organ_id="/"; if(StringUtils.isNotEmpty(model.getHospitalId())){ organ_id =organizationService.getPlatHosNewCode(model.getHospitalId()); } map.put("organ_id", organ_id); - //现住址国家区划编码(取 县/区 级的编码) 分别两个地址获取,谁有用谁 - String areaName=""; + //现住址国家区划编码(取 县/区 级的编码) 分别两个地址获取,谁不是空用谁 + String areaName="/"; if(StringUtils.isNotEmpty(model.getAreaId())){ areaName=CommonsHelper.getName1(model.getAreaId(), basicConfigService); } @@ -448,9 +505,9 @@ public class LivelihoodProjectsFacade { } map.put("district_nation_code", organizationService.getAreaCode(areaName)); //母亲姓名简拼 - map.put("mother_en_name", ""); + map.put("mother_en_name", "/"); //导入时间(存入数据) -// map.put("import_time", ""); +// map.put("import_time", null); //修改时间 map.put("last_modified_time", null); //删除状态 0正常,1删除 @@ -489,13 +546,13 @@ public class LivelihoodProjectsFacade { //id map.put("id",patients.getId()); //档案状态 - map.put("file_status_code", null!=patients.getType()?(patients.getType()==1?"1":"2"):""); + map.put("file_status_code", null!=patients.getType()?(patients.getType()==1?"1":"2"):"/"); //末次月经 - map.put("last_menstrual_period", patients.getLastMenses()); + map.put("last_menstrual_period",null!=patients.getLastMenses()?DateUtil.getyyyy_MM_dd(patients.getLastMenses()):DateUtil.getyyyy_MM_dd(new Date())); //预产期 - map.put("expected_date", patients.getDueDate()); + map.put("expected_date", null!=patients.getDueDate()?DateUtil.getyyyy_MM_dd(patients.getDueDate()):DateUtil.getyyyy_MM_dd(new Date())); //建档医生 - String doctor_name=""; + String doctor_name="/"; if(StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { Users user = usersService.getUsers(Integer.parseInt(patients.getBookbuildingDoctor())); if (null!=user && StringUtils.isNotEmpty(user.getName())) { @@ -512,21 +569,30 @@ public class LivelihoodProjectsFacade { //结案时间 map.put("close_date", null); //结案原因 - map.put("close_reason_code", ""); + map.put("close_reason_code", "/"); //结案原因-其它 - map.put("close_reason_detailed", ""); + map.put("close_reason_detailed", "/"); //母子保健卡号 - map.put("health_card_number", ""); + map.put("health_card_number", "/"); //姓名 - map.put("mother_name", patients.getUsername()); + map.put("mother_name", StringUtils.isNotEmpty(patients.getUsername())?patients.getUsername():"/"); //年龄 - map.put("mother_age", patients.getAge()); + Integer mother_age=patients.getAge(); + if(null==mother_age){ + if(StringUtils.isNotEmpty(patients.getCardNo())){ + //用身份证获取 + mother_age=DateUtil.getAgeForIdcard(patients.getCardNo()); + }else { + mother_age=0; + } + } + map.put("mother_age", mother_age); //国籍 String gj= CdGwPcountryEnums.getId(getBasicConfig(patients.getPcountryId())); - map.put("mother_nationality_code", gj); + map.put("mother_nationality_code", StringUtils.isNotEmpty(gj)?gj:"156"); //民族 String mz=NationEnums.getId(getBasicConfig(patients.getPnationId())); - map.put("mother_nation_code", mz); + map.put("mother_nation_code", StringUtils.isNotEmpty(mz)?mz:"99"); //母亲现住址标识,母亲现住址区划编码(居委会/村)取 县/区 级的编码 String areaRegisterName=""; if(StringUtils.isNotEmpty(patients.getAreaRegisterId())){ @@ -543,8 +609,14 @@ public class LivelihoodProjectsFacade { map.put("mother_address_id", organizationService.getAreaCode(areaName)); //母亲户籍地址--详情部分 map.put("mother_address_detail", patients.getAddress()); - //母亲地址(出生证明母亲地址)????? - map.put("mother_address", ""); + //母亲地址(出生证明母亲地址) 获取母亲 户籍地址,没有 就/ + String mother_address="/"; + if(StringUtils.isNotEmpty(patients.getProvinceId()) && StringUtils.isNotEmpty(patients.getCityId()) && + StringUtils.isNotEmpty(patients.getAreaId()) && StringUtils.isNotEmpty(patients.getStreetId()) && + StringUtils.isNotEmpty(patients.getAddress())){ + mother_address= CommonsHelper.getResidence(patients.getProvinceId(), patients.getCityId(), patients.getAreaId(), patients.getStreetId(), patients.getAddress(), basicConfigService); + } + map.put("mother_address", mother_address); //证件类型(lyms_basicconfig表中查"parentId": "c914bb2e-1825-4036-8a41-fe617c90d405") String mother_credentials_type_code="99"; if(StringUtils.isNotEmpty(patients.getPcerteTypeId())){ @@ -565,19 +637,28 @@ public class LivelihoodProjectsFacade { } map.put("mother_credentials_type_code", mother_credentials_type_code); //其他证件名称 - map.put("mother_other_credentials_type", ""); + map.put("mother_other_credentials_type", "/"); //有效身份证件号码 - map.put("mother_credentials_number", patients.getCardNo()); + map.put("mother_credentials_number", StringUtils.isNotEmpty(patients.getCardNo())?patients.getCardNo():"/"); //丈夫姓名 - map.put("father_name", patients.getHusbandName()); + map.put("father_name", StringUtils.isNotEmpty(patients.getHusbandName())?patients.getHusbandName():"/"); //丈夫年龄 - map.put("father_age", DateUtil.getAge(patients.getHusbandBirth())); + Integer father_age=DateUtil.getAge(patients.getHusbandBirth()); + if(null==father_age){ + if(StringUtils.isNotEmpty(patients.getHcertificateNum())){ + //用身份证获取 + father_age=DateUtil.getAgeForIdcard(patients.getHcertificateNum()); + }else { + father_age=0; + } + } + map.put("father_age", father_age); //丈夫国籍 String hgj= CdGwPcountryEnums.getId(getBasicConfig(patients.getHcountryId())); - map.put("father_nationality_code", hgj); + map.put("father_nationality_code", StringUtils.isNotEmpty(hgj)?hgj:"156"); //丈夫民族 String hmz=NationEnums.getId(getBasicConfig(patients.getHnationId())); - map.put("father_nation_code", hmz); + map.put("father_nation_code", StringUtils.isNotEmpty(hmz)?hmz:"99"); //丈夫现住址标识,丈夫现住址区划编码(居委会/村)取 县/区 级的编码 String hareaName=""; if(StringUtils.isNotEmpty(patients.getHareaId())){ @@ -593,9 +674,15 @@ public class LivelihoodProjectsFacade { } map.put("father_address_id", organizationService.getAreaCode(hareaRegisterName)); //丈夫户籍地址--详情部分 - map.put("father_address_detail", patients.getHaddressRegister()); - //父亲地址(出生证明父亲地址)????? - map.put("father_address", ""); + map.put("father_address_detail", StringUtils.isNotEmpty(patients.getHaddressRegister())?patients.getHaddressRegister():"/"); + //父亲地址(出生证明母亲地址) 获取父亲 户籍地址,没有 就/ + String father_address="/"; + if(StringUtils.isNotEmpty(patients.getHprovinceRegisterId()) && StringUtils.isNotEmpty(patients.getHcityRegisterId()) && + StringUtils.isNotEmpty(patients.getHareaRegisterId()) && StringUtils.isNotEmpty(patients.getHstreetRegisterId()) && + StringUtils.isNotEmpty(patients.getHaddressRegister())){ + father_address= CommonsHelper.getResidence(patients.getHprovinceRegisterId(), patients.getHcityRegisterId(), patients.getHareaRegisterId(), patients.getHstreetRegisterId(), patients.getHaddressRegister(), basicConfigService); + } + map.put("father_address", father_address); //丈夫证件类型(lyms_basicconfig表中查"parentId": "c914bb2e-1825-4036-8a41-fe617c90d405") String father_credentials_type_code="99"; if(StringUtils.isNotEmpty(patients.getHcertificateTypeId())){ @@ -616,33 +703,33 @@ public class LivelihoodProjectsFacade { } map.put("father_credentials_type_code", father_credentials_type_code); //丈夫其他证件名称 - map.put("father_other_credentials_type", ""); + map.put("father_other_credentials_type", "/"); //丈夫有效身份证件号码 - map.put("father_credentials_number", patients.getHcertificateNum()); + map.put("father_credentials_number", StringUtils.isNotEmpty(patients.getHcertificateNum())?patients.getHcertificateNum():"/"); //手机号码 - map.put("phone", patients.getHusbandPhone()); + map.put("phone", StringUtils.isNotEmpty(patients.getHusbandPhone())?patients.getHusbandPhone():"/"); //是否高危 - map.put("is_high_risk", ""); + map.put("is_high_risk", "/"); //是否早孕建档 - map.put("is_early_pregnancy", ""); + map.put("is_early_pregnancy", "/"); //是否已打印出生证明 - map.put("is_birth_certificate", ""); + map.put("is_birth_certificate", "/"); //录入系统时间 - map.put("entering_time", DateUtil.getyyyy_MM_dd_hms(patients.getCreated())); + map.put("entering_time", null!=patients.getCreated()?DateUtil.getyyyy_MM_dd_hms(patients.getCreated()):DateUtil.getyyyy_MM_dd_hms(new Date())); //是否未提供男方信息(建档时是否未提供男方信息) - map.put("not_provided_father_info", null!=patients.getReqHusband()?(patients.getReqHusband()?false:true):null); + map.put("not_provided_father_info", null!=patients.getReqHusband()?(patients.getReqHusband()?false:true):false); //丈夫电话 - map.put("father_phone", ""); + map.put("father_phone", "/"); //建档日期 - map.put("this_date", DateUtil.getyyyy_MM_dd_hms(patients.getBookbuildingDate())); + map.put("this_date",null!=patients.getBookbuildingDate()?DateUtil.getyyyy_MM_dd_hms(patients.getBookbuildingDate()):DateUtil.getyyyy_MM_dd_hms(new Date())); //所属机构编码 - String organ_id=""; + String organ_id="/"; if(StringUtils.isNotEmpty(patients.getHospitalId())){ organ_id =organizationService.getPlatHosNewCode(patients.getHospitalId()); } map.put("organ_id", organ_id); //关联妇女档id - String person_id=""; + String person_id="/"; if(StringUtils.isNotEmpty(patients.getCardNo())){ ResidentsArchiveQuery query = new ResidentsArchiveQuery(); query.setYn(YnEnums.YES.getId()); @@ -654,9 +741,9 @@ public class LivelihoodProjectsFacade { } map.put("person_id", person_id); //导入时间 -// map.put("import_time", ""); +// map.put("import_time", null); //修改时间 -// map.put("last_modified_time", ""); + map.put("last_modified_time", null); //删除状态 map.put("is_deleted", "0"); //删除时间 @@ -674,4 +761,238 @@ public class LivelihoodProjectsFacade { objectResponse.setData(data); return objectResponse; } + + public BaseObjectResponse getMsgcC301(String startDate, String endDate) { + + Query query=new Query(); + query.addCriteria(Criteria.where("yn").is(1)); + if(StringUtils.isNotEmpty(startDate) && StringUtils.isNotEmpty(endDate)){ + query.addCriteria(Criteria.where("dueDate1").gte(DateUtil.getDayFirstSecond(DateUtil.parseYMD(startDate))) + .lte(DateUtil.getDayLastSecond(DateUtil.parseYMD(endDate)))); + }else { + //当天的数据 + query.addCriteria(Criteria.where("dueDate1").gte(DateUtil.getDayFirstSecond(new Date())) + .lte(DateUtil.getDayLastSecond(new Date()))); + } + List fmList = mongoTemplate.find(query, MaternalDeliverModel.class); + List data = new ArrayList<>(); + for (MaternalDeliverModel model : fmList) { + try { + Map map=new HashMap(); + //id + map.put("id", StringUtils.isNotEmpty(model.getId())?model.getId():"/"); + //分娩日期 + map.put("this_date", null!=model.getDueDate1()?DateUtil.getyyyy_MM_dd_hms(model.getDueDate1()):DateUtil.getyyyy_MM_dd_hms(new Date())); + //住院病历号 + map.put("medical_record_number", StringUtils.isNotEmpty(model.getInHospitalNo())?model.getInHospitalNo():"/"); + //分娩时孕周 + Integer week_num=0; + if(StringUtils.isNotEmpty(model.getDueWeek())){ + String[] week = model.getDueWeek().split("周"); + if (NumberUtils.isNumber(week[0])) { + week_num=Integer.parseInt(week[0]); + } + } + map.put("week_num",week_num); + //分娩时孕天 + Integer day_num=0; + if(StringUtils.isNotEmpty(model.getDueWeek())){ + String[] week = model.getDueWeek().split("[+]"); + if (week.length==2 && NumberUtils.isNumber(week[1].substring(0,week[1].length()-1))) { + day_num=Integer.parseInt(week[1].substring(0,week[1].length()-1)); + } + } + map.put("day_num", day_num); + //分娩方式 + String birth_fashion_code = "6"; + if (StringUtils.isNotEmpty(model.getDeliveryMode())) { + Map m = JsonUtil.str2Obj(model.getDeliveryMode(), Map.class); + if (m != null) { + Object b = m.get("fmfs"); + if (b != null) { + switch (b.toString()) { + case "1": + birth_fashion_code = "1"; + break; + case "2": + birth_fashion_code = "5"; + break; + } + } + } + } + map.put("birth_fashion_code", birth_fashion_code); + //产程Ⅰ(小时) + map.put("production_process_one_hour", null); + //产程Ⅰ(分钟) + map.put("production_process_one_minute", null); + //产程Ⅱ(小时) + map.put("production_process_tow_hour", null); + //产程Ⅱ(分钟) + map.put("production_process_tow_minute", null); + //产程Ⅲ(小时) + map.put("production_process_three_hour", null); + //产程Ⅲ(分钟) + map.put("production_process_threeminute", null); + //总产程(小时) + map.put("production_process_total_hour", null); + //总产程(分钟) + map.put("production_process_totalminute", null); + //产后血压高压 + map.put("blood_pressure_high", null); + //产后血压低压 + map.put("blood_pressure_low", null); + //产后2小时血压高压 + map.put("blood_pressure_secondhour_high", null); + //产后2小时血压低压 + map.put("blood_pressure_second_hour_low", null); + //呼吸(次/分) + map.put("breathing_rate", null); + //脉搏(次/分) + map.put("pulse_rate", null); + //产时出血量(ml) + map.put("bleeding_amount_first_hour", null); + //产后2小时出血量(ml) + map.put("bleeding_amount_second_hour", null); + //总出血量 + map.put("bleeding_amount_total", null); + //会阴情况 + map.put("perineal_condition_code", "/"); + //撕裂Ⅰ° + map.put("perineal_tearing_one", "/"); + //撕裂Ⅱ° + map.put("perineal_tearing_two", "/"); + //撕裂Ⅲ° + map.put("perineal_tearing_three", "/"); + //撕裂缝线 + map.put("perineal_tearing_suture", "/"); + //新生儿情况 + String neonatal_condition_code="/"; + if (null!=model.getTireNumber()) { + switch (model.getTireNumber()){ + case 1: + neonatal_condition_code="1"; + break; + case 2: + neonatal_condition_code="2"; + break; + default: + neonatal_condition_code="3"; + } + } + map.put("neonatal_condition_code", neonatal_condition_code); + //畸形详细 + map.put("malformation_detailed", "/"); + //新生儿情况其它 + map.put("neonatal_condition_other", "/"); + //出院时间 + map.put("out_time", null); + //分娩医院名称 + String birth_hospital_name = couponMapper.findHospitalNameById(model.getFmHospital()); + map.put("birth_hospital_name", StringUtils.isNotEmpty(birth_hospital_name)?birth_hospital_name:"/"); + //接生者(接生医生) + String mid_wife="/"; + if(StringUtils.isNotEmpty(model.getDeliverDoctor())) { + Users user = usersService.getUsers(Integer.parseInt(model.getDeliverDoctor())); + if (null!=user && StringUtils.isNotEmpty(user.getName())) { + mid_wife=user.getName(); + } + } + map.put("mid_wife", mid_wife); + //产妇状态 + String maternal_state_code=model.getMaternalInfo(); + map.put("maternal_state_code", StringUtils.isNotEmpty(maternal_state_code)?maternal_state_code:"/"); + //产时并发症 + map.put("obstetric_morbidity_code", "/"); + //产时并发症--详述 + map.put("obstetric_morbidity_contents", "/"); + //开奶时间 + map.put("milk_open_time", null); + //分娩机构(分娩医疗机构统一社会信用代码) + String delivery_institution_id="/"; + if(StringUtils.isNotEmpty(model.getFmHospital())){ + delivery_institution_id =organizationService.getPlatHosNewCode(model.getFmHospital()); + } + map.put("delivery_institution_id", delivery_institution_id); + //录入系统时间 + map.put("entering_time", null!=model.getCreated()?DateUtil.getyyyy_MM_dd_hms(model.getCreated()):DateUtil.getyyyy_MM_dd_hms(new Date())); + //所属机构编码(所属医疗机构统一社会信用代码) + String organ_id="/"; + if(StringUtils.isNotEmpty(model.getHospitalId())){ + organ_id =organizationService.getPlatHosNewCode(model.getHospitalId()); + } + map.put("organ_id", organ_id); + //关联妇女档id + String person_id="/"; + if(StringUtils.isNotEmpty(model.getParentId())){ + Patients patients = patientsService.findOnePatientById(model.getParentId()); + if(null!=patients && StringUtils.isNotEmpty(patients.getCardNo())) { + ResidentsArchiveQuery archiveQuery = new ResidentsArchiveQuery(); + archiveQuery.setYn(YnEnums.YES.getId()); + archiveQuery.setCertificateNum(patients.getCardNo()); + List modelList = residentsArchiveService.queryResident(archiveQuery); + if (CollectionUtils.isNotEmpty(modelList)) { + person_id = modelList.get(0).getId(); + } + } + } + map.put("person_id", person_id); + //关联专档id + map.put("file_id", StringUtils.isNotEmpty(model.getParentId())?model.getParentId():"/"); + //导入时间 +// map.put("import_time", null); + //修改时间 + map.put("last_modified_time", null); + //删除状态 + map.put("is_deleted", "0"); + //删除时间 + map.put("deleted_time", null); + + data.add(map); + } catch (Exception e) { + e.printStackTrace(); + } + } + + BaseObjectResponse objectResponse = new BaseObjectResponse(); + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); + objectResponse.setErrormsg("成功"); + objectResponse.setData(data); + return objectResponse; + } + + public BaseObjectResponse getMsgcC401(String startDate, String endDate) { + + Query query=new Query(); + query.addCriteria(Criteria.where("yn").is(1)); + if(StringUtils.isNotEmpty(startDate) && StringUtils.isNotEmpty(endDate)){ + query.addCriteria(Criteria.where("dueDate1").gte(DateUtil.getDayFirstSecond(DateUtil.parseYMD(startDate))) + .lte(DateUtil.getDayLastSecond(DateUtil.parseYMD(endDate)))); + }else { + //当天的数据 + query.addCriteria(Criteria.where("dueDate1").gte(DateUtil.getDayFirstSecond(new Date())) + .lte(DateUtil.getDayLastSecond(new Date()))); + } + List fmList = mongoTemplate.find(query, MaternalDeliverModel.class); + List data = new ArrayList<>(); + for (MaternalDeliverModel model : fmList) { + try { + Map map=new HashMap(); + + + + + data.add(map); + } catch (Exception e) { + e.printStackTrace(); + } + } + + + BaseObjectResponse objectResponse = new BaseObjectResponse(); + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); + objectResponse.setErrormsg("成功"); + objectResponse.setData(data); + return objectResponse; + } } -- 1.8.3.1