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.AnalyzeResult;
import thyyxxk.webserver.entity.outpatient.interactive.clinicsatisfied.response.SatisfiedBody;
import thyyxxk.webserver.entity.outpatient.interactive.clinicsatisfied.response.SatisfiedResponse;
import thyyxxk.webserver.service.outpatient.interactive.clinicsatisfied.ClinicSatisfiedService;
import thyyxxk.webserver.utils.ResultVoUtil;

import java.util.List;

@RestController
@RequestMapping("/clinicSatisfied")
public class ClinicSatisfiedController {
    private final ClinicSatisfiedService service;

    @Autowired
    public ClinicSatisfiedController(ClinicSatisfiedService service) {
        this.service = service;
    }

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

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

    @PostMapping("/assessmentsAnalyse")
    public ResultVo<AnalyzeResult> 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);
    }
}
