|
@@ -19,6 +19,7 @@ import thyyxxk.wxservice_server.entity.hrgresponse.CreateCardResponse;
|
|
|
import thyyxxk.wxservice_server.entity.patientcards.BindPatientIdParam;
|
|
|
import thyyxxk.wxservice_server.entity.patientcards.CreatCardParam;
|
|
|
import thyyxxk.wxservice_server.utils.ResultVoUtil;
|
|
|
+import thyyxxk.wxservice_server.utils.StringUtil;
|
|
|
|
|
|
import java.text.DateFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
@@ -96,9 +97,13 @@ public class IdCardAnalyzeService {
|
|
|
card.setPatIdType(1);
|
|
|
card.setPatIdNo(param.getSocialNo());
|
|
|
card.setPatMobile(param.getPhone());
|
|
|
- card.setPatAge(calculateAge(param.getSocialNo()));
|
|
|
- card.setPatSex(calculateSex(param.getSocialNo()));
|
|
|
- card.setPatBirth(formatBirthday(param.getSocialNo().substring(6, 14)));
|
|
|
+ card.setPatAge(calculateAge(param.getSocialNo(), param.getBirthday()));
|
|
|
+ if (StringUtil.isBlank(param.getSocialNo())) {
|
|
|
+ card.setPatSex(param.getSex());
|
|
|
+ } else {
|
|
|
+ card.setPatSex(calculateSex(param.getSocialNo()));
|
|
|
+ }
|
|
|
+ card.setPatBirth(formatBirthday(param.getSocialNo(), param.getBirthday()));
|
|
|
card.setPatType(calculatePatType(card.getPatAge()));
|
|
|
card.setGuardName(param.getGuardName());
|
|
|
card.setGuardIdType(1);
|
|
@@ -106,7 +111,7 @@ public class IdCardAnalyzeService {
|
|
|
String provinceName = dao.selectRegionName(param.getProvince());
|
|
|
String cityName = dao.selectRegionName(param.getCity());
|
|
|
String districtName = dao.selectRegionName(param.getDistrict());
|
|
|
- card.setPatAddress(provinceName+cityName+districtName+param.getStreet());
|
|
|
+ card.setPatAddress(provinceName + cityName + districtName + param.getStreet());
|
|
|
RestTemplate template = new RestTemplate();
|
|
|
CreateCardResponse hrgResponse = template.postForObject(hrgApiUrl + "/savePatientInfo", card, CreateCardResponse.class);
|
|
|
log.info("首诊患者建档:参数:{},结果:{}", card, hrgResponse);
|
|
@@ -141,17 +146,18 @@ public class IdCardAnalyzeService {
|
|
|
return CompletableFuture.completedFuture(ResultVoUtil.success(hrgResponse.getData()));
|
|
|
}
|
|
|
|
|
|
- private String formatBirthday(String day) throws Exception {
|
|
|
+ private String formatBirthday(String socialNo, String birth) throws Exception {
|
|
|
+ String day = StringUtil.isBlank(socialNo) ? birth : socialNo.substring(6, 14);
|
|
|
SimpleDateFormat origin = new SimpleDateFormat("yyyyMMdd");
|
|
|
SimpleDateFormat destination = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
return destination.format(origin.parse(day));
|
|
|
}
|
|
|
|
|
|
- private Integer calculateAge(String socialNo) throws Exception {
|
|
|
- String dates = socialNo.substring(6, 10) + "-" + socialNo.substring(10, 12) + "-" + socialNo.substring(12, 14);
|
|
|
+ private Integer calculateAge(String socialNo, String birth) throws Exception {
|
|
|
+ String dates = StringUtil.isBlank(socialNo) ? birth : socialNo.substring(6, 14);
|
|
|
Date nowDate = new Date();
|
|
|
//获取当前时间
|
|
|
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ DateFormat df = new SimpleDateFormat("yyyyMMdd");
|
|
|
Date birthDate = df.parse(dates);
|
|
|
//格式化出生日期
|
|
|
long diff = nowDate.getTime() - birthDate.getTime();
|
|
@@ -166,6 +172,9 @@ public class IdCardAnalyzeService {
|
|
|
}
|
|
|
|
|
|
private Integer calculatePatType(Integer age) {
|
|
|
+ if (null == age) {
|
|
|
+ return 2;
|
|
|
+ }
|
|
|
return age > 12 ? 1 : 2;
|
|
|
}
|
|
|
}
|