|
@@ -1,5 +1,6 @@
|
|
|
package cn.hnthyy.thmz.service.impl.his.yf;
|
|
|
|
|
|
+import cn.hnthyy.thmz.common.Constants;
|
|
|
import cn.hnthyy.thmz.entity.MzException;
|
|
|
import cn.hnthyy.thmz.entity.his.YzActOrder;
|
|
|
import cn.hnthyy.thmz.entity.his.mz.Employee;
|
|
@@ -22,7 +23,9 @@ import cn.hnthyy.thmz.mapper.his.zy.*;
|
|
|
import cn.hnthyy.thmz.service.his.yf.YfWardPrescriptionService;
|
|
|
import cn.hnthyy.thmz.vo.YfWardVo;
|
|
|
import cn.hnthyy.thmz.vo.YzYpPageNoVo;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.json.JSONObject;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -39,6 +42,7 @@ import java.util.stream.Collectors;
|
|
|
/**
|
|
|
* 病房医嘱药品请领单
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService {
|
|
|
|
|
@@ -87,10 +91,12 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
|
|
|
@SuppressWarnings("all")
|
|
|
@Autowired
|
|
|
private PrescriptionMapper prescriptionMapper;
|
|
|
-
|
|
|
@SuppressWarnings("all")
|
|
|
@Autowired
|
|
|
private YpZdManufactoryMapper ypZdManufactoryMapper;
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ @Autowired
|
|
|
+ private ZyDetailChargeMapper zyDetailChargeMapper;
|
|
|
|
|
|
@Override
|
|
|
public List<YzYpPageNoVo> queryYzYpPageNo(YzYpPageNoVo yzYpPageNoVo){
|
|
@@ -198,18 +204,18 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
|
|
|
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
|
|
|
public Map<String, Object> sendWard(List<YzYpZyOrder> yzYpZyOrders,String pageNo,String userCode) throws MzException {
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
- List<YpZyPatient> ypZyPatients = new ArrayList<>();
|
|
|
String[] pageNos = pageNo.split("/");
|
|
|
List<YzYpZyOrder> yyzos;
|
|
|
int count =0;
|
|
|
for (int j = 0; j < pageNos.length; j++) {
|
|
|
+ List<YpZyPatient> ypZyPatients = new ArrayList<>();
|
|
|
String pageNoStr = pageNos[j];
|
|
|
if(yzYpZyOrders.get(0).getPageClass().equals("A")){//医技药单
|
|
|
count = zyDrugMapper.selectDrugCountByPageNo(pageNoStr);
|
|
|
}else if(!yzYpZyOrders.get(0).getPageClass().equals("T")){
|
|
|
count = yzYpZyOrderMapper.selectDrugCountByPageNo(Integer.parseInt(pageNoStr));
|
|
|
}
|
|
|
- if(StringUtils.isBlank(yzYpZyOrders.get(0).getName())){
|
|
|
+ if(StringUtils.isBlank(yzYpZyOrders.get(0).getName())){//判断前端传值是否为明细
|
|
|
List<YfWardVo> yfWardVos = getDetail(pageNoStr, yzYpZyOrders.get(0).getPageClass(), "1,3,4");
|
|
|
List<YzYpZyOrder> yyzo = new ArrayList<>();
|
|
|
Set<String> chargeCodes = yzYpZyOrders.parallelStream().map(YzYpZyOrder::getChargeCode).distinct().collect(Collectors.toSet());
|
|
@@ -242,7 +248,7 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
|
|
|
}
|
|
|
ypZyPatient.setOrderDate(yzYpZyOrder.getOccTime());
|
|
|
ypZyPatient.setSectionCode("");
|
|
|
- ypZyPatient.setAcctSign(yzYpZyOrder.getAmount()>=0?"2":"0");
|
|
|
+ ypZyPatient.setAcctSign(yzYpZyOrder.getAmount()==0?"2":"0");
|
|
|
ypZyPatient.setOutSeri(i+1);
|
|
|
ypZyPatient.setKeeper(userCode);
|
|
|
ypZyPatient.setTotalFlag("");
|
|
@@ -285,10 +291,30 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
|
|
|
supplyCode = "w";
|
|
|
}
|
|
|
ypZyPatient.setSupplyCode(supplyCode);
|
|
|
- ypZyPatients.add(ypZyPatient);
|
|
|
- if(yzYpZyOrder.getPageClass().equals("4") || yzYpZyOrder.getPageClass().equals("3")){//基数药和大输液
|
|
|
+ if(yzYpZyOrder.getPageClass().equals("4") || yzYpZyOrder.getPageClass().equals("3")){//基数药、大输液
|
|
|
ypZyPatientMapper.updateYpZyPatient(ypZyPatient);
|
|
|
}else{
|
|
|
+ if(yzYpZyOrder.getPageClass().equals("A")){//医技
|
|
|
+ ZyDetailCharge zyDetailCharge = new ZyDetailCharge();
|
|
|
+ zyDetailCharge.setInpatientNo(ypZyPatient.getInpatientNo());
|
|
|
+ zyDetailCharge.setAdmissTimes(ypZyPatient.getAdmissTimes());
|
|
|
+ zyDetailCharge.setChargeCodeMx(ypZyPatient.getChargeCode());
|
|
|
+ zyDetailCharge.setChargeDate(ypZyPatient.getOrderDate());
|
|
|
+ List<ZyDetailCharge> zyDetailCharges = zyDetailChargeMapper.selectZyDetailChargeList(zyDetailCharge);
|
|
|
+ String zySerialNo = "";
|
|
|
+ if(zyDetailCharges.size() >0){
|
|
|
+ zySerialNo = zyDetailCharges.get(0).getZySerialNo();
|
|
|
+ }else{
|
|
|
+ log.info("未查询到该病人的住院流水号[{}]", JSONObject.valueToString(zyDetailCharge));
|
|
|
+ }
|
|
|
+ ypZyPatient.setZySerialNo(zySerialNo);
|
|
|
+ String execUnit = zyDrugMapper.selectExecUnitPageNo(pageNoStr);
|
|
|
+ ypZyPatient.setSectionCode(execUnit);
|
|
|
+ }else{
|
|
|
+ if(ypZyPatient.getAmount() != 0){
|
|
|
+ ypZyPatients.add(ypZyPatient);
|
|
|
+ }
|
|
|
+ }
|
|
|
ypZyPatientMapper.insertYpZyPatient(ypZyPatient);
|
|
|
}
|
|
|
if(ypZyPatient.getAmount() != 0){
|
|
@@ -296,6 +322,7 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
|
|
|
,ypZyPatient.getGroupNo(), -ypZyPatient.getAmount(), BigDecimal.valueOf(-ypZyPatient.getAmount() * ypZyPatient.getRetprice()))){
|
|
|
throw new MzException("保存住院病人发药记录失败,更新库存异常");
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
if(yzYpZyOrder.getPageClass().equals("A")){//医技药单
|
|
|
if(0 == zyDrugMapper.updateZyDrugConfirm(ypZyPatient.getAmount()==0?"2":"1",userCode,ypZyPatient.getAmount()==0?"2":"1",yzYpZyOrder.getInpatientNo(),yzYpZyOrder.getAdmissTimes(),yzYpZyOrder.getLedgerSn(),yzYpZyOrder.getDetailSn())){
|
|
@@ -313,6 +340,9 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ /*if(ypZyPatients.size() > 0){
|
|
|
+ saveZyDetailCharge(ypZyPatients);
|
|
|
+ }*/
|
|
|
if (yzYpZyOrders.get(0).getPageClass().equals("5") || yzYpZyOrders.get(0).getPageClass().equals("6")){
|
|
|
savePrescription(ypZyPatients);
|
|
|
}
|
|
@@ -326,7 +356,51 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 发药记录插入摆药机中间表
|
|
|
+ * 确认发药费用上账
|
|
|
+ * @param ypZyPatients
|
|
|
+ */
|
|
|
+ public void saveZyDetailCharge(List<YpZyPatient> ypZyPatients){
|
|
|
+ List<ZyDetailCharge> zyDetailCharges = new ArrayList<>();
|
|
|
+ int maxDetailSn = zyDetailChargeMapper.selectMaxDetailSn(ypZyPatients.get(0).getInpatientNo(), ypZyPatients.get(0).getAdmissTimes());
|
|
|
+ for (YpZyPatient ypZyPatient : ypZyPatients) {
|
|
|
+ ZyDetailCharge zyDetailCharge = new ZyDetailCharge();
|
|
|
+ zyDetailCharge.setInpatientNo(ypZyPatient.getInpatientNo());
|
|
|
+ zyDetailCharge.setAdmissTimes(ypZyPatient.getAdmissTimes());
|
|
|
+ zyDetailCharge.setLedgerSn(1);
|
|
|
+ maxDetailSn += 1;
|
|
|
+ zyDetailCharge.setDetailSn(maxDetailSn);
|
|
|
+ zyDetailCharge.setChargeDate(ypZyPatient.getOrderDate());
|
|
|
+ zyDetailCharge.setOpIdCode(ypZyPatient.getDrawer());
|
|
|
+ YpZdDict ypZdDict = ypZdDictMapper.selectYpZdDictByCodeAndSerial(ypZyPatient.getChargeCode(),ypZyPatient.getSerial());
|
|
|
+ zyDetailCharge.setChargeCode(Constants.BILL_ITEM_CODE_prev + ypZdDict.getBillItemZy().substring(1));
|
|
|
+ zyDetailCharge.setInfantFlag(ypZyPatient.getInpatientNo().indexOf("$")==-1?"0":"1");
|
|
|
+ zyDetailCharge.setChargeStatus("2");
|
|
|
+ zyDetailCharge.setChargeAmount(ypZyPatient.getAmount()+"");
|
|
|
+ zyDetailCharge.setChargeFee((ypZyPatient.getAmount()*ypZyPatient.getRetprice())+"");
|
|
|
+ zyDetailCharge.setSelfFlag(ypZdDict.getSelfFlag()==null?"0":ypZdDict.getSelfFlag());
|
|
|
+ zyDetailCharge.setSeparateFlag(ypZdDict.getSeparateFlag()==null?"0":ypZdDict.getSeparateFlag());
|
|
|
+ zyDetailCharge.setSuppressFlag(ypZdDict.getSupriceFlag()==null?"0":ypZdDict.getSupriceFlag());
|
|
|
+ YzActOrder yzActOrder = yzActOrderMapper.selectYzActOrderByActOrderNo(ypZyPatient.getActOrderNo());
|
|
|
+ ZyActpatient zyActpatient = zyActpatientMapper.selectByInpatientNo("zy_actpatient", ypZyPatient.getInpatientNo(), ypZyPatient.getAdmissTimes());
|
|
|
+ zyDetailCharge.setWardCode(zyActpatient.getZkWard());
|
|
|
+ zyDetailCharge.setDeptCode(ypZyPatient.getDeptCode());
|
|
|
+ zyDetailCharge.setOrderNo((float) ypZyPatient.getActOrderNo());
|
|
|
+ zyDetailCharge.setOpeFlag("0");
|
|
|
+ zyDetailCharge.setExecUnit(yzActOrder.getExecUnit());
|
|
|
+ zyDetailCharge.setGenTime(new Date());
|
|
|
+ zyDetailCharge.setChargeCodeMx(ypZyPatient.getChargeCode());
|
|
|
+ zyDetailCharge.setSerial(ypZyPatient.getSerial());
|
|
|
+ zyDetailCharge.setDoctorCode(ypZyPatient.getDoctorName());
|
|
|
+ zyDetailCharge.setYbSelfFlag(yzActOrder.getYbSelfFlag());
|
|
|
+ zyDetailCharge.setReferPhysician(ypZyPatient.getDoctorName());
|
|
|
+ zyDetailCharge.setConsultPhysician(yzActOrder.getConsultPhysician());
|
|
|
+ zyDetailCharges.add(zyDetailCharge);
|
|
|
+ }
|
|
|
+ zyDetailChargeMapper.insertZyDetailCharges(zyDetailCharges);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 确认发药插入摆药机中间表
|
|
|
* @param ypZyPatients
|
|
|
* @return
|
|
|
*/
|