| | |
| | | //package cn.lihu.jh.module.ecg.service.appointment; |
| | | // |
| | | //import org.junit.jupiter.api.Disabled; |
| | | //import org.junit.jupiter.api.Test; |
| | | //import org.springframework.boot.test.mock.mockito.MockBean; |
| | | // |
| | | //import jakarta.annotation.Resource; |
| | | // |
| | | //import cn.lihu.jh.framework.test.core.ut.BaseDbUnitTest; |
| | | // |
| | | //import cn.lihu.jh.module.ecg.controller.admin.appointment.vo.*; |
| | | //import cn.lihu.jh.module.ecg.dal.dataobject.appointment.AppointmentDO; |
| | | //import cn.lihu.jh.module.ecg.dal.mysql.appointment.AppointmentMapper; |
| | | //import cn.lihu.jh.framework.common.pojo.PageResult; |
| | | // |
| | | //import jakarta.annotation.Resource; |
| | | //import org.springframework.context.annotation.Import; |
| | | //import java.util.*; |
| | | //import java.time.LocalDateTime; |
| | | // |
| | | //import static cn.hutool.core.util.RandomUtil.*; |
| | | //import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.*; |
| | | //import static cn.lihu.jh.framework.test.core.util.AssertUtils.*; |
| | | //import static cn.lihu.jh.framework.test.core.util.RandomUtils.*; |
| | | //import static cn.lihu.jh.framework.common.util.date.LocalDateTimeUtils.*; |
| | | //import static cn.lihu.jh.framework.common.util.object.ObjectUtils.*; |
| | | //import static cn.lihu.jh.framework.common.util.date.DateUtils.*; |
| | | //import static org.junit.jupiter.api.Assertions.*; |
| | | //import static org.mockito.Mockito.*; |
| | | // |
| | | ///** |
| | | // * {@link AppointmentServiceImpl} 的单元测试类 |
| | | // * |
| | | // * @author 马剑波 |
| | | // */ |
| | | //@Import(AppointmentServiceImpl.class) |
| | | //public class AppointmentServiceImplTest extends BaseDbUnitTest { |
| | | // |
| | | // @Resource |
| | | // private AppointmentServiceImpl appointmentService; |
| | | // |
| | | // @Resource |
| | | // private AppointmentMapper appointmentMapper; |
| | | // |
| | | // @Test |
| | | // public void testCreateAppointment_success() { |
| | | // // 准备参数 |
| | | // AppointmentSaveReqVO createReqVO = randomPojo(AppointmentSaveReqVO.class).setId(null); |
| | | // |
| | | // // 调用 |
| | | // Integer appointmentId = appointmentService.createAppointment(createReqVO); |
| | | // // 断言 |
| | | // assertNotNull(appointmentId); |
| | | // // 校验记录的属性是否正确 |
| | | // AppointmentDO appointment = appointmentMapper.selectById(appointmentId); |
| | | // assertPojoEquals(createReqVO, appointment, "id"); |
| | | // } |
| | | // |
| | | // @Test |
| | | // public void testUpdateAppointment_success() { |
| | | // // mock 数据 |
| | | // AppointmentDO dbAppointment = randomPojo(AppointmentDO.class); |
| | | // appointmentMapper.insert(dbAppointment);// @Sql: 先插入出一条存在的数据 |
| | | // // 准备参数 |
| | | // AppointmentSaveReqVO updateReqVO = randomPojo(AppointmentSaveReqVO.class, o -> { |
| | | // o.setId(dbAppointment.getId()); // 设置更新的 ID |
| | | // }); |
| | | // |
| | | // // 调用 |
| | | // appointmentService.updateAppointment(updateReqVO); |
| | | // // 校验是否更新正确 |
| | | // AppointmentDO appointment = appointmentMapper.selectById(updateReqVO.getId()); // 获取最新的 |
| | | // assertPojoEquals(updateReqVO, appointment); |
| | | // } |
| | | // |
| | | // @Test |
| | | // public void testUpdateAppointment_notExists() { |
| | | // // 准备参数 |
| | | // AppointmentSaveReqVO updateReqVO = randomPojo(AppointmentSaveReqVO.class); |
| | | // |
| | | // // 调用, 并断言异常 |
| | | // assertServiceException(() -> appointmentService.updateAppointment(updateReqVO), APPOINTMENT_NOT_EXISTS); |
| | | // } |
| | | // |
| | | // @Test |
| | | // public void testDeleteAppointment_success() { |
| | | // // mock 数据 |
| | | // AppointmentDO dbAppointment = randomPojo(AppointmentDO.class); |
| | | // appointmentMapper.insert(dbAppointment);// @Sql: 先插入出一条存在的数据 |
| | | // // 准备参数 |
| | | // Integer id = dbAppointment.getId(); |
| | | // |
| | | // // 调用 |
| | | // appointmentService.deleteAppointment(id); |
| | | // // 校验数据不存在了 |
| | | // assertNull(appointmentMapper.selectById(id)); |
| | | // } |
| | | // |
| | | // @Test |
| | | // public void testDeleteAppointment_notExists() { |
| | | // // 准备参数 |
| | | // Integer id = randomIntegerId(); |
| | | // |
| | | // // 调用, 并断言异常 |
| | | // assertServiceException(() -> appointmentService.deleteAppointment(id), APPOINTMENT_NOT_EXISTS); |
| | | // } |
| | | // |
| | | // @Test |
| | | // @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 |
| | | // public void testGetAppointmentPage() { |
| | | // // mock 数据 |
| | | // AppointmentDO dbAppointment = randomPojo(AppointmentDO.class, o -> { // 等会查询到 |
| | | // o.setPatId(null); |
| | | // o.setPatName(null); |
| | | // o.setPatGender(null); |
| | | // o.setPatBirthday(null); |
| | | // o.setPatMobile(null); |
| | | // o.setPatPhone(null); |
| | | // o.setPatIdentityId(null); |
| | | // o.setPatAddr(null); |
| | | // o.setPatDeptCode(null); |
| | | // o.setPatDeptDesc(null); |
| | | // o.setPatWardCode(null); |
| | | // o.setPatWardDesc(null); |
| | | // o.setPatBedNo(null); |
| | | // o.setBookId(null); |
| | | // o.setBookPeriodStart(null); |
| | | // o.setBookPeriodEnd(null); |
| | | // o.setBookTime(null); |
| | | // o.setBookCheckType(null); |
| | | // o.setBookSrc(null); |
| | | // }); |
| | | // appointmentMapper.insert(dbAppointment); |
| | | // // 测试 patId 不匹配 |
| | | // appointmentMapper.insert(cloneIgnoreId(dbAppointment, o -> o.setPatId(null))); |
| | | // // 测试 patName 不匹配 |
| | | // appointmentMapper.insert(cloneIgnoreId(dbAppointment, o -> o.setPatName(null))); |
| | | // // 测试 patGender 不匹配 |
| | | // appointmentMapper.insert(cloneIgnoreId(dbAppointment, o -> o.setPatGender(null))); |
| | | // // 测试 patBirthday 不匹配 |
| | | // appointmentMapper.insert(cloneIgnoreId(dbAppointment, o -> o.setPatBirthday(null))); |
| | | // // 测试 patMobile 不匹配 |
| | | // appointmentMapper.insert(cloneIgnoreId(dbAppointment, o -> o.setPatMobile(null))); |
| | | // // 测试 patPhone 不匹配 |
| | | // appointmentMapper.insert(cloneIgnoreId(dbAppointment, o -> o.setPatPhone(null))); |
| | | // // 测试 patIdentityId 不匹配 |
| | | // appointmentMapper.insert(cloneIgnoreId(dbAppointment, o -> o.setPatIdentityId(null))); |
| | | // // 测试 patAddr 不匹配 |
| | | // appointmentMapper.insert(cloneIgnoreId(dbAppointment, o -> o.setPatAddr(null))); |
| | | // // 测试 patDeptCode 不匹配 |
| | | // appointmentMapper.insert(cloneIgnoreId(dbAppointment, o -> o.setPatDeptCode(null))); |
| | | // // 测试 patDeptDesc 不匹配 |
| | | // appointmentMapper.insert(cloneIgnoreId(dbAppointment, o -> o.setPatDeptDesc(null))); |
| | | // // 测试 patWardCode 不匹配 |
| | | // appointmentMapper.insert(cloneIgnoreId(dbAppointment, o -> o.setPatWardCode(null))); |
| | | // // 测试 patWardDesc 不匹配 |
| | | // appointmentMapper.insert(cloneIgnoreId(dbAppointment, o -> o.setPatWardDesc(null))); |
| | | // // 测试 patBedNo 不匹配 |
| | | // appointmentMapper.insert(cloneIgnoreId(dbAppointment, o -> o.setPatBedNo(null))); |
| | | // // 测试 bookId 不匹配 |
| | | // appointmentMapper.insert(cloneIgnoreId(dbAppointment, o -> o.setBookId(null))); |
| | | // // 测试 bookPeriodStart 不匹配 |
| | | // appointmentMapper.insert(cloneIgnoreId(dbAppointment, o -> o.setBookPeriodStart(null))); |
| | | // // 测试 bookPeriodEnd 不匹配 |
| | | // appointmentMapper.insert(cloneIgnoreId(dbAppointment, o -> o.setBookPeriodEnd(null))); |
| | | // // 测试 bookTime 不匹配 |
| | | // appointmentMapper.insert(cloneIgnoreId(dbAppointment, o -> o.setBookTime(null))); |
| | | // // 测试 bookCheckType 不匹配 |
| | | // appointmentMapper.insert(cloneIgnoreId(dbAppointment, o -> o.setBookCheckType(null))); |
| | | // // 测试 bookSrc 不匹配 |
| | | // appointmentMapper.insert(cloneIgnoreId(dbAppointment, o -> o.setBookSrc(null))); |
| | | // // 准备参数 |
| | | // AppointmentPageReqVO reqVO = new AppointmentPageReqVO(); |
| | | // reqVO.setPatId(null); |
| | | // reqVO.setPatName(null); |
| | | // reqVO.setPatGender(null); |
| | | // reqVO.setPatBirthday(null); |
| | | // reqVO.setPatMobile(null); |
| | | // reqVO.setPatPhone(null); |
| | | // reqVO.setPatIdentityId(null); |
| | | // reqVO.setPatAddr(null); |
| | | // reqVO.setPatDeptCode(null); |
| | | // reqVO.setPatDeptDesc(null); |
| | | // reqVO.setPatWardCode(null); |
| | | // reqVO.setPatWardDesc(null); |
| | | // reqVO.setPatBedNo(null); |
| | | // reqVO.setBookId(null); |
| | | // reqVO.setBookPeriodStart(null); |
| | | // reqVO.setBookPeriodEnd(null); |
| | | // reqVO.setBookTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); |
| | | // reqVO.setBookCheckType(null); |
| | | // reqVO.setBookSrc(null); |
| | | // |
| | | // // 调用 |
| | | // PageResult<AppointmentDO> pageResult = appointmentService.getAppointmentPage(reqVO); |
| | | // // 断言 |
| | | // assertEquals(1, pageResult.getTotal()); |
| | | // assertEquals(1, pageResult.getList().size()); |
| | | // assertPojoEquals(dbAppointment, pageResult.getList().get(0)); |
| | | // } |
| | | // |
| | | //} |
| | | package cn.lihu.jh.module.ecg.service.appointment; |
| | | |
| | | import cn.lihu.jh.module.ecg.controller.admin.appointment.vo.*; |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.appointment.AppointmentDO; |
| | | import cn.lihu.jh.module.ecg.dal.mysql.appointment.AppointmentMapper; |
| | | import cn.lihu.jh.framework.common.pojo.PageResult; |
| | | |
| | | import cn.lihu.jh.module.ecg.feign.ExmRequest; |
| | | import cn.lihu.jh.module.ecg.feign.HisFeeConfirmReqBody; |
| | | import cn.lihu.jh.module.ecg.feign.Item; |
| | | import cn.lihu.jh.module.ecg.feign.MsgHeader; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.dataformat.xml.XmlMapper; |
| | | import org.junit.Test; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | import org.springframework.context.annotation.Import; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | /** |
| | | * {@link AppointmentServiceImpl} 的单元测试类 |
| | | * |
| | | * @author 马剑波 |
| | | */ |
| | | @SpringBootTest |
| | | public class AppointmentServiceImplTest { |
| | | |
| | | @Resource |
| | | private AppointmentServiceImpl appointmentService; |
| | | |
| | | @Resource |
| | | private AppointmentMapper appointmentMapper; |
| | | |
| | | @Test |
| | | public void test() { |
| | | String regex = "(\\d+)[::](\\d+)"; |
| | | String input = "08:00"; |
| | | |
| | | Pattern pattern = Pattern.compile(regex); |
| | | Matcher matcher = pattern.matcher(input); |
| | | |
| | | if (matcher.find()) { |
| | | // 获取整个匹配的字符串 |
| | | String fullMatch = matcher.group(); |
| | | System.out.println("Full match: " + fullMatch); |
| | | |
| | | |
| | | // 获取第一个捕获组(用户名) |
| | | String username = matcher.group(1); |
| | | System.out.println("Username: " + username); |
| | | System.out.println("Username: " + Integer.valueOf(username)); |
| | | |
| | | |
| | | // 获取第二个捕获组(域名) |
| | | String domain = matcher.group(2); |
| | | System.out.println("Domain: " + domain); |
| | | System.out.println("Domain: " + Integer.valueOf(domain)); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void test2() throws JsonProcessingException { |
| | | HisFeeConfirmReqBody hisFeeConfirmReqBody = new HisFeeConfirmReqBody(); |
| | | MsgHeader msgHeader = new MsgHeader(); |
| | | msgHeader.setMsgType("ODS_2212"); |
| | | msgHeader.setMsgVersion("3.0"); |
| | | msgHeader.setSender("ECG"); |
| | | hisFeeConfirmReqBody.setMsgHeader(msgHeader); |
| | | Item item = new Item(); |
| | | item.setItemCode("559542128"); |
| | | item.setItemStatus("5"); |
| | | item.setExeOrganization("47162057-2"); |
| | | item.setExeDeptName("心电科"); |
| | | item.setExeDept("心电科"); |
| | | item.setExeDoctor("0457"); |
| | | item.setExeDoctorName("徐小英"); |
| | | item.setExeDateTime("2024-11-21 16:28:28"); |
| | | ExmRequest exmRequest = new ExmRequest(); |
| | | exmRequest.setAuthorOrganization("47162057-2"); |
| | | exmRequest.setRequestId("815769404"); |
| | | exmRequest.setPatientType("01"); |
| | | exmRequest.setItem(item); |
| | | hisFeeConfirmReqBody.setExmRequest(exmRequest); |
| | | XmlMapper xmlMapper = new XmlMapper(); |
| | | String xml = xmlMapper.writeValueAsString(hisFeeConfirmReqBody); |
| | | System.out.println(xml); |
| | | } |
| | | } |