package thyyxxk.webserver.entity.zhuyuanyisheng.emr;

import com.alibaba.fastjson.JSONObject;
import thyyxxk.webserver.entity.zhuyuanyisheng.emrcontrolrule.QualityControlAnalysisOfMedicalRecords;

import java.util.HashMap;
import java.util.Map;

public class ProblemQualityControl {
    Map<String, Integer> numberOfProblemMedicalRecords = new HashMap<>();
    Map<String, QualityControlAnalysisOfMedicalRecords> detailedErrorInformation = new HashMap<>();
    String name;

    public ProblemQualityControl() {

    }

    public void setName(String name) {
        if (!numberOfProblemMedicalRecords.containsKey(name)) {
            numberOfProblemMedicalRecords.put(name, 0);
        }
        this.name = name;
    }

    public void setTheErrorMessage(QualityControlAnalysisOfMedicalRecords p, String message) {
        String key = p.getInpatientNo() + "_" + p.getAdmissTimes();
        numberOfProblemMedicalRecords.replace(name, numberOfProblemMedicalRecords.get(name) + 1);
        p.setMapMessage(name, message);
        detailedErrorInformation.put(key, p);
    }

    public void setTheErrorMessage(QualityControlAnalysisOfMedicalRecords p, String message, int count) {
        message = "第【" + (count + 1) + "】次" + message;
        setTheErrorMessage(p, message);
    }

    public JSONObject returnsData() {
        JSONObject js = new JSONObject();
        js.put("numberOfQuestions", numberOfProblemMedicalRecords);
        js.put("details", detailedErrorInformation.values());
        return js;
    }

}
