package thyyxxk.webserver.controller.zhuyuanyizheng.emr;

import com.alibaba.fastjson.JSONObject;
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 javax.annotation.PostConstruct;
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;
    }

    @GetMapping("/getAuditMessages")
    public ResultVo<JSONObject> getAuditMessages(@RequestParam("id") String id,
                                                 @RequestParam("code") String code,
                                                 @RequestParam("finalControl") Integer finalControl) {
        return server.getAuditMessages(id, code, finalControl);
    }

    @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);
    }
}
