代码层级调整

This commit is contained in:
Wang.Huan
2025-03-10 15:22:12 +08:00
parent eb966de4a5
commit 7ca339e3c7
14 changed files with 458 additions and 316 deletions

View File

@@ -120,7 +120,7 @@ public class PractitionerRoleController {
// 编辑practitionerRole信息
PractitionerRole practitionerRole = new PractitionerRole();
BeanUtils.copyProperties(practitionerRoleDto, practitionerRole);
if (practitionerRole.getRole_code() == null) {
if (practitionerRole.getRoleCode() == null) {
return R.fail(PromptMsgConstant.Common.M00007, "角色编码不能为空");
}
if (practitionerRole.getOrgId() == null) {

View File

@@ -1,23 +1,55 @@
package com.openhis.web.doctorstation.appservice;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.openhis.web.doctorstation.dto.PatientInfoDto;
import com.core.common.core.domain.R;
import com.openhis.web.doctorstation.dto.EmrTemplateDto;
import com.openhis.web.doctorstation.dto.PatientEmrDto;
/**
* 医生站-电子病历 应用Service
*/
public interface IDoctorStationEmrAppService {
/**
* 添加病人病历信息
*
* @param patientEmrDto 电子病历信息dto
* @return 操作结果
*/
R<?> addPatientEmr(PatientEmrDto patientEmrDto);
/**
* 查询就诊患者信息
* 获取患者历史病历
*
* @param patientInfoDto 查询条件 (前端传 statusEnum 区分就诊状态tab)
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @return 就诊患者信息
* @param patientEmrDto 查询条件
* @param pageNo 当前页码
* @param pageSize 查询条数
* @return 分页数据列表
*/
IPage<PatientInfoDto> getPatientInfo(PatientInfoDto patientInfoDto, String searchKey, Integer pageNo,
Integer pageSize);
R<?> getPatientEmrHistory(PatientEmrDto patientEmrDto, Integer pageNo, Integer pageSize);
/**
* 保存病历模板
*
* @param emrTemplateDto 病历模板信息
* @return 操作结果
*/
R<?> addEmrTemplate(EmrTemplateDto emrTemplateDto);
/**
* 获取电子病历模板列表
*
* @param emrTemplateDto 查询参数
* @param pageNo 当前页码
* @param pageSize 查询条数
* @return
*/
R<?> getEmrTemplate(EmrTemplateDto emrTemplateDto, Integer pageNo, Integer pageSize);
/**
* 删除病历模板
*
* @param id 模板id
* @return 操作结果
*/
R<?> deleteEmrTemplate(Long id);
}

View File

@@ -0,0 +1,23 @@
package com.openhis.web.doctorstation.appservice;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.openhis.web.doctorstation.dto.PatientInfoDto;
/**
* 医生站-电子病历 应用Service
*/
public interface IDoctorStationMainAppService {
/**
* 查询就诊患者信息
*
* @param patientInfoDto 查询条件 (前端传 statusEnum 区分就诊状态tab)
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @return 就诊患者信息
*/
IPage<PatientInfoDto> getPatientInfo(PatientInfoDto patientInfoDto, String searchKey, Integer pageNo,
Integer pageSize);
}

View File

@@ -1,25 +1,31 @@
package com.openhis.web.doctorstation.appservice.impl;
import java.util.Arrays;
import java.util.HashSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.core.common.utils.AgeCalculatorUtil;
import com.openhis.common.enums.AdministrativeGender;
import com.openhis.common.enums.ClinicalStatus;
import com.openhis.common.enums.EncounterStatus;
import com.openhis.common.enums.ParticipantType;
import com.openhis.common.utils.EnumUtils;
import com.openhis.common.utils.HisQueryUtils;
import com.core.common.core.domain.R;
import com.openhis.document.domain.Emr;
import com.openhis.document.domain.EmrDetail;
import com.openhis.document.domain.EmrDict;
import com.openhis.document.domain.EmrTemplate;
import com.openhis.document.service.IEmrDetailService;
import com.openhis.document.service.IEmrDictService;
import com.openhis.document.service.IEmrService;
import com.openhis.document.service.IEmrTemplateService;
import com.openhis.web.doctorstation.appservice.IDoctorStationEmrAppService;
import com.openhis.web.doctorstation.dto.PatientInfoDto;
import com.openhis.web.doctorstation.mapper.DoctorStationEmrAppMapper;
import com.openhis.web.doctorstation.dto.EmrTemplateDto;
import com.openhis.web.doctorstation.dto.PatientEmrDto;
/**
* 医生站-电子病历 应用实现类
@@ -28,34 +34,107 @@ import com.openhis.web.doctorstation.mapper.DoctorStationEmrAppMapper;
public class DoctorStationEmrAppServiceImpl implements IDoctorStationEmrAppService {
@Resource
DoctorStationEmrAppMapper doctorStationEmrAppMapper;
IEmrService emrService;
@Resource
IEmrTemplateService emrTemplateService;
@Resource
IEmrDetailService emrDetailService;
@Resource
IEmrDictService emrDictService;
/**
* 查询就诊患者信息
* 添加病人病历信息
*
* @param patientInfoDto 查询条件 (前端传 statusEnum 区分就诊状态tab)
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @return 就诊患者信息
* @param patientEmrDto 电子病历信息dto
* @return 操作结果
*/
@Override
public IPage<PatientInfoDto> getPatientInfo(PatientInfoDto patientInfoDto, String searchKey, Integer pageNo,
Integer pageSize) {
// 构建查询条件
QueryWrapper<PatientInfoDto> queryWrapper = HisQueryUtils.buildQueryWrapper(patientInfoDto, searchKey,
new HashSet<>(Arrays.asList("patient_name", "id_card", "phone")), null);
IPage<PatientInfoDto> patientInfo = doctorStationEmrAppMapper.getPatientInfo(new Page<>(pageNo, pageSize),
ParticipantType.ADMITTER.getCode(), ClinicalStatus.INACTIVE.getValue(), null, null, queryWrapper);
patientInfo.getRecords().forEach(e -> {
// 性别
e.setGenderEnum_enumText(EnumUtils.getInfoByValue(AdministrativeGender.class, e.getGenderEnum()));
// 计算年龄
e.setAge(AgeCalculatorUtil.getAge(e.getBirthDate()));
// 就诊状态
e.setStatusEnum_enumText(EnumUtils.getInfoByValue(EncounterStatus.class, e.getStatusEnum()));
});
return patientInfo;
public R<?> addPatientEmr(PatientEmrDto patientEmrDto) {
Emr emr = new Emr();
BeanUtils.copyProperties(patientEmrDto, emr);
String contextStr = patientEmrDto.getContextJson().toString();
boolean saveSuccess = emrService.save(emr.setContextJson(contextStr));
if (!saveSuccess) {
return R.fail();
}
// 获取电子病历字典表中全部key用来判断病历JSON串中是否有需要加入到病历详情表的字段
List<String> emrDictList = emrDictService.list(new LambdaQueryWrapper<EmrDict>().select(EmrDict::getEmrKey))
.stream().map(EmrDict::getEmrKey).collect(Collectors.toList());
Map<String, String> emrContextMap =
JSONObject.parseObject(contextStr, new TypeReference<Map<String, String>>() {});
List<EmrDetail> emrDetailList = new ArrayList<>();
// 遍历病历内容map
for (Map.Entry<String, String> entry : emrContextMap.entrySet()) {
EmrDetail emrDetail = new EmrDetail();
emrDetail.setEmrId(emr.getId());
if (!emrDictList.isEmpty() && emrDictList.contains(entry.getKey())) {
emrDetail.setEmrKey(entry.getKey());
emrDetail.setEmrValue(entry.getValue());
}
emrDetailList.add(emrDetail);
}
boolean save = emrDetailService.saveBatch(emrDetailList);
return save ? R.ok() : R.fail();
}
/**
* 获取患者历史病历
*
* @param patientEmrDto 查询条件
* @param pageNo 当前页码
* @param pageSize 查询条数
* @return 分页数据列表
*/
@Override
public R<?> getPatientEmrHistory(PatientEmrDto patientEmrDto, Integer pageNo, Integer pageSize) {
Page<Emr> page = emrService.page(new Page<>(pageNo, pageSize),
new LambdaQueryWrapper<Emr>().eq(Emr::getPatientId, patientEmrDto.getPatientId()));
return R.ok(page);
}
/**
* 保存病历模板
*
* @param emrTemplateDto 病历模板信息
* @return 操作结果
*/
@Override
public R<?> addEmrTemplate(EmrTemplateDto emrTemplateDto) {
EmrTemplate emrTemplate = new EmrTemplate();
BeanUtils.copyProperties(emrTemplateDto, emrTemplate);
return emrTemplateService.save(emrTemplate) ? R.ok() : R.fail();
}
/**
* 获取电子病历模板列表
*
* @param emrTemplateDto 查询参数
* @param pageNo 当前页码
* @param pageSize 查询条数
* @return
*/
@Override
public R<?> getEmrTemplate(EmrTemplateDto emrTemplateDto, Integer pageNo, Integer pageSize) {
LambdaQueryWrapper<EmrTemplate> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(EmrTemplate::getTemplateName, emrTemplateDto.getTemplateName())
.eq(EmrTemplate::getUseScopeCode, emrTemplateDto.getUseScopeCode())
.eq(EmrTemplate::getUserId, emrTemplateDto.getUserId());
Page<EmrTemplate> emrTemplatePage = emrTemplateService.page(new Page<>(pageNo, pageSize), queryWrapper);
return R.ok(emrTemplatePage);
}
/**
* 删除病历模板
*
* @param id 模板id
* @return 操作结果
*/
@Override
public R<?> deleteEmrTemplate(Long id) {
return emrTemplateService.removeById(id) ? R.ok() : R.fail();
}
}

View File

@@ -0,0 +1,63 @@
package com.openhis.web.doctorstation.appservice.impl;
import java.util.Arrays;
import java.util.HashSet;
import javax.annotation.Resource;
import com.openhis.web.doctorstation.appservice.IDoctorStationMainAppService;
import com.openhis.web.doctorstation.mapper.DoctorStationMainAppMapper;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.core.common.utils.AgeCalculatorUtil;
import com.openhis.common.enums.AdministrativeGender;
import com.openhis.common.enums.ClinicalStatus;
import com.openhis.common.enums.EncounterStatus;
import com.openhis.common.enums.ParticipantType;
import com.openhis.common.utils.EnumUtils;
import com.openhis.common.utils.HisQueryUtils;
import com.openhis.web.doctorstation.appservice.IDoctorStationEmrAppService;
import com.openhis.web.doctorstation.dto.PatientInfoDto;
import com.openhis.web.doctorstation.mapper.DoctorStationEmrAppMapper;
/**
* 医生站-电子病历 应用实现类
*/
@Service
public class DoctorStationMainAppServiceImpl implements IDoctorStationMainAppService {
@Resource
DoctorStationMainAppMapper doctorStationMainAppMapper;
/**
* 查询就诊患者信息
*
* @param patientInfoDto 查询条件 (前端传 statusEnum 区分就诊状态tab)
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @return 就诊患者信息
*/
@Override
public IPage<PatientInfoDto> getPatientInfo(PatientInfoDto patientInfoDto, String searchKey, Integer pageNo,
Integer pageSize) {
// 构建查询条件
QueryWrapper<PatientInfoDto> queryWrapper = HisQueryUtils.buildQueryWrapper(patientInfoDto, searchKey,
new HashSet<>(Arrays.asList("patient_name", "id_card", "phone")), null);
IPage<PatientInfoDto> patientInfo = doctorStationMainAppMapper.getPatientInfo(new Page<>(pageNo, pageSize),
ParticipantType.ADMITTER.getCode(), ClinicalStatus.INACTIVE.getValue(), null, null, queryWrapper);
patientInfo.getRecords().forEach(e -> {
// 性别
e.setGenderEnum_enumText(EnumUtils.getInfoByValue(AdministrativeGender.class, e.getGenderEnum()));
// 计算年龄
e.setAge(AgeCalculatorUtil.getAge(e.getBirthDate()));
// 就诊状态
e.setStatusEnum_enumText(EnumUtils.getInfoByValue(EncounterStatus.class, e.getStatusEnum()));
});
return patientInfo;
}
}

View File

@@ -3,15 +3,13 @@
*/
package com.openhis.web.doctorstation.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.core.common.core.domain.R;
import com.openhis.web.doctorstation.appservice.IDoctorStationEmrAppService;
import com.openhis.web.doctorstation.dto.DoctorStationInitDto;
import com.openhis.web.doctorstation.dto.PatientInfoDto;
import com.openhis.web.doctorstation.dto.EmrTemplateDto;
import com.openhis.web.doctorstation.dto.PatientEmrDto;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -28,31 +26,66 @@ public class DoctorStationEmrController {
private final IDoctorStationEmrAppService iDoctorStationEmrAppService;
/**
* 医生站基础数据初始化
* 添加病人病历信息
*
* @return 基础数据
* @param patientEmrDto 电子病历信息dto
* @return 操作结果
*/
@GetMapping(value = "/init")
public R<?> init() {
// DoctorStationInitDto doctorStationInitDto = new DoctorStationInitDto();
return R.ok(new DoctorStationInitDto());
@PostMapping("/emr")
public R<?> addPatientEmr(@Validated @RequestBody PatientEmrDto patientEmrDto) {
return iDoctorStationEmrAppService.addPatientEmr(patientEmrDto);
}
/**
* 查询就诊患者信息
* 获取患者历史病历
*
* @param patientInfoDto 查询条件 (前端传 statusEnum 区分就诊状态tab)
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @return 就诊患者信息
* @param patientEmrDto 查询条件
* @param pageNo 当前页码
* @param pageSize 查询条数
* @return 分页数据列表
*/
@GetMapping(value = "/patient-info")
public R<?> getPatientInfo(PatientInfoDto patientInfoDto,
@RequestParam(value = "searchKey", defaultValue = "") String searchKey,
@GetMapping("/emr-page")
public R<?> getPatientEmrHistory(PatientEmrDto patientEmrDto,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
return R.ok(iDoctorStationEmrAppService.getPatientInfo(patientInfoDto, searchKey, pageNo, pageSize));
return iDoctorStationEmrAppService.getPatientEmrHistory(patientEmrDto, pageNo, pageSize);
}
/**
* 保存病历模板
*
* @param emrTemplateDto 病历模板信息
* @return 操作结果
*/
@PostMapping("emr-template")
public R<?> addEmrTemplate(@RequestBody @Validated EmrTemplateDto emrTemplateDto) {
return iDoctorStationEmrAppService.addEmrTemplate(emrTemplateDto);
}
/**
* 获取电子病历模板列表
*
* @param emrTemplateDto 查询参数
* @param pageNo 当前页码
* @param pageSize 查询条数
* @return
*/
@GetMapping("emr-template-page")
public R<?> getEmrTemplate(EmrTemplateDto emrTemplateDto,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
return iDoctorStationEmrAppService.getEmrTemplate(emrTemplateDto, pageNo, pageSize);
}
/**
* 删除病历模板
*
* @param id 模板id
* @return 操作结果
*/
@DeleteMapping("emr-template")
public R<?> deleteEmrTemplate(@RequestParam Long id) {
return iDoctorStationEmrAppService.deleteEmrTemplate(id);
}
}

View File

@@ -0,0 +1,58 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.doctorstation.controller;
import com.openhis.web.doctorstation.appservice.IDoctorStationMainAppService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.core.common.core.domain.R;
import com.openhis.web.doctorstation.appservice.IDoctorStationEmrAppService;
import com.openhis.web.doctorstation.dto.DoctorStationInitDto;
import com.openhis.web.doctorstation.dto.PatientInfoDto;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
/**
* 医生站-主页面 controller
*/
@RestController
@RequestMapping("/doctor-station/main")
@Slf4j
@AllArgsConstructor
public class DoctorStationMainController {
private final IDoctorStationMainAppService iDoctorStationMainAppService;
/**
* 医生站基础数据初始化
*
* @return 基础数据
*/
@GetMapping(value = "/init")
public R<?> init() {
return R.ok(new DoctorStationInitDto());
}
/**
* 查询就诊患者信息
*
* @param patientInfoDto 查询条件 (前端传 statusEnum 区分就诊状态tab)
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @return 就诊患者信息
*/
@GetMapping(value = "/patient-info")
public R<?> getPatientInfo(PatientInfoDto patientInfoDto,
@RequestParam(value = "searchKey", defaultValue = "") String searchKey,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
return R.ok(iDoctorStationMainAppService.getPatientInfo(patientInfoDto, searchKey, pageNo, pageSize));
}
}

View File

@@ -1,7 +1,7 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.emr.dto;
package com.openhis.web.doctorstation.dto;
import lombok.Data;
import lombok.experimental.Accessors;

View File

@@ -1,7 +1,7 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.emr.dto;
package com.openhis.web.doctorstation.dto;
import javax.validation.constraints.NotNull;

View File

@@ -1,34 +1,11 @@
package com.openhis.web.doctorstation.mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.openhis.web.doctorstation.dto.PatientInfoDto;
/**
* 医生站-电子病历 应用Mapper
*/
@Repository
public interface DoctorStationEmrAppMapper {
/**
* 查询就诊患者信息
*
* @param page 分页参数
* @param participantType 参与者类型
* @param ClinicalStatus 过敏史状态
* @param userId 当前登录账号ID
* @param currentUserOrganizationId 当前登录账号所属的科室ID
* @param queryWrapper 查询条件
* @return 就诊患者信息
*/
IPage<PatientInfoDto> getPatientInfo(@Param("page") Page<PatientInfoDto> page,
@Param("participantType") String participantType, @Param("ClinicalStatus") Integer ClinicalStatus,
@Param("userId") Long userId, @Param("currentUserOrganizationId") Long currentUserOrganizationId,
@Param(Constants.WRAPPER) QueryWrapper<PatientInfoDto> queryWrapper);
}

View File

@@ -0,0 +1,34 @@
package com.openhis.web.doctorstation.mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.openhis.web.doctorstation.dto.PatientInfoDto;
/**
* 医生站-电子病历 应用Mapper
*/
@Repository
public interface DoctorStationMainAppMapper {
/**
* 查询就诊患者信息
*
* @param page 分页参数
* @param participantType 参与者类型
* @param ClinicalStatus 过敏史状态
* @param userId 当前登录账号ID
* @param currentUserOrganizationId 当前登录账号所属的科室ID
* @param queryWrapper 查询条件
* @return 就诊患者信息
*/
IPage<PatientInfoDto> getPatientInfo(@Param("page") Page<PatientInfoDto> page,
@Param("participantType") String participantType, @Param("ClinicalStatus") Integer ClinicalStatus,
@Param("userId") Long userId, @Param("currentUserOrganizationId") Long currentUserOrganizationId,
@Param(Constants.WRAPPER) QueryWrapper<PatientInfoDto> queryWrapper);
}

View File

@@ -1,157 +0,0 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.emr.controller;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.core.common.core.domain.R;
import com.openhis.document.domain.Emr;
import com.openhis.document.domain.EmrDetail;
import com.openhis.document.domain.EmrDict;
import com.openhis.document.domain.EmrTemplate;
import com.openhis.document.service.IEmrDetailService;
import com.openhis.document.service.IEmrDictService;
import com.openhis.document.service.IEmrService;
import com.openhis.document.service.IEmrTemplateService;
import com.openhis.web.emr.dto.EmrTemplateDto;
import com.openhis.web.emr.dto.PatientEmrDto;
import lombok.extern.slf4j.Slf4j;
/**
* 电子病历controller
*
* @author ZhangYC
* @date 2025-02-22
*/
@RestController
@RequestMapping("/doc-emr")
@Slf4j
public class PatientEmrController {
@Autowired
private IEmrService emrService;
@Autowired
private IEmrTemplateService emrTemplateService;
@Autowired
private IEmrDetailService emrDetailService;
@Autowired
private IEmrDictService emrDictService;
/**
* 添加病人病历信息
*
* @param patientEmrDto 电子病历信息dto
* @return 操作结果
*/
@PostMapping("/emr")
public R<?> addPatientEmr(@Validated @RequestBody PatientEmrDto patientEmrDto) {
Emr emr = new Emr();
BeanUtils.copyProperties(patientEmrDto, emr);
String contextStr = patientEmrDto.getContextJson().toString();
boolean saveSuccess = emrService.save(emr.setContextJson(contextStr));
if (!saveSuccess) {
return R.fail();
}
// 获取电子病历字典表中全部key用来判断病历JSON串中是否有需要加入到病历详情表的字段
List<String> emrDictList = emrDictService.list(new LambdaQueryWrapper<EmrDict>().select(EmrDict::getEmrKey))
.stream().map(EmrDict::getEmrKey).collect(Collectors.toList());
Map<String, String> emrContextMap =
JSONObject.parseObject(contextStr, new TypeReference<Map<String, String>>() {});
List<EmrDetail> emrDetailList = new ArrayList<>();
// 遍历病历内容map
for (Map.Entry<String, String> entry : emrContextMap.entrySet()) {
EmrDetail emrDetail = new EmrDetail();
emrDetail.setEmrId(emr.getId());
if (!emrDictList.isEmpty() && emrDictList.contains(entry.getKey())) {
emrDetail.setEmrKey(entry.getKey());
emrDetail.setEmrValue(entry.getValue());
}
emrDetailList.add(emrDetail);
}
boolean save = emrDetailService.saveBatch(emrDetailList);
return save ? R.ok() : R.fail();
}
/**
* 获取患者历史病历
*
* @param patientEmrDto 查询条件
* @param pageNo 当前页码
* @param pageSize 查询条数
* @return 分页数据列表
*/
@GetMapping("/emr-page")
public R<?> getPatientEmrHistory(PatientEmrDto patientEmrDto,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
// 根据患者id 获取历史病历列表
Page<Emr> emrPage = emrService.page(new Page<>(pageNo, pageSize),
new LambdaQueryWrapper<Emr>().eq(Emr::getPatientId, patientEmrDto.getPatientId()));
return R.ok(emrPage);
}
/**
* 保存病历模板
*
* @param emrTemplateDto 病历模板信息
* @return 操作结果
*/
@PostMapping("emr-template")
public R<?> addEmrTemplate(@RequestBody @Validated EmrTemplateDto emrTemplateDto) {
EmrTemplate emrTemplate = new EmrTemplate();
BeanUtils.copyProperties(emrTemplateDto, emrTemplate);
return emrTemplateService.save(emrTemplate) ? R.ok() : R.fail();
}
/**
* 获取电子病历模板列表
*
* @param emrTemplateDto 查询参数
* @param pageNo 当前页码
* @param pageSize 查询条数
* @return
*/
@GetMapping("emr-template-page")
public R<?> getEmrTemplate(EmrTemplateDto emrTemplateDto,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
LambdaQueryWrapper<EmrTemplate> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(EmrTemplate::getTemplateName, emrTemplateDto.getTemplateName())
.eq(EmrTemplate::getUseScopeCode, emrTemplateDto.getUseScopeCode())
.eq(EmrTemplate::getUserId, emrTemplateDto.getUserId());
Page<EmrTemplate> emrTemplatePage = emrTemplateService.page(new Page<>(pageNo, pageSize), queryWrapper);
return R.ok(emrTemplatePage);
}
/**
* 删除病历模板
*
* @param id 模板id
* @return 操作结果
*/
@DeleteMapping("emr-template")
public R<?> deleteEmrTemplate(@RequestParam Long id) {
return emrTemplateService.removeById(id) ? R.ok() : R.fail();
}
}

View File

@@ -4,67 +4,4 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.openhis.web.doctorstation.mapper.DoctorStationEmrAppMapper">
<select id="getPatientInfo" resultType="com.openhis.web.doctorstation.dto.PatientInfoDto">
SELECT T10.tenant_id,
T10.encounter_id,
T10.organization_id,
T10.organization_name,
T10.healthcare_name,
T10.practitioner_user_id,
T10.practitioner_name,
T10.contract_name,
T10.patient_id,
T10.patient_name,
T10.gender_enum,
T10.id_card,
T10.phone,
T10.birth_date,
T10.status_enum,
T10.register_time,
T10.allergy_history_flag
from
(
SELECT T1.tenant_id AS tenant_id,
T1.ID AS encounter_id,
T1.organization_id AS organization_id,
T2.NAME AS organization_name,
T3.NAME AS healthcare_name,
T5.user_id AS practitioner_user_id,
T5.NAME AS practitioner_name,
T7.contract_name AS contract_name,
T8.ID AS patient_id,
T8.NAME AS patient_name,
T8.gender_enum AS gender_enum,
T8.id_card AS id_card,
T8.phone AS phone,
T8.birth_date AS birth_date,
T1.status_enum AS status_enum,
T1.create_time AS register_time,
CASE
WHEN T9.patient_id IS NOT NULL THEN 1
ELSE 0
END AS allergy_history_flag
FROM adm_encounter AS T1
LEFT JOIN adm_organization AS T2 ON T1.organization_id = T2.ID AND T2.delete_flag = '0'
LEFT JOIN adm_healthcare_service AS T3 ON T1.service_type_id = T3.ID AND T3.delete_flag = '0'
LEFT JOIN adm_encounter_participant AS T4
ON T1.ID = T4.encounter_id AND T4.type_code = #{participantType} AND T4.delete_flag = '0'
LEFT JOIN adm_practitioner AS T5 ON T5.ID = T4.practitioner_id AND T5.delete_flag = '0'
LEFT JOIN adm_account AS T6 ON T1.ID = T6.encounter_id AND T6.delete_flag = '0'
LEFT JOIN fin_contract AS T7 ON T6.contract_no = T7.bus_no AND T7.delete_flag = '0'
LEFT JOIN adm_patient AS T8 ON T1.patient_id = T8.ID AND T8.delete_flag = '0'
LEFT JOIN cli_allergy_intolerance AS T9
ON T1.patient_id = T9.patient_id AND T9.clinical_status_enum != #{ClinicalStatus} AND T9.delete_flag = '0'
WHERE
T1.delete_flag = '0'
<!-- 当前登录账号ID 和 当前登录账号所属的科室ID 用于控制数据权限 -->
<if test="userId != null and currentUserOrganizationId != null">
AND ( T5.user_id = #{userId}
OR T1.organization_id = #{currentUserOrganizationId} )
</if>
ORDER BY
T1.create_time ) AS T10
${ew.customSqlSegment}
</select>
</mapper>

View File

@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.openhis.web.doctorstation.mapper.DoctorStationMainAppMapper">
<select id="getPatientInfo" resultType="com.openhis.web.doctorstation.dto.PatientInfoDto">
SELECT
T10.encounter_id,
T10.patient_id,
T10.patient_name,
T10.gender_enum,
T10.id_card,
T10.phone,
T10.birth_date,
T10.status_enum,
T10.allergy_history_flag
from
(
SELECT T1.tenant_id AS tenant_id,
T1.ID AS encounter_id,
T1.organization_id AS organization_id,
T2.NAME AS organization_name,
T3.NAME AS healthcare_name,
T5.user_id AS practitioner_user_id,
T5.NAME AS practitioner_name,
T7.contract_name AS contract_name,
T8.ID AS patient_id,
T8.NAME AS patient_name,
T8.gender_enum AS gender_enum,
T8.id_card AS id_card,
T8.phone AS phone,
T8.birth_date AS birth_date,
T1.status_enum AS status_enum,
T1.create_time AS register_time,
CASE
WHEN T9.patient_id IS NOT NULL THEN 1
ELSE 0
END AS allergy_history_flag
FROM adm_encounter AS T1
LEFT JOIN adm_organization AS T2 ON T1.organization_id = T2.ID AND T2.delete_flag = '0'
LEFT JOIN adm_healthcare_service AS T3 ON T1.service_type_id = T3.ID AND T3.delete_flag = '0'
LEFT JOIN adm_encounter_participant AS T4
ON T1.ID = T4.encounter_id AND T4.type_code = #{participantType} AND T4.delete_flag = '0'
LEFT JOIN adm_practitioner AS T5 ON T5.ID = T4.practitioner_id AND T5.delete_flag = '0'
LEFT JOIN adm_account AS T6 ON T1.ID = T6.encounter_id AND T6.delete_flag = '0'
LEFT JOIN fin_contract AS T7 ON T6.contract_no = T7.bus_no AND T7.delete_flag = '0'
LEFT JOIN adm_patient AS T8 ON T1.patient_id = T8.ID AND T8.delete_flag = '0'
LEFT JOIN cli_allergy_intolerance AS T9
ON T1.patient_id = T9.patient_id AND T9.clinical_status_enum != #{ClinicalStatus} AND T9.delete_flag = '0'
WHERE
T1.delete_flag = '0'
<!-- 当前登录账号ID 和 当前登录账号所属的科室ID 用于控制数据权限 -->
<if test="userId != null and currentUserOrganizationId != null">
AND ( T5.user_id = #{userId}
OR T1.organization_id = #{currentUserOrganizationId} )
</if>
ORDER BY
T1.create_time ) AS T10
${ew.customSqlSegment}
</select>
</mapper>