|  | @@ -1198,13 +1198,13 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          if (mzPrescriptionVo.getMzChargeDetailList() != null && mzPrescriptionVo.getMzChargeDetailList().size() > 0) {
 | 
	
		
			
				|  |  |              //麻、精一
 | 
	
		
			
				|  |  | -            List<MzZdYpYsh> mjyList = mzZdYpYshMapper.selectMjyByCommonParams( null, null);
 | 
	
		
			
				|  |  | +            List<MzZdYpYsh> mjyList = mzZdYpYshMapper.selectMjyByCommonParams(null, null);
 | 
	
		
			
				|  |  |              Set<String> mjySet = null;
 | 
	
		
			
				|  |  |              if (mjyList != null) {
 | 
	
		
			
				|  |  |                  mjySet = mjyList.stream().map(m -> m.getCode()).collect(Collectors.toSet());
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              //精二
 | 
	
		
			
				|  |  | -            List<MzZdYpYsh> jeList = mzZdYpYshMapper.selectJeByCommonParams( null, null);
 | 
	
		
			
				|  |  | +            List<MzZdYpYsh> jeList = mzZdYpYshMapper.selectJeByCommonParams(null, null);
 | 
	
		
			
				|  |  |              Set<String> jeSet = null;
 | 
	
		
			
				|  |  |              if (jeList != null) {
 | 
	
		
			
				|  |  |                  jeSet = jeList.stream().map(m -> m.getCode()).collect(Collectors.toSet());
 | 
	
	
		
			
				|  | @@ -1341,10 +1341,10 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
 | 
	
		
			
				|  |  |                      if (mzChargeDetail.getGroupOrder() != null) {
 | 
	
		
			
				|  |  |                          name = mzChargeDetail.getGroupOrder() + "." + name;
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  | -                    if(StringUtils.isNotBlank(ypZdDict.getManuCode())){
 | 
	
		
			
				|  |  | -                        String manufactoryName= ypZdManufactoryService.queryYpZdManufactoryByCode(ypZdDict.getManuCode());
 | 
	
		
			
				|  |  | -                        if(StringUtils.isNotBlank(manufactoryName)){
 | 
	
		
			
				|  |  | -                            name+="("+manufactoryName+")    ";
 | 
	
		
			
				|  |  | +                    if (StringUtils.isNotBlank(ypZdDict.getManuCode())) {
 | 
	
		
			
				|  |  | +                        String manufactoryName = ypZdManufactoryService.queryYpZdManufactoryByCode(ypZdDict.getManuCode());
 | 
	
		
			
				|  |  | +                        if (StringUtils.isNotBlank(manufactoryName)) {
 | 
	
		
			
				|  |  | +                            name += "(" + manufactoryName + ")    ";
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                      String unitDesc = "";
 | 
	
	
		
			
				|  | @@ -1357,11 +1357,11 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
 | 
	
		
			
				|  |  |  //                        }
 | 
	
		
			
				|  |  |                          // name += " " + mzChargeDetail.getDrugQuan() + unitDesc;
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  | -                    if(StringUtils.isNotBlank(ypZdDict.getSpecification())){
 | 
	
		
			
				|  |  | -                        name+=ypZdDict.getSpecification()+"    X  ";
 | 
	
		
			
				|  |  | +                    if (StringUtils.isNotBlank(ypZdDict.getSpecification())) {
 | 
	
		
			
				|  |  | +                        name += ypZdDict.getSpecification() + "    X  ";
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                      name += mzChargeDetail.getQuantity() + UnitTypeEnum.getUnitTypeByCode(ypZdDict.getPackUnit()).name;
 | 
	
		
			
				|  |  | -                   // name += " 共" + mzChargeDetail.getQuantity() + UnitTypeEnum.getUnitTypeByCode(ypZdDict.getPackUnit()).name;
 | 
	
		
			
				|  |  | +                    // name += " 共" + mzChargeDetail.getQuantity() + UnitTypeEnum.getUnitTypeByCode(ypZdDict.getPackUnit()).name;
 | 
	
		
			
				|  |  |                      if (StringUtils.isNotBlank(mzChargeDetail.getSupplyCode())) {
 | 
	
		
			
				|  |  |                          SupplyTypeEnum supplyTypeEnum = SupplyTypeEnum.getSupplyTypeByCode(mzChargeDetail.getSupplyCode());
 | 
	
		
			
				|  |  |                          if (supplyTypeEnum != null) {
 | 
	
	
		
			
				|  | @@ -1787,11 +1787,11 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
 | 
	
		
			
				|  |  |                          mzYjReq.setExecDept(jyZdItem.getExecUnit());
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -                if(mzYjReq.getReqComment().length()>62){
 | 
	
		
			
				|  |  | -                    mzYjReq.setReqComment(mzYjReq.getReqComment().substring(0,61));
 | 
	
		
			
				|  |  | +                if (mzYjReq.getReqComment().length() > 62) {
 | 
	
		
			
				|  |  | +                    mzYjReq.setReqComment(mzYjReq.getReqComment().substring(0, 61));
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -                if(mzYjReq.getReqComment().length()>37){
 | 
	
		
			
				|  |  | -                    mzYjReq.setReqComment(mzYjReq.getReqComment().substring(0,36));
 | 
	
		
			
				|  |  | +                if (mzYjReq.getReqComment().length() > 37) {
 | 
	
		
			
				|  |  | +                    mzYjReq.setReqComment(mzYjReq.getReqComment().substring(0, 36));
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  if (setEmrProcess) {
 | 
	
		
			
				|  |  |                      zlIndex++;
 | 
	
	
		
			
				|  | @@ -1816,8 +1816,8 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
 | 
	
		
			
				|  |  |              //精二药品编码
 | 
	
		
			
				|  |  |              Set<String> jeSet = null;
 | 
	
		
			
				|  |  |              if (needPatient) {
 | 
	
		
			
				|  |  | -                List<MzZdYpYsh> mjList = mzZdYpYshMapper.selectMjyByCommonParams( null, null);
 | 
	
		
			
				|  |  | -                List<MzZdYpYsh> jeList = mzZdYpYshMapper.selectJeByCommonParams( null, null);
 | 
	
		
			
				|  |  | +                List<MzZdYpYsh> mjList = mzZdYpYshMapper.selectMjyByCommonParams(null, null);
 | 
	
		
			
				|  |  | +                List<MzZdYpYsh> jeList = mzZdYpYshMapper.selectJeByCommonParams(null, null);
 | 
	
		
			
				|  |  |                  mjSet = mjList.stream().map(m -> m.getCode()).collect(Collectors.toSet());
 | 
	
		
			
				|  |  |                  jeSet = jeList.stream().map(m -> m.getCode()).collect(Collectors.toSet());
 | 
	
		
			
				|  |  |              }
 | 
	
	
		
			
				|  | @@ -1879,7 +1879,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
 | 
	
		
			
				|  |  |                  if (ypZdDict != null) {
 | 
	
		
			
				|  |  |                      //当前处方购药量
 | 
	
		
			
				|  |  |                      BigDecimal thisQuantity = BigDecimal.valueOf(mzChargeDetail.getQuantity()).multiply(BigDecimal.valueOf(mzChargeDetail.getDrugWin()));
 | 
	
		
			
				|  |  | -                    if(needVerify){
 | 
	
		
			
				|  |  | +                    if (needVerify) {
 | 
	
		
			
				|  |  |                          if (ypZdDict.getMzRestrict() != null) {
 | 
	
		
			
				|  |  |                              //本月已经购买量
 | 
	
		
			
				|  |  |                              Integer quantityDb = mzChargeDetailMapper.selectTotalQuantityForDate(mzChargeDetail.getPatientId(), mzChargeDetail.getChargeItemCode(), mzChargeDetail.getSerial(), DateUtil.getFirstSecondForMonth(new Date()));
 | 
	
	
		
			
				|  | @@ -1897,7 +1897,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
 | 
	
		
			
				|  |  |                          if (ypZdDict.getPrescriptionLimitDays() != null && ypZdDict.getPrescriptionLimitDays() > 0) {
 | 
	
		
			
				|  |  |                              Integer quantityDb = mzChargeDetailMapper.selectTotalQuantityForDate(mzChargeDetail.getPatientId(), mzChargeDetail.getChargeItemCode(), mzChargeDetail.getSerial(), DateUtil.getDateFromNow(-ypZdDict.getPrescriptionLimitDays()));
 | 
	
		
			
				|  |  |                              if (quantityDb != null && quantityDb > 0) {
 | 
	
		
			
				|  |  | -                                throw new MzException("药品【" + ypZdDict.getName() + "】编码【" + ypZdDict.getCode() + "】的药品超过限购量,最近"+ypZdDict.getPrescriptionLimitDays()+"天已经购买过该药品!");
 | 
	
		
			
				|  |  | +                                throw new MzException("药品【" + ypZdDict.getName() + "】编码【" + ypZdDict.getCode() + "】的药品超过限购量,最近" + ypZdDict.getPrescriptionLimitDays() + "天已经购买过该药品!");
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                      }
 | 
	
	
		
			
				|  | @@ -1917,13 +1917,13 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
 | 
	
		
			
				|  |  |                          if (StringUtils.isBlank(mzChargeDetail.getFrequency())) {
 | 
	
		
			
				|  |  |                              throw new MzException("保存处方失败,第" + itemNo + "行药品频率不能为空");
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  | -                        if(needVerify){
 | 
	
		
			
				|  |  | +                        if (needVerify) {
 | 
	
		
			
				|  |  |                              YpBaseYf ypBaseYf = ypBaseYfMapper.selectYpBaseYf(ypZdDict.getCode(), ypZdDict.getSerial(), Constants.XY_ZCY_GROUP_NO);
 | 
	
		
			
				|  |  |                              if (ypBaseYf == null) {
 | 
	
		
			
				|  |  |                                  throw new MzException("无药品【" + ypZdDict.getName() + "】编码【" + ypZdDict.getCode() + "】的库存信息!");
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  | -                            if(thisQuantity.compareTo(ypBaseYf.getStockAmountVirtual()==null?BigDecimal.ZERO:BigDecimal.valueOf(ypBaseYf.getStockAmountVirtual()))==1){
 | 
	
		
			
				|  |  | -                                throw new MzException("药品【" + ypZdDict.getName() + "】编码【" + ypZdDict.getCode() + "】的药品超过库存数量,该药品实际库存"+(ypBaseYf.getStockAmountVirtual()==null?0:ypBaseYf.getStockAmountVirtual())+"请调整该药品数量!");
 | 
	
		
			
				|  |  | +                            if (thisQuantity.compareTo(ypBaseYf.getStockAmountVirtual() == null ? BigDecimal.ZERO : BigDecimal.valueOf(ypBaseYf.getStockAmountVirtual())) == 1) {
 | 
	
		
			
				|  |  | +                                throw new MzException("药品【" + ypZdDict.getName() + "】编码【" + ypZdDict.getCode() + "】的药品超过库存数量,该药品实际库存" + (ypBaseYf.getStockAmountVirtual() == null ? 0 : ypBaseYf.getStockAmountVirtual()) + "请调整该药品数量!");
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                          if (Constants.CLF.equals(ypZdDict.getBillItemMz())) {
 | 
	
	
		
			
				|  | @@ -2043,11 +2043,11 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
 | 
	
		
			
				|  |  |              mzZyReq.setReqWard(mzZyReq.getReqDept());
 | 
	
		
			
				|  |  |              mzZyReq.setIcdCodeNew(mzPrescriptionVo.getIcdCode());
 | 
	
		
			
				|  |  |              mzZyReq.setIcdTextNew(mzPrescriptionVo.getIcdText());
 | 
	
		
			
				|  |  | -            if(mzZyReq.getIcdCodeNew().length()>10){
 | 
	
		
			
				|  |  | -                mzZyReq.setIcdCode(mzZyReq.getIcdCodeNew().substring(0,9));
 | 
	
		
			
				|  |  | +            if (mzZyReq.getIcdCodeNew() != null && mzZyReq.getIcdCodeNew().length() > 10) {
 | 
	
		
			
				|  |  | +                mzZyReq.setIcdCode(mzZyReq.getIcdCodeNew().substring(0, 9));
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            if(mzZyReq.getIcdTextNew().length()>25){
 | 
	
		
			
				|  |  | -                mzZyReq.setIcdText(mzZyReq.getIcdTextNew().substring(0,20));
 | 
	
		
			
				|  |  | +            if (mzZyReq.getIcdTextNew() != null && mzZyReq.getIcdTextNew().length() > 25) {
 | 
	
		
			
				|  |  | +                mzZyReq.setIcdText(mzZyReq.getIcdTextNew().substring(0, 20));
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              if (StringUtils.isBlank(mzZyReq.getIcdText())) {
 | 
	
		
			
				|  |  |                  mzZyReq.setIcdText(mzPrescriptionVo.getMzBlRecord().getTentativeDiagnosis());
 | 
	
	
		
			
				|  | @@ -2409,9 +2409,9 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          mzPrescriptionVo.setFirstOrNot(mzVisitTable.getFirstOrNot());
 | 
	
		
			
				|  |  |          mzPrescriptionVo.setIcdCode(mzVisitTable.getIcdCode());
 | 
	
		
			
				|  |  | -        String icdText=StringUtils.isBlank(mzBlRecord.getTentativeDiagnosis())?"":mzBlRecord.getTentativeDiagnosis();
 | 
	
		
			
				|  |  | +        String icdText = StringUtils.isBlank(mzBlRecord.getTentativeDiagnosis()) ? "" : mzBlRecord.getTentativeDiagnosis();
 | 
	
		
			
				|  |  |          if (mzVisitTable != null && mzVisitTable.getIcdText() != null && StringUtils.isNotBlank(mzVisitTable.getIcdText())) {
 | 
	
		
			
				|  |  | -            icdText+=mzVisitTable.getIcdText();
 | 
	
		
			
				|  |  | +            icdText += mzVisitTable.getIcdText();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          mzPrescriptionVo.setIcdText(icdText);
 | 
	
		
			
				|  |  |          mzPrescriptionVo.setMzBlRecord(mzBlRecord);
 | 
	
	
		
			
				|  | @@ -2491,13 +2491,13 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
 | 
	
		
			
				|  |  |          List<MzChargeDetail> removeList = null;
 | 
	
		
			
				|  |  |          if (mzChargeDetailList != null && mzChargeDetailList.size() > 0) {
 | 
	
		
			
				|  |  |              //麻、精一
 | 
	
		
			
				|  |  | -            List<MzZdYpYsh> mjyList = mzZdYpYshMapper.selectMjyByCommonParams( null, null);
 | 
	
		
			
				|  |  | +            List<MzZdYpYsh> mjyList = mzZdYpYshMapper.selectMjyByCommonParams(null, null);
 | 
	
		
			
				|  |  |              Set<String> mjySet = null;
 | 
	
		
			
				|  |  |              if (mjyList != null) {
 | 
	
		
			
				|  |  |                  mjySet = mjyList.stream().map(m -> m.getCode()).collect(Collectors.toSet());
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              //精二
 | 
	
		
			
				|  |  | -            List<MzZdYpYsh> jeList = mzZdYpYshMapper.selectJeByCommonParams( null, null);
 | 
	
		
			
				|  |  | +            List<MzZdYpYsh> jeList = mzZdYpYshMapper.selectJeByCommonParams(null, null);
 | 
	
		
			
				|  |  |              Set<String> jeSet = null;
 | 
	
		
			
				|  |  |              if (jeList != null) {
 | 
	
		
			
				|  |  |                  jeSet = jeList.stream().map(m -> m.getCode()).collect(Collectors.toSet());
 | 
	
	
		
			
				|  | @@ -2651,7 +2651,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
 | 
	
		
			
				|  |  |          MzBlRecord mzBlRecord = mzBlRecordMapper.selectMzBlRecordByPatientIdAndTimes(patientId, times);
 | 
	
		
			
				|  |  |          if (mzBlRecord == null) {
 | 
	
		
			
				|  |  |              //历史数据会存在没有病历数据
 | 
	
		
			
				|  |  | -            mzBlRecord=new MzBlRecord();
 | 
	
		
			
				|  |  | +            mzBlRecord = new MzBlRecord();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          resultMap.put("mzBlRecord", mzBlRecord);
 | 
	
		
			
				|  |  |          return resultMap;
 |