病人信息
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.openhis.administration.service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.openhis.administration.domain.Patient;
|
||||
|
||||
@@ -11,4 +13,11 @@ import com.openhis.administration.domain.Patient;
|
||||
*/
|
||||
public interface IPatientService extends IService<Patient> {
|
||||
|
||||
/**
|
||||
* 从身份证号码中提取生日
|
||||
*
|
||||
* @param idCard 身份证号
|
||||
* @return 出生日
|
||||
*/
|
||||
Date extractBirthday(String idCard);
|
||||
}
|
||||
@@ -54,14 +54,14 @@ public class OrganizationServiceImpl extends ServiceImpl<OrganizationMapper, Org
|
||||
/**
|
||||
* 通过机构ID查询机构名称
|
||||
*
|
||||
* @param code 机构ID
|
||||
* @param busNo 机构ID
|
||||
* @return 机构名称
|
||||
*/
|
||||
@Override
|
||||
public Organization getByCode(String code) {
|
||||
public Organization getByBusNo(String busNo) {
|
||||
QueryWrapper<Organization> queryWrapper = new QueryWrapper<>();
|
||||
// 设置查询条件为机构Id code
|
||||
queryWrapper.eq("code", code);
|
||||
queryWrapper.eq("bus_no", busNo);
|
||||
return organizationMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package com.openhis.administration.service.impl;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -16,4 +22,25 @@ import com.openhis.administration.service.IPatientService;
|
||||
@Service
|
||||
public class PatientServiceImpl extends ServiceImpl<PatientMapper, Patient> implements IPatientService {
|
||||
|
||||
/**
|
||||
* 从身份证号码中提取生日
|
||||
*
|
||||
* @param idCard 身份证号
|
||||
* @return 出生日
|
||||
*/
|
||||
public Date extractBirthday(String idCard) {
|
||||
if (idCard == null) {
|
||||
// 身份证号码为空
|
||||
return null;
|
||||
}
|
||||
|
||||
// 提取第7到14位作为生日字符串
|
||||
String birthdayStr = idCard.substring(6, 14);
|
||||
// 将生日字符串转换为 LocalDate
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
LocalDate date = LocalDate.parse(birthdayStr, formatter);
|
||||
// 使用系统默认时区,将 LocalDate 转换为 Date
|
||||
return Date.from(Instant.from(date.atStartOfDay(ZoneId.systemDefault())));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user