package thyyxxk.webserver.entity.covid;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

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

@Data
public class CovidDetail {
    private String patientId;
    private String name;
    private String phone;
    private String idcard;
    private String addrProvince;
    private String addrCity;
    private String addrDistrict;
    private String addrAdditional;
    private Integer temperature;
    private String feverNumber;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date date;
    private Integer item1;
    private Integer item2;
    private Integer item3;
    private Integer item4;
    private Integer item5;
    private String symptomsSelect;
    private String symptomsSubmit;
    private List<Integer> symptoms;
    private List<Integer> symptomsList;

    public String getSymptomsSubmit() {
        return null == symptoms ? "[]" : symptoms.toString();
    }

    public List<Integer> getSymptomsList() {
        symptomsList = new ArrayList<>();
        if (null == symptomsSelect || symptomsSelect.equals("[]")) {
            return symptomsList;
        }
        String[] temp = symptomsSelect.substring(1, symptomsSelect.length() - 1).split(",");
        for (String item : temp) {
            symptomsList.add(Integer.parseInt(item.trim()));
        }
        return symptomsList;
    }
}
