package thyyxxk.webserver.controller.chronicdisease;

import com.alibaba.fastjson.JSONArray;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.chronicDisease.CrmPatientMi;
import thyyxxk.webserver.entity.chronicDisease.CrmPatientVo;
import thyyxxk.webserver.entity.chronicDisease.CrmVisitRecord;
import thyyxxk.webserver.entity.dictionary.CodeName;
import thyyxxk.webserver.service.chronicDisease.ChronicDiseaseService;
import thyyxxk.webserver.utils.ResultVoUtil;

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

/**
 * @ClassName ChronicDiseaseController
 * @Author Administrator
 * @Date 2023/11/23 14:33
 * @Version 1.0
 * @Description 慢特病管理
 **/
@RestController
@RequestMapping("/chronicDisease")
public class ChronicDiseaseController {

    private final ChronicDiseaseService service;

    public ChronicDiseaseController(ChronicDiseaseService service) {
        this.service = service;
    }

    @PassToken
    @GetMapping("/selectCrmPatientMiByCode")
    public ResultVo<CrmPatientMi> selectCrmPatientMiByCode(@RequestParam("keyCode") String keyCode){
        return service.selectCrmPatientMiByCode(keyCode);
    }

    @PassToken
    @PostMapping("/saveCrmPatientMi")
    public ResultVo<Map<String, Object>> saveCrmPatientMi(@RequestBody @Validated CrmPatientMi mi){
        return service.saveCrmPatientMi(mi);
    }
    @PassToken
    @PostMapping("/updateCrmPatientMi")
    public ResultVo<Map<String, Object>> updateCrmPatientMi(@RequestBody @Validated CrmPatientMi mi){
        return service.updateCrmPatientMi(mi);
    }

    @PassToken
    @GetMapping("/getCrmDictionary")
    public ResultVo<Map<String, List<CodeName>>> getCrmDictionary(){
        return service.getCrmDictionary();
    }

    @PassToken
    @GetMapping("/getCrmCityByCode")
    public ResultVo<List<CodeName>> getCrmCityByCode(@RequestParam("code") String code){
        return service.getCrmCityByCode(code);
    }

    @PassToken
    @GetMapping("/getCrmAreaByCode")
    public ResultVo<List<CodeName>> getCrmAreaByCode(@RequestParam("code") String code){
        return service.getCrmAreaByCode(code);
    }

    @PassToken
    @GetMapping("/getCrmEmrModel")
    public ResultVo<JSONArray> getCrmEmrModel(){
        return ResultVoUtil.success(service.getCrmEmrModel());
    }

    @PassToken
    @PostMapping("/queryCrmEmrTree")
    public ResultVo<List<CrmVisitRecord>> queryCrmEmrTree(@RequestBody CrmVisitRecord param){
        return ResultVoUtil.success(service.queryCrmEmrTree(param));
    }

    @PassToken
    @GetMapping("/queryCrmPatientInfoByCode")
    public ResultVo<CrmPatientMi>  queryCrmPatientInfoByCode(@RequestParam("code") String code){
        return service.queryCrmPatientInfoByCode(code);
    }

    @PassToken
    @PostMapping("/saveCrmEmrModel")
    public ResultVo<String>  saveCrmEmrModel(@RequestBody CrmVisitRecord param){
        return service.saveCrmEmrModel(param);
    }

    @PassToken
    @GetMapping("/selectBrInfoByCode")
    public ResultVo<Map<String, Object>> selectBrInfoByCode(@RequestParam("code") String code){
        return service.selectBrInfoByCode(code);
    }

    @PassToken
    @PostMapping("/selectChronicDisease")
    public ResultVo<List<CrmPatientMi>> selectChronicDisease(@RequestBody CrmPatientVo vo){
        return service.selectChronicDisease(vo);
    }

    @PassToken
    @GetMapping("/selectMbDelPermissions")
    public ResultVo<Map<String, Object>> selectMbDelPermissions(){
        return service.selectMbDelPermissions();
    }

    @PassToken
    @GetMapping("/delChronicDiseaseById")
    public ResultVo<Map<String, Object>> delChronicDiseaseById(@RequestParam("pId") String pId){
        return service.delChronicDiseaseById(pId);
    }

    @PassToken
    @GetMapping("/hfChronicDiseaseById")
    public ResultVo<Map<String, Object>> hfChronicDiseaseById(@RequestParam("pId") String pId){
        return service.hfChronicDiseaseById(pId);
    }

}
