|
@@ -42,21 +42,19 @@ public class DoctorInfoFacade extends DoctorInfoServiceImpl {
|
|
|
|
|
|
/**
|
|
|
* 保存医生信息
|
|
|
+ * 如果医生存在,医院、科室不存在,也无法查询到数据
|
|
|
+ * 查询之前先查询医院和科室信息,如果不存在则保存
|
|
|
* @param doctorInfoVo
|
|
|
* @return 医生信息
|
|
|
*/
|
|
|
- public DoctorInfoDTO saveDoctorInfo(DoctorInfoVO doctorInfoVo){
|
|
|
- DoctorInfoDTO doctorInfoDTO = new DoctorInfoDTO();
|
|
|
- if("view".equals(doctorInfoVo.getType())){
|
|
|
- //从视图或数据库中获取医生信息保存到本系统
|
|
|
- doctorInfoDTO=DBConn.getDoctorInfo(doctorInfoVo);
|
|
|
- }else if("api".equals(doctorInfoVo.getType())){
|
|
|
- //通过HIS接口获取信息保存到本系统
|
|
|
- Response<DoctorInfoDTO> data=aiServiceClient.getDoctorInfo(doctorInfoVo);
|
|
|
- doctorInfoDTO=data.getData();
|
|
|
- }
|
|
|
- updateOrInsert(doctorInfoDTO,doctorInfoVo);
|
|
|
- return doctorInfoDTO;
|
|
|
+ public List<DoctorInfoDTO> saveDoctorInfo(DoctorInfoVO doctorInfoVo){
|
|
|
+ //初始化医院科室的信息
|
|
|
+ getHospitalInfo(doctorInfoVo);
|
|
|
+ getDeptInfo(doctorInfoVo);
|
|
|
+ //查询是否有内部存储
|
|
|
+ List<DoctorInfoDTO> doctorInfoDTOList=this.getDoctorInfos(doctorInfoVo.getDoctorCode(), doctorInfoVo.getHosptialCode(), doctorInfoVo.getDeptCode());
|
|
|
+ updateOrInsert(doctorInfoDTOList,doctorInfoVo);
|
|
|
+ return doctorInfoDTOList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -64,28 +62,46 @@ public class DoctorInfoFacade extends DoctorInfoServiceImpl {
|
|
|
* @param doctorInfoDTO
|
|
|
* @param doctorInfoVo
|
|
|
*/
|
|
|
- private void updateOrInsert(DoctorInfoDTO doctorInfoDTO,DoctorInfoVO doctorInfoVo){
|
|
|
- getHospitalInfo(doctorInfoVo);//遍历医院信息,是否存在,不存在则新增
|
|
|
- getDeptInfo(doctorInfoVo);//遍历科室信息,是否存在,不存在则新增
|
|
|
+ private void updateOrInsert(List<DoctorInfoDTO> doctorInfoDTOList,DoctorInfoVO doctorInfoVo){
|
|
|
+ DoctorInfoDTO doctorInfoDTO = new DoctorInfoDTO();
|
|
|
|
|
|
- BeanUtil.copyProperties(doctorInfoVo, doctorInfoDTO);
|
|
|
- doctorInfoDTO.setHospitalCode(doctorInfoVo.getHosptialCode());
|
|
|
- doctorInfoDTO.setHospitalDeptCode(doctorInfoVo.getDeptCode());
|
|
|
- doctorInfoDTO.setCode(doctorInfoVo.getDoctorCode());
|
|
|
- if(doctorInfoDTO!=null){
|
|
|
- //优先在本地数据库查看医生信息是否存在
|
|
|
- List<DoctorInfoDTO> doctorInfoDTOList=this.getDoctorInfos(doctorInfoDTO.getCode(), doctorInfoDTO.getHospitalCode(), doctorInfoDTO.getHospitalDeptCode());
|
|
|
+ if(doctorInfoDTOList.size()>0){
|
|
|
+ //更新
|
|
|
+ getDoctorInfo(doctorInfoDTO,doctorInfoVo);//从不同的来源获取医生信息
|
|
|
+
|
|
|
+ doctorInfoDTO.setId(doctorInfoDTOList.get(0).getId());
|
|
|
+ doctorInfoDTO.setGmtModified(new Date());
|
|
|
+ this.updateById(doctorInfoDTO);
|
|
|
+
|
|
|
+ }else{
|
|
|
+ //新增
|
|
|
+ getDoctorInfo(doctorInfoDTO,doctorInfoVo);//从不同的来源获取医生信息
|
|
|
|
|
|
+ doctorInfoDTO.setGmtCreate(new Date());
|
|
|
+ this.save(doctorInfoDTO);
|
|
|
+ }
|
|
|
+ doctorInfoDTOList.add(doctorInfoDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 从不同的来源获取医生信息
|
|
|
+ * @param doctorInfoDTO
|
|
|
+ * @param doctorInfoVo
|
|
|
+ */
|
|
|
+ private void getDoctorInfo(DoctorInfoDTO doctorInfoDTO,DoctorInfoVO doctorInfoVo){
|
|
|
+ if("view".equals(doctorInfoVo.getType())){
|
|
|
+ //从视图或数据库中获取医生信息保存到本系统
|
|
|
+ List<DoctorInfoDTO> list=DBConn.getDoctorInfo(doctorInfoVo);
|
|
|
+ BeanUtil.copyProperties(list.get(0), doctorInfoDTO);
|
|
|
+ }else if("api".equals(doctorInfoVo.getType())){
|
|
|
//通过HIS接口获取信息保存到本系统
|
|
|
- if(doctorInfoDTOList.size()>0){
|
|
|
- doctorInfoDTO.setId(doctorInfoDTOList.get(0).getId());
|
|
|
- doctorInfoDTO.setGmtModified(new Date());
|
|
|
- this.updateById(doctorInfoDTO);
|
|
|
- }else{
|
|
|
- //不存在则insert新增
|
|
|
- doctorInfoDTO.setGmtCreate(new Date());
|
|
|
- this.save(doctorInfoDTO);
|
|
|
- }
|
|
|
+ Response<DoctorInfoDTO> data=aiServiceClient.getDoctorInfo(doctorInfoVo);
|
|
|
+ BeanUtil.copyProperties(data.getData(), doctorInfoDTO);
|
|
|
+ }else{
|
|
|
+ BeanUtil.copyProperties(doctorInfoVo, doctorInfoDTO);
|
|
|
+ doctorInfoDTO.setHospitalCode(doctorInfoVo.getHosptialCode());
|
|
|
+ doctorInfoDTO.setHospitalDeptCode(doctorInfoVo.getDeptCode());
|
|
|
+ doctorInfoDTO.setCode(doctorInfoVo.getDoctorCode());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -148,6 +164,7 @@ public class DoctorInfoFacade extends DoctorInfoServiceImpl {
|
|
|
*/
|
|
|
public List<DoctorInfoDTO> getDoctorInfo(DoctorInfoVO doctorInfoVo) {
|
|
|
List<DoctorInfoDTO> doctorInfoDTOList = this.getDoctorInfos(doctorInfoVo.getDoctorCode(), doctorInfoVo.getHosptialCode(), doctorInfoVo.getDeptCode());
|
|
|
+ //updateOrInsert(doctorInfoDTOList,doctorInfoVo);
|
|
|
return doctorInfoDTOList;
|
|
|
}
|
|
|
|