package thyyxxk.webserver.controller.outpatient.interactive.clinicsatisfied;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.config.exception.ExceptionEnum;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.inpatient.nursemodule.response.PatientBriefInfo;
import thyyxxk.webserver.entity.outpatient.interactive.clinicsatisfied.request.ClinicSatisfiedInquiry;
import thyyxxk.webserver.entity.outpatient.interactive.clinicsatisfied.request.ModifyStatus;
import thyyxxk.webserver.entity.outpatient.interactive.clinicsatisfied.response.AnalyzeResultV2;
import thyyxxk.webserver.entity.outpatient.interactive.clinicsatisfied.response.Patientinfo;
import thyyxxk.webserver.entity.outpatient.interactive.clinicsatisfied.response.QuestionnaireV2;
import thyyxxk.webserver.entity.outpatient.interactive.clinicsatisfied.response.SatisfiedResponse;
import thyyxxk.webserver.service.outpatient.interactive.clinicsatisfied.QuestionnaireService;
import thyyxxk.webserver.utils.ResultVoUtil;

import java.util.List;

@RestController
@RequestMapping("/questionnaire")
public class QuestionnaireController {
    private final QuestionnaireService service;

    @Autowired
    public QuestionnaireController(QuestionnaireService service) {
        this.service = service;
    }

    @PostMapping("/getQuestionnaireBodies")
    public ResultVo<SatisfiedResponse> getQuestionnaireBodies(@RequestBody ClinicSatisfiedInquiry inquiry) {
        return service.getQuestionnaireBodies(inquiry);
    }

    @PostMapping("/getPatInfoList")
    public ResultVo<List<Patientinfo>> getPatInfoList(@RequestBody ClinicSatisfiedInquiry inquiry) {
        return service.getPatInfoList(inquiry);
    }

    @PostMapping("/getAllQuestionnaireBodies")
    public ResultVo<List<QuestionnaireV2>> getAllQuestionnaireBodies(@RequestBody ClinicSatisfiedInquiry inquiry) {
        return service.getAllQuestionnaireBodies(inquiry);
    }

    @PostMapping("/assessmentsAnalyse")
    public ResultVo<AnalyzeResultV2> assessmentsAnalyse(@RequestBody ClinicSatisfiedInquiry inquiry) {
        return service.assessmentsAnalyse(inquiry);
    }

    @PostMapping("/updateAssessmentStatus")
    public ResultVo<String> updateAssessmentStatus(@RequestBody ModifyStatus modifyStatus) {
        return service.updateAssessmentStatus(modifyStatus);
    }

    @GetMapping("/getPatientBriefInfo")
    public ResultVo<PatientBriefInfo> getPatientBriefInfo(@RequestParam("patNo") String patNo,
                                                          @RequestParam("times") Integer times) {
        PatientBriefInfo info = service.getPatientBriefInfo(patNo, times);
        if (null == info) {
            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有找到患者的基础数据。");
        }
        return ResultVoUtil.success(info);
    }
}
