123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- package com.diagbot.process;
- import com.diagbot.dto.*;
- import com.diagbot.enums.NeoEnum;
- import com.diagbot.facade.NeoFacade;
- import com.diagbot.model.entity.*;
- import com.diagbot.model.label.ChiefLabel;
- import com.diagbot.model.label.DiagLabel;
- import com.diagbot.model.label.PastLabel;
- import com.diagbot.model.label.PresentLabel;
- import com.diagbot.rule.*;
- import com.diagbot.util.BeanUtil;
- import com.diagbot.util.ListUtil;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Component;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Map;
- /**
- * @Description: 开单总入口
- * @author: zhoutg
- * @time: 2018/8/6 9:11
- */
- @Component
- public class BillProcess {
- @Autowired
- NeoFacade neoFacade;
- public void process(List<BillNeoDTO> billNeoDTOList, WordCrfDTO wordCrfDTO, IndicationDTO res) {
- // 合并图谱数据到同一个对象中
- List<BillNeoMaxDTO> billNeoMaxDTOList = new ArrayList<>();
- for (BillNeoDTO billNeoDTO : billNeoDTOList) {
- BillNeoMaxDTO billNeoMaxDTO = new BillNeoMaxDTO();
- if (billNeoDTO.getDrugBillNeoDTO() != null) {
- BeanUtil.copyProperties(billNeoDTO.getDrugBillNeoDTO(), billNeoMaxDTO);
- } else if (billNeoDTO.getLisBillNeoDTO() != null) {
- BeanUtil.copyProperties(billNeoDTO.getLisBillNeoDTO(), billNeoMaxDTO);
- } else if (billNeoDTO.getPacsBillNeoDTO() != null) {
- BeanUtil.copyProperties(billNeoDTO.getPacsBillNeoDTO(), billNeoMaxDTO);
- }
- billNeoMaxDTO.setOrderName(billNeoDTO.getName()); // 开单名称
- billNeoMaxDTO.setOrderStandName(billNeoDTO.getStandname()); // 开单标准名称
- // TODO 测试数据开始
- if (billNeoDTO.getName().equals("普通胃镜检查")) {
- NodeNeoDTO sexNeo = new NodeNeoDTO();
- sexNeo.setName("男");
- billNeoMaxDTO.setGender(sexNeo);
- NodeNeoDTO nodeNeoDTO = new NodeNeoDTO();
- nodeNeoDTO.setName("红细胞压积");
- nodeNeoDTO.setVal("阳性");
- billNeoDTO.getPacsBillNeoDTO().getLis().add(nodeNeoDTO);
- NodeNeoDTO opereat = new NodeNeoDTO();
- opereat.setName("胸腔镜下左下肺叶切除术");
- billNeoDTO.getPacsBillNeoDTO().getOperations().add(opereat);
- NodeNeoDTO opereat2 = new NodeNeoDTO();
- opereat2.setName("区域淋巴结清扫术");
- billNeoDTO.getPacsBillNeoDTO().getOperations().add(opereat2);
- NodeNeoDTO drug = new NodeNeoDTO();
- drug.setName("青霉素类");
- billNeoDTO.getPacsBillNeoDTO().getAllergicmeds().add(drug);
- NodeNeoDTO drug3 = new NodeNeoDTO();
- drug3.setName("泰舒达类");
- billNeoDTO.getPacsBillNeoDTO().getOralmeds().add(drug3);
- // NodeNeoDTO vital = new NodeNeoDTO();
- // vital.setName("体温");
- // vital.setMax(new BigDecimal(39.1));
- // vital.setMin(new BigDecimal(37.1));
- // billNeoDTO.getVitals().add(vital);
- }
- // 测试数据结束
- System.out.println(billNeoMaxDTO);
- billNeoMaxDTOList.add(billNeoMaxDTO);
- }
- processRule(billNeoMaxDTOList, wordCrfDTO, res);
- }
- // 规则处理
- public void processRule(List<BillNeoMaxDTO> billNeoMaxDTOList, WordCrfDTO wordCrfDTO, IndicationDTO indicationDTO) {
- // 获取药品缓存
- Map<String, List<String>> drugMap = neoFacade.getDrugCache();
- DiagLabel diagLabel = wordCrfDTO.getDiagLabel();
- ChiefLabel chiefLabel = wordCrfDTO.getChiefLabel();
- PresentLabel presentLabel = wordCrfDTO.getPresentLabel();
- PastLabel pastLabel = wordCrfDTO.getPastLabel();
- // 体征
- List<Vital> vitals = wordCrfDTO.getVitalLabel().getVitals();
- // 诊断数据
- List<Diag> diags = diagLabel.getDiags();
- // 手术数据
- List<Operation> operations_present = presentLabel.getOperations();
- List<Operation> operations_past = pastLabel.getOperations();
- operations_present.addAll(operations_past);
- // 临床表现数据
- List<Clinical> clinicals = new ArrayList<>();
- if(chiefLabel != null && ListUtil.isNotEmpty(chiefLabel.getClinicals())){
- clinicals.addAll(chiefLabel.getClinicals());
- }
- // 现病史临床表现数据先不用
- if(presentLabel != null && ListUtil.isNotEmpty(presentLabel.getClinicals())){
- clinicals.addAll(presentLabel.getClinicals());
- }
- List<BillMsg> billMsgList = new ArrayList<>();
- for (BillNeoMaxDTO bill : billNeoMaxDTOList) {
- // 性别
- SexRule.compareSexWithBill(wordCrfDTO, bill, billMsgList, NeoEnum.gender.getName());
- // 年龄
- AgeRule.compareAgeWithBill(wordCrfDTO, bill, billMsgList, NeoEnum.ageNeoDTO.getName());
- // 诊断
- CommonRule.compareNameWithBill(bill.getDisease(), diags, bill, billMsgList, NeoEnum.disease.getName());
- // 化验
- LisRule.compareLisWithBill(wordCrfDTO.getLis(), bill, billMsgList, NeoEnum.lis.getName());
- //体征
- VitalRule.compareVitalWithBill(vitals, bill, billMsgList, NeoEnum.vitals.getName());
- // 辅检
- PacsRule.comparePacsWithBill(bill.getPacs(), wordCrfDTO.getPacs(), bill, billMsgList, NeoEnum.pacs.getName());
- // 临床表现
- CommonRule.compareNameWithBill(bill.getClinicfindings(), clinicals, bill, billMsgList, NeoEnum.clinicfindings.getName());
- // 手术(既往史、现病史)
- CommonRule.compareNameWithBill(bill.getOperations(), operations_present, bill, billMsgList, NeoEnum.operations.getName());
- // 禁忌过敏药品(既往史)
- DrugRule.compareDrugWithBill(bill.getAllergicmeds(), pastLabel.getAllergyMedicines(), bill, billMsgList, drugMap, NeoEnum.allergicmeds.getName());
- // 服用药品(现病史一般情况后的药品)
- DrugRule.compareDrugWithBill(bill.getOralmeds(), takeMedicine(presentLabel), bill, billMsgList, drugMap, NeoEnum.oralmeds.getName());
- }
- indicationDTO.setBillMsgList(billMsgList);
- }
- /**
- * 一般情况以后的药品
- * @param presentLabel
- */
- public List<Medicine> takeMedicine(PresentLabel presentLabel){
- List<Medicine> takems = new ArrayList<>();
- List<GeneralDesc> generals = presentLabel.getGenerals();
- List<Medicine> medicines = presentLabel.getMedicines();
- if (generals.size() > 0) {
- String presentText = presentLabel.getText();
- if (StringUtils.isNotBlank(presentText) && medicines != null && medicines.size() > 0) {
- String lastGeneral = generals.get(generals.size() - 1).getName();
- int lastGeneralIndex = presentText.lastIndexOf(lastGeneral);
- for (Medicine medicine : medicines) {
- /* 现病史中一般情况之后的药品名称,并且不包含不详 */
- int medicine_index = presentText.indexOf(medicine.getName());
- if (medicine_index > lastGeneralIndex && !medicine.getName().contains("不详")) {
- takems.add(medicine);
- }
- }
- }
- }
- return takems;
- }
- }
|