package com.joju.datamanager.controller;

import cn.hutool.core.collection.CollUtil;
import com.joju.datamanager.common.annotation.EleganceLog;
import com.joju.datamanager.common.result.Result;
import com.joju.datamanager.common.result.ResultUtil;
import com.joju.datamanager.model.medicalprescription.MedicalPrescription;
import com.joju.datamanager.model.viewmodel.PatientList;
import com.joju.datamanager.service.HisViewSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * @description: his视图获取
 * @author: Mr.zs
 * @create: 2024-03-15 17:44
 **/
@RestController
@RequestMapping("/hisViewSearch")
public class HisViewSearchController {

    @Autowired
    HisViewSearchService hisViewSearchService;

    /**
     * his手术管理视图
     *
     * @param hzxm
     * @param blh
     * @return
     */
    @GetMapping("/getSurgicalViewData")
    @EleganceLog(description = "his手术管理视图")
    public Result getSurgicalViewData(String hzxm, String blh) {
        List<Map<String, Object>> maps = hisViewSearchService.getSurgicalView(hzxm, blh);
        if (!CollUtil.isEmpty(maps)) {//有数据
            return ResultUtil.successData(maps);
        }
        return ResultUtil.failureMsg("未获取到数据");
    }


    /**
     * his历史就诊记录查询
     *
     * @param patient_name
     * @param idcard
     * @return
     */
    @GetMapping("/getHistoricalVisits")
    @EleganceLog(description = "his历史就诊记录查询")
    public Result getHistoricalVisits(String patient_name, String idcard) {
        List<PatientList> historicalVisits = hisViewSearchService.getHistoricalVisits(patient_name, idcard);

        if (!CollUtil.isEmpty(historicalVisits)) {//有数据
            return ResultUtil.successData(historicalVisits);
        }
        return ResultUtil.failureMsg("未获取到数据");
    }


    @GetMapping("/getMedicalPrescription")
    @EleganceLog(description = "获取今天的遗嘱开单信息！")
    public Result getMedicalPrescription() {
        List<MedicalPrescription> medicalPrescriptions = hisViewSearchService.getMedicalPrescription();

        if (!CollUtil.isEmpty(medicalPrescriptions)) {
            return ResultUtil.successData(medicalPrescriptions);
        }
        return ResultUtil.failureMsg("获取失败!");
    }

}
