package cn.hnthyy.thmz.controller.mz;

import cn.hnthyy.thmz.comment.UserLoginToken;
import cn.hnthyy.thmz.service.his.ResponceTypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * 病人身份类型
 */
@Slf4j
@RestController
public class ResponceTypeController {
    @Autowired
    private ResponceTypeService responceTypeService;

    /**
     * 查询所有门诊病人身份类型
     * @return
     */
    @UserLoginToken
    @RequestMapping(value = "/getMzResponceType", method = {RequestMethod.GET})
    public Map<String, Object> getMzResponceType() {
        log.info("查询所有门诊病人身份类型");
        Map<String, Object> resultMap = new HashMap<>();
        try {
            resultMap.put("code", 0);
            resultMap.put("message", "查询门诊病人身份类型成功");
            resultMap.put("data", responceTypeService.queryAllMzResponceType());
            return resultMap;
        }catch (Exception e){
            e.printStackTrace();
            resultMap.put("code", -1);
            resultMap.put("message", "系统出错，请联系管理员");
            log.error("门诊病人身份类型查询出现系统异常，错误信息{}",e.getMessage());
            return resultMap;
        }
    }

    /**
     * 查询所有住院病人身份类型
     * @return
     */
    @UserLoginToken
    @RequestMapping(value = "/getZyResponceType", method = {RequestMethod.GET})
    public Map<String, Object> getZyResponceType() {
        log.info("查询所有住院病人身份类型");
        Map<String, Object> resultMap = new HashMap<>();
        try {
            resultMap.put("code", 0);
            resultMap.put("message", "查询住院病人身份类型成功");
            resultMap.put("data", responceTypeService.queryAllZyResponceType());
            return resultMap;
        }catch (Exception e){
            e.printStackTrace();
            resultMap.put("code", -1);
            resultMap.put("message", "系统出错，请联系管理员");
            log.error("住院病人身份类型查询出现系统异常，错误信息{}",e.getMessage());
            return resultMap;
        }
    }
}
