package com.yihu.wlyy.web.doctor.record;

import com.yihu.wlyy.service.app.record.RegDeptSpeDoctorService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by zhenglingfeng on 2016/10/17.
 */
@Controller
@RequestMapping(value = "/wlyy_service/record", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-获取转诊预约医生号源信息")
public class RegDeptSpeDoctorController extends BaseController {

    @Autowired
    private RegDeptSpeDoctorService regDeptSpeDoctorService;
    /**
     * 获取转诊预约医生号源信息
     *
     * @return
     */
    @ApiOperation("获取转诊预约医生号源信息")
    @RequestMapping(value = "regDeptSpeDoctor", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String getRegDeptSpeDoctorSectionList(@ApiParam(name="OrgCode",value="机构编码",defaultValue = "350211A1001")
                                                 @RequestParam(value="OrgCode",required = true) String OrgCode,
                                                 @ApiParam(name="DeptCode",value="科室编码",defaultValue = "1040610")
                                                 @RequestParam(value="DeptCode",required = true) String DeptCode,
                                                 @ApiParam(name="strStart",value="预约排班开始时间",defaultValue = "2016-10-18")
                                                 @RequestParam(value="strStart",required = true) String strStart,
                                                 @ApiParam(name="strEnd",value="预约排班结束时间",defaultValue = "2016-10-20")
                                                 @RequestParam(value="strEnd",required = true) String strEnd,
                                                 @ApiParam(name="DocCode",value="医生编码",defaultValue = "80772")
                                                 @RequestParam(value="DocCode",required = true) String DocCode) {
        try {
            String result = regDeptSpeDoctorService.getRegDeptSpeDoctorSectionList(OrgCode, DeptCode, strStart, strEnd, DocCode);
            if (result.startsWith("error")) {
                return write(200, result, "data", new JSONArray().toString());
            }
            return write(200, "获取转诊预约医生号源信息成功！", "data", result);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取转诊预约医生号源信息失败！");
        }
    }
}
