package thyyxxk.webserver.controller.examinations;

import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.dao.his.examinations.BloodSugarQueryDao;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.examinations.BloodSugar.BgNursingTestSync;
import thyyxxk.webserver.service.examinations.BloodSugarQueryServer;
import thyyxxk.webserver.utils.ResultVoUtil;

import java.util.Map;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/bloodSugar")
public class BloodSugarQueryController {

    private final BloodSugarQueryServer server;

    private final BloodSugarQueryDao dao;

    public BloodSugarQueryController(BloodSugarQueryServer server, BloodSugarQueryDao dao) {
        this.server = server;
        this.dao = dao;
    }


    @GetMapping("/getThePatienMaxHospitalizationTimes")
    public ResultVo<Integer> getPatientNoTimes(@RequestParam("patNo") String patNo) {
        return ResultVoUtil.success(dao.getPatientTimes(patNo));
    }

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

    @PostMapping("/modifyPatientBloodGlucoseInfo")
    public ResultVo<String> modifyPatientBloodGlucoseInfo(@RequestBody BgNursingTestSync param) {
        return server.modifyPatientBloodGlucoseInfo(param);
    }
}
