package thyyxxk.webserver.controller.zhuyuanyizheng.emr;

import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrAuditDetail;
import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrSetAudit;
import thyyxxk.webserver.service.zhuyuanyisheng.emr.EmrAuditServer;

import java.util.Date;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/emrAudit")
public class EmrAuditController {
    private final EmrAuditServer server;

    public EmrAuditController(EmrAuditServer server) {
        this.server = server;
    }

    @PostMapping("/setAudit")
    public ResultVo<String> setAudit(@RequestBody EmrSetAudit data) {
        return server.setAudit(data);
    }

    @GetMapping("/rectifyMedicalRecords")
    public ResultVo<String> rectifyMedicalRecords(@RequestParam("id") Integer id,
                                                  @RequestParam("state") Integer state) {
        return server.rectifyMedicalRecords(id, state);
    }

    @GetMapping("/getHistoricalAudit")
    public ResultVo<Map<Date, List<EmrAuditDetail>>> getHistoricalAudit(@RequestParam("emrId") Integer emrId,
                                                                        @RequestParam("finalControl") Integer finalControl) {
        return server.getHistoricalAudit(emrId, finalControl);
    }

    @GetMapping("/updateFinalControl")
    public ResultVo<String> updateFinalControl(@RequestParam("patNo") String patNo,
                                               @RequestParam("times") Integer times) {
        return server.updateFinalControl(patNo, times);
    }

    @GetMapping("/updateControlLevel")
    public ResultVo<String> updateControlLevel(@RequestParam("patNo") String patNo,
                                               @RequestParam("times") Integer times,
                                               @RequestParam("bazl") Integer bazl) {
        return server.updateControlLevel(patNo, times, bazl);
    }

    @PostMapping("/getEmrAuditByEmrId")
    public ResultVo<List<EmrAuditDetail>> getEmrAuditByEmrId(@RequestBody EmrAuditDetail params) {
        return server.getEmrAuditByEmrId(params);
    }

    @GetMapping("/deleteEmrAuditByEmrId")
    public ResultVo<String>  deleteEmrAuditByEmrId(@RequestParam("id") String id) {
        return server.deleteEmrAuditByEmrId(id);
    }

}
