|
@@ -2,21 +2,75 @@ package thyyxxk.webserver.service.inpatient;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import thyyxxk.webserver.constants.sidicts.MedType;
|
|
|
import thyyxxk.webserver.dao.his.inpatient.ChargeListDao;
|
|
|
import thyyxxk.webserver.entity.inpatient.chargelist.BriefPatInfo;
|
|
|
+import thyyxxk.webserver.entity.inpatient.chargelist.ChargeItem;
|
|
|
+import thyyxxk.webserver.entity.inpatient.chargelist.PatOverview;
|
|
|
+import thyyxxk.webserver.service.redislike.RedisLikeService;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Service
|
|
|
public class ChargeListService {
|
|
|
private final ChargeListDao dao;
|
|
|
+ private final RedisLikeService redis;
|
|
|
|
|
|
@Autowired
|
|
|
- public ChargeListService(ChargeListDao dao) {
|
|
|
+ public ChargeListService(ChargeListDao dao, RedisLikeService redis) {
|
|
|
this.dao = dao;
|
|
|
+ this.redis = redis;
|
|
|
}
|
|
|
|
|
|
- public List<BriefPatInfo> selectBriefPatInfo(String patNo) {
|
|
|
- return dao.selectBriefPatInfo(patNo);
|
|
|
+ public List<PatOverview> selectPatOverviews(String patNo) {
|
|
|
+ return dao.selectPatOverviews(patNo);
|
|
|
+ }
|
|
|
+
|
|
|
+ public BriefPatInfo selectBriefPatInfo(PatOverview overview) {
|
|
|
+ BriefPatInfo briefPatInfo = dao.selectBriefPatInfo(overview.getPatNo(), overview.getTimes(), "zy_actpatient");
|
|
|
+ if (null == briefPatInfo) {
|
|
|
+ briefPatInfo = dao.selectBriefPatInfo(overview.getPatNo(), overview.getTimes(), "zy_inactpatient");
|
|
|
+ }
|
|
|
+ if (null != briefPatInfo) {
|
|
|
+ briefPatInfo.setMedtype(MedType.getName(briefPatInfo.getMedtype()));
|
|
|
+ briefPatInfo.setDept(redis.getDeptName(briefPatInfo.getDept()));
|
|
|
+ if (briefPatInfo.getDays() < 1) {
|
|
|
+ briefPatInfo.setDays(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return briefPatInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String, Object> selectChargeList(PatOverview overview) {
|
|
|
+ List<ChargeItem> chargeList = dao.selectChargeList(overview.getPatNo(), overview.getTimes());
|
|
|
+ Map<String, List<ChargeItem>> chargeListMap = new HashMap<>();
|
|
|
+ Map<String, BigDecimal> sumsTempMap = new HashMap<>();
|
|
|
+ sumsTempMap.put("总计", BigDecimal.ZERO);
|
|
|
+ for (ChargeItem chargeItem : chargeList) {
|
|
|
+ String mapKey = chargeItem.getBillItemName();
|
|
|
+ sumsTempMap.replace("总计", sumsTempMap.get("总计").add(chargeItem.getCost()));
|
|
|
+ if (chargeListMap.containsKey(mapKey)) {
|
|
|
+ chargeListMap.get(mapKey).add(chargeItem);
|
|
|
+ sumsTempMap.replace(mapKey, sumsTempMap.get(mapKey).add(chargeItem.getCost()));
|
|
|
+ } else {
|
|
|
+ List<ChargeItem> tempList = new ArrayList<>();
|
|
|
+ tempList.add(chargeItem);
|
|
|
+ chargeListMap.put(mapKey, tempList);
|
|
|
+ sumsTempMap.put(mapKey, chargeItem.getCost());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<String, String> sumsMap = new HashMap<>();
|
|
|
+ for (Map.Entry<String, BigDecimal> entry : sumsTempMap.entrySet()) {
|
|
|
+ sumsMap.put(entry.getKey(), entry.getValue().setScale(2, RoundingMode.HALF_DOWN).toString());
|
|
|
+ }
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("chargeList", chargeListMap);
|
|
|
+ resultMap.put("sumsMap", sumsMap);
|
|
|
+ return resultMap;
|
|
|
}
|
|
|
}
|