|
@ -2,6 +2,13 @@ package com.yihu.jw.service.channel;
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
|
|
|
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
|
|
|
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDiagnosisDO;
|
|
|
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
|
|
|
import com.yihu.jw.hospital.prescription.dao.*;
|
|
|
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionDiagnosisVO;
|
|
|
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionInfoVO;
|
|
|
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
|
|
|
import com.yihu.jw.restmodel.web.ListEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.status.EnvelopStatus;
|
|
@ -17,9 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 处方状态更新job
|
|
@ -38,6 +43,14 @@ public class PrescriptionStatusUpdateService {
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Value("${hlwyyEntrance.url}")
|
|
|
private String hlwyyEntranceUrl;
|
|
|
@Autowired
|
|
|
private PrescriptionDao prescriptionDao;
|
|
|
@Autowired
|
|
|
private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
|
|
|
@Autowired
|
|
|
private PrescriptionInfoDao prescriptionInfoDao;
|
|
|
@Autowired
|
|
|
private OutpatientDao outpatientDao;
|
|
|
|
|
|
public void autoPush() throws Exception{
|
|
|
//获取所有就诊中已挂号、已下临时处方、并且未结束的处方
|
|
@ -55,6 +68,10 @@ public class PrescriptionStatusUpdateService {
|
|
|
String conNo=String.valueOf(map.get("con_no"));
|
|
|
//处方原状态
|
|
|
String status=String.valueOf(map.get("status"));
|
|
|
//处方Id
|
|
|
String preId=String.valueOf(map.get("preId"));
|
|
|
//门诊记录Id
|
|
|
String outPatientId=String.valueOf(map.get("id"));
|
|
|
|
|
|
//根据处方号获取处方状态
|
|
|
Map<String, Object> params =new HashMap<>();
|
|
@ -71,15 +88,108 @@ public class PrescriptionStatusUpdateService {
|
|
|
params.remove("realOrder");
|
|
|
wlyyPrescriptionVOS= getWlyyPrescriptionVO(params);
|
|
|
}
|
|
|
//根据处方id获取处方详情
|
|
|
WlyyPrescriptionDO wlyyPrescriptionDO=prescriptionDao.findOne(preId);
|
|
|
//根据门诊id获取门诊记录:如果处方状态为已完成,需要将门诊状态改为已诊
|
|
|
WlyyOutpatientDO wlyyOutpatientDO=outpatientDao.findById(outPatientId);
|
|
|
if(null!=wlyyPrescriptionVOS){
|
|
|
//如果状态为100,门诊记录需要变更为结束
|
|
|
|
|
|
//如果状态为13 则需要保存处方状态
|
|
|
|
|
|
//如果原来状态为13,则需要将处方重新获取
|
|
|
|
|
|
//
|
|
|
|
|
|
WlyyPrescriptionVO wlyyPrescriptionVO=wlyyPrescriptionVOS.get(0);
|
|
|
wlyyPrescriptionDO.setStatus(wlyyPrescriptionVO.getStatus());
|
|
|
//用处方号获取不到处方时,重新更新处方到本地
|
|
|
if(!preExistFlag){
|
|
|
//删除原有药品信息
|
|
|
List<WlyyPrescriptionInfoDO> oldInfos = prescriptionInfoDao.findByPrescriptionId(preId);
|
|
|
if(oldInfos!=null&&oldInfos.size()>0){
|
|
|
prescriptionInfoDao.delete(oldInfos);
|
|
|
}
|
|
|
//删除之前诊断
|
|
|
List<WlyyPrescriptionDiagnosisDO> ds = prescriptionDiagnosisDao.findByPrescriptionId(preId);
|
|
|
if(ds!=null&&ds.size()>0){
|
|
|
prescriptionDiagnosisDao.delete(ds);
|
|
|
}
|
|
|
String Icd10 = "";
|
|
|
String Icd10Name = "";
|
|
|
List<WlyyPrescriptionDiagnosisDO> wlyyPrescriptionDiagnosisDOS=new ArrayList<>();
|
|
|
for(WlyyPrescriptionDiagnosisVO diagnosisVO:wlyyPrescriptionVO.getDiagnosisVOs()){
|
|
|
WlyyPrescriptionDiagnosisDO diagnosisDO=new WlyyPrescriptionDiagnosisDO();
|
|
|
//将诊断拼接放到门诊记录中
|
|
|
if("1".equals(diagnosisVO.getType())){
|
|
|
Icd10 = diagnosisVO.getCode()+","+Icd10;
|
|
|
Icd10Name+=diagnosisVO.getName()+","+Icd10Name;
|
|
|
}else {
|
|
|
Icd10+=diagnosisVO.getCode()+",";
|
|
|
Icd10Name+=diagnosisVO.getName()+",";
|
|
|
}
|
|
|
diagnosisDO.setCode(diagnosisVO.getCode());
|
|
|
diagnosisDO.setName(diagnosisVO.getName());
|
|
|
diagnosisDO.setType(diagnosisVO.getType());
|
|
|
diagnosisDO.setPrescriptionId(preId);
|
|
|
diagnosisDO.setCreateTime(new Date());
|
|
|
wlyyPrescriptionDiagnosisDOS.add(diagnosisDO);
|
|
|
}
|
|
|
//重新保存诊断
|
|
|
prescriptionDiagnosisDao.save(wlyyPrescriptionDiagnosisDOS);
|
|
|
//药品更新
|
|
|
List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS=new ArrayList<>();
|
|
|
for(WlyyPrescriptionInfoVO infoVO:wlyyPrescriptionVO.getInfoVOs()){
|
|
|
WlyyPrescriptionInfoDO infoDO=new WlyyPrescriptionInfoDO();
|
|
|
//处方code 关联表wlyy_prescription code
|
|
|
infoDO.setPrescriptionId(preId);
|
|
|
//药品编号
|
|
|
infoDO.setDrugNo(infoVO.getDrugNo());
|
|
|
//药品名称
|
|
|
infoDO.setDrugName(infoVO.getDrugName());
|
|
|
//库房号
|
|
|
infoDO.setDispDeposite(infoVO.getDispDeposite());
|
|
|
// 药量
|
|
|
infoDO.setDosage(infoVO.getDosage());
|
|
|
//数量
|
|
|
infoDO.setQuantity(infoVO.getQuantity());
|
|
|
//单位
|
|
|
infoDO.setUnit(infoVO.getUnit());
|
|
|
//單位名稱
|
|
|
infoDO.setUnitName(infoVO.getUnitName());
|
|
|
//包装单位
|
|
|
infoDO.setPackUnit(infoVO.getPackUnit());
|
|
|
//包装单位名称
|
|
|
infoDO.setPackUnitName(infoVO.getPackUnitName());
|
|
|
// 用法
|
|
|
infoDO.setSupplyCode(infoVO.getSupplyCode());
|
|
|
//用法名稱
|
|
|
infoDO.setSupplyName(infoVO.getSupplyName());
|
|
|
//天数
|
|
|
infoDO.setDays(infoVO.getDays());
|
|
|
//组号
|
|
|
infoDO.setFrequency(infoVO.getFrequency());
|
|
|
//药品收费码
|
|
|
infoDO.setSerial(infoVO.getSerial());
|
|
|
//库房号
|
|
|
infoDO.setGroupNo(infoVO.getGroupNo());
|
|
|
//规格
|
|
|
infoDO.setSpecification(infoVO.getSpecification());
|
|
|
// 1可用 0删除
|
|
|
infoDO.setDel(1);
|
|
|
//频率
|
|
|
infoDO.setUsageCode(infoVO.getUsageCode());
|
|
|
//頻率名稱
|
|
|
infoDO.setUsageName(infoVO.getUsageName());
|
|
|
//包装价格
|
|
|
infoDO.setPackRetprice(infoVO.getPackRetprice());
|
|
|
wlyyPrescriptionInfoDOS.add(infoDO);
|
|
|
}
|
|
|
prescriptionInfoDao.save(wlyyPrescriptionInfoDOS);
|
|
|
|
|
|
Icd10 = Icd10.substring(0,Icd10.length()-1);
|
|
|
Icd10Name = Icd10Name.substring(0,Icd10Name.length()-1);
|
|
|
wlyyOutpatientDO.setIcd10(Icd10);
|
|
|
wlyyOutpatientDO.setIcd10Name(Icd10Name);
|
|
|
}
|
|
|
if(100==wlyyPrescriptionVO.getStatus()){
|
|
|
wlyyOutpatientDO.setStatus("2");
|
|
|
}
|
|
|
outpatientDao.save(wlyyOutpatientDO);
|
|
|
prescriptionDao.save(wlyyPrescriptionDO);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@ -103,26 +213,4 @@ public class PrescriptionStatusUpdateService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void updatePrescriptionStatusByAdmNo(String admNo,String realOrder,String status)throws Exception{
|
|
|
String sql="";
|
|
|
String outPatientSql="";
|
|
|
if ("1".equals(status)) {
|
|
|
sql = "UPDATE base.wlyy_prescription p SET p.`status`='13' WHERE p.adm_no='" + admNo + "' AND p.real_order='" + realOrder + "' ";
|
|
|
} else if ("2".equals(status)) {
|
|
|
//开方成功时候,先用处方号获取本地处方状态是否为开方失败,如果是则需要更新本地的处方
|
|
|
sql = "UPDATE base.wlyy_prescription p SET p.`status`='20' WHERE p.adm_no='" + admNo + "' AND p.real_order='" + realOrder + "' ";
|
|
|
//变更门诊状态
|
|
|
outPatientSql="UPDATE base.wlyy_outpatient p SET p.`status`='2' WHERE p.adm_no='" + admNo + "'";
|
|
|
jdbcTemplate.execute(outPatientSql);
|
|
|
} else if ("3".equals(status)) {
|
|
|
//自取处方结束
|
|
|
sql = "UPDATE base.wlyy_prescription p SET p.`status`='100',p.pay_status='1' WHERE p.adm_no='" + admNo + "' AND p.real_order='" + realOrder + "' ";
|
|
|
}
|
|
|
jdbcTemplate.execute(sql);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|