diff --git a/platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/LisServiceImpl.java b/platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/LisServiceImpl.java index 1ece7ec..d4de1df 100644 --- a/platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/LisServiceImpl.java +++ b/platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/LisServiceImpl.java @@ -1,6 +1,9 @@ package com.lyms.platform.permission.service.impl; +import com.lyms.platform.biz.service.AntenatalExaminationService; +import com.lyms.platform.biz.service.PatientsService; import com.lyms.platform.common.constants.ErrorCodeConstants; +import com.lyms.platform.common.enums.YnEnums; import com.lyms.platform.common.result.BaseResponse; import com.lyms.platform.common.utils.JsonUtil; import com.lyms.platform.permission.DataAccessLayerService; @@ -9,7 +12,16 @@ import com.lyms.platform.permission.model.LisReportItemModel; import com.lyms.platform.permission.model.LisReportModel; import com.lyms.platform.permission.model.LisReportQuery; import com.lyms.platform.permission.service.LisService; +import com.lyms.platform.permission.service.OrganizationService; +import com.lyms.platform.pojo.AntExChuModel; +import com.lyms.platform.pojo.AntenatalExaminationModel; import com.lyms.platform.pojo.BasicConfig; +import com.lyms.platform.pojo.Patients; +import com.lyms.platform.query.AntExChuQuery; +import com.lyms.platform.query.AntExQuery; +import com.lyms.platform.query.PatientsQuery; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; import org.apache.commons.collections.CollectionUtils; import org.codehaus.jackson.type.TypeReference; import org.springframework.beans.factory.annotation.Autowired; @@ -28,7 +40,12 @@ public class LisServiceImpl implements LisService { @Autowired private MasterLisMapper masterLisMapper; - + @Autowired + private AntenatalExaminationService antExService; + @Autowired + private PatientsService patientsService; + @Autowired + private OrganizationService organizationService; @Override public BaseResponse saveLisData(final List lisList,ThreadPoolTaskExecutor commonThreadPool) { try { @@ -129,6 +146,16 @@ public class LisServiceImpl implements LisService { try { masterLisMapper.deleteLisData(model); masterLisMapper.saveLisData(model); + + //临时用一下,未确定使用查询方式 + LisReportQuery lisReportQuery = new LisReportQuery(); + lisReportQuery.setLisId(model.getLisId()); + lisReportQuery.setVcCardNo(model.getVcCardNo()); + lisReportQuery.setHospitalId(model.getHospitalId()); + + List lisReportModels = masterLisMapper.queryLisDataByModel(lisReportQuery); + saveLisUpdateData(lisReportModels.get(0)); + } catch (Exception e) { continue; @@ -138,4 +165,246 @@ public class LisServiceImpl implements LisService { countDownLatch.countDown(); } } + + /** + * 根据孕妇,修改检查项为空,检查项结果 + * @param model + */ + private void saveLisUpdateData(LisReportModel model) { + + //1获取孕妇pid + PatientsQuery patientsQuery = new PatientsQuery(); + patientsQuery.setHospitalId(model.getHospitalId()); + patientsQuery.setVcCardNo(model.getVcCardNo()); + patientsQuery.setName(model.getName()); + patientsQuery.setSort("created"); + List list = patientsService.queryPatient(patientsQuery); + Patients patients = list.get(list.size()-1); + + //2 判断更新初诊还是复诊 + AntExQuery antExQuery = new AntExQuery(); + antExQuery.setYn(YnEnums.YES.getId()); + antExQuery.setParentId(patients.getId()); + List AntenatalExaminationModels = antExService.queryAntenatalExamination(antExQuery.convertToQuery()); //复诊记录 + if (CollectionUtils.isEmpty(AntenatalExaminationModels)){ + AntExChuQuery antExChuQuery = new AntExChuQuery(); + antExChuQuery.setYn(YnEnums.YES.getId()); + antExChuQuery.setParentId(patients.getId()); + List antExChuModels = antExService.queryAntExChu(antExChuQuery);//初诊记录 + if (CollectionUtils.isNotEmpty(antExChuModels)) { + AntExChuModel antExChuModel = antExChuModels.get(antExChuModels.size() - 1); + AntExChuModel antExChuModel1 = new AntExChuModel(); + //3 更新初诊记录 + antExChuModelUpadte(model, antExChuModel, antExChuModel1); + antExService.updateAntExChu(antExChuModel1,antExChuModel.getId()); + } + }else { + AntenatalExaminationModel antenatalExaminationModel= AntenatalExaminationModels.get(AntenatalExaminationModels.size() - 1); + AntenatalExaminationModel antenatalExaminationModel1 = new AntenatalExaminationModel(); + //3 更新复诊记录 + fuZhenUpdate(model, antenatalExaminationModel, antenatalExaminationModel1); + antExService.updateOneAnt(antenatalExaminationModel1,antenatalExaminationModel.getId()); + } + } + + /** + * 更新复诊记录 + * @param model + * @param antenatalExaminationModel + * @param antenatalExaminationModel1 + */ + private void fuZhenUpdate(LisReportModel model, AntenatalExaminationModel antenatalExaminationModel, AntenatalExaminationModel antenatalExaminationModel1) { + if("".equals(antenatalExaminationModel.getHemoglobin()) || antenatalExaminationModel.getHemoglobin()==null){ + antenatalExaminationModel1.setHemoglobin(getCodeValue(model, "HGB")); //血红蛋白 + } + if("".equals(antenatalExaminationModel.getUrineProtein()) || antenatalExaminationModel.getUrineProtein()==null){ + antenatalExaminationModel1.setUrineProtein(getCodeValue(model, "PRO")); //尿蛋白 + } + + if("".equals(antenatalExaminationModel.getTtita()) || antenatalExaminationModel.getTtita()==null){ + antenatalExaminationModel1.setTtita(getCodeValue(model, "T3")); // 总三碘甲状腺原氨酸(TT3) + } + if("".equals(antenatalExaminationModel.getTotalThy()) || antenatalExaminationModel.getTotalThy()==null){ + antenatalExaminationModel1.setTotalThy(getCodeValue(model, "T4")); // //总甲状腺素(TT4) + } + if("".equals(antenatalExaminationModel.getFtita()) || antenatalExaminationModel.getFtita()==null){ + antenatalExaminationModel1.setFtita(getCodeValue(model, "FT3")); // //游离三碘甲状腺原氨酸(FT3) + } + if("".equals(antenatalExaminationModel.getFreeThy()) || antenatalExaminationModel.getFreeThy()==null){ + antenatalExaminationModel1.setFreeThy(getCodeValue(model, "FT4")); //游离甲状腺素(FT4) + } + if("".equals(antenatalExaminationModel.getPta()) || antenatalExaminationModel.getPta()==null){ + antenatalExaminationModel1.setPta(getCodeValue(model, "PT")); //凝血酶原活动度(PT%) + } + if("".equals(antenatalExaminationModel.getActPar()) || antenatalExaminationModel.getActPar()==null){ + antenatalExaminationModel1.setActPar(getCodeValue(model, "APTT")); //活化部分凝血活酶时间(APTT) + } + if("".equals(antenatalExaminationModel.getThrTime()) || antenatalExaminationModel.getThrTime()==null){ + antenatalExaminationModel1.setThrTime(getCodeValue(model, "TT")); //凝血酶时间(TT) + } + if("".equals(antenatalExaminationModel.getFibrin()) || antenatalExaminationModel.getFibrin()==null){ + antenatalExaminationModel1.setFibrin(getCodeValue(model, "FIB")); //纤维蛋白原(FIB) + } + + if("".equals(antenatalExaminationModel.getDimer()) || antenatalExaminationModel.getDimer()==null){ + antenatalExaminationModel1.setDimer(getCodeValue(model, "D-Dimer")); //D-二聚体(D-Dimer) + } + + if("".equals(antenatalExaminationModel.getTotalChol()) || antenatalExaminationModel.getTotalChol()==null){ + antenatalExaminationModel1.setTotalChol(getCodeValue(model, "TC")); //总胆固醇(TC) + } + if("".equals(antenatalExaminationModel.getTricer()) || antenatalExaminationModel.getTricer()==null){ + antenatalExaminationModel1.setTricer(getCodeValue(model, "TG")); //甘油三酯(TG) + } + if("".equals(antenatalExaminationModel.getHighDens()) || antenatalExaminationModel.getHighDens()==null){ + antenatalExaminationModel1.setHighDens(getCodeValue(model, "HDL-C")); //高密度脂蛋白胆固醇(HDL-C) + } + if("".equals(antenatalExaminationModel.getLowDens()) || antenatalExaminationModel.getLowDens()==null){ + antenatalExaminationModel1.setLowDens(getCodeValue(model, "LDL-C")); //低密度脂蛋白胆固醇(LDL-C) + } + + } + + /** + * 更新初诊记录 + * @param model + * @param antExChuModel + * @param antExChuModel1 + */ + private void antExChuModelUpadte(LisReportModel model, AntExChuModel antExChuModel, AntExChuModel antExChuModel1) { + if("".equals(antExChuModel.getXhdb()) || antExChuModel.getXhdb()==null){//血红蛋白 + antExChuModel1.setXhdb(getCodeValue(model, "HGB")); + } + if("".equals(antExChuModel.getBxbjs()) || antExChuModel.getBxbjs()==null){//白细胞计数 + antExChuModel1.setBxbjs(getCodeValue(model, "WBC")); + } + if("".equals(antExChuModel.getPlatelet()) || antExChuModel.getPlatelet()==null){//血小板 + antExChuModel1.setPlatelet(getCodeValue(model, "PLT")); + } + if("".equals(antExChuModel.getNdb()) || antExChuModel.getNdb()==null){//尿蛋白 + antExChuModel1.setNdb(getCodeValue(model, "PRO")); + } + + if("".equals(antExChuModel.getUrineKetone()) || antExChuModel.getUrineKetone()==null){//尿酮体 + antExChuModel1.setUrineKetone(getCodeValue(model, "KET")); + } + if("".equals(antExChuModel.getBld()) || antExChuModel.getBld()==null){//尿潜血 + antExChuModel1.setBld(getCodeValue(model, "BLD")); + } + if("".equals(antExChuModel.getAbo()) || antExChuModel.getAbo()==null){//血型 + antExChuModel1.setAbo(getCodeValue(model, "ABO")); + } + if("".equals(antExChuModel.getRh()) || antExChuModel.getRh()==null){//RH血型 + antExChuModel1.setRh(getCodeValue(model, "RH")); + } + if("".equals(antExChuModel.getBloodSugar()) || antExChuModel.getBloodSugar()==null){//血糖 + antExChuModel1.setBloodSugar(getCodeValue(model, "GLU")); + } + if("".equals(antExChuModel.getXqgbzam()) || antExChuModel.getXqgbzam()==null){//血清谷丙转氨酶 + antExChuModel1.setXqgbzam(getCodeValue(model, "ALT")); + } + if("".equals(antExChuModel.getXqgczam()) || antExChuModel.getXqgczam()==null){//血清谷草转氨酶 + antExChuModel1.setXqgczam(getCodeValue(model, "AST")); + } + + if("".equals(antExChuModel.getAlbumin()) || antExChuModel.getAlbumin()==null){//白蛋白 + antExChuModel1.setAlbumin(getCodeValue(model, "ALB")); + } + if("".equals(antExChuModel.getTotalBilirubin()) || antExChuModel.getTotalBilirubin()==null){//总胆红素 + antExChuModel1.setTotalBilirubin(getCodeValue(model, "TBIL")); + } + if("".equals(antExChuModel.getJhBilirubin()) || antExChuModel.getJhBilirubin()==null){//结合胆红素 + antExChuModel1.setJhBilirubin(getCodeValue(model, "DBIL")); + } + if("".equals(antExChuModel.getBg()) || antExChuModel.getBg()==null){//丙肝 + antExChuModel1.setBg(getCodeValue(model, "HCV")); + } + if("".equals(antExChuModel.getYgbmky()) || antExChuModel.getYgbmky()==null){//乙肝表面抗原 + antExChuModel1.setYgbmky(getCodeValue(model, "HBsAg")); + } + if("".equals(antExChuModel.getYgbmkt()) || antExChuModel.getYgbmkt()==null){//乙肝表面抗体 + antExChuModel1.setYgbmkt(getCodeValue(model, "HBsAb")); + } + if("".equals(antExChuModel.getYgeky()) || antExChuModel.getYgeky()==null){//乙肝e抗原 + antExChuModel1.setYgeky(getCodeValue(model, "HBeAg")); + } + if("".equals(antExChuModel.getYgekt()) || antExChuModel.getYgekt()==null){//乙肝e抗体 + antExChuModel1.setYgekt(getCodeValue(model, "HBeAb")); + } + if("".equals(antExChuModel.getYghxkt()) || antExChuModel.getYghxkt()==null){//乙肝核心抗体 + antExChuModel1.setYghxkt(getCodeValue(model, "HBcAb")); + } + if("".equals(antExChuModel.getXqjq()) || antExChuModel.getXqjq()==null){//血清肌 + antExChuModel1.setXqjq(getCodeValue(model, "CRE")); + } + if("".equals(antExChuModel.getXnsd()) || antExChuModel.getXnsd()==null){//血尿素氮 + antExChuModel1.setXnsd(getCodeValue(model, "UREA")); + } + if("".equals(antExChuModel.getSyjg()) || antExChuModel.getSyjg()==null){//实验结果 + antExChuModel1.setSyjg(getCodeValue(model, "TP1")); + } + if("".equals(antExChuModel.getHivkt()) || antExChuModel.getHivkt()==null){//hit抗体检测 + antExChuModel1.setHivkt(getCodeValue(model, "HIV1")); + } + + if("".equals(antExChuModel.getYdqjd()) || antExChuModel.getYdqjd()==null){//阴道清洁度 + antExChuModel1.setYdqjd(getCodeValue(model, "QJD")); + } + if("".equals(antExChuModel.getTtita()) || antExChuModel.getTtita()==null){ + antExChuModel1.setTtita(getCodeValue(model, "T3")); // 总三碘甲状腺原氨酸(TT3) + } + if("".equals(antExChuModel.getTotalThy()) || antExChuModel.getTotalThy()==null){ + antExChuModel1.setTotalThy(getCodeValue(model, "T4")); //总甲状腺素(TT4) + } + if("".equals(antExChuModel.getFtita()) || antExChuModel.getFtita()==null){ + antExChuModel1.setFtita(getCodeValue(model, "FT3")); // //游离三碘甲状腺原氨酸(FT3) + } + if("".equals(antExChuModel.getFreeThy()) || antExChuModel.getFreeThy()==null){ + antExChuModel1.setFreeThy(getCodeValue(model, "FT4")); //游离甲状腺素(FT4) + } + if("".equals(antExChuModel.getPta()) || antExChuModel.getPta()==null){ + antExChuModel1.setPta(getCodeValue(model, "PT")); //凝血酶原活动度(PT%) + } + if("".equals(antExChuModel.getActPar()) || antExChuModel.getActPar()==null){ + antExChuModel1.setActPar(getCodeValue(model, "APTT")); //活化部分凝血活酶时间(APTT) + } + if("".equals(antExChuModel.getThrTime()) || antExChuModel.getThrTime()==null){ + antExChuModel1.setThrTime(getCodeValue(model, "TT")); //凝血酶时间(TT) + } + if("".equals(antExChuModel.getFibrin()) || antExChuModel.getFibrin()==null){ + antExChuModel1.setFibrin(getCodeValue(model, "FIB")); //纤维蛋白原(FIB) + } + + if("".equals(antExChuModel.getDimer()) || antExChuModel.getDimer()==null){ + antExChuModel1.setDimer(getCodeValue(model, "D-Dimer")); //D-二聚体(D-Dimer) + } + + if("".equals(antExChuModel.getTotalChol()) || antExChuModel.getTotalChol()==null){ + antExChuModel1.setTotalChol(getCodeValue(model, "TC")); //总胆固醇(TC) + } + if("".equals(antExChuModel.getTricer()) || antExChuModel.getTricer()==null){ + antExChuModel1.setTricer(getCodeValue(model, "TG")); //甘油三酯(TG) + } + if("".equals(antExChuModel.getHighDens()) || antExChuModel.getHighDens()==null){ + antExChuModel1.setHighDens(getCodeValue(model, "HDL-C")); //高密度脂蛋白胆固醇(HDL-C) + } + if("".equals(antExChuModel.getLowDens()) || antExChuModel.getLowDens()==null){ + antExChuModel1.setLowDens(getCodeValue(model, "LDL-C")); //低密度脂蛋白胆固醇(LDL-C) + } + + } + + + private String getCodeValue(LisReportModel model, String codeStr) { + JSONArray jsonArray=JSONArray.fromObject(model.getItemJson()); + for (int i = 0; i < jsonArray.size(); i++) { + Object o=jsonArray.get(i); + JSONObject jsonObject2=JSONObject.fromObject(o); + String code = (String)jsonObject2.get("code"); + if (code.equals(codeStr)){ + return (String)jsonObject2.get("result"); + } + } + return null; + } } \ No newline at end of file