package com.openhis.web.inpatientmanage.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.*;

import com.core.common.core.domain.R;
import com.openhis.web.inpatientmanage.appservice.IVitalSignsAppService;
import com.openhis.web.inpatientmanage.dto.VitalSignsDeleteDto;
import com.openhis.web.inpatientmanage.dto.VitalSignsSaveDto;
import com.openhis.web.inpatientmanage.dto.VitalSignsSearchParam;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 三测单 应用实现
 *
 * @author SY
 * @since 2025/05/29
 */
@RestController
@RequestMapping("/vital-signs")
@Slf4j
@AllArgsConstructor
public class VitalSignsController {

    @Resource
    private IVitalSignsAppService vitalSignsAppService;

    /**
     * 获取三测单-患者信息数据列表
     *
     * @return 患者信息数据列表
     */
    @GetMapping("/patient-message")
    public R<?> getVitalSignsInfo(VitalSignsSearchParam vitalSignsSearchParam,
        @RequestParam(value = "searchKey", defaultValue = "") String searchKey,
        @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
        @RequestParam(value = "pageSize", defaultValue = "50") Integer pageSize, HttpServletRequest request) {
        return vitalSignsAppService.getVitalSignsInfo(vitalSignsSearchParam, searchKey, pageNo, pageSize, request);
    }

    /**
     * 体温单记录保存
     *
     * @return 体温单记录保存结果
     */
    @PutMapping("/record-saving")
    public R<?> saveVitalSigns(@RequestBody VitalSignsSaveDto vitalSignsSaveDto) {
        return R.ok(vitalSignsAppService.saveVitalSigns(vitalSignsSaveDto));
    }

    /**
     * 体温单检索
     *
     * @return 体温单检索结果
     */
    @GetMapping("/record-search")
    public R<?> searchVitalSigns(String startTime, String endTime) {
        return R.ok(vitalSignsAppService.searchVitalSigns(startTime, endTime));
    }

    /**
     * 体温单记录删除
     *
     * @return 体温单记录修改结果
     */
    @PutMapping("/record-delete")
    public R<?> deleteVitalSigns(@RequestBody List<VitalSignsDeleteDto> vitalSignsDeleteDto) {
        return R.ok(vitalSignsAppService.deleteVitalSigns(vitalSignsDeleteDto));
    }

}
