package thyyxxk.webserver.controller.outpatient.booking;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.service.outpatient.booking.OutpatientBookingService;

@RestController
@RequestMapping("/outpatientBooking")
public class OutpatientBookingController {
    private final OutpatientBookingService service;

    public OutpatientBookingController(OutpatientBookingService service) {
        this.service = service;
    }

    @GetMapping("/getAmpmByDateAndDeptCode")
    public ResultVo<JSONArray> getAmpmByDateAndDeptCode(@RequestParam("date") String date,
                                                        @RequestParam("deptCode") String deptCode) {
        return service.getAmpmByDateAndDeptCode(date, deptCode);
    }

    @GetMapping("/getChargeTypeByRequestDayAndDoctor")
    public ResultVo<JSONArray> getChargeTypeByRequestDayAndDoctor(@RequestParam("unitCode") String unitCode,
                                                                  @RequestParam("ampm") String ampm,
                                                                  @RequestParam("date") String date,
                                                                  @RequestParam("apTime") String apTime) {
        return service.getChargeTypeByRequestDayAndDoctor(unitCode, ampm, date, apTime);
    }

    @GetMapping("/getDoctorCodeByRequestDayAndDoctor")
    public ResultVo<JSONArray> getDoctorCodeByRequestDayAndDoctor(@RequestParam("unitCode") String unitCode,
                                                                  @RequestParam("ampm") String ampm,
                                                                  @RequestParam("date") String date,
                                                                  @RequestParam("apTime") String apTime,
                                                                  @RequestParam("chargeType") String chargeType) {
        return service.getDoctorCodeByRequestDayAndDoctor(unitCode, ampm, date, apTime, chargeType);
    }

    @GetMapping("/getMzChargeTypeByMzyRequestId")
    public ResultVo<JSONObject> getMzChargeTypeByMzyRequestId(@RequestParam("mzyRequestId") String mzyRequestId,
                                                              @RequestParam("birthDay") String birthDay,
                                                              @RequestParam("patientId") String patientId) {
        return service.getMzChargeTypeByMzyRequestId(mzyRequestId, birthDay, patientId);
    }

    @PostMapping("/saveMzyReqrec")
    public ResultVo<String> saveMzyReqrec(@RequestBody JSONObject req) {
        return service.saveMzyReqrec(req);
    }

}
