package com.xinelu.manage.controller.patientvisitouthospital;

import io.swagger.annotations.Api;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xinelu.common.annotation.Log;
import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.enums.BusinessType;
import com.xinelu.manage.domain.patientvisitouthospital.PatientVisitOutHospital;
import com.xinelu.manage.service.patientvisitouthospital.IPatientVisitOutHospitalService;
import com.xinelu.common.utils.poi.ExcelUtil;
import com.xinelu.common.core.page.TableDataInfo;

/**
 * 患者就诊出院记录信息Controller
 *
 * @author xinelu
 * @date 2024-02-26
 */
@Api(tags = "患者就诊出院记录信息控制器")
@RestController
@RequestMapping("/manage/visitOut")
public class PatientVisitOutHospitalController extends BaseController {
    @Resource
    private IPatientVisitOutHospitalService patientVisitOutHospitalService;

	/**
	 * 查询患者就诊出院记录信息列表
	 */
	@PreAuthorize("@ss.hasPermi('manage:visit:list')")
	@GetMapping("/list")
    public TableDataInfo list(PatientVisitOutHospital patientVisitOutHospital) {
        startPage();
        List<PatientVisitOutHospital> list = patientVisitOutHospitalService.selectPatientVisitOutHospitalList(patientVisitOutHospital);
        return getDataTable(list);
    }

	/**
	 * 根据患者就诊记录查询患者入院记录信息
	 */
	@GetMapping("/getByVisitRecord/{patientVisitRecordId}")
	public AjaxResult getByVisitRecord(@PathVariable("patientVisitRecordId") Long patientVisitRecordId) {
		return AjaxResult.success(patientVisitOutHospitalService.getByVisitRecord(patientVisitRecordId));
	}

    /**
     * 导出患者就诊出院记录信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:visit:export')")
    @Log(title = "患者就诊出院记录信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PatientVisitOutHospital patientVisitOutHospital) {
        List<PatientVisitOutHospital> list = patientVisitOutHospitalService.selectPatientVisitOutHospitalList(patientVisitOutHospital);
        ExcelUtil<PatientVisitOutHospital> util = new ExcelUtil<PatientVisitOutHospital>(PatientVisitOutHospital. class);
        util.exportExcel(response, list, "患者就诊出院记录信息数据");
    }

    /**
     * 获取患者就诊出院记录信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:visit:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(patientVisitOutHospitalService.selectPatientVisitOutHospitalById(id));
    }

    /**
     * 新增患者就诊出院记录信息
     */
    @PreAuthorize("@ss.hasPermi('manage:visit:add')")
    @Log(title = "患者就诊出院记录信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PatientVisitOutHospital patientVisitOutHospital) {
        return toAjax(patientVisitOutHospitalService.insertPatientVisitOutHospital(patientVisitOutHospital));
    }

    /**
     * 修改患者就诊出院记录信息
     */
    @PreAuthorize("@ss.hasPermi('manage:visit:edit')")
    @Log(title = "患者就诊出院记录信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PatientVisitOutHospital patientVisitOutHospital) {
        return toAjax(patientVisitOutHospitalService.updatePatientVisitOutHospital(patientVisitOutHospital));
    }

    /**
     * 删除患者就诊出院记录信息
     */
    @PreAuthorize("@ss.hasPermi('manage:visit:remove')")
    @Log(title = "患者就诊出院记录信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(patientVisitOutHospitalService.deletePatientVisitOutHospitalByIds(ids));
    }
}
