package com.lantone.structure.ai.process;

import com.alibaba.fastjson.JSONObject;
import com.lantone.structure.ai.model.EntityEnum;
import com.lantone.structure.ai.model.Lemma;
import com.lantone.structure.model.entity.*;
import com.lantone.structure.model.label.TreatPlanLabel;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName : EntityProcessTreatPlan
 * @Description : 首次病程录--诊疗计划
 * @Author : 楼辉荣
 * @Date: 2020-03-19 15:45
 */
public class EntityProcessTreatPlan extends EntityProcess {
    public TreatPlanLabel extractEntity(JSONObject aiOut) {
        TreatPlanLabel treatPlanLabel = new TreatPlanLabel();
        //护理级别
        List<Lemma> nursingLevelLemmas = createEntityTree(aiOut, EntityEnum.NURSING_LEVEL.toString());
        for (Lemma lemma :nursingLevelLemmas) {
            NursingLevel nursingLevel = new NursingLevel();
            nursingLevel.setName(lemma.getText());
            treatPlanLabel.setNursingLevel(nursingLevel);
        }
        //药品
        List<Lemma> medicineLemmas = createEntityTree(aiOut, EntityEnum.DRUG.toString());
        for (Lemma lemma :medicineLemmas) {
            Medicine medicine = new Medicine();
            medicine.setName(lemma.getText());
            treatPlanLabel.setMedicine(medicine);
        }
        //治疗或治疗目的
        List<Lemma> treatLemmas = createEntityTree(aiOut, EntityEnum.TREAT_MENT.toString());
        List<Treat> treats = new ArrayList<>();
        for (Lemma lemma :treatLemmas) {
            Treat treat = new Treat();
            treat.setName(lemma.getText());
            treats.add(treat);
        }
        treatPlanLabel.setTreat(treats);
//        //化验
//        List<Lemma> lisLemmas = createEntityTree(aiOut, EntityEnum.LABORATORY.toString());
//        List<Lis> lises = new ArrayList<>();
//        for (Lemma lemma :lisLemmas) {
//            Lis lis = new Lis();
//            lis.setName(lemma.getText());
//            lises.add(lis);
//        }
//        treatPlanLabel.setLis(lises);
        //检查
        List<Lemma> pacsLemmas = createEntityTree(aiOut, EntityEnum.INSPECTION_ITEMS.toString());
        List<Pacs> paces = new ArrayList<>();
        for (Lemma lemma :pacsLemmas) {
            Pacs pacs = new Pacs();
            pacs.setName(lemma.getText());
            paces.add(pacs);
        }
        treatPlanLabel.setPacs(paces);
        return treatPlanLabel;
    }
}