|
|
@@ -751,20 +751,20 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public int savePrescription(MzPrescriptionVo mzPrescriptionVo,Clinic dbClinic) throws MzException {
|
|
|
+ public int savePrescription(MzPrescriptionVo mzPrescriptionVo, Clinic dbClinic) throws MzException {
|
|
|
setFullMzPrescriptionVo(mzPrescriptionVo, true);
|
|
|
- if(dbClinic!=null && dbClinic.getId()!=null && StringUtils.isNotBlank(dbClinic.getPatientId()) && dbClinic.getTimes()!=null){
|
|
|
- List<MzChargeDetail> dbMzChargeDetailList = mzChargeDetailMapper.selectNotPayMzChargeDetailByPatientId(mzPrescriptionVo.getPatientId(),dbClinic.getTimes());
|
|
|
+ if (dbClinic != null && dbClinic.getId() != null && StringUtils.isNotBlank(dbClinic.getPatientId()) && dbClinic.getTimes() != null) {
|
|
|
+ List<MzChargeDetail> dbMzChargeDetailList = mzChargeDetailMapper.selectNotPayMzChargeDetailByPatientId(mzPrescriptionVo.getPatientId(), dbClinic.getTimes());
|
|
|
if (dbMzChargeDetailList != null && dbMzChargeDetailList.size() > 0) {
|
|
|
for (MzChargeDetail mzChargeDetail : dbMzChargeDetailList) {
|
|
|
if (Arrays.asList(Constants.XY_ZCY_GROUP_NO, Constants.ZY_GROUP_NO, Constants.YC_GROUP_NO, Constants.GRANULA_GROUP_NO).contains(mzChargeDetail.getGroupNo())) {
|
|
|
ypBaseYfMapper.updateStockAmountVirtualAdd(mzChargeDetail.getChargeItemCode(), mzChargeDetail.getSerial(), mzChargeDetail.getGroupNo(), BigDecimal.valueOf(mzChargeDetail.getQuantity()).multiply(BigDecimal.valueOf(mzChargeDetail.getDrugWin())));
|
|
|
}
|
|
|
}
|
|
|
- mzChargeDetailMapper.deleteNotPayMzChargeDetailByPatientId(mzPrescriptionVo.getPatientId(),dbClinic.getTimes());
|
|
|
+ mzChargeDetailMapper.deleteNotPayMzChargeDetailByPatientId(mzPrescriptionVo.getPatientId(), dbClinic.getTimes());
|
|
|
}
|
|
|
- mzYjReqMapper.deleteNotPayYjReByPatientId(mzPrescriptionVo.getPatientId(),dbClinic.getTimes());
|
|
|
- mzBlRecordMapper.deleteNotPayBlRecordByPatientId(mzPrescriptionVo.getPatientId(),dbClinic.getTimes());
|
|
|
+ mzYjReqMapper.deleteNotPayYjReByPatientId(mzPrescriptionVo.getPatientId(), dbClinic.getTimes());
|
|
|
+ mzBlRecordMapper.deleteNotPayBlRecordByPatientId(mzPrescriptionVo.getPatientId(), dbClinic.getTimes());
|
|
|
clinicMapper.deleteById(dbClinic.getId());
|
|
|
}
|
|
|
int times = 0;
|
|
|
@@ -801,6 +801,9 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
mzBlRecord.setDoctorCode(mzPrescriptionVo.getDoctorCode());
|
|
|
mzBlRecord.setDeptCode(mzPrescriptionVo.getVisitDeptCode());
|
|
|
mzBlRecord.setFirstOrNot(mzPrescriptionVo.getFirstOrNot().toString());
|
|
|
+ if (mzBlRecord.getTentativeDiagnosis() == null) {
|
|
|
+ mzBlRecord.setTentativeDiagnosis("");
|
|
|
+ }
|
|
|
mzBlRecordMapper.insertMzBlRecord(mzBlRecord);
|
|
|
//保存医技入库
|
|
|
if (mzPrescriptionVo.getMzYjReqList() != null && mzPrescriptionVo.getMzYjReqList().size() > 0) {
|
|
|
@@ -811,7 +814,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
if (mzPrescriptionVo.getMzChargeDetailList() != null && mzPrescriptionVo.getMzChargeDetailList().size() > 0) {
|
|
|
getMzChargeDetailService().saveMzChargeDetail(mzPrescriptionVo.getMzChargeDetailList());
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(mzPrescriptionVo.getSerialNo())){
|
|
|
+ if (StringUtils.isNotBlank(mzPrescriptionVo.getSerialNo())) {
|
|
|
MzfzPatientOrder updateMzfzPatientOrder = new MzfzPatientOrder();
|
|
|
updateMzfzPatientOrder.setSerialNo(Integer.valueOf(mzPrescriptionVo.getSerialNo()));
|
|
|
updateMzfzPatientOrder.setStatusFlag(MzfzStatusEnum.CLINIC.code);
|
|
|
@@ -834,7 +837,6 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 设置完整处方
|
|
|
*
|
|
|
@@ -861,7 +863,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
if (!Arrays.asList(YesNoEnum.YES.code, YesNoEnum.NO.code).contains(mzPrescriptionVo.getJzFlag())) {
|
|
|
throw new MzException("保存处方失败,急诊标志值错误");
|
|
|
}
|
|
|
- if(mzPrescriptionVo.getFirstOrNot()==null){
|
|
|
+ if (mzPrescriptionVo.getFirstOrNot() == null) {
|
|
|
throw new MzException("保存处方失败,初诊复诊标识为空");
|
|
|
}
|
|
|
if (!Arrays.asList(YesNoEnum.YES.code, YesNoEnum.NO.code).contains(mzPrescriptionVo.getFirstOrNot())) {
|
|
|
@@ -886,29 +888,22 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
mzPatientMi = new MzPatientMi();
|
|
|
}
|
|
|
Date now = new Date();
|
|
|
-// MzVisitTable newMzVisitTable = getMzVisitTable(mzPrescriptionVo, times, now, mzPatientMi.getResponseType());
|
|
|
-// mzVisitTableMapper.insertMzVisitTable(newMzVisitTable);
|
|
|
-// MzPatientMi updateMzPatientMi = new MzPatientMi();
|
|
|
-// updateMzPatientMi.setPatientId(mzPrescriptionVo.getPatientId());
|
|
|
-// updateMzPatientMi.setTimes(times);
|
|
|
-// updateMzPatientMi.setLvDate(now);
|
|
|
-// mzPatientMiMapper.updateMzPatientMi(updateMzPatientMi);
|
|
|
-//
|
|
|
-// int blNo = mzYshConfigService.getBlNo();
|
|
|
-// MzBaRecord mzBaRecord = MzBaRecord.getMzBaRecord(mzPrescriptionVo, times, now, blNo);
|
|
|
-// mzBaRecordMapper.insertMzBaRecord(mzBaRecord);
|
|
|
-// MzBlRecord mzBlRecord = mzPrescriptionVo.getMzBlRecord();
|
|
|
-// mzBlRecord.setPatientId(mzPrescriptionVo.getPatientId());
|
|
|
-// mzBlRecord.setTimes(times);
|
|
|
-// mzBlRecord.setEmrNo(String.valueOf(blNo));
|
|
|
-// mzBlRecord.setEmrType(YesNoEnum.YES.code.toString());
|
|
|
-// mzBlRecord.setVisitDate(now);
|
|
|
-// mzBlRecord.setDoctorCode(mzPrescriptionVo.getDoctorCode());
|
|
|
-// mzBlRecord.setDeptCode(mzPrescriptionVo.getVisitDeptCode());
|
|
|
-// mzBlRecordMapper.insertMzBlRecord(mzBlRecord);
|
|
|
+ //自助开处方且是保存入库的时候
|
|
|
+ boolean setEmrProcess = needPatient && Constants.BRZZJF_CODE.equals(mzPrescriptionVo.getDoctorCode());
|
|
|
+ //中药治疗
|
|
|
+ String zyzlContent = null;
|
|
|
+ //西药治疗
|
|
|
+ String xyzlContent = null;
|
|
|
+ //诊疗治疗
|
|
|
+ String zlzlContent = null;
|
|
|
+ //辅助检查
|
|
|
+ String emrFzjc = null;
|
|
|
+ int zlIndex = 0;
|
|
|
+ int xyIndex = 0;
|
|
|
String reqTzComment = getReqTzComment(mzPrescriptionVo.getMzBlRecord());
|
|
|
//保存医技入库
|
|
|
if (mzPrescriptionVo.getMzYjReqList() != null && mzPrescriptionVo.getMzYjReqList().size() > 0) {
|
|
|
+
|
|
|
for (MzYjReq mzYjReq : mzPrescriptionVo.getMzYjReqList()) {
|
|
|
if (StringUtils.isBlank(mzYjReq.getOrderCode())) {
|
|
|
throw new MzException("保存处方失败,医技项目编码不能为空");
|
|
|
@@ -945,7 +940,17 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
mzYjReq.setReqType(ReqTypeEnum.JIAN_YAN.code);
|
|
|
mzYjReq.setExecDept(jyZdItem.getExecUnit());
|
|
|
}
|
|
|
- // mzYjReqMapper.insertMzYjReq(mzYjReq);
|
|
|
+ if (setEmrProcess) {
|
|
|
+ zlIndex++;
|
|
|
+ String value = zlIndex + "." + mzYjReq.getOrderName() + " " + (mzYjReq.getJyRemark() == null ? "" : mzYjReq.getJyRemark()) + " ";
|
|
|
+ if (zlzlContent == null) {
|
|
|
+ zlzlContent = "医技与诊疗:" + value;
|
|
|
+ emrFzjc = value;
|
|
|
+ } else {
|
|
|
+ zlzlContent += "_" + value;
|
|
|
+ emrFzjc += "," + value;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
//保存药品入库
|
|
|
@@ -1033,6 +1038,17 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
mzChargeDetail.setDrugWin(1);
|
|
|
mzChargeDetail.setGroupType(Constants.XYF.equals(ypZdDict.getBillItemMz()) ? "1" : "2");
|
|
|
mzChargeDetail.setSupplyAmount(mzChargeDetail.getOrderDays() * OrderFrequencyEnum.getOrderFrequencyByCode(mzChargeDetail.getFrequency()).times);
|
|
|
+ if (setEmrProcess) {
|
|
|
+ xyIndex++;
|
|
|
+ SupplyTypeEnum supplyType = SupplyTypeEnum.getSupplyTypeByCode(mzChargeDetail.getSupplyCode());
|
|
|
+ OrderFrequencyEnum orderFrequency = OrderFrequencyEnum.getOrderFrequencyByCode(mzChargeDetail.getFrequency());
|
|
|
+ String value = xyIndex + "." + mzChargeDetail.getTcName() + " " + mzChargeDetail.getQuantity() + ypZdDict.getPackUnit() + " 用法:" + supplyType != null ? supplyType.name : "" + " 频次:" + orderFrequency != null ? orderFrequency.name : "" + " ";
|
|
|
+ if (xyzlContent == null) {
|
|
|
+ xyzlContent = "西药治疗:" + value;
|
|
|
+ } else {
|
|
|
+ xyzlContent += "_" + value;
|
|
|
+ }
|
|
|
+ }
|
|
|
} else if (Constants.CYF.equals(ypZdDict.getBillItemMz())) {
|
|
|
if (Constants.GRANULA_DRUG_KIND.equals(ypZdDict.getDrugKind())) {
|
|
|
mzChargeDetail.setGroupNo(Constants.GRANULA_GROUP_NO);
|
|
|
@@ -1046,6 +1062,18 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
throw new MzException("保存处方失败,第" + itemNo + "行药品的剂量为空");
|
|
|
}
|
|
|
mzChargeDetail.setSupplyAmount(1);
|
|
|
+ if (setEmrProcess) {
|
|
|
+ String value = mzChargeDetail.getTcName() + " ";
|
|
|
+ if (StringUtils.isNotBlank(mzChargeDetail.getInstructionText())) {
|
|
|
+ value += "[" + mzChargeDetail.getInstructionText() + "]";
|
|
|
+ }
|
|
|
+ value += mzChargeDetail.getDrugQuan() + "g" + " ";
|
|
|
+ if (zyzlContent == null) {
|
|
|
+ zyzlContent = "中药治疗:付数" + mzChargeDetail.getDrugWin() + "_" + value;
|
|
|
+ } else {
|
|
|
+ zyzlContent += "_" + value;
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
throw new MzException("保存处方失败,第" + itemNo + "行药品的账单类型错误");
|
|
|
}
|
|
|
@@ -1066,6 +1094,18 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
mzChargeDetail.setDrugWin(1);
|
|
|
mzChargeDetail.setGroupType(GroupTypeEnum.DIAGNOSIS.code);
|
|
|
mzChargeDetail.setSupplyAmount(1);
|
|
|
+ //诊疗在页面开立的时候是在医技里,但是保存入库是在项目明细表
|
|
|
+ if (setEmrProcess) {
|
|
|
+ zlIndex++;
|
|
|
+ String value = zlIndex + "." + mzChargeDetail.getTcName() + " " + mzChargeDetail.getInstructionText() + " ";
|
|
|
+ if (zlzlContent == null) {
|
|
|
+ zlzlContent = "医技与诊疗:" + value;
|
|
|
+ emrFzjc = value;
|
|
|
+ } else {
|
|
|
+ zlzlContent += "_" + value;
|
|
|
+ emrFzjc += "," + value;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
mzChargeDetail.setWarnDept(mzPrescriptionVo.getVisitDeptCode());
|
|
|
mzChargeDetail.setPriceId(mzPrescriptionVo.getDoctorCode());
|
|
|
@@ -1093,7 +1133,20 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
}
|
|
|
itemNo++;
|
|
|
}
|
|
|
- // getMzChargeDetailService().saveMzChargeDetail(mzPrescriptionVo.getMzChargeDetailList());
|
|
|
+ }
|
|
|
+ if (setEmrProcess) {
|
|
|
+ String emrProcess = "";
|
|
|
+ if (xyzlContent != null) {
|
|
|
+ emrProcess += xyzlContent;
|
|
|
+ }
|
|
|
+ if (zyzlContent != null) {
|
|
|
+ emrProcess += zyzlContent;
|
|
|
+ }
|
|
|
+ if (zlzlContent != null) {
|
|
|
+ emrProcess += zlzlContent;
|
|
|
+ }
|
|
|
+ mzPrescriptionVo.getMzBlRecord().setEmrProcess(emrProcess);
|
|
|
+ mzPrescriptionVo.getMzBlRecord().setEmrFzjc(emrFzjc);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1133,7 +1186,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
mzYjReq.setOrderNo(1);
|
|
|
mzYjReq.setJyRemark("申请核酸检测");
|
|
|
mzPrescriptionVo.setMzYjReqList(Arrays.asList(mzYjReq));
|
|
|
- return savePrescription(mzPrescriptionVo,null);
|
|
|
+ return savePrescription(mzPrescriptionVo, null);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1277,50 +1330,50 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public MzPrescriptionVo getMzPrescriptionVo(String patientId, Integer times,Boolean MzBlRecordFlag,String payMark) throws MzException {
|
|
|
- if(StringUtils.isBlank(patientId)){
|
|
|
+ public MzPrescriptionVo getMzPrescriptionVo(String patientId, Integer times, Boolean MzBlRecordFlag, String payMark) throws MzException {
|
|
|
+ if (StringUtils.isBlank(patientId)) {
|
|
|
throw new MzException("病人Id为空!");
|
|
|
}
|
|
|
- if(times==null){
|
|
|
+ if (times == null) {
|
|
|
throw new MzException("病人就诊次数为空!");
|
|
|
}
|
|
|
- if(MzBlRecordFlag==null){
|
|
|
+ if (MzBlRecordFlag == null) {
|
|
|
throw new MzException("病历类型为空!");
|
|
|
}
|
|
|
- if(!MzBlRecordFlag && StringUtils.isBlank(payMark)){
|
|
|
+ if (!MzBlRecordFlag && StringUtils.isBlank(payMark)) {
|
|
|
throw new MzException("缴费状态为空!");
|
|
|
}
|
|
|
- MzPrescriptionVo mzPrescriptionVo=new MzPrescriptionVo();
|
|
|
+ MzPrescriptionVo mzPrescriptionVo = new MzPrescriptionVo();
|
|
|
mzPrescriptionVo.setPatientId(patientId);
|
|
|
- MzVisitTable mzVisitTable=mzVisitTableService.queryByPatientIdAndTimes(patientId,times);
|
|
|
- if(mzVisitTable==null){
|
|
|
+ MzVisitTable mzVisitTable = mzVisitTableService.queryByPatientIdAndTimes(patientId, times);
|
|
|
+ if (mzVisitTable == null) {
|
|
|
throw new MzException("病人就诊记录不存在!");
|
|
|
}
|
|
|
mzPrescriptionVo.setFirstOrNot(mzVisitTable.getFirstOrNot());
|
|
|
mzPrescriptionVo.setIcdCode(mzVisitTable.getIcdCode());
|
|
|
mzPrescriptionVo.setIcdText(mzVisitTable.getIcdText());
|
|
|
- MzBlRecord mzBlRecord = mzBlRecordMapper.selectMzBlRecordByPatientIdAndTimes(patientId,times);
|
|
|
- if(mzBlRecord==null){
|
|
|
+ MzBlRecord mzBlRecord = mzBlRecordMapper.selectMzBlRecordByPatientIdAndTimes(patientId, times);
|
|
|
+ if (mzBlRecord == null) {
|
|
|
throw new MzException("病人门诊病历记录不存在!");
|
|
|
}
|
|
|
mzPrescriptionVo.setMzBlRecord(mzBlRecord);
|
|
|
- if(MzBlRecordFlag){
|
|
|
+ if (MzBlRecordFlag) {
|
|
|
//只需要构造病历信息,不需要设置用药和诊疗信息
|
|
|
return mzPrescriptionVo;
|
|
|
}
|
|
|
- List<MzChargeDetail> mzChargeDetailList= mzChargeDetailMapper.selectMzChargeDetailByPatientId(patientId,times, null, payMark);
|
|
|
- if(PayMarkEnum.CHARGED.code.equals(payMark)){
|
|
|
+ List<MzChargeDetail> mzChargeDetailList = mzChargeDetailMapper.selectMzChargeDetailByPatientId(patientId, times, null, payMark);
|
|
|
+ if (PayMarkEnum.CHARGED.code.equals(payMark)) {
|
|
|
//对于已经收费的药品记录查询,只需要查询医生开立的药品,给要方式等记录需要过滤
|
|
|
List<MzChargeDetail> removeList = new ArrayList<>();
|
|
|
- for (MzChargeDetail mzChargeDetail:mzChargeDetailList){
|
|
|
- if(YesNoEnum.YES.code!=(mzChargeDetail.getGroupId())){
|
|
|
+ for (MzChargeDetail mzChargeDetail : mzChargeDetailList) {
|
|
|
+ if (YesNoEnum.YES.code != (mzChargeDetail.getGroupId())) {
|
|
|
removeList.add(mzChargeDetail);
|
|
|
}
|
|
|
}
|
|
|
mzChargeDetailList.removeAll(removeList);
|
|
|
}
|
|
|
mzPrescriptionVo.setMzChargeDetailList(mzChargeDetailList);
|
|
|
- mzPrescriptionVo.setMzYjReqList(mzYjReqMapper.selectNotPayMzYjReq(new MzYjReq(patientId,times)));
|
|
|
+ mzPrescriptionVo.setMzYjReqList(mzYjReqMapper.selectNotPayMzYjReq(new MzYjReq(patientId, times)));
|
|
|
return mzPrescriptionVo;
|
|
|
}
|
|
|
|
|
|
@@ -1619,7 +1672,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
updateMzPatientMi.setLvDate(now);
|
|
|
mzPatientMiMapper.updateMzPatientMi(updateMzPatientMi);
|
|
|
|
|
|
- Clinic dbClinic= clinicMapper.selectByPatientIdAndTimesAndReceiptNo(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes(),mzDepositFileVo.getReceiptNo());
|
|
|
+ Clinic dbClinic = clinicMapper.selectByPatientIdAndTimesAndReceiptNo(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes(), mzDepositFileVo.getReceiptNo());
|
|
|
Clinic newClinic = new Clinic();
|
|
|
newClinic.setPatientId(mzPatientMi.getPatientId());
|
|
|
newClinic.setPatientName(mzPatientMi.getName());
|
|
|
@@ -1628,7 +1681,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
newClinic.setFirstOrNot(YesNoEnum.NO.code);
|
|
|
newClinic.setOpDay(new Date());
|
|
|
newClinic.setClinicStatus(ClinicStatusEnum.CHARGED.code);
|
|
|
- if(dbClinic!=null){
|
|
|
+ if (dbClinic != null) {
|
|
|
newClinic.setDeptCode(dbClinic.getDeptCode());
|
|
|
newClinic.setDoctorCode(dbClinic.getDoctorCode());
|
|
|
newClinic.setOpId(dbClinic.getDoctorCode());
|