package thyyxxk.webserver.controller.zhuyuanyizheng;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.zhuyuanyisheng.EmrPatientData;
import thyyxxk.webserver.service.zhuyuanyisheng.EmrServer;

import java.util.List;

@RequestMapping("/Emr")
@RestController
public class EmrController {

    private final EmrServer server;

    public EmrController(EmrServer server) {
        this.server = server;
    }

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

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

    @PostMapping("/insertEmrData")
    public ResultVo<String> insertEmrData(@RequestBody @Validated EmrPatientData param) {
        return server.insertEmrData(param);
    }

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

    @PostMapping("/queryWhetherThePatientHasASpecifiedMedicalRecord")
    public ResultVo<Boolean> queryWhetherThePatientHasASpecifiedMedicalRecord(@RequestBody EmrPatientData param) {
        return server.queryWhetherThePatientHasASpecifiedMedicalRecord(param);
    }


}
