|
@ -8,19 +8,21 @@ import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
import com.yihu.jw.entity.base.servicePackage.ServiceItemPlanDO;
|
|
import com.yihu.jw.entity.base.servicePackage.ServiceItemPlanDO;
|
|
import com.yihu.jw.entity.door.SignPatientLabelInfo;
|
|
|
|
import com.yihu.jw.entity.patient.BasePatientDischargeRecord;
|
|
import com.yihu.jw.entity.patient.BasePatientDischargeRecord;
|
|
import com.yihu.jw.entity.specialist.RehabilitationServiceItemDO;
|
|
import com.yihu.jw.entity.specialist.RehabilitationServiceItemDO;
|
|
import com.yihu.jw.entity.specialist.rehabilitation.*;
|
|
import com.yihu.jw.entity.specialist.rehabilitation.*;
|
|
|
|
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
|
|
import com.yihu.jw.hospital.module.rehabilitation.dao.PatientRehabilitationPlanDao;
|
|
import com.yihu.jw.hospital.module.rehabilitation.dao.PatientRehabilitationPlanDao;
|
|
import com.yihu.jw.hospital.module.rehabilitation.dao.RehabilitationDetailDao;
|
|
import com.yihu.jw.hospital.module.rehabilitation.dao.RehabilitationDetailDao;
|
|
import com.yihu.jw.hospital.module.rehabilitation.dao.RehabilitationPatientInfoDao;
|
|
import com.yihu.jw.hospital.module.rehabilitation.dao.RehabilitationPatientInfoDao;
|
|
import com.yihu.jw.hospital.module.rehabilitation.dao.RehabilitationServiceItemDao;
|
|
import com.yihu.jw.hospital.module.rehabilitation.dao.RehabilitationServiceItemDao;
|
|
|
|
import com.yihu.jw.hospital.module.specialist.dao.PatientMedicalRecordsRehabilitationDao;
|
|
import com.yihu.jw.hospital.prescription.service.DsyyPrescriptionService;
|
|
import com.yihu.jw.hospital.prescription.service.DsyyPrescriptionService;
|
|
import com.yihu.jw.hospital.team.dao.SignPatientLabelInfoDao;
|
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
import com.yihu.jw.patient.dao.BasePatientDischargeRecordDao;
|
|
import com.yihu.jw.patient.dao.BasePatientDischargeRecordDao;
|
|
import com.yihu.jw.patient.service.BasePatientService;
|
|
import com.yihu.jw.patient.service.BasePatientService;
|
|
|
|
import com.yihu.jw.rehabilitation.ServiceItemPlanDao;
|
|
|
|
import com.yihu.jw.restmodel.hospital.prescription.WlyyOutpatientVO;
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
import com.yihu.jw.wlyy.service.WlyyBusinessService;
|
|
import com.yihu.jw.wlyy.service.WlyyBusinessService;
|
|
@ -34,7 +36,6 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@ -66,7 +67,7 @@ public class SynchronizePatientService {
|
|
@Autowired
|
|
@Autowired
|
|
private PatientRecordService patientRecordService;
|
|
private PatientRecordService patientRecordService;
|
|
@Autowired
|
|
@Autowired
|
|
private SignPatientLabelInfoDao signPatientLabelInfoDao;
|
|
|
|
|
|
private ServiceItemPlanDao serviceItemPlanDao;
|
|
@Autowired
|
|
@Autowired
|
|
private PatientRehabilitationPlanDao patientRehabilitationPlanDao;
|
|
private PatientRehabilitationPlanDao patientRehabilitationPlanDao;
|
|
@Autowired
|
|
@Autowired
|
|
@ -81,193 +82,316 @@ public class SynchronizePatientService {
|
|
private DsyyPrescriptionService dsyyPrescriptionService;
|
|
private DsyyPrescriptionService dsyyPrescriptionService;
|
|
@Autowired
|
|
@Autowired
|
|
private RehabilitationServiceItemDao serviceItemDao;
|
|
private RehabilitationServiceItemDao serviceItemDao;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private DoctorMappingDao doctorMappingDao;
|
|
|
|
@Autowired
|
|
|
|
private PatientMedicalRecordsRehabilitationDao patientMedicalRecordsDao;
|
|
|
|
|
|
//手动重新下转
|
|
//手动重新下转
|
|
public String synchronizePationSingle(Long id) throws Exception{
|
|
public String synchronizePationSingle(Long id) throws Exception{
|
|
RehabilitationPatientInfoDO re = rehabilitationPatientInfoDao.findById(id).orElse(null);
|
|
|
|
if(re==null){
|
|
|
|
|
|
RehabilitationPatientInfoDO infoDO = rehabilitationPatientInfoDao.findById(id).orElse(null);
|
|
|
|
if(infoDO==null){
|
|
return "数据不存在";
|
|
return "数据不存在";
|
|
}
|
|
}
|
|
if(re.getStatus()==1){
|
|
|
|
|
|
//1 6 7 8 11
|
|
|
|
if(infoDO.getStatus()==1||infoDO.getStatus()==6||infoDO.getStatus()==7||infoDO.getStatus()==8||infoDO.getStatus()==11){
|
|
return "已下转成功,不允许操作";
|
|
return "已下转成功,不允许操作";
|
|
}
|
|
}
|
|
|
|
|
|
List<RehabilitationPatientInfoDO> modifyList = new ArrayList<>();
|
|
|
|
List<RehabilitationPatientInfoDO> tmpList = getPatientInfoList(re.getIdcard(), DateUtil.dateToStrShort(re.getCreateTime()));
|
|
|
|
|
|
String name = infoDO.getName();
|
|
|
|
String idcard = infoDO.getIdcard();
|
|
|
|
String conNo = infoDO.getConNo();//就诊次数
|
|
|
|
String visitNo = infoDO.getVisitNo();//就诊号
|
|
|
|
String hisPid = infoDO.getHisPid();//就诊号
|
|
|
|
|
|
|
|
JSONArray cardList = null;
|
|
BasePatientDO patient = null;
|
|
BasePatientDO patient = null;
|
|
if(StringUtils.isBlank(re.getIdcard())){
|
|
|
|
infoUpdate(tmpList,5,modifyList,null);
|
|
|
|
saveModifyList(modifyList);
|
|
|
|
return "下转数据错误,身份证号不存在";
|
|
|
|
}
|
|
|
|
if(StringUtils.isBlank(re.getPatient())){
|
|
|
|
List<BasePatientDO> patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//获取患者信息
|
|
|
|
|
|
if(StringUtils.isBlank(infoDO.getPatient())){
|
|
|
|
List<BasePatientDO> patientList = patientDao.getPatientByIdcard(idcard);//获取患者信息
|
|
|
|
cardList = dsyyPrescriptionService.findCardNo(idcard);
|
|
if (patientList.size() == 0) {
|
|
if (patientList.size() == 0) {
|
|
//未找到居民,从健康档案添加居民
|
|
|
|
patient = patientService.addPaitentByIdcard(re.getIdcard(),re.getName(),re.getSsc(),re.getMobile(),re.getSex());
|
|
|
|
|
|
//未找到居民,从his视图添加居民
|
|
|
|
patient = dsyyPrescriptionService.addPaitentByIdcard(cardList,idcard,name);
|
|
if (patient == null) {
|
|
if (patient == null) {
|
|
infoUpdate(tmpList,5,modifyList,null);
|
|
|
|
saveModifyList(modifyList);
|
|
|
|
|
|
infoDO.setStatus(5);
|
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
return "居民信息不存在";
|
|
return "居民信息不存在";
|
|
} else {
|
|
} else {
|
|
patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//重新获取该患者信息
|
|
|
|
|
|
patientList = patientDao.getPatientByIdcardOrSsc(idcard);//重新获取该患者信息
|
|
patient = patientList.get(0);
|
|
patient = patientList.get(0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
infoUpdate4(tmpList,patient.getId(),modifyList);
|
|
|
|
}else {
|
|
}else {
|
|
patient = patientDao.findByIdAndDel(re.getPatient(),"1");
|
|
|
|
|
|
patient = patientDao.findById(infoDO.getPatient()).orElse(null);
|
|
}
|
|
}
|
|
|
|
|
|
String dept = re.getDept();
|
|
|
|
String diagnosis = re.getDiagnosis();
|
|
|
|
//专病配置
|
|
|
|
RehabilitationPlanTemplateDO planTemplateDO = findPlanTemplate(dept,diagnosis);
|
|
|
|
if(planTemplateDO==null){
|
|
|
|
return "未找到满足条件的专病配置";
|
|
|
|
|
|
if(StringUtils.isBlank(hisPid)&&cardList==null){
|
|
|
|
infoDO.setStatus(9);
|
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
|
return "就诊卡信息不存在";
|
|
}
|
|
}
|
|
if(planTemplateDO.getIsFamily()==1){
|
|
|
|
//判断签约的才推送i健康
|
|
|
|
JSONObject isSign = businessService.isSign(re.getIdcard());
|
|
|
|
if(isSign==null){
|
|
|
|
return "请求i健康失败";
|
|
|
|
}
|
|
|
|
if(isSign.getJSONObject("obj")!=null){
|
|
|
|
//推送i健康数据
|
|
|
|
infoUpdate2(tmpList,planTemplateDO.getFamilyRelation(),modifyList);
|
|
|
|
saveModifyList(modifyList);
|
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = businessService.pushPatientInfos(re);
|
|
|
|
if(jsonObject==null||jsonObject.getInteger("status")==-1){
|
|
|
|
return "请求i健康失败";
|
|
|
|
|
|
infoDO.setSex(patient.getSex());
|
|
|
|
infoDO.setPatient(patient.getId());
|
|
|
|
infoDO.setIdcard(patient.getIdcard());
|
|
|
|
infoDO.setAge(IdCardUtil.getAgeByBirthdayOrIdcard(patient.getIdcard(), patient.getBirthday()));
|
|
|
|
infoDO.setAddress(patient.getAddress());
|
|
|
|
String ssc = null;
|
|
|
|
String mobile = null;
|
|
|
|
JSONObject jaMzbl = new JSONObject();
|
|
|
|
JSONObject jaCy = new JSONObject();
|
|
|
|
String eventType = infoDO.getEventType();//1门诊 2住院
|
|
|
|
try {
|
|
|
|
if(StringUtils.isBlank(eventType)){
|
|
|
|
for (int i=0;i<cardList.size();i++){
|
|
|
|
JSONObject tmp = cardList.getJSONObject(i);
|
|
|
|
String SICK_ID = tmp.getString("SICK_ID");
|
|
|
|
String CARD_NO = tmp.getString("CARD_NO");
|
|
|
|
String LXDH = tmp.getString("LXDH");
|
|
|
|
//门诊病历
|
|
|
|
if(StringUtils.isBlank(eventType)){
|
|
|
|
String mzbl = dsyyPrescriptionService.selectReportInfo("JHIDS-USD-HLWMZBL-014",SICK_ID,conNo,1,1);
|
|
|
|
if(StringUtils.isNotBlank(mzbl)&&!"[]".equals(mzbl)){
|
|
|
|
jaMzbl = JSONArray.parseArray(mzbl).getJSONObject(0);
|
|
|
|
eventType = "1";
|
|
|
|
hisPid = SICK_ID;
|
|
|
|
ssc = CARD_NO;
|
|
|
|
mobile = LXDH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(StringUtils.isBlank(eventType)){
|
|
|
|
//出院小结
|
|
|
|
String cyxj = dsyyPrescriptionService.selectReportInfo("JHIDS-USD-HLWCYXJ-013",SICK_ID,conNo,1,1);
|
|
|
|
if(StringUtils.isNotBlank(cyxj)&&!"[]".equals(cyxj)){
|
|
|
|
jaCy = JSONArray.parseArray(cyxj).getJSONObject(0);
|
|
|
|
eventType = "2";
|
|
|
|
hisPid = SICK_ID;
|
|
|
|
ssc = CARD_NO;
|
|
|
|
mobile = LXDH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else if("1".equals(eventType)){
|
|
|
|
String mzbl = dsyyPrescriptionService.selectReportInfo("JHIDS-USD-HLWMZBL-014",hisPid,conNo,1,1);
|
|
|
|
if(StringUtils.isNotBlank(mzbl)&&!"[]".equals(mzbl)){
|
|
|
|
jaMzbl = JSONArray.parseArray(mzbl).getJSONObject(0);
|
|
|
|
}
|
|
|
|
}else if("2".equals(eventType)){
|
|
|
|
String cyxj = dsyyPrescriptionService.selectReportInfo("JHIDS-USD-HLWCYXJ-013",hisPid,conNo,1,1);
|
|
|
|
if(StringUtils.isNotBlank(cyxj)&&!"[]".equals(cyxj)){
|
|
|
|
jaCy = JSONArray.parseArray(cyxj).getJSONObject(0);
|
|
}
|
|
}
|
|
Long ijkId = jsonObject.getLong("data");
|
|
|
|
infoUpdate3(tmpList,3,ijkId,modifyList,null);
|
|
|
|
saveModifyList(modifyList);
|
|
|
|
return "推送i健康成功";
|
|
|
|
}
|
|
}
|
|
|
|
}catch (Exception e){
|
|
|
|
e.printStackTrace();
|
|
|
|
return "获取患者无门诊病历/患者无出院小结失败";
|
|
}
|
|
}
|
|
String diseaseId = planTemplateDO.getDiseaseId();
|
|
|
|
String diseaseName = planTemplateDO.getDiseaseName();
|
|
|
|
String planTemplateId = planTemplateDO.getId();
|
|
|
|
String planDoctorId = planTemplateDO.getPlanDoctor();//计划负责人
|
|
|
|
BaseDoctorDO planDoctor = doctorDao.findByIdAndDel(planDoctorId);
|
|
|
|
|
|
|
|
//同步病历 //如果同步病历失败,不做下转
|
|
|
|
String result = "";
|
|
|
|
if (demoFlag) {//测试线获取病历模板
|
|
|
|
result = patientRecordService.getJosnFileResullt("event" + "2");
|
|
|
|
} else {
|
|
|
|
//同步住院病历信息
|
|
|
|
// try {
|
|
|
|
// JSONObject jsonEvent = new JSONObject();
|
|
|
|
// List<Map<String, String>> resultMap = patientRecordService.getAllEvent_new(patient.getId(), "2", "1", "1", "2010-10-10 00:00:00", hos.getCode());
|
|
|
|
// jsonEvent.put("data", JSON.parseArray(JSON.toJSONString(resultMap)));
|
|
|
|
// result = jsonEvent.toString();
|
|
|
|
// }catch (Exception e){
|
|
|
|
// infoUpdate(tmpList,3,modifyList,null);
|
|
|
|
// saveModifyList(modifyList);
|
|
|
|
// return "同步患者病历:" + re.getIdcard() + "----无住院病历信息";
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
com.alibaba.fastjson.JSONObject rejson = com.alibaba.fastjson.JSONObject.parseObject(result);
|
|
|
|
JSONArray temlist = rejson.getJSONArray("data");
|
|
|
|
if (0 == temlist.size()) {
|
|
|
|
infoUpdate(tmpList,3,modifyList,null);
|
|
|
|
saveModifyList(modifyList);
|
|
|
|
return "同步患者病历:" + re.getIdcard() + "----无住院病历信息";
|
|
|
|
|
|
if(StringUtils.isBlank(eventType)){
|
|
|
|
infoDO.setStatus(3);
|
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
|
return "患者无门诊病历或患者无出院小结";
|
|
}
|
|
}
|
|
|
|
infoDO.setSsc(ssc);
|
|
|
|
infoDO.setMobile(mobile);
|
|
|
|
infoDO.setHisPid(hisPid);
|
|
|
|
infoDO.setEventType(eventType);
|
|
|
|
|
|
com.alibaba.fastjson.JSONObject tem = temlist.getJSONObject(0);
|
|
|
|
|
|
|
|
|
|
String dept = "科室";
|
|
|
|
String deptName = null;
|
|
|
|
String diagnosis = "诊断";
|
|
|
|
String doctorId = null;
|
|
|
|
String doctorName = null;
|
|
|
|
String doctorIdMz = null;//门诊医生
|
|
|
|
String doctorNameMz = null;
|
|
|
|
String doctorIdZy = null;//住院医生
|
|
|
|
String doctorNameZy = null;
|
|
|
|
String mzTime = null;
|
|
|
|
String zyTime = null;
|
|
PatientMedicalRecordsDO pmr = new PatientMedicalRecordsDO();
|
|
PatientMedicalRecordsDO pmr = new PatientMedicalRecordsDO();
|
|
pmr.setHospitalName(tem.getString("orgName"));
|
|
|
|
pmr.setHospital(tem.getString("orgCode"));
|
|
|
|
if (demoFlag) {//测试获取为病历模板 hospitalcode获取为自己的code
|
|
|
|
// pmr.setHospital(hos.getCode());
|
|
|
|
}
|
|
|
|
pmr.setDischargeDiagnosis(re.getDiagnosis());
|
|
|
|
pmr.setDischargeDiagnosisName(re.getDiagnosisName());
|
|
|
|
pmr.setAdmittingDiagnosis(re.getDiagnosis());
|
|
|
|
pmr.setJwpatient(tem.getString("patient"));
|
|
|
|
pmr.setAdmittingDiagnosisName(re.getDiagnosisName());
|
|
|
|
pmr.setEvent(tem.getString("id"));
|
|
|
|
pmr.setDataFrom(tem.getString("dataFrom"));
|
|
|
|
pmr.setAdvice("出院继续观察");
|
|
|
|
if (tem.getString("dataFrom").equals("4"))//3中山 4智业
|
|
|
|
{
|
|
|
|
// if (StringUtils.isNoneBlank(diagnosisIn)){//入院诊断
|
|
|
|
// pmr.setAdmittingDiagnosisName(diagnosisIn);
|
|
|
|
// }
|
|
|
|
// if (StringUtils.isNoneBlank(diagnosisOut)){//出院诊断
|
|
|
|
// pmr.setDischargeDiagnosisName(diagnosisOut);
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
pmr.setPatient(patient.getId());
|
|
|
|
pmr.setPatientName(patient.getName());
|
|
|
|
pmr.setCode(getCode());
|
|
|
|
pmr.setDataFrom("1");
|
|
|
|
pmr.setCreateTime(new Date());
|
|
|
|
pmr.setJwpatient(hisPid);
|
|
|
|
pmr.setEventType(eventType);
|
|
|
|
pmr.setConNo(conNo);
|
|
|
|
if("1".equals(eventType)){
|
|
|
|
//门诊
|
|
|
|
String ASSISTEXAMINATION = jaMzbl.getString("ASSISTEXAMINATION");//辅助检查
|
|
|
|
String JHDL_CREATED_AT = jaMzbl.getString("JHDL_CREATED_AT");//": "2025-06-18T16:32:52.000+0000",
|
|
|
|
String MEDICALHISTORY = jaMzbl.getString("MEDICALHISTORY");//现病史
|
|
|
|
String EMRPDF = jaMzbl.getString("EMRPDF");//电子病历详情pdf
|
|
|
|
String PHYSICALEXAMINATION = jaMzbl.getString("PHYSICALEXAMINATION");//体格检查
|
|
|
|
String JHDL_UPDATED_AT = jaMzbl.getString("JHDL_UPDATED_AT");//": "2025-06-18T16:32:52.000+0000",
|
|
|
|
String VISIT_ID = jaMzbl.getString("VISIT_ID");//就诊次数
|
|
|
|
// String JHDL_ROWKEY = jaMzbl.getString("JHDL_ROWKEY");//": 5620492334960637262,
|
|
|
|
String PASTHISTORY = jaMzbl.getString("PASTHISTORY");//既往史
|
|
|
|
String PATIENT_ID = jaMzbl.getString("PATIENT_ID");//居民id
|
|
|
|
// String ID = jaMzbl.getString("ID");//": "42661889-5-6000861496-0-73-0-1",
|
|
|
|
String COMPLAINT = jaMzbl.getString("COMPLAINT");//主诉
|
|
|
|
// String JHDL_SRC_TAB = jaMzbl.getString("JHDL_SRC_TAB");//": "JHDL:01_HLW_MZBL",
|
|
|
|
// String LAST_MODIFY_DATE_TIME = jaMzbl.getString("LAST_MODIFY_DATE_TIME");//": "2025-06-18 08:29:07"
|
|
|
|
//查询历史门诊记录获取科室和医生
|
|
|
|
try {
|
|
|
|
WlyyOutpatientVO outpatientVO = dsyyPrescriptionService.selectOutpatientInfoByHisId(hisPid,conNo);
|
|
|
|
dept = outpatientVO.getDept();
|
|
|
|
deptName = outpatientVO.getDeptName();
|
|
|
|
// List<DoctorMappingDO> doctorMappingDOS = doctorMappingDao.findByMappingCode(outpatientVO.getDoctor());
|
|
|
|
// if(doctorMappingDOS.size()>0){
|
|
|
|
// doctorIdMz = doctorMappingDOS.get(0).getDoctor();
|
|
|
|
// }
|
|
|
|
doctorNameMz = outpatientVO.getDoctorName();
|
|
|
|
mzTime = DateUtil.dateToStrLong(outpatientVO.getConDate());
|
|
|
|
}catch (Exception e){
|
|
|
|
e.printStackTrace();
|
|
|
|
return "获取历史门诊记录失败";
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
//住院
|
|
|
|
String ATTENDINGPHYSICIAN = jaCy.getString("ATTENDINGPHYSICIAN");//黎喜梅 主治医师
|
|
|
|
String DISCHARGEDISEASE = jaCy.getString("DISCHARGEDISEASE");//出院诊断
|
|
|
|
String ADMISSIONDAY = jaCy.getString("ADMISSIONDAY");//5, 住院天数
|
|
|
|
// String BIRTH = jaCy.getString("BIRTH");//1968-12-02 00:00:00", 出生日期
|
|
|
|
// String ID = jaCy.getString("ID");//42661889-5-6000861496-2-9-0-20",
|
|
|
|
// String LAST_MODIFY_DATE_TIME = jaCy.getString("LAST_MODIFY_DATE_TIME");//2025-05-13 21:16:12",
|
|
|
|
// String BEDNO = jaCy.getString("BEDNO");//A12-46",
|
|
|
|
String DISCHARGEDESC = jaCy.getString("DISCHARGEDESC");//出院时情况
|
|
|
|
String RESIDENTPHYSICIAN = jaCy.getString("RESIDENTPHYSICIAN");//夏小艺 住院医师
|
|
|
|
String ADMISSIONNO = jaCy.getString("ADMISSIONNO");//326405",住院号
|
|
|
|
// String JHDL_CREATED_AT = jaCy.getString("JHDL_CREATED_AT");//2025-05-13T16:02:07.000+0000",
|
|
|
|
String ADMISSIONDISEASE = jaCy.getString("ADMISSIONDISEASE");//入院诊断
|
|
|
|
String NAME = jaCy.getString("NAME");//李兴英 居民姓名
|
|
|
|
String DATE = jaCy.getString("DATE");//2025-05-10 08:11:38",填写日期
|
|
|
|
// String JHDL_UPDATED_AT = jaCy.getString("JHDL_UPDATED_AT");//2025-05-13T16:02:07.000+0000",
|
|
|
|
String VISIT_ID = jaCy.getString("VISIT_ID");//9 就诊次数
|
|
|
|
String DEPTNAME = jaCy.getString("DEPTNAME");//肿瘤科",//科室名称
|
|
|
|
String DISCHARGETIME = jaCy.getString("DISCHARGETIME");//2025-05-11 08:03:15 出院时间
|
|
|
|
String TREATMENTCOURSE = jaCy.getString("TREATMENTCOURSE");//主要诊疗经过
|
|
|
|
String DISCHARGEORDER = jaCy.getString("DISCHARGEORDER");//出院医嘱
|
|
|
|
// String JHDL_ROWKEY = jaCy.getString("JHDL_ROWKEY");//4179340454200282426,
|
|
|
|
String ADMISSIONDESC = jaCy.getString("ADMISSIONDESC");//入院情况
|
|
|
|
String PATIENT_ID = jaCy.getString("PATIENT_ID");//6000861496 居民id
|
|
|
|
String ATTENDNUMBER = jaCy.getString("ATTENDNUMBER");//326405 住院号
|
|
|
|
// String JHDL_SRC_TAB = jaCy.getString("JHDL_SRC_TAB");//JHDL:01_HLW_CYXJ",
|
|
|
|
String ADMISSIONTIME = jaCy.getString("ADMISSIONTIME");//2025-05-06 08:23:10 入院时间
|
|
|
|
pmr.setAdmissionTime(DateUtil.strToDate(ADMISSIONTIME));
|
|
|
|
pmr.setDischargeTime(DateUtil.strToDate(DISCHARGETIME));
|
|
|
|
pmr.setAdmittingDiagnosisName(ADMISSIONDISEASE);
|
|
|
|
pmr.setDischargeDiagnosisName(DISCHARGEDISEASE);
|
|
|
|
pmr.setAdvice(DISCHARGEORDER);
|
|
|
|
infoDO.setVisitNo(ADMISSIONNO);
|
|
|
|
|
|
pmr.setDiseaseCode(diseaseId);//疾病code
|
|
|
|
pmr.setDiseaseName(diseaseName);//疾病名称
|
|
|
|
|
|
deptName = DEPTNAME;
|
|
|
|
dept = findDeptByName(DEPTNAME);
|
|
|
|
doctorNameZy = RESIDENTPHYSICIAN;
|
|
|
|
pmr.setDept(dept);
|
|
|
|
pmr.setDeptName(deptName);
|
|
|
|
zyTime = DISCHARGETIME;
|
|
|
|
}
|
|
|
|
infoDO.setDept(dept);
|
|
|
|
infoDO.setDeptName(deptName);
|
|
|
|
|
|
//创建居民住院病历
|
|
|
|
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
PatientMedicalRecordsDO patientMedicalRecordsDO1 = rehabilitationInfoService.createMedicalRecords(planDoctorId, patient.getId(), patient.getName(), pmr, null);
|
|
|
|
|
|
//三院专病配置
|
|
|
|
RehabilitationPlanTemplateDO planTemplateDO = findPlanTemplate(dept,diagnosis,eventType);
|
|
|
|
if(planTemplateDO==null){
|
|
|
|
infoDO.setStatus(2);
|
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
|
return "无匹配的康复计划";
|
|
|
|
}
|
|
|
|
infoDO.setDiseaseId(planTemplateDO.getDiseaseId());
|
|
|
|
infoDO.setDiseaseName(planTemplateDO.getDiseaseName());
|
|
|
|
infoDO.setTemplatePlanId(planTemplateDO.getId());
|
|
|
|
infoDO.setTemplatePlanName(planTemplateDO.getTitle());
|
|
|
|
if("1".equals(eventType)){
|
|
|
|
doctorIdMz = findDoctorByName(doctorNameMz,planTemplateDO.getDepts());
|
|
|
|
if(StringUtils.isBlank(doctorIdMz)){
|
|
|
|
infoDO.setStatus(4);
|
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
|
return "医生信息查询不到";
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
doctorIdZy = findDoctorByName(doctorNameZy,planTemplateDO.getDepts());
|
|
|
|
if(StringUtils.isBlank(doctorIdZy)){
|
|
|
|
infoDO.setStatus(4);
|
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
|
return "医生信息查询不到";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(planTemplateDO.getIsFamily()==1){
|
|
|
|
boolean flag = pushIjk(planTemplateDO,null,infoDO);
|
|
|
|
if(!flag){
|
|
|
|
return "推送i健康失败";
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
// ↓创建康复计划。创建完成即为已下转
|
|
|
|
PatientRehabilitationPlanDO planDO = new PatientRehabilitationPlanDO();
|
|
|
|
|
|
if (patientMedicalRecordsDO1 == null) {
|
|
|
|
infoUpdate(tmpList,2,modifyList,null);
|
|
|
|
saveModifyList(modifyList);
|
|
|
|
return "创建病历失败";
|
|
|
|
} else {//
|
|
|
|
// ↓创建康复计划。创建完成即为已下转
|
|
|
|
PatientRehabilitationPlanDO planDO = new PatientRehabilitationPlanDO();
|
|
|
|
planDO.setStatus(3);//待分配 执行医生和科室
|
|
|
|
planDO.setPatient(patient.getId());
|
|
|
|
planDO.setName(patient.getName());
|
|
|
|
planDO.setTitle(patient.getName()+"的康复计划");
|
|
|
|
planDO.setHealthStatusCode("2");
|
|
|
|
planDO.setPlanType(1);
|
|
|
|
planDO.setPayment(2);
|
|
|
|
planDO.setAdviceContent("出院继续观察");
|
|
|
|
planDO.setMedicalRecordsCode(patientMedicalRecordsDO1.getCode());//居民住院病历code
|
|
|
|
|
|
String diseaseId = planTemplateDO.getDiseaseId();
|
|
|
|
String diseaseName = planTemplateDO.getDiseaseName();
|
|
|
|
String planTemplateId = planTemplateDO.getId();
|
|
|
|
String planDoctorType = planTemplateDO.getPlanDoctorType();//计划负责人 1手动获取,2自动获取
|
|
|
|
String planDoctorId = planTemplateDO.getPlanDoctor();//类型=1康复计划负责人,类型2 1门诊医生 2住院医生
|
|
|
|
String distributionType = planTemplateDO.getDistributionType();//分配方式 1手动分配 2自动分配(分配康复计划项的执行医生)
|
|
|
|
String distributionTo = planTemplateDO.getDistributionTo();//分配对象 1门诊医生 2住院医生
|
|
|
|
BaseDoctorDO planDoctor = null;
|
|
|
|
if("1".equals(planDoctorType)){
|
|
|
|
planDoctor = doctorDao.findByIdAndDel(planDoctorId);
|
|
planDO.setPlanDoctor(planDoctorId);
|
|
planDO.setPlanDoctor(planDoctorId);
|
|
planDO.setPlanDoctorName(planDoctor.getName());
|
|
planDO.setPlanDoctorName(planDoctor.getName());
|
|
planDO.setPatientInfoCode(re.getCode());
|
|
|
|
planDO.setCreateTime(new Date());
|
|
|
|
planDO.setUpdateTime(new Date());
|
|
|
|
planDO.setDisease(diseaseId);
|
|
|
|
planDO.setDiseaseName(diseaseName);
|
|
|
|
// planDO.setTotalExpense();
|
|
|
|
StringBuilder results = new StringBuilder();
|
|
|
|
//创建康复计划
|
|
|
|
planDO = createRehabilitationPlanJson(planDO,planTemplateId,results,re);
|
|
|
|
if (planDO == null) {//创建康复计划不成功,无法下转
|
|
|
|
infoUpdate(tmpList,2,modifyList,null);
|
|
|
|
saveModifyList(modifyList);
|
|
|
|
return "创建康复计划失败";
|
|
|
|
} else {//创建康复计划成功
|
|
|
|
String planId = planDO.getId();
|
|
|
|
//居民专科标签。
|
|
|
|
List<SignPatientLabelInfo> healthList = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patient.getId(), "8", 1);
|
|
|
|
if (healthList.size() > 0) {
|
|
|
|
//先删除已有健康情况标签
|
|
|
|
signPatientLabelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient.getId(), "8", 1);
|
|
|
|
}
|
|
|
|
SignPatientLabelInfo signPatientLabelInfo = new SignPatientLabelInfo();
|
|
|
|
signPatientLabelInfo.setPatient(patient.getId());
|
|
|
|
signPatientLabelInfo.setPname(patient.getName());
|
|
|
|
signPatientLabelInfo.setLabel("2");
|
|
|
|
signPatientLabelInfo.setLabelName("出院康复");
|
|
|
|
signPatientLabelInfo.setLabelType("8");
|
|
|
|
signPatientLabelInfo.setStatus(1);
|
|
|
|
signPatientLabelInfo.setCzrq(new Date());
|
|
|
|
signPatientLabelInfoDao.save(signPatientLabelInfo);
|
|
|
|
infoUpdate(tmpList,1,modifyList,planDoctor);
|
|
|
|
// logger.info("康复计划自动下转————" +"下转结束:" + re.getIdcard() + "----下转成功,已转至医生:"+doctor.getName()+"《"+hos.getName()+"》的已下转列表,下转疾病:"+diseaseObj.getString("diseaseName"));
|
|
|
|
//给服务医生群组发送下转消息
|
|
|
|
if (StringUtils.isNoneBlank(planId)){
|
|
|
|
// asynService.sendMsg(planId,signFamily,patient,doctor,patientMedicalRecordsDO1,re);
|
|
|
|
}
|
|
|
|
|
|
}else {
|
|
|
|
if("1".equals(planDoctorId)){
|
|
|
|
//1门诊医生
|
|
|
|
doctorId = doctorIdMz;
|
|
|
|
doctorName = doctorNameMz;
|
|
|
|
}else {
|
|
|
|
//2住院医生
|
|
|
|
doctorId = doctorIdZy;
|
|
|
|
doctorName = doctorNameZy;
|
|
|
|
}
|
|
|
|
planDO.setPlanDoctor(doctorId);
|
|
|
|
planDO.setPlanDoctorName(doctorName);
|
|
|
|
}
|
|
|
|
|
|
|
|
if("2".equals(eventType)){
|
|
|
|
planDO.setMedicalRecordsCode(pmr.getCode());//居民住院病历code
|
|
|
|
}
|
|
|
|
infoDO.setDoctor(doctorId);
|
|
|
|
infoDO.setDoctorName(doctorName);
|
|
|
|
planDO.setStatus(1);
|
|
|
|
planDO.setPatient(patient.getId());
|
|
|
|
planDO.setName(patient.getName());
|
|
|
|
planDO.setTitle(patient.getName()+"的康复计划");
|
|
|
|
planDO.setHealthStatusCode("2");
|
|
|
|
planDO.setPlanType(1);
|
|
|
|
planDO.setPayment(2);
|
|
|
|
planDO.setAdviceContent("出院继续观察");
|
|
|
|
|
|
|
|
planDO.setPatientInfoCode(infoDO.getCode());
|
|
|
|
planDO.setCreateTime(new Date());
|
|
|
|
planDO.setUpdateTime(new Date());
|
|
|
|
planDO.setDisease(diseaseId);
|
|
|
|
planDO.setDiseaseName(diseaseName);
|
|
|
|
//目前默认为冠心病
|
|
|
|
//创建康复计划
|
|
|
|
planDO = createRehabilitationPlanJson(planDO,planTemplateId,null,infoDO,distributionType,distributionTo,dept,deptName,doctorId,doctorName,mzTime,zyTime);
|
|
|
|
if (planDO == null) {//创建康复计划不成功,无法下转
|
|
|
|
infoDO.setStatus(2);
|
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
|
return "创建康复计划请求失败";
|
|
|
|
} else {//创建康复计划成功
|
|
|
|
if("2".equals(distributionType)){
|
|
|
|
infoDO.setStatus(7);
|
|
|
|
}else {
|
|
|
|
infoDO.setStatus(1);
|
|
}
|
|
}
|
|
saveModifyList(modifyList);
|
|
|
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
|
pmr.setDiseaseCode(diseaseId);//疾病code
|
|
|
|
pmr.setDiseaseName(diseaseName);//疾病名称
|
|
|
|
//创建居民住院病历
|
|
|
|
createMedicalRecords(doctorId,doctorName,pmr);
|
|
}
|
|
}
|
|
|
|
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
@ -292,10 +416,11 @@ public class SynchronizePatientService {
|
|
|
|
|
|
//获取三院专病配置
|
|
//获取三院专病配置
|
|
public RehabilitationPlanTemplateDO findPlanTemplate(String dept,String diagnosis,String turnDownRange){
|
|
public RehabilitationPlanTemplateDO findPlanTemplate(String dept,String diagnosis,String turnDownRange){
|
|
String sql = "SELECT t.*,d.is_family isFamily,d.id diseaseId,d.name diseaseName,d.family_relation familyRelation " +
|
|
|
|
|
|
String sql = "SELECT t.*,d.is_family isFamily,d.id diseaseId,d.name diseaseName,d.family_relation familyRelation,d.dept depts " +
|
|
",d.distribution_type distributionType,d.distribution_to distributionTo FROM base_disease_hospital d,wlyy_rehabilitation_plan_template t " +
|
|
",d.distribution_type distributionType,d.distribution_to distributionTo FROM base_disease_hospital d,wlyy_rehabilitation_plan_template t " +
|
|
" WHERE d.rehabilitation_template_id=t.id and d.`status`='1' and d.rehabilitation_down_type='0' and d.rehabilitation_type='1'" +
|
|
" WHERE d.rehabilitation_template_id=t.id and d.`status`='1' and d.rehabilitation_down_type='0' and d.rehabilitation_type='1'" +
|
|
" and d.turn_down_range in('"+turnDownRange+"','3') and d.dept like '%"+dept+"%' and d.diagnosis like '%"+diagnosis+"%' LIMIT 1";
|
|
|
|
|
|
" and d.turn_down_range = '"+turnDownRange+"' and d.dept like '%"+dept+"%' LIMIT 1";
|
|
|
|
// " and d.turn_down_range in('"+turnDownRange+"','3') and d.dept like '%"+dept+"%' and d.diagnosis like '%"+diagnosis+"%' LIMIT 1";
|
|
List<RehabilitationPlanTemplateDO> diseaseList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(RehabilitationPlanTemplateDO.class));
|
|
List<RehabilitationPlanTemplateDO> diseaseList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(RehabilitationPlanTemplateDO.class));
|
|
if(diseaseList.size()==0){
|
|
if(diseaseList.size()==0){
|
|
return null;
|
|
return null;
|
|
@ -306,248 +431,7 @@ public class SynchronizePatientService {
|
|
//基卫补推送出院小结后,重新下转
|
|
//基卫补推送出院小结后,重新下转
|
|
public StringBuilder reSynchronizePation(String type,String hospital,String createTime) throws Exception{
|
|
public StringBuilder reSynchronizePation(String type,String hospital,String createTime) throws Exception{
|
|
StringBuilder results = new StringBuilder("居民下转\n");
|
|
StringBuilder results = new StringBuilder("居民下转\n");
|
|
List<RehabilitationPatientInfoDO> rehabilitationPatientInfoDOs;
|
|
|
|
Date nowDate = DateUtil.strToDate(createTime);
|
|
|
|
Date preTime = DateUtil.getPreDays(nowDate,-30);
|
|
|
|
if (StringUtils.isBlank(type)){//为空
|
|
|
|
results.append("未分配居民下转type:"+type+"\n");
|
|
|
|
rehabilitationPatientInfoDOs = rehabilitationPatientInfoDao.findUnDispation(preTime,hospital);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
Integer typeInt = Integer.parseInt(type);
|
|
|
|
results.append("指定状态居民下转type:"+type+"\n");
|
|
|
|
rehabilitationPatientInfoDOs = rehabilitationPatientInfoDao.findUnDispationByStatus(typeInt,preTime,hospital);
|
|
|
|
}
|
|
|
|
logger.info("康复计划自动下转————需要下转的居民人数" + rehabilitationPatientInfoDOs.size());
|
|
|
|
results.append("需要下转的居民人数" + rehabilitationPatientInfoDOs.size() + "\n");
|
|
|
|
List<RehabilitationPatientInfoDO> modifyList = new ArrayList<>();
|
|
|
|
for (RehabilitationPatientInfoDO re : rehabilitationPatientInfoDOs) {
|
|
|
|
List<RehabilitationPatientInfoDO> tmpList = getPatientInfoList(re.getIdcard(),DateUtil.dateToStrShort(re.getCreateTime()));
|
|
|
|
Date diagnoseTime = re.getDiagnoseTime();
|
|
|
|
//诊断时间为空或超过一个月 也不做下转
|
|
|
|
if (diagnoseTime==null){
|
|
|
|
infoUpdate(tmpList,4,modifyList,null);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (DateUtil.getDays(nowDate,diagnoseTime)>30){
|
|
|
|
infoUpdate(tmpList,4,modifyList,null);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
BasePatientDO patient = null;
|
|
|
|
if(StringUtils.isBlank(re.getIdcard())){
|
|
|
|
infoUpdate(tmpList,5,modifyList,null);
|
|
|
|
saveModifyList(modifyList);
|
|
|
|
results.append("下转数据错误,身份证号不存在\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(StringUtils.isBlank(re.getPatient())){
|
|
|
|
List<BasePatientDO> patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//获取患者信息
|
|
|
|
if (patientList.size() == 0) {
|
|
|
|
//未找到居民,从健康档案添加居民
|
|
|
|
patient = patientService.addPaitentByIdcard(re.getIdcard(),re.getName(),re.getSsc(),re.getMobile(),re.getSex());
|
|
|
|
if (patient == null) {
|
|
|
|
infoUpdate(tmpList,5,modifyList,null);
|
|
|
|
saveModifyList(modifyList);
|
|
|
|
results.append("居民信息不存在\n");
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//重新获取该患者信息
|
|
|
|
patient = patientList.get(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
infoUpdate4(tmpList,patient.getId(),modifyList);
|
|
|
|
}else {
|
|
|
|
patient = patientDao.findByIdAndDel(re.getPatient(),"1");
|
|
|
|
}
|
|
|
|
String dept = re.getDept();
|
|
|
|
String diagnosis = re.getDiagnosis();
|
|
|
|
//三院专病配置
|
|
|
|
RehabilitationPlanTemplateDO planTemplateDO = findPlanTemplate(dept,diagnosis);
|
|
|
|
if(planTemplateDO==null){
|
|
|
|
results.append("未找到满足条件的专病配置\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(planTemplateDO.getIsFamily()==1){
|
|
|
|
//判断签约的才推送i健康
|
|
|
|
JSONObject isSign = businessService.isSign(re.getIdcard());
|
|
|
|
if(isSign==null){
|
|
|
|
results.append("推送i健康失败\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(isSign.getJSONObject("obj")!=null) {
|
|
|
|
//推送i健康数据
|
|
|
|
infoUpdate2(tmpList,planTemplateDO.getFamilyRelation(),modifyList);
|
|
|
|
saveModifyList(modifyList);
|
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = businessService.pushPatientInfos(re);
|
|
|
|
if(jsonObject==null||jsonObject.getInteger("status")==-1){
|
|
|
|
results.append("推送i健康失败\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
Long ijkId = jsonObject.getLong("data");
|
|
|
|
infoUpdate3(tmpList,3,ijkId,modifyList,null);
|
|
|
|
saveModifyList(modifyList);
|
|
|
|
results.append("推送i健康成功\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String diseaseId = planTemplateDO.getDiseaseId();
|
|
|
|
String diseaseName = planTemplateDO.getDiseaseName();
|
|
|
|
String planTemplateId = planTemplateDO.getId();
|
|
|
|
String planDoctorId = planTemplateDO.getPlanDoctor();//计划负责人
|
|
|
|
BaseDoctorDO planDoctor = doctorDao.findByIdAndDel(planDoctorId);
|
|
|
|
|
|
|
|
//同步病历 //如果同步病历失败,不做下转
|
|
|
|
String result = "";
|
|
|
|
if (demoFlag) {//测试线获取病历模板
|
|
|
|
result = patientRecordService.getJosnFileResullt("event" + "2");
|
|
|
|
} else {
|
|
|
|
// try {
|
|
|
|
// JSONObject jsonEvent = new JSONObject();
|
|
|
|
// List<Map<String, String>> resultMap = patientRecordService.getAllEvent_new(patient.getId(), "2", "1", "1", "2010-10-10 00:00:00", hos.getCode());
|
|
|
|
// jsonEvent.put("data", JSON.parseArray(JSON.toJSONString(resultMap)));
|
|
|
|
// result = jsonEvent.toString();
|
|
|
|
// }catch (Exception e){
|
|
|
|
// infoUpdate(tmpList,3,modifyList,null);
|
|
|
|
// results.append("同步患者病历:" + re.getIdcard() + "----无住院病历信息\n");
|
|
|
|
// logger.info("康复计划自动下转————" + "同步患者病历:" + re.getIdcard() + "----无住院病历信息");
|
|
|
|
// continue;
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
com.alibaba.fastjson.JSONObject rejson = com.alibaba.fastjson.JSONObject.parseObject(result);
|
|
|
|
JSONArray temlist = rejson.getJSONArray("data");
|
|
|
|
if (0 == temlist.size()) {
|
|
|
|
results.append("同步患者病历:" + re.getIdcard() + "----无住院病历信息\n");
|
|
|
|
logger.info("康复计划自动下转————" + "同步患者病历:" + re.getIdcard() + "----无住院病历信息");
|
|
|
|
infoUpdate(tmpList,3,modifyList,null);
|
|
|
|
// if(!isPatientExist){//患者不存在与医生原有的康复列表中,添加推送消息
|
|
|
|
// successSync = addSyncPatientInfo(successSync, doctor.getId(), doctor.getName(), teamId, adminTeam.getName(), hos.getCode(), hos.getName(), patient.getId(),0);
|
|
|
|
// }
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if (!needCreateRehabilitationPlan(hos.getCode())) {//仅厦心进行自动下转至已下转 //厦心不推送消息
|
|
|
|
// if(!isPatientExist){//患者不存在与医生原有的康复列表中,添加推送消息
|
|
|
|
// successSync = addSyncPatientInfo(successSync, doctor.getId(), doctor.getName(), teamId, adminTeam.getName(), hos.getCode(), hos.getName(), patient.getId(),0);
|
|
|
|
// }
|
|
|
|
// continue;
|
|
|
|
// }
|
|
|
|
com.alibaba.fastjson.JSONObject tem = temlist.getJSONObject(0);
|
|
|
|
/**
|
|
|
|
* {
|
|
|
|
"orgName": "厦门大学附属心血管病医院",
|
|
|
|
"createTime": "2013-09-26 10:13:38",
|
|
|
|
"patient": "386a35b8d17a47cbab6174ae7952b9b6",
|
|
|
|
"orgCode": "182",
|
|
|
|
"dataFrom": "1",
|
|
|
|
"id": "9f35ff1f-f683-4f3c-a0a5-7ff8ef3df89e",
|
|
|
|
"": "2",
|
|
|
|
"dianosis": "高血压2级",
|
|
|
|
"eventDate": "2013-09-26 10:13:38"
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
PatientMedicalRecordsDO pmr = new PatientMedicalRecordsDO();
|
|
|
|
pmr.setHospitalName(tem.getString("orgName"));
|
|
|
|
pmr.setHospital(tem.getString("orgCode"));
|
|
|
|
if (demoFlag) {//测试获取为病历模板 hospitalcode获取为自己的code
|
|
|
|
// pmr.setHospital(hos.getCode());
|
|
|
|
}
|
|
|
|
pmr.setDischargeDiagnosis(re.getDiagnosis());
|
|
|
|
pmr.setDischargeDiagnosisName(re.getDiagnosisName());
|
|
|
|
pmr.setAdmittingDiagnosis(re.getDiagnosis());
|
|
|
|
pmr.setJwpatient(tem.getString("patient"));
|
|
|
|
pmr.setAdmittingDiagnosisName(re.getDiagnosisName());
|
|
|
|
pmr.setEvent(tem.getString("id"));
|
|
|
|
pmr.setDataFrom(tem.getString("dataFrom"));
|
|
|
|
pmr.setAdvice("出院继续观察");
|
|
|
|
if (tem.getString("dataFrom").equals("4"))//3中山 4智业
|
|
|
|
{
|
|
|
|
// if (StringUtils.isNoneBlank(diagnosisIn)){//入院诊断
|
|
|
|
// pmr.setAdmittingDiagnosisName(diagnosisIn);
|
|
|
|
// }
|
|
|
|
// if (StringUtils.isNoneBlank(diagnosisOut)){//出院诊断
|
|
|
|
// pmr.setDischargeDiagnosisName(diagnosisOut);
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
pmr.setDiseaseCode(diseaseId);//疾病code
|
|
|
|
pmr.setDiseaseName(diseaseName);//疾病名称
|
|
|
|
|
|
|
|
//创建居民住院病历
|
|
|
|
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
PatientMedicalRecordsDO patientMedicalRecordsDO1 = rehabilitationInfoService.createMedicalRecords(planDoctorId, patient.getId(), patient.getName(), pmr, null);
|
|
|
|
|
|
|
|
if (patientMedicalRecordsDO1 == null) {
|
|
|
|
results.append("创建病历请求:" + re.getIdcard() + "----创建病历失败\n");
|
|
|
|
logger.info("康复计划自动下转————" + "创建病历请求:" + re.getIdcard() + "----创建病历失败");
|
|
|
|
infoUpdate(tmpList,2,modifyList,null);
|
|
|
|
// if(!isPatientExist){//患者不存在与医生原有的康复列表中,添加推送消息
|
|
|
|
// successSync = addSyncPatientInfo(successSync, doctor.getId(), doctor.getName(), teamId, adminTeam.getName(), hos.getCode(), hos.getName(), patient.getId(),0);
|
|
|
|
// }
|
|
|
|
continue;
|
|
|
|
} else {//
|
|
|
|
// ↓创建康复计划。创建完成即为已下转
|
|
|
|
PatientRehabilitationPlanDO planDO = new PatientRehabilitationPlanDO();
|
|
|
|
planDO.setStatus(3);//待分配 执行医生和科室
|
|
|
|
planDO.setPatient(patient.getId());
|
|
|
|
planDO.setName(patient.getName());
|
|
|
|
planDO.setTitle(patient.getName()+"的康复计划");
|
|
|
|
planDO.setHealthStatusCode("2");
|
|
|
|
planDO.setPlanType(1);
|
|
|
|
planDO.setPayment(2);
|
|
|
|
planDO.setAdviceContent("出院继续观察");
|
|
|
|
planDO.setMedicalRecordsCode(patientMedicalRecordsDO1.getCode());//居民住院病历code
|
|
|
|
planDO.setPlanDoctor(planDoctorId);
|
|
|
|
planDO.setPlanDoctorName(planDoctor.getName());
|
|
|
|
planDO.setPatientInfoCode(re.getCode());
|
|
|
|
planDO.setCreateTime(new Date());
|
|
|
|
planDO.setUpdateTime(new Date());
|
|
|
|
planDO.setDisease(diseaseId);
|
|
|
|
planDO.setDiseaseName(diseaseName);
|
|
|
|
// planDO.setTotalExpense();
|
|
|
|
//目前默认为冠心病
|
|
|
|
//创建康复计划
|
|
|
|
planDO = createRehabilitationPlanJson(planDO,planTemplateId,results,re);
|
|
|
|
if (planDO == null) {//创建康复计划不成功,无法下转
|
|
|
|
results.append("创建康复计划请求:" + re.getIdcard() + "----创建康复计划请求失败\n");
|
|
|
|
logger.info("康复计划自动下转————" + "创建康复计划请求:" + re.getIdcard() + "----创建康复计划请求失败");
|
|
|
|
infoUpdate(tmpList,2,modifyList,null);
|
|
|
|
// if(!isPatientExist){//患者不存在与医生原有的康复列表中,添加推送消息
|
|
|
|
// successSync = addSyncPatientInfo(successSync, doctor.getId(), doctor.getName(), teamId, adminTeam.getName(), hos.getCode(), hos.getName(), patient.getId(),0);
|
|
|
|
// }
|
|
|
|
continue;
|
|
|
|
} else {//创建康复计划成功
|
|
|
|
String planId = planDO.getId();
|
|
|
|
Date date = new Date();
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
String relationId = " ";
|
|
|
|
//居民专科标签。
|
|
|
|
List<SignPatientLabelInfo> healthList = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patient.getId(), "8", 1);
|
|
|
|
if (healthList.size() > 0) {
|
|
|
|
//先删除已有健康情况标签
|
|
|
|
signPatientLabelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient.getId(), "8", 1);
|
|
|
|
}
|
|
|
|
SignPatientLabelInfo signPatientLabelInfo = new SignPatientLabelInfo();
|
|
|
|
signPatientLabelInfo.setPatient(patient.getId());
|
|
|
|
signPatientLabelInfo.setPname(patient.getName());
|
|
|
|
signPatientLabelInfo.setLabel("2");
|
|
|
|
signPatientLabelInfo.setLabelName("出院康复");
|
|
|
|
signPatientLabelInfo.setLabelType("8");
|
|
|
|
signPatientLabelInfo.setStatus(1);
|
|
|
|
signPatientLabelInfo.setCzrq(new Date());
|
|
|
|
signPatientLabelInfoDao.save(signPatientLabelInfo);
|
|
|
|
infoUpdate(tmpList,1,modifyList,null);
|
|
|
|
// successSync = addSyncPatientInfo(successSync, doctor.getId(), doctor.getName(), teamId, adminTeam.getName(), hos.getCode(), hos.getName(), patient.getId(),1);
|
|
|
|
results.append("下转结束:" + re.getIdcard() + "----下转成功\n");
|
|
|
|
logger.info("康复计划自动下转————" +"下转结束:" + re.getIdcard() + "----下转成功");
|
|
|
|
//给服务医生群组发送下转消息
|
|
|
|
// if (StringUtils.isNoneBlank(planId)){
|
|
|
|
// asynService.sendMsg(planId,signFamily,patient,doctor,patientMedicalRecordsDO1,re);
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rehabilitationPatientInfoDao.saveAll(modifyList);
|
|
|
|
return results;
|
|
return results;
|
|
}
|
|
}
|
|
|
|
|
|
@ -555,7 +439,8 @@ public class SynchronizePatientService {
|
|
public StringBuilder synchronizePation(String type) throws Exception {
|
|
public StringBuilder synchronizePation(String type) throws Exception {
|
|
StringBuilder results = new StringBuilder("居民下转\n");
|
|
StringBuilder results = new StringBuilder("居民下转\n");
|
|
Date nowDate = new Date();
|
|
Date nowDate = new Date();
|
|
String preTimeStr = DateUtil.dateToStrShort(DateUtil.getPreDays(nowDate,-30));
|
|
|
|
|
|
// String preTimeStr = DateUtil.dateToStrShort(DateUtil.getPreDays(nowDate,-30));
|
|
|
|
String preTimeStr = DateUtil.getStringDateShort();
|
|
String sql = "";
|
|
String sql = "";
|
|
if (StringUtils.isBlank(type)){//为空
|
|
if (StringUtils.isBlank(type)){//为空
|
|
results.append("未分配居民下转type:"+type+"\n");
|
|
results.append("未分配居民下转type:"+type+"\n");
|
|
@ -567,12 +452,11 @@ public class SynchronizePatientService {
|
|
List<BasePatientDischargeRecord> patientDischargeRecords = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(BasePatientDischargeRecord.class));
|
|
List<BasePatientDischargeRecord> patientDischargeRecords = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(BasePatientDischargeRecord.class));
|
|
logger.info("康复计划自动下转————需要下转的居民人数" + patientDischargeRecords.size());
|
|
logger.info("康复计划自动下转————需要下转的居民人数" + patientDischargeRecords.size());
|
|
results.append("需要下转的居民人数" + patientDischargeRecords.size() + "\n");
|
|
results.append("需要下转的居民人数" + patientDischargeRecords.size() + "\n");
|
|
List<BasePatientDischargeRecord> modifyList = new ArrayList<>();
|
|
|
|
for (BasePatientDischargeRecord re : patientDischargeRecords) {
|
|
for (BasePatientDischargeRecord re : patientDischargeRecords) {
|
|
String idcard = re.getIdcard();
|
|
String idcard = re.getIdcard();
|
|
if(StringUtils.isBlank(idcard)){
|
|
if(StringUtils.isBlank(idcard)){
|
|
re.setStatus("2");
|
|
|
|
basePatientDischargeRecordDao.equals(re);
|
|
|
|
|
|
re.setStatus("-1");
|
|
|
|
basePatientDischargeRecordDao.save(re);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
String content = re.getContent();
|
|
String content = re.getContent();
|
|
@ -583,8 +467,8 @@ public class SynchronizePatientService {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
if(json==null){
|
|
if(json==null){
|
|
re.setStatus("2");
|
|
|
|
basePatientDischargeRecordDao.equals(re);
|
|
|
|
|
|
re.setStatus("-1");
|
|
|
|
basePatientDischargeRecordDao.save(re);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
// List<BasePatientDischargeRecord> tmpList = getPatientInfoList(re.getIdcard(),DateUtil.dateToStrShort(re.getCreateTime()));
|
|
// List<BasePatientDischargeRecord> tmpList = getPatientInfoList(re.getIdcard(),DateUtil.dateToStrShort(re.getCreateTime()));
|
|
@ -597,268 +481,397 @@ public class SynchronizePatientService {
|
|
// if (DateUtil.getDays(nowDate,diagnoseTime)>30){
|
|
// if (DateUtil.getDays(nowDate,diagnoseTime)>30){
|
|
// dischargeUpdate(tmpList,"4",modifyList);
|
|
// dischargeUpdate(tmpList,"4",modifyList);
|
|
// continue;
|
|
// continue;
|
|
// }
|
|
|
|
// //去除智业获取的厦心患者,智业获取到的一定有problemCode
|
|
|
|
// if(StringUtils.isNoneBlank(re.getProblemCode())){
|
|
|
|
// dischargeUpdate(tmpList,"2",modifyList);
|
|
|
|
// continue;
|
|
|
|
// }
|
|
// }
|
|
//"idcard":"510722201908261751","patientName":"龚嘉乐","cardNo":"510722201908261751" "conNo":"9","visitNo":"1727810009"}
|
|
//"idcard":"510722201908261751","patientName":"龚嘉乐","cardNo":"510722201908261751" "conNo":"9","visitNo":"1727810009"}
|
|
String name = json.getString("patientName");
|
|
String name = json.getString("patientName");
|
|
String cardNo = json.getString("cardNo");
|
|
String cardNo = json.getString("cardNo");
|
|
String conNo = json.getString("conNo");//就诊次数
|
|
String conNo = json.getString("conNo");//就诊次数
|
|
String visitNo = json.getString("visitNo");//就诊号
|
|
String visitNo = json.getString("visitNo");//就诊号
|
|
|
|
//创建下转记录表
|
|
|
|
RehabilitationPatientInfoDO infoDO = rehabilitationPatientInfoDao.findByVisitNo(idcard,conNo,visitNo);
|
|
|
|
if(infoDO==null){
|
|
|
|
infoDO = new RehabilitationPatientInfoDO();
|
|
|
|
infoDO.setStatus(0);
|
|
|
|
infoDO.setCode(getCode());
|
|
|
|
infoDO.setCreateTime(new Date());
|
|
|
|
infoDO.setName(name);
|
|
|
|
infoDO.setIdcard(idcard);
|
|
|
|
infoDO.setFromSource(2);
|
|
|
|
infoDO.setConNo(conNo);
|
|
|
|
infoDO.setVisitNo(visitNo);
|
|
|
|
infoDO.setSignStatus(0);
|
|
|
|
infoDO.setDischargeRecordId(re.getId());
|
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
|
re.setStatus("1");
|
|
|
|
basePatientDischargeRecordDao.save(re);
|
|
|
|
}
|
|
|
|
if(infoDO.getStatus()!=0){
|
|
|
|
results.append("重复下推\n");
|
|
|
|
re.setStatus("2");
|
|
|
|
basePatientDischargeRecordDao.save(re);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
BasePatientDO patient = null;
|
|
BasePatientDO patient = null;
|
|
List<BasePatientDO> patientList = patientDao.getPatientByIdcard(re.getIdcard());//获取患者信息
|
|
List<BasePatientDO> patientList = patientDao.getPatientByIdcard(re.getIdcard());//获取患者信息
|
|
|
|
JSONArray cardList = dsyyPrescriptionService.findCardNo(idcard);
|
|
if (patientList.size() == 0) {
|
|
if (patientList.size() == 0) {
|
|
//未找到居民,从his视图添加居民
|
|
//未找到居民,从his视图添加居民
|
|
patient = dsyyPrescriptionService.addPaitentByIdcard(re.getIdcard(),name);
|
|
|
|
|
|
patient = dsyyPrescriptionService.addPaitentByIdcard(cardList,re.getIdcard(),name);
|
|
if (patient == null) {
|
|
if (patient == null) {
|
|
re.setStatus("3");
|
|
|
|
basePatientDischargeRecordDao.equals(re);
|
|
|
|
|
|
infoDO.setStatus(5);
|
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
results.append("居民信息不存在\n");
|
|
results.append("居民信息不存在\n");
|
|
continue;
|
|
continue;
|
|
} else {
|
|
} else {
|
|
patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//重新获取该患者信息
|
|
patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//重新获取该患者信息
|
|
patient = patientList.get(0);
|
|
patient = patientList.get(0);
|
|
}
|
|
}
|
|
|
|
}else {
|
|
|
|
patient = patientList.get(0);
|
|
|
|
}
|
|
|
|
if(cardList==null){
|
|
|
|
infoDO.setStatus(9);
|
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
|
results.append("就诊卡信息不存在\n");
|
|
|
|
continue;
|
|
}
|
|
}
|
|
JSONArray jaMzbl = new JSONArray();
|
|
|
|
JSONArray jaCy = new JSONArray();
|
|
|
|
|
|
infoDO.setSex(patient.getSex());
|
|
|
|
// infoDO.setMobile(patient.getMobile());
|
|
|
|
infoDO.setPatient(patient.getId());
|
|
|
|
infoDO.setIdcard(patient.getIdcard());
|
|
|
|
infoDO.setAge(IdCardUtil.getAgeByBirthdayOrIdcard(patient.getIdcard(), patient.getBirthday()));
|
|
|
|
String ssc = null;
|
|
|
|
String mobile = null;
|
|
|
|
infoDO.setAddress(patient.getAddress());
|
|
|
|
|
|
|
|
JSONObject jaMzbl = new JSONObject();
|
|
|
|
JSONObject jaCy = new JSONObject();
|
|
|
|
String hisPid = null;
|
|
String eventType = "";//1门诊 2住院
|
|
String eventType = "";//1门诊 2住院
|
|
try {
|
|
try {
|
|
//门诊病历
|
|
|
|
String mzbl = dsyyPrescriptionService.selectReportInfo("JHIDS-USD-HLWMZBL-014","",conNo,1,1);
|
|
|
|
if(StringUtils.isNotBlank(mzbl)){
|
|
|
|
jaMzbl = JSONArray.parseArray(mzbl);
|
|
|
|
}
|
|
|
|
//出院小结
|
|
|
|
String cyxj = dsyyPrescriptionService.selectReportInfo("JHIDS-USD-HLWCYXJ-013","",conNo,1,1);
|
|
|
|
if(StringUtils.isNotBlank(cyxj)){
|
|
|
|
jaCy = JSONArray.parseArray(cyxj);
|
|
|
|
|
|
for (int i=0;i<cardList.size();i++){
|
|
|
|
JSONObject tmp = cardList.getJSONObject(i);
|
|
|
|
String SICK_ID = tmp.getString("SICK_ID");
|
|
|
|
String CARD_NO = tmp.getString("CARD_NO");
|
|
|
|
String LXDH = tmp.getString("LXDH");
|
|
|
|
//门诊病历
|
|
|
|
if(StringUtils.isBlank(eventType)){
|
|
|
|
String mzbl = dsyyPrescriptionService.selectReportInfo("JHIDS-USD-HLWMZBL-014",SICK_ID,conNo,1,1);
|
|
|
|
if(StringUtils.isNotBlank(mzbl)&&!"[]".equals(mzbl)){
|
|
|
|
jaMzbl = JSONArray.parseArray(mzbl).getJSONObject(0);
|
|
|
|
eventType = "1";
|
|
|
|
hisPid = SICK_ID;
|
|
|
|
ssc = CARD_NO;
|
|
|
|
mobile = LXDH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(StringUtils.isBlank(eventType)){
|
|
|
|
//出院小结
|
|
|
|
String cyxj = dsyyPrescriptionService.selectReportInfo("JHIDS-USD-HLWCYXJ-013",SICK_ID,conNo,1,1);
|
|
|
|
if(StringUtils.isNotBlank(cyxj)&&!"[]".equals(cyxj)){
|
|
|
|
jaCy = JSONArray.parseArray(cyxj).getJSONObject(0);
|
|
|
|
eventType = "2";
|
|
|
|
hisPid = SICK_ID;
|
|
|
|
ssc = CARD_NO;
|
|
|
|
mobile = LXDH;
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
if(StringUtils.isBlank(eventType)){
|
|
if(StringUtils.isBlank(eventType)){
|
|
re.setStatus("4");
|
|
|
|
basePatientDischargeRecordDao.equals(re);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
//同步病历 //如果同步病历失败,不做下转
|
|
|
|
String result = "";
|
|
|
|
if (demoFlag) {//测试线获取病历模板
|
|
|
|
result = patientRecordService.getJosnFileResullt("event2");
|
|
|
|
} else {
|
|
|
|
// try {
|
|
|
|
// JSONObject jsonEvent = new JSONObject();
|
|
|
|
// List<Map<String, String>> resultMap = patientRecordService.getAllEvent_new(patient.getId(), "2", "1", "1", "2010-10-10 00:00:00", hos.getCode());
|
|
|
|
// jsonEvent.put("data", JSON.parseArray(JSON.toJSONString(resultMap)));
|
|
|
|
// result = jsonEvent.toString();
|
|
|
|
// }catch (Exception e){
|
|
|
|
// infoUpdate(tmpList,3,modifyList,null);
|
|
|
|
// results.append("同步患者病历:" + re.getIdcard() + "----无住院病历信息\n");
|
|
|
|
// logger.info("康复计划自动下转————" + "同步患者病历:" + re.getIdcard() + "----无住院病历信息");
|
|
|
|
// continue;
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
com.alibaba.fastjson.JSONObject rejson = com.alibaba.fastjson.JSONObject.parseObject(result);
|
|
|
|
JSONArray temlist = rejson.getJSONArray("data");
|
|
|
|
if (0 == temlist.size()) {
|
|
|
|
results.append("同步患者病历:" + re.getIdcard() + "----无住院病历信息\n");
|
|
|
|
logger.info("康复计划自动下转————" + "同步患者病历:" + re.getIdcard() + "----无住院病历信息");
|
|
|
|
|
|
infoDO.setStatus(3);
|
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
|
results.append("患者无门诊病历或患者无出院小结\n");
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
com.alibaba.fastjson.JSONObject tem = temlist.getJSONObject(0);
|
|
|
|
|
|
|
|
//创建下转记录表
|
|
|
|
RehabilitationPatientInfoDO infoDO = new RehabilitationPatientInfoDO();
|
|
|
|
infoDO.setPatient(patient.getId());
|
|
|
|
infoDO.setStatus(0);
|
|
|
|
infoDO.setIdcard(patient.getIdcard());
|
|
|
|
infoDO.setAge(IdCardUtil.getAgeByBirthdayOrIdcard(patient.getIdcard(), patient.getBirthday()));
|
|
|
|
infoDO.setSsc(patient.getSsc());
|
|
|
|
infoDO.setAddress(patient.getAddress());
|
|
|
|
infoDO.setCode(UUID.randomUUID().toString().replaceAll("-", ""));
|
|
|
|
infoDO.setCreateTime(new Date());
|
|
|
|
infoDO.setName(patient.getName());
|
|
|
|
infoDO.setSex(patient.getSex());
|
|
|
|
infoDO.setMobile(patient.getMobile());
|
|
|
|
infoDO.setFromSource(2);
|
|
|
|
infoDO.setSignStatus(0);
|
|
|
|
infoDO.setDischargeRecordId(re.getId());
|
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
|
|
|
infoDO.setSsc(ssc);
|
|
|
|
infoDO.setMobile(mobile);
|
|
|
|
infoDO.setHisPid(hisPid);
|
|
|
|
infoDO.setEventType(eventType);
|
|
|
|
|
|
String dept = "科室";
|
|
String dept = "科室";
|
|
// String dept = re.getDept();
|
|
|
|
// String diagnosis = re.getDiagnosis();
|
|
|
|
|
|
String deptName = null;
|
|
String diagnosis = "诊断";
|
|
String diagnosis = "诊断";
|
|
|
|
String doctorId = null;
|
|
|
|
String doctorName = null;
|
|
|
|
String doctorIdMz = null;//门诊医生
|
|
|
|
String doctorNameMz = null;
|
|
|
|
String doctorIdZy = null;//住院医生
|
|
|
|
String doctorNameZy = null;
|
|
|
|
String mzTime = null;
|
|
|
|
String zyTime = null;
|
|
|
|
PatientMedicalRecordsDO pmr = new PatientMedicalRecordsDO();
|
|
|
|
pmr.setPatient(patient.getId());
|
|
|
|
pmr.setPatientName(patient.getName());
|
|
|
|
pmr.setCode(getCode());
|
|
|
|
pmr.setDataFrom("1");
|
|
|
|
pmr.setCreateTime(new Date());
|
|
|
|
pmr.setJwpatient(hisPid);
|
|
|
|
pmr.setEventType(eventType);
|
|
|
|
pmr.setConNo(conNo);
|
|
|
|
if("1".equals(eventType)){
|
|
|
|
//门诊
|
|
|
|
String ASSISTEXAMINATION = jaMzbl.getString("ASSISTEXAMINATION");//辅助检查
|
|
|
|
String JHDL_CREATED_AT = jaMzbl.getString("JHDL_CREATED_AT");//": "2025-06-18T16:32:52.000+0000",
|
|
|
|
String MEDICALHISTORY = jaMzbl.getString("MEDICALHISTORY");//现病史
|
|
|
|
String EMRPDF = jaMzbl.getString("EMRPDF");//电子病历详情pdf
|
|
|
|
String PHYSICALEXAMINATION = jaMzbl.getString("PHYSICALEXAMINATION");//体格检查
|
|
|
|
String JHDL_UPDATED_AT = jaMzbl.getString("JHDL_UPDATED_AT");//": "2025-06-18T16:32:52.000+0000",
|
|
|
|
String VISIT_ID = jaMzbl.getString("VISIT_ID");//就诊次数
|
|
|
|
// String JHDL_ROWKEY = jaMzbl.getString("JHDL_ROWKEY");//": 5620492334960637262,
|
|
|
|
String PASTHISTORY = jaMzbl.getString("PASTHISTORY");//既往史
|
|
|
|
String PATIENT_ID = jaMzbl.getString("PATIENT_ID");//居民id
|
|
|
|
// String ID = jaMzbl.getString("ID");//": "42661889-5-6000861496-0-73-0-1",
|
|
|
|
String COMPLAINT = jaMzbl.getString("COMPLAINT");//主诉
|
|
|
|
// String JHDL_SRC_TAB = jaMzbl.getString("JHDL_SRC_TAB");//": "JHDL:01_HLW_MZBL",
|
|
|
|
// String LAST_MODIFY_DATE_TIME = jaMzbl.getString("LAST_MODIFY_DATE_TIME");//": "2025-06-18 08:29:07"
|
|
|
|
//查询历史门诊记录获取科室和医生
|
|
|
|
try {
|
|
|
|
WlyyOutpatientVO outpatientVO = dsyyPrescriptionService.selectOutpatientInfoByHisId(hisPid,conNo);
|
|
|
|
dept = outpatientVO.getDept();
|
|
|
|
deptName = outpatientVO.getDeptName();
|
|
|
|
// List<DoctorMappingDO> doctorMappingDOS = doctorMappingDao.findByMappingCode(outpatientVO.getDoctor());
|
|
|
|
// if(doctorMappingDOS.size()>0){
|
|
|
|
// doctorIdMz = doctorMappingDOS.get(0).getDoctor();
|
|
|
|
// }
|
|
|
|
doctorNameMz = outpatientVO.getDoctorName();
|
|
|
|
mzTime = DateUtil.dateToStrLong(outpatientVO.getConDate());
|
|
|
|
}catch (Exception e){
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
//住院
|
|
|
|
String ATTENDINGPHYSICIAN = jaCy.getString("ATTENDINGPHYSICIAN");//黎喜梅 主治医师
|
|
|
|
String DISCHARGEDISEASE = jaCy.getString("DISCHARGEDISEASE");//出院诊断
|
|
|
|
String ADMISSIONDAY = jaCy.getString("ADMISSIONDAY");//5, 住院天数
|
|
|
|
// String BIRTH = jaCy.getString("BIRTH");//1968-12-02 00:00:00", 出生日期
|
|
|
|
// String ID = jaCy.getString("ID");//42661889-5-6000861496-2-9-0-20",
|
|
|
|
// String LAST_MODIFY_DATE_TIME = jaCy.getString("LAST_MODIFY_DATE_TIME");//2025-05-13 21:16:12",
|
|
|
|
// String BEDNO = jaCy.getString("BEDNO");//A12-46",
|
|
|
|
String DISCHARGEDESC = jaCy.getString("DISCHARGEDESC");//出院时情况
|
|
|
|
String RESIDENTPHYSICIAN = jaCy.getString("RESIDENTPHYSICIAN");//夏小艺 住院医师
|
|
|
|
String ADMISSIONNO = jaCy.getString("ADMISSIONNO");//326405",住院号
|
|
|
|
// String JHDL_CREATED_AT = jaCy.getString("JHDL_CREATED_AT");//2025-05-13T16:02:07.000+0000",
|
|
|
|
String ADMISSIONDISEASE = jaCy.getString("ADMISSIONDISEASE");//入院诊断
|
|
|
|
String NAME = jaCy.getString("NAME");//李兴英 居民姓名
|
|
|
|
String DATE = jaCy.getString("DATE");//2025-05-10 08:11:38",填写日期
|
|
|
|
// String JHDL_UPDATED_AT = jaCy.getString("JHDL_UPDATED_AT");//2025-05-13T16:02:07.000+0000",
|
|
|
|
String VISIT_ID = jaCy.getString("VISIT_ID");//9 就诊次数
|
|
|
|
String DEPTNAME = jaCy.getString("DEPTNAME");//肿瘤科",//科室名称
|
|
|
|
String DISCHARGETIME = jaCy.getString("DISCHARGETIME");//2025-05-11 08:03:15 出院时间
|
|
|
|
String TREATMENTCOURSE = jaCy.getString("TREATMENTCOURSE");//主要诊疗经过
|
|
|
|
String DISCHARGEORDER = jaCy.getString("DISCHARGEORDER");//出院医嘱
|
|
|
|
// String JHDL_ROWKEY = jaCy.getString("JHDL_ROWKEY");//4179340454200282426,
|
|
|
|
String ADMISSIONDESC = jaCy.getString("ADMISSIONDESC");//入院情况
|
|
|
|
String PATIENT_ID = jaCy.getString("PATIENT_ID");//6000861496 居民id
|
|
|
|
String ATTENDNUMBER = jaCy.getString("ATTENDNUMBER");//326405 住院号
|
|
|
|
// String JHDL_SRC_TAB = jaCy.getString("JHDL_SRC_TAB");//JHDL:01_HLW_CYXJ",
|
|
|
|
String ADMISSIONTIME = jaCy.getString("ADMISSIONTIME");//2025-05-06 08:23:10 入院时间
|
|
|
|
pmr.setAdmissionTime(DateUtil.strToDate(ADMISSIONTIME));
|
|
|
|
pmr.setDischargeTime(DateUtil.strToDate(DISCHARGETIME));
|
|
|
|
pmr.setAdmittingDiagnosisName(ADMISSIONDISEASE);
|
|
|
|
pmr.setDischargeDiagnosisName(DISCHARGEDISEASE);
|
|
|
|
pmr.setAdvice(DISCHARGEORDER);
|
|
|
|
|
|
|
|
deptName = DEPTNAME;
|
|
|
|
dept = findDeptByName(DEPTNAME);
|
|
|
|
doctorNameZy = RESIDENTPHYSICIAN;
|
|
|
|
pmr.setDept(dept);
|
|
|
|
pmr.setDeptName(deptName);
|
|
|
|
zyTime = DISCHARGETIME;
|
|
|
|
}
|
|
|
|
infoDO.setDeptName(deptName);
|
|
|
|
infoDO.setDept(dept);
|
|
|
|
|
|
//三院专病配置
|
|
//三院专病配置
|
|
RehabilitationPlanTemplateDO planTemplateDO = findPlanTemplate(dept,diagnosis,eventType);
|
|
RehabilitationPlanTemplateDO planTemplateDO = findPlanTemplate(dept,diagnosis,eventType);
|
|
if(planTemplateDO==null){
|
|
if(planTemplateDO==null){
|
|
re.setStatus("5");
|
|
|
|
basePatientDischargeRecordDao.equals(re);
|
|
|
|
results.append("未找到满足条件的专病配置\n");
|
|
|
|
|
|
infoDO.setStatus(2);
|
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
if(planTemplateDO.getIsFamily()==1){
|
|
|
|
//判断签约的才推送i健康
|
|
|
|
JSONObject isSign = businessService.isSign(re.getIdcard());
|
|
|
|
if(isSign==null){
|
|
|
|
re.setStatus("6");
|
|
|
|
basePatientDischargeRecordDao.equals(re);
|
|
|
|
results.append("推送i健康失败\n");
|
|
|
|
|
|
infoDO.setDiseaseId(planTemplateDO.getDiseaseId());
|
|
|
|
infoDO.setDiseaseName(planTemplateDO.getDiseaseName());
|
|
|
|
infoDO.setTemplatePlanId(planTemplateDO.getId());
|
|
|
|
infoDO.setTemplatePlanName(planTemplateDO.getTitle());
|
|
|
|
if("1".equals(eventType)){
|
|
|
|
doctorIdMz = findDoctorByName(doctorNameMz,planTemplateDO.getDepts());
|
|
|
|
if(StringUtils.isBlank(doctorIdMz)){
|
|
|
|
infoDO.setStatus(4);
|
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
infoDO.setSignStatus(1);
|
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
|
if(isSign.getJSONObject("obj")!=null) {
|
|
|
|
//推送i健康数据
|
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = businessService.pushPatientInfos(infoDO);
|
|
|
|
if(jsonObject==null||jsonObject.getInteger("status")==-1){
|
|
|
|
re.setStatus("6");
|
|
|
|
basePatientDischargeRecordDao.equals(re);
|
|
|
|
results.append("推送i健康失败\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
Long ijkId = jsonObject.getLong("data");
|
|
|
|
infoDO.setIjkId(ijkId);
|
|
|
|
|
|
}else {
|
|
|
|
doctorIdZy = findDoctorByName(doctorNameZy,planTemplateDO.getDepts());
|
|
|
|
if(StringUtils.isBlank(doctorIdZy)){
|
|
|
|
infoDO.setStatus(4);
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
re.setStatus("7");
|
|
|
|
basePatientDischargeRecordDao.equals(re);
|
|
|
|
results.append("推送i健康成功\n");
|
|
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if(planTemplateDO.getIsFamily()==1){
|
|
|
|
pushIjk(planTemplateDO,re,infoDO);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// ↓创建康复计划。创建完成即为已下转
|
|
|
|
PatientRehabilitationPlanDO planDO = new PatientRehabilitationPlanDO();
|
|
|
|
|
|
String diseaseId = planTemplateDO.getDiseaseId();
|
|
String diseaseId = planTemplateDO.getDiseaseId();
|
|
String diseaseName = planTemplateDO.getDiseaseName();
|
|
String diseaseName = planTemplateDO.getDiseaseName();
|
|
String planTemplateId = planTemplateDO.getId();
|
|
String planTemplateId = planTemplateDO.getId();
|
|
String planDoctorType = planTemplateDO.getPlanDoctorType();//计划负责人 1手动获取,2自动获取
|
|
String planDoctorType = planTemplateDO.getPlanDoctorType();//计划负责人 1手动获取,2自动获取
|
|
String planDoctorId = planTemplateDO.getPlanDoctor();//类型=1康复计划负责人,类型2 1主管医生 2主治医生
|
|
|
|
|
|
String planDoctorId = planTemplateDO.getPlanDoctor();//类型=1康复计划负责人,类型2 1门诊医生 2住院医生
|
|
String distributionType = planTemplateDO.getDistributionType();//分配方式 1手动分配 2自动分配(分配康复计划项的执行医生)
|
|
String distributionType = planTemplateDO.getDistributionType();//分配方式 1手动分配 2自动分配(分配康复计划项的执行医生)
|
|
String distributionTo = planTemplateDO.getDistributionTo();//分配对象 1主管医生 2主治医生
|
|
|
|
|
|
String distributionTo = planTemplateDO.getDistributionTo();//分配对象 1门诊医生 2住院医生
|
|
BaseDoctorDO planDoctor = null;
|
|
BaseDoctorDO planDoctor = null;
|
|
BaseDoctorDO zgDoctor = null;//主管医生
|
|
|
|
BaseDoctorDO zzDoctor = null;//主治医生
|
|
|
|
if("1".equals(planDoctorType)){
|
|
if("1".equals(planDoctorType)){
|
|
planDoctor = doctorDao.findByIdAndDel(planDoctorId);
|
|
planDoctor = doctorDao.findByIdAndDel(planDoctorId);
|
|
|
|
planDO.setPlanDoctor(planDoctorId);
|
|
|
|
planDO.setPlanDoctorName(planDoctor.getName());
|
|
}else {
|
|
}else {
|
|
if("1".equals(planDoctorId)){
|
|
if("1".equals(planDoctorId)){
|
|
//1主管医生
|
|
|
|
|
|
|
|
|
|
//1门诊医生
|
|
|
|
doctorId = doctorIdMz;
|
|
|
|
doctorName = doctorNameMz;
|
|
}else {
|
|
}else {
|
|
//2主治医生
|
|
|
|
|
|
|
|
|
|
//2住院医生
|
|
|
|
doctorId = doctorIdZy;
|
|
|
|
doctorName = doctorNameZy;
|
|
}
|
|
}
|
|
|
|
planDO.setPlanDoctor(doctorId);
|
|
|
|
planDO.setPlanDoctorName(doctorName);
|
|
}
|
|
}
|
|
|
|
infoDO.setDoctor(doctorId);
|
|
|
|
infoDO.setDoctorName(doctorName);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {
|
|
|
|
"orgName": "厦门大学附属心血管病医院",
|
|
|
|
"createTime": "2013-09-26 10:13:38",
|
|
|
|
"patient": "386a35b8d17a47cbab6174ae7952b9b6",
|
|
|
|
"orgCode": "182",
|
|
|
|
"dataFrom": "1",
|
|
|
|
"id": "9f35ff1f-f683-4f3c-a0a5-7ff8ef3df89e",
|
|
|
|
"": "2",
|
|
|
|
"dianosis": "高血压2级",
|
|
|
|
"eventDate": "2013-09-26 10:13:38"
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
PatientMedicalRecordsDO pmr = new PatientMedicalRecordsDO();
|
|
|
|
pmr.setHospitalName(tem.getString("orgName"));
|
|
|
|
pmr.setHospital(tem.getString("orgCode"));
|
|
|
|
if (demoFlag) {//测试获取为病历模板 hospitalcode获取为自己的code
|
|
|
|
// pmr.setHospital(hos.getCode());
|
|
|
|
}
|
|
|
|
// pmr.setDischargeDiagnosis(re.getDiagnosis());
|
|
|
|
// pmr.setDischargeDiagnosisName(re.getDiagnosisName());
|
|
|
|
// pmr.setAdmittingDiagnosis(re.getDiagnosis());
|
|
|
|
pmr.setJwpatient(tem.getString("patient"));
|
|
|
|
// pmr.setAdmittingDiagnosisName(re.getDiagnosisName());
|
|
|
|
pmr.setEvent(tem.getString("id"));
|
|
|
|
pmr.setDataFrom(tem.getString("dataFrom"));
|
|
|
|
pmr.setAdvice("出院继续观察");
|
|
|
|
if (tem.getString("dataFrom").equals("4"))//3中山 4智业
|
|
|
|
{
|
|
|
|
// if (StringUtils.isNoneBlank(diagnosisIn)){//入院诊断
|
|
|
|
// pmr.setAdmittingDiagnosisName(diagnosisIn);
|
|
|
|
// }
|
|
|
|
// if (StringUtils.isNoneBlank(diagnosisOut)){//出院诊断
|
|
|
|
// pmr.setDischargeDiagnosisName(diagnosisOut);
|
|
|
|
// }
|
|
|
|
|
|
if("2".equals(eventType)){
|
|
|
|
planDO.setMedicalRecordsCode(pmr.getCode());//居民住院病历code
|
|
}
|
|
}
|
|
pmr.setDiseaseCode(diseaseId);//疾病code
|
|
|
|
pmr.setDiseaseName(diseaseName);//疾病名称
|
|
|
|
|
|
|
|
//创建居民住院病历
|
|
|
|
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
PatientMedicalRecordsDO patientMedicalRecordsDO1 = rehabilitationInfoService.createMedicalRecords(planDoctorId, patient.getId(), patient.getName(), pmr, null);
|
|
|
|
|
|
planDO.setStatus(1);
|
|
|
|
planDO.setPatient(patient.getId());
|
|
|
|
planDO.setName(patient.getName());
|
|
|
|
planDO.setTitle(patient.getName()+"的康复计划");
|
|
|
|
planDO.setHealthStatusCode("2");
|
|
|
|
planDO.setPlanType(1);
|
|
|
|
planDO.setPayment(2);
|
|
|
|
planDO.setAdviceContent("出院继续观察");
|
|
|
|
|
|
if (patientMedicalRecordsDO1 == null) {
|
|
|
|
results.append("创建病历请求:" + re.getIdcard() + "----创建病历失败\n");
|
|
|
|
logger.info("康复计划自动下转————" + "创建病历请求:" + re.getIdcard() + "----创建病历失败");
|
|
|
|
|
|
planDO.setPatientInfoCode(infoDO.getCode());
|
|
|
|
planDO.setCreateTime(new Date());
|
|
|
|
planDO.setUpdateTime(new Date());
|
|
|
|
planDO.setDisease(diseaseId);
|
|
|
|
planDO.setDiseaseName(diseaseName);
|
|
|
|
//目前默认为冠心病
|
|
|
|
//创建康复计划
|
|
|
|
planDO = createRehabilitationPlanJson(planDO,planTemplateId,results,infoDO,distributionType,distributionTo,dept,deptName,doctorId,doctorName,mzTime,zyTime);
|
|
|
|
if (planDO == null) {//创建康复计划不成功,无法下转
|
|
|
|
infoDO.setStatus(2);
|
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
|
results.append("创建康复计划请求:" + re.getIdcard() + "----创建康复计划请求失败\n");
|
|
|
|
logger.info("康复计划自动下转————" + "创建康复计划请求:" + re.getIdcard() + "----创建康复计划请求失败");
|
|
continue;
|
|
continue;
|
|
} else {//
|
|
|
|
// ↓创建康复计划。创建完成即为已下转
|
|
|
|
PatientRehabilitationPlanDO planDO = new PatientRehabilitationPlanDO();
|
|
|
|
planDO.setStatus(3);//待分配 执行医生和科室
|
|
|
|
planDO.setPatient(patient.getId());
|
|
|
|
planDO.setName(patient.getName());
|
|
|
|
planDO.setTitle(patient.getName()+"的康复计划");
|
|
|
|
planDO.setHealthStatusCode("2");
|
|
|
|
planDO.setPlanType(1);
|
|
|
|
planDO.setPayment(2);
|
|
|
|
planDO.setAdviceContent("出院继续观察");
|
|
|
|
planDO.setMedicalRecordsCode(patientMedicalRecordsDO1.getCode());//居民住院病历code
|
|
|
|
planDO.setPlanDoctor(planDoctorId);
|
|
|
|
planDO.setPlanDoctorName(planDoctor.getName());
|
|
|
|
planDO.setPatientInfoCode(infoDO.getCode());
|
|
|
|
planDO.setCreateTime(new Date());
|
|
|
|
planDO.setUpdateTime(new Date());
|
|
|
|
planDO.setDisease(diseaseId);
|
|
|
|
planDO.setDiseaseName(diseaseName);
|
|
|
|
//目前默认为冠心病
|
|
|
|
//创建康复计划
|
|
|
|
planDO = createRehabilitationPlanJson(planDO,planTemplateId,results,infoDO,distributionType,distributionTo,zgDoctor,zzDoctor);
|
|
|
|
if (planDO == null) {//创建康复计划不成功,无法下转
|
|
|
|
results.append("创建康复计划请求:" + re.getIdcard() + "----创建康复计划请求失败\n");
|
|
|
|
logger.info("康复计划自动下转————" + "创建康复计划请求:" + re.getIdcard() + "----创建康复计划请求失败");
|
|
|
|
continue;
|
|
|
|
} else {//创建康复计划成功
|
|
|
|
String planId = planDO.getId();
|
|
|
|
////创建患者疾病类型 wlyy_patient_disease_server
|
|
|
|
String relationId = "";
|
|
|
|
//居民专科标签。
|
|
|
|
List<SignPatientLabelInfo> healthList = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patient.getId(), "8", 1);
|
|
|
|
if (healthList.size() > 0) {
|
|
|
|
//先删除已有健康情况标签
|
|
|
|
signPatientLabelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient.getId(), "8", 1);
|
|
|
|
}
|
|
|
|
SignPatientLabelInfo signPatientLabelInfo = new SignPatientLabelInfo();
|
|
|
|
signPatientLabelInfo.setPatient(patient.getId());
|
|
|
|
signPatientLabelInfo.setPname(patient.getName());
|
|
|
|
signPatientLabelInfo.setLabel("2");
|
|
|
|
signPatientLabelInfo.setLabelName("出院康复");
|
|
|
|
signPatientLabelInfo.setLabelType("8");
|
|
|
|
signPatientLabelInfo.setStatus(1);
|
|
|
|
signPatientLabelInfo.setCzrq(new Date());
|
|
|
|
signPatientLabelInfoDao.save(signPatientLabelInfo);
|
|
|
|
|
|
|
|
|
|
} else {//创建康复计划成功
|
|
|
|
if("2".equals(distributionType)){
|
|
|
|
infoDO.setStatus(7);
|
|
|
|
}else {
|
|
infoDO.setStatus(1);
|
|
infoDO.setStatus(1);
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
|
re.setStatus("1");
|
|
|
|
basePatientDischargeRecordDao.equals(re);
|
|
|
|
results.append("下转结束:" + re.getIdcard() + "----下转成功");
|
|
|
|
logger.info("康复计划自动下转————" +"下转结束:" + re.getIdcard() + "----下转成功");
|
|
|
|
}
|
|
}
|
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
|
pmr.setDiseaseCode(diseaseId);//疾病code
|
|
|
|
pmr.setDiseaseName(diseaseName);//疾病名称
|
|
|
|
|
|
|
|
//创建居民住院病历
|
|
|
|
createMedicalRecords(doctorId,doctorName,pmr);
|
|
|
|
results.append("下转结束:" + re.getIdcard() + "----下转成功");
|
|
|
|
logger.info("康复计划自动下转————" +"下转结束:" + re.getIdcard() + "----下转成功");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return results;
|
|
return results;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//推送ijk
|
|
|
|
public boolean pushIjk(RehabilitationPlanTemplateDO planTemplateDO,BasePatientDischargeRecord re,RehabilitationPatientInfoDO infoDO){
|
|
|
|
try {
|
|
|
|
//判断签约的才推送i健康
|
|
|
|
JSONObject isSign = businessService.isSign(infoDO.getIdcard());
|
|
|
|
if(isSign==null){
|
|
|
|
infoDO.setStatus(10);
|
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
infoDO.setProblemCode(planTemplateDO.getFamilyRelation());
|
|
|
|
infoDO.setSignStatus(1);
|
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
|
if(isSign.getJSONObject("obj")!=null) {
|
|
|
|
//推送i健康数据
|
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = businessService.pushPatientInfos(infoDO);
|
|
|
|
if(jsonObject==null||jsonObject.getInteger("status")==-1){
|
|
|
|
infoDO.setStatus(10);
|
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
Long ijkId = jsonObject.getLong("data");
|
|
|
|
infoDO.setIjkId(ijkId);
|
|
|
|
infoDO.setStatus(11);
|
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}catch (Exception e){
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 新增住院病历
|
|
|
|
* @param doctorCode
|
|
|
|
* @param patientMedicalRecordsDO
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public PatientMedicalRecordsDO createMedicalRecords(String doctorCode,String doctorName, PatientMedicalRecordsDO patientMedicalRecordsDO) {
|
|
|
|
patientMedicalRecordsDO.setHospitalName("厦门市第三医院");
|
|
|
|
patientMedicalRecordsDO.setHospital("350211A1004");
|
|
|
|
patientMedicalRecordsDO.setCreateUser(doctorCode);
|
|
|
|
patientMedicalRecordsDO.setCreateUserName(doctorName);
|
|
|
|
patientMedicalRecordsDO.setCreateTime(new Date());
|
|
|
|
patientMedicalRecordsDao.save(patientMedicalRecordsDO);
|
|
|
|
return patientMedicalRecordsDO;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getCode(){
|
|
|
|
return UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
|
}
|
|
|
|
|
|
|
|
//查找科室编码
|
|
|
|
public String findDeptByName(String deptName){
|
|
|
|
String sql = "SELECT code from dict_hospital_dept where name = '"+deptName+"'";
|
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
if(list.size()>0){
|
|
|
|
return list.get(0).get("code")+"";
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
//查找医生编码
|
|
|
|
public String findDoctorByName(String doctorName,String deptCode){
|
|
|
|
if(StringUtils.isBlank(deptCode)){
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
String sql = "SELECT d.id from base_doctor_hospital h,base_doctor d " +
|
|
|
|
" WHERE h.dept_code in ('"+deptCode.replace(",","','")+"') and h.del='1' and h.doctor_code=d.id" +
|
|
|
|
" and d.del='1' and d.`name`='"+doctorName+"'";
|
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
if(list.size()>0){
|
|
|
|
return list.get(0).get("id")+"";
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 创建康复计划json
|
|
* 创建康复计划json
|
|
*/
|
|
*/
|
|
@ -896,11 +909,14 @@ public class SynchronizePatientService {
|
|
* 创建康复计划json
|
|
* 创建康复计划json
|
|
*/
|
|
*/
|
|
public PatientRehabilitationPlanDO createRehabilitationPlanJson(PatientRehabilitationPlanDO planDO, String planTemplateId,StringBuilder results
|
|
public PatientRehabilitationPlanDO createRehabilitationPlanJson(PatientRehabilitationPlanDO planDO, String planTemplateId,StringBuilder results
|
|
, RehabilitationPatientInfoDO re,String distributionType,String distributionTo,BaseDoctorDO zgDoctor,BaseDoctorDO zzDoctor) throws Exception{
|
|
|
|
|
|
, RehabilitationPatientInfoDO re,String distributionType,String distributionTo,String dept,String deptName
|
|
|
|
,String doctorId,String doctorName,String mzTime,String zyTime) throws Exception{
|
|
String sql = "select * from wlyy_rehabilitation_template_detail where template_id = '" + planTemplateId + "'";
|
|
String sql = "select * from wlyy_rehabilitation_template_detail where template_id = '" + planTemplateId + "'";
|
|
List<RehabilitationTemplateDetailDO> templateDetail = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(RehabilitationTemplateDetailDO.class));
|
|
List<RehabilitationTemplateDetailDO> templateDetail = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(RehabilitationTemplateDetailDO.class));
|
|
if (templateDetail.size() == 0) {
|
|
if (templateDetail.size() == 0) {
|
|
results.append("系统默认的康复模板请求:" + re.getIdcard() + "----系统默认的康复模板为空,请手动进行下转\n");
|
|
|
|
|
|
if(results!=null){
|
|
|
|
results.append("系统默认的康复模板请求:" + re.getIdcard() + "----系统默认的康复模板为空,请手动进行下转\n");
|
|
|
|
}
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
planDO = patientRehabilitationPlanDao.save(planDO);
|
|
planDO = patientRehabilitationPlanDao.save(planDO);
|
|
@ -915,20 +931,13 @@ public class SynchronizePatientService {
|
|
detail.setUpdateTime(new Date());
|
|
detail.setUpdateTime(new Date());
|
|
detail.setPlanId(planDO.getId());
|
|
detail.setPlanId(planDO.getId());
|
|
detail.setFrequencyCode(frequency_code);
|
|
detail.setFrequencyCode(frequency_code);
|
|
|
|
detail.setServerCount(detailDO.getServerCount());
|
|
|
|
detail.setTimeType(Integer.parseInt(detailDO.getPlanStartTimeType()));
|
|
|
|
detail.setDept(dept);
|
|
|
|
detail.setDeptName(deptName);
|
|
if("2".equals(distributionType)){
|
|
if("2".equals(distributionType)){
|
|
if("1".equals(distributionTo)){
|
|
|
|
//1主管医生
|
|
|
|
// detail.setDept();
|
|
|
|
// detail.setDeptName();
|
|
|
|
detail.setDoctor(zgDoctor.getId());
|
|
|
|
detail.setDoctorName(zgDoctor.getName());
|
|
|
|
}else {
|
|
|
|
//2主治医生
|
|
|
|
// detail.setDept();
|
|
|
|
// detail.setDeptName();
|
|
|
|
detail.setDoctor(zzDoctor.getId());
|
|
|
|
detail.setDoctorName(zzDoctor.getName());
|
|
|
|
}
|
|
|
|
|
|
detail.setDoctor(doctorId);
|
|
|
|
detail.setDoctorName(doctorName);
|
|
}
|
|
}
|
|
detailDOList.add(detail);
|
|
detailDOList.add(detail);
|
|
}
|
|
}
|
|
@ -947,9 +956,12 @@ public class SynchronizePatientService {
|
|
detailDO.setDept(newDetail.getDept());
|
|
detailDO.setDept(newDetail.getDept());
|
|
detailDO.setDeptName(newDetail.getDeptName());
|
|
detailDO.setDeptName(newDetail.getDeptName());
|
|
//生成执行计划列表
|
|
//生成执行计划列表
|
|
planDOList = rehabilitationManageService.addServicePlan(serviceItemMap, planDO, detailDO, planDOList);
|
|
|
|
|
|
planDOList = rehabilitationManageService.addServicePlan(serviceItemMap, planDO, detailDO, planDOList,mzTime,zyTime);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (planDOList.size() > 0) {
|
|
|
|
serviceItemPlanDao.saveAll(planDOList);
|
|
|
|
}
|
|
|
|
|
|
rehabilitationManageService.addPlanLog(planDO.getId(),planDO.getPlanDoctor(),planDO.getPlanDoctorName());
|
|
rehabilitationManageService.addPlanLog(planDO.getId(),planDO.getPlanDoctor(),planDO.getPlanDoctorName());
|
|
|
|
|