package thyyxxk.webserver.controller.inpatient;

import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.inpatient.ZyActpatient;
import thyyxxk.webserver.entity.inpatient.patient.*;
import thyyxxk.webserver.service.inpatient.PatientService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author dj
 */
@RestController
@RequestMapping("/patient")
public class PatientController {
    private final PatientService service;

    @Autowired
    public PatientController(PatientService service) {
        this.service = service;
    }

    @GetMapping("/getOverView")
    public ResultVo<List<Overview>> getOverView(@RequestParam("ward") String ward,
                                                @RequestParam("viewBabies") Boolean viewBabies) {
        return service.getOverView(ward, viewBabies);
    }

    @GetMapping("/getInfo")
    public ResultVo<Patient> getPatientInfo(@RequestParam("inpatientNo") String inpatientNo) {
        return service.getPatientInfo(inpatientNo);
    }

    @PostMapping("/getDrgPatInfo")
        public ResultVo<JSONObject> getDrgPatInfo(@RequestBody Patient p) {
        return service.getDrgPatInfo(p);
    }

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

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

    @GetMapping("/getDisDiag")
    public ResultVo<HashMap<String, Object>> getYbDiag(@RequestParam("inpatientNo") String inpatientNo,
                                                       @RequestParam("admissTimes") Integer admissTimes) {
        return service.getDisDiag(inpatientNo, admissTimes);
    }

    @PostMapping("/getNotUploadedFees")
    public ResultVo<Map<String, Object>> getNotUploadedFees(@RequestBody GetFeesParam param) {
        return service.getNotUploadedFees(param);
    }

    @GetMapping("/getIdCardInfo")
    public ResultVo<Map<String, Object>> getIdCardInfo(@RequestParam("inpatientNo") String inpatientNo,
                                                       @RequestParam("admissTimes") Integer admissTimes) {
        return service.getIdCardInfo(inpatientNo, admissTimes);
    }

    @GetMapping("/getCancelRegisterRequests")
    public ResultVo<List<ToYbkRequest>> getCancelRegisterRequests(@Param("inpatientNo") String inpatientNo,
                                                                  @Param("admissTimes") Integer admissTimes,
                                                                  @Param("requestType") Integer requestType) {
        return service.getCancelRegisterRequests(inpatientNo, admissTimes, requestType);
    }

    @PostMapping("/submitCancelRegisterRequest")
    public ResultVo<String> submitCancelRegisterRequest(@RequestBody ToYbkRequest indata) {
        return service.submitCancelRegisterRequest(indata);
    }

    @PostMapping("/submitSiPatientInfo")
    public ResultVo<String> submitSiPatientInfo(@RequestBody SubmitSiPtnt param) {
        return service.submitSiPatientYbInfo(param);
    }

    @GetMapping("/getZyInYbDiags")
    public ResultVo<List<ZyInYbDiag>> getZyInYbDiags(@RequestParam("inpatientNo") String inpatientNo,
                                                     @RequestParam("admissTimes") Integer admissTimes) {
        return service.getZyInYbDiags(inpatientNo, admissTimes);
    }

    @PostMapping("/saveZyInYbDiags")
    public ResultVo<String> saveZyInYbDiags(@RequestBody List<ZyInYbDiag> list) {
        return service.saveZyInYbDiags(list);
    }

    @PostMapping("/saveSiZyInDiags")
    public ResultVo<String> saveSiZyInDiags(@RequestBody SaveSiZyDiags param) {
        return service.saveSiZyInDiags(param);
    }

    @PostMapping("/genDismissActOrder")
    public ResultVo<String> genDismissActOrder(@RequestBody Patient param) {
        return service.genDismissActOrder(param);
    }

    @PostMapping("/receiveAndRecalculateCost")
    public ResultVo<Patient> receiveAndRecalculateCost(@RequestBody Patient p) {
        return service.receiveAndRecalculateCost(p);
    }

    @GetMapping("/getZyActpatient")
    public ResultVo<ZyActpatient> getZyActpatient(@RequestParam("socialNo") String socialNo) {
        return service.getZyActpatient(socialNo);
    }
}
