package cn.hnthyy.thmz.controller.mz;

import cn.hnthyy.thmz.comment.UserLoginToken;
import cn.hnthyy.thmz.entity.his.mz.MzVisitTable;
import cn.hnthyy.thmz.service.his.mz.MzVisitTableService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;

@Slf4j
@RestController
public class MzVisitTableController {
    @Autowired
    private MzVisitTableService mzVisitTableService;


    /**
     * 查询病人诊断
     * @return
     */
    @UserLoginToken
    @RequestMapping(value = "/getVisitTableByPatientIdAndTimes", method = {RequestMethod.POST})
    public Map<String, Object> getVisitTableByPatientIdAndTimes(@RequestBody MzVisitTable mzVisitTable) {
        Map<String, Object> resultMap = new HashMap<>();
        try {
            resultMap.put("code", 0);
            resultMap.put("message", "查询病人诊断成功");
            resultMap.put("data", mzVisitTableService.queryByPatientIdAndTimes(mzVisitTable.getPatientId(),mzVisitTable.getTimes()));
            return resultMap;
        }catch (Exception e){
            e.printStackTrace();
            resultMap.put("code", -1);
            resultMap.put("message", "查询病人诊断失败，系统出错，请联系管理员");
            log.error("查询病人诊断失败，系统异常，错误信息{}",e.getMessage());
            return resultMap;
        }
    }


}
