|
@@ -40,10 +40,6 @@ public class HL7PatientServiceImpl extends ServiceImpl<PatientMapper, Patient> i
|
|
|
@Autowired
|
|
|
HL7ReportService orcReportService; //申请报告单
|
|
|
|
|
|
- @Autowired
|
|
|
- private VisitMapper visitMapper;
|
|
|
-
|
|
|
-
|
|
|
@Override
|
|
|
public Message savePatientInfo(Message message) throws Exception {
|
|
|
if (message instanceof ADT_A01){
|
|
@@ -58,16 +54,13 @@ public class HL7PatientServiceImpl extends ServiceImpl<PatientMapper, Patient> i
|
|
|
String wnPatId = pid.getPatientID().getID().getValue(); //卫宁患者ID
|
|
|
//保存患者入院
|
|
|
if ("A01".equals(msgType)){
|
|
|
- //根据推送的数据提取患者唯一标识ID查询数据库,判断患者是否存在
|
|
|
- LambdaQueryWrapper<Patient> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(Patient::getWnPatId, wnPatId);
|
|
|
- Patient patient = baseMapper.selectOne(wrapper);
|
|
|
- if (patient != null){ //存在
|
|
|
+ //根据卫宁患者ID查询患者
|
|
|
+ Patient patient = findPatientByWnPatId(wnPatId);
|
|
|
+ if (patient != null){
|
|
|
Long id = patient.getId(); //患者Id
|
|
|
//保存患者新的就诊信息tb_visit
|
|
|
visitService.saveVisitInfo(dg1All,pv1,pv2, id);
|
|
|
}else {
|
|
|
- //不存在
|
|
|
//保存当前患者基本信息
|
|
|
log.info("A01消息类型>>>>>保存本次患者入院的信息");
|
|
|
Long PatId = SavePatientInfo(pid, evn);//保存患者基本信息 PatId患者Id
|
|
@@ -79,13 +72,10 @@ public class HL7PatientServiceImpl extends ServiceImpl<PatientMapper, Patient> i
|
|
|
return ResponseSuccessful.ResponseADTA01Msg(a01);
|
|
|
}
|
|
|
if ("A08".equals(msgType)){
|
|
|
- //患者建卡、患者入出转等
|
|
|
- //根据卫宁患者id查询当前患者是否存在
|
|
|
- LambdaQueryWrapper<Patient> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(Patient::getWnPatId,wnPatId);
|
|
|
- Patient patient = baseMapper.selectOne(wrapper);
|
|
|
- if (patient != null){
|
|
|
- //修改病人信息 tb_patient
|
|
|
+ //根据卫宁患者ID查询患者
|
|
|
+ Patient patient = findPatientByWnPatId(wnPatId);
|
|
|
+ if (patient != null) {
|
|
|
+ // 更新患者信息 tb_patient
|
|
|
String evenType = evn.getEventReasonCode().getValue(); //住院业务类型
|
|
|
String phone = pid.getPhoneNumberHome(0).getPhoneNumber().getValue(); //电话
|
|
|
String address = pid.getPatientAddress(0).getStreetAddress().getStreetOrMailingAddress().getValue(); //患者地址
|
|
@@ -112,12 +102,13 @@ public class HL7PatientServiceImpl extends ServiceImpl<PatientMapper, Patient> i
|
|
|
patient.setPhone(phone);
|
|
|
}
|
|
|
patient.setEventType(evenType); //住院业务类型
|
|
|
- baseMapper.updateById(patient); //修改病人信息 tb_patient表
|
|
|
+ baseMapper.updateById(patient);
|
|
|
+
|
|
|
// 获取患者ID
|
|
|
- Long patId = patient.getId();//患者ID
|
|
|
- //修改tb_visit表
|
|
|
- visitService.updateVisitInfoByPatId(dg1All,patId, pv1, pv2);
|
|
|
- log.info("A08消息类型>>>>>修改病人信息、入区、转科、出区和取消、取消登记、婴儿更新成功");
|
|
|
+ Long patId = patient.getId();
|
|
|
+
|
|
|
+ // 修改tb_visit表
|
|
|
+ visitService.updateVisitInfoByPatId(dg1All, patId, pv1, pv2);
|
|
|
}
|
|
|
return ResponseSuccessful.ResponseADTA01Msg(a01);
|
|
|
}
|
|
@@ -130,65 +121,41 @@ public class HL7PatientServiceImpl extends ServiceImpl<PatientMapper, Patient> i
|
|
|
return ResponseSuccessful.ResponseORUR01Msg(oruR01);
|
|
|
}
|
|
|
if (message instanceof ADT_A03) {
|
|
|
- //根据患者类别(PV1_2)区分,O:门诊、I、住院
|
|
|
- log.info("门诊结束就诊、患者出院");
|
|
|
+ log.info("患者出院更新在院状态、出院时间、出院方式");
|
|
|
ADT_A03 a03 = (ADT_A03) message;
|
|
|
PV1 pv1 = a03.getPV1(); //提取患者信息段
|
|
|
PID pid = a03.getPID(); //提取患者的信息段
|
|
|
EVN evn = a03.getEVN(); //提取患者的事件类型
|
|
|
List<DG1> dg1All = a03.getDG1All(); //提取患者的诊断信息
|
|
|
- String wnPatId = pid.getPatientID().getID().getValue(); //卫宁患者ID
|
|
|
- String evenType = evn.getEventReasonCode().getValue(); //住院业务类型
|
|
|
- String hospitalStatus = pv1.getBedStatus().getValue(); //在院状态
|
|
|
- String dischargeMethod = pv1.getDischargeDisposition().getValue(); //出院方式
|
|
|
- String doctorCode = pv1.getAttendingDoctor(0).getIDNumber().getValue();//医生代码
|
|
|
- String physician = pv1.getAttendingDoctor(0).getFamilyName().getSurname().getValue(); //主治医师
|
|
|
- //判断当前患者是门诊出院还是住院患者出院
|
|
|
- String patClass = pv1.getPatientClass().getValue(); //患者类别
|
|
|
+ String patClass = pv1.getPatientClass().getValue(); //患者类别 O:门诊、I、住院
|
|
|
if ("I".equals(patClass)) {
|
|
|
- // 住院患者出院 修改患者的在院状态即可
|
|
|
- // 患者地址,对于刚刚入院登记的如果没有地址,在出院进行更新
|
|
|
- String dischargeTime = pv1.getDischargeDateTime(0).getTimeOfAnEvent().getValue();//出院时间
|
|
|
- String address = pid.getPatientAddress(0).getStreetAddress().getStreetOrMailingAddress().getValue(); //患者地址
|
|
|
- LambdaQueryWrapper<Patient> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(Patient::getWnPatId, wnPatId);
|
|
|
- Patient patientEntity = baseMapper.selectOne(wrapper);
|
|
|
- if (patientEntity != null) {
|
|
|
- log.info("住院患者出院---->修改患者和就诊住院业务类型");
|
|
|
- patientEntity.setEventType(evenType); //住院业务类型
|
|
|
- patientEntity.setAddress(address); //患者地址
|
|
|
- baseMapper.updateById(patientEntity); //更新住院患者出院状态
|
|
|
- Long dbPid = patientEntity.getId(); //患者ID
|
|
|
- LambdaQueryWrapper<Visit> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- //3 患者tb_visit出院
|
|
|
- queryWrapper.eq(Visit::getPatId, dbPid);
|
|
|
- List<Visit> visitEntities = visitMapper.selectList(queryWrapper);
|
|
|
- if (visitEntities.size() > 0) {
|
|
|
- Visit visitEntity = visitEntities.get(visitEntities.size() - 1); //获取获取最后一次就诊记录
|
|
|
- //修改住院患者的就诊记录在院状态
|
|
|
- visitEntity.setHospitalStatus(hospitalStatus); //在院状态
|
|
|
- visitEntity.setDischargeTime(dischargeTime); //出院时间
|
|
|
- visitEntity.setDischargeMethod(dischargeMethod); //出院方式
|
|
|
- String dbPhysician = visitEntity.getPhysician();
|
|
|
- String dbDoctorCode = visitEntity.getDoctorCode();
|
|
|
- if (!StringUtils.hasText(dbPhysician)) {
|
|
|
- visitEntity.setPhysician(physician); //对于没有医生的进行更新
|
|
|
- }
|
|
|
- if (!StringUtils.hasText(dbDoctorCode)) {
|
|
|
- visitEntity.setDoctorCode(doctorCode); //对于没有医生代码的进行更新
|
|
|
- }
|
|
|
- visitMapper.updateById(visitEntity);
|
|
|
- log.info("住院患者出院状态更新成功!");
|
|
|
- //保存诊断信息
|
|
|
- dg1Service.saveDiagnosisInfo(dg1All, visitEntity.getId(), pv1, dbPid);
|
|
|
- return ResponseSuccessful.ResponseADTA03Msg(a03);
|
|
|
- }
|
|
|
+ // 住院患者出院 更新住院业务类型
|
|
|
+ String wnPatId = pid.getPatientID().getID().getValue(); //卫宁患者ID
|
|
|
+ // 根据卫宁患者ID查询患者
|
|
|
+ Patient patient = findPatientByWnPatId(wnPatId);
|
|
|
+ if (patient != null) {
|
|
|
+ String evenType = evn.getEventReasonCode().getValue(); //住院业务类型
|
|
|
+ patient.setEventType(evenType);
|
|
|
+ baseMapper.updateById(patient);
|
|
|
+ Long dbPid = patient.getId(); //患者ID
|
|
|
+ //更新患者就诊记录的在院状态、出院时间、出院方式
|
|
|
+ Long visitId = visitService.updateVisitHospitalStatus(dbPid, pv1);
|
|
|
+ //保存诊断信息
|
|
|
+ dg1Service.saveDiagnosisInfo(dg1All,visitId,pv1,dbPid);
|
|
|
}
|
|
|
+ return ResponseSuccessful.ResponseADTA03Msg(a03);
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ // 提取方法:根据卫宁患者ID查询患者
|
|
|
+ private Patient findPatientByWnPatId(String wnPatId) {
|
|
|
+ LambdaQueryWrapper<Patient> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(Patient::getWnPatId, wnPatId);
|
|
|
+ return baseMapper.selectOne(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 保存患者的基本信息
|
|
|
* @param pid
|