package com.yihu.jw.hospital.ykyy.service;


import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.idcard.IdCardUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * 眼科通接口
 *
 * Created by wangzhinan on 2020/4/11.
 */
@Service
public class YkyyService {

    private Logger logger = LoggerFactory.getLogger(YkyyService.class);

    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private BasePatientDao patientDao;

    private static String yktUrl = "http://www.yanketong.com:133/api/";
    private static String yktUrl_90 = "http://www.yanketong.com:90/";



    public String selectCards(String patient) throws Exception {
        String response = null;
        BasePatientDO basePatientDO  = patientDao.findById(patient);
        if (basePatientDO!=null){
            String userId = basePatientDO.getUserId();
            if (StringUtils.isNoneBlank(userId)){
               response = selectCardList(userId);
            }else {
               String response1 = getShortMessage("1",basePatientDO.getMobile());
                JSONObject jsonObject = JSONObject.parseObject(response1);
                if (jsonObject.getString("code").equalsIgnoreCase("10000")){
                    String code = jsonObject.getString("value");
                    String r =getRegisterUser(basePatientDO.getMobile(),"123456",code,"a01522","xmijk","xmijk");
                    JSONObject object = JSONObject.parseObject(r);
                    if (object.getString("code").equalsIgnoreCase("200")){
                        JSONObject object1 = object.getJSONObject("data");
                        if (object1!=null){
                            userId = object1.getString("ID");
                            basePatientDO.setUserId(userId);
                            patientDao.save(basePatientDO);
                            response = selectCardList(userId);
                        }
                    }else {
                        throw new Exception("用户注册失败");
                    }
                }else {
                    throw new Exception("获取验证码失败");
                }

            }
        }
        return response;
    }


    /**
     * 获取充值订单号接口
     * @param mzhm 卡号
     * @param jkje  交款金额
     * @param type  类型0 就诊卡号 1 门诊卡号
     * @param PaymentType  1支付宝 2微信
     * @param UserId  用户Id
     * @param HospitalId  医院Id
     * @return
     */
    public String getNewSerialNumber(String mzhm,Integer jkje,Integer type,Integer PaymentType,String UserId,String HospitalId){
        String response="";
        Map<String, String> map = new HashMap<>();
        map.put("mzhm",mzhm);
        map.put("jkje",Integer.toString(jkje));
        map.put("type",Integer.toString(type));
        map.put("PaymentType",Integer.toString(PaymentType));
        map.put("UserId",UserId);
        if (StringUtils.isNotEmpty(HospitalId)){
            map.put("HospitalId",HospitalId);
        }
        logger.info("眼科获取充值订单号接口入参:"+map.toString());
        String url=yktUrl_90+"api/His/GetNewSerialNumber4Jkzl";
        try {
            response=httpClientUtil.httpPost(url,map);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return response;
    }

    /**
     * 充值接口(充值成功后在回调中调用此接口)
     * @param guid  订单号
     * @param jkje  交款金额
     * @param type  类型0 就诊卡号 1 门诊卡号
     * @return
     */
    public String upRecharge4Jkzl(String guid,Integer jkje,Integer type){
        String response="";
        Map<String, String> map = new HashMap<>();
        map.put("guid",guid);
        map.put("jkje",Integer.toString(jkje));
        map.put("type",Integer.toString(type));
        logger.info("眼科充值接口入参:"+map.toString());
        String url=yktUrl_90+"api/His/UpRecharge4Jkzl";
        try {
            response=httpClientUtil.httpPost(url,map);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return response;
    }



    /**
     * 互联网-添加就诊卡
     * @param patient
     * @param card
     * @param userId
     * @param type
     * @return
     */
    public String addYkCard(String patient,String card,String userId,String type){
        String response = null;
        BasePatientDO patientDO = patientDao.findById(patient);
        String user_id=null;
        if (StringUtils.isNoneBlank(userId)){
            user_id=userId;
        }else {
            user_id=patientDO.getUserId();
        }
        response = addCard(user_id,patientDO.getName(),card,"7A585AB3-ED33-B40D-C3E3-A8BB0A1195D8","厦门大学附属厦门眼科中心思北院区",type,"1");
        return response;
    }


    /**
     * 眼科通验证码
     * @param type
     * @param phone
     * @return
     */
    public String getShortMessage(String type,String phone){
        String response="";
        String url = yktUrl+"verification_code/short_message?type="+type+"&telephone="+phone;
        response = httpClientUtil.get(url,"GBK");
        logger.info("眼科通验证码:"+response);
        return response;
    }


    /**
     * telephone=15578008051&patient_pwd=123456&code=513970&invite_code=a01522&equipment_type=ios&equipment_guid=12312321
     * 眼科通用户注册
     *
     * @param telephone
     * @param patientPwd
     * @param code
     * @return
     */
    public String getRegisterUser(String telephone,String patientPwd,String code,String inviteCode,String equipmentType,String equipmentGuid){
        String response="";
        String url = yktUrl+"user_center/patient_register01?telephone="+telephone+"&patient_pwd="+patientPwd+"&code="+code+"&invite_code="+inviteCode+"&equipment_type="+equipmentType+
                "&equipment_guid="+equipmentGuid;
        response = httpClientUtil.get(url,"GBK");
        logger.info("眼科通用户注册:"+response);
        return response;
    }


    /**
     * 获取就诊卡数据接口
     * @param userId
     * @return
     */
    public String selectCardList(String userId){
        String response="";
        Map<String,Object> param = new HashedMap();
        param.put("user_id",userId);
        String url = yktUrl+"patient/get_patient_card_list?user_id="+userId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("获取就诊卡数据接口:"+response);
        return response;
    }


    /**
     * user_id=1a6a0016-a788-3c84-82e0-f1283e891ccc&patient_name=wangzhinan&card=12345678901&hospital_id=7A585AB3-ED33-B40D-C3E3-A8BB0A1195D8&hospital_name=厦门大学附属厦门眼科中心思北院区&type=0&hos_num=1
     *
     * 添加就诊卡接口
     *
     *
     */
    public String addCard(String userId,String patientName,String card,String hospitalId,String hospitalName,String type,String hosNum){
        String response="";
        String url = yktUrl+"patient/add_card?user_id="+userId+"&patient_name="+patientName+"&card="+card+"&hospital_id="+hospitalId+
                "&hospital_name="+hospitalName+"&type="+type+"&hos_num="+hosNum;
        response = httpClientUtil.get(url,"GBK");
        logger.info("添加就诊卡接口:"+response);
        return response;
    }


    /**
     * 眼科通新增订单接口
     *
     * @param orderNo
     * @param patientId
     * @param orderAmout
     * @param description
     * @param state
     * @param orderType
     * @param doctorId
     * @param payType
     * @param payAccount
     * @param patientTel
     * @return
     */
    public String addYktOrder(String orderNo,String patientId,String orderAmout,String description,String state,String orderType,String doctorId,String payType,String payAccount,String patientTel,String orderCategory,String pcCallbackUrl,String appCallbackUrl){
        String response="";
        if ("17".equalsIgnoreCase(orderType)){
            orderType = "3";
        }
        String url = yktUrl+"doc_jkzl/add_inquiry_order?order_no="+orderNo+"&patient_id="+patientId+"&order_amout="+orderAmout+"&description="+URLEncoder.encode(description)+
                "&state="+state+"&order_type="+orderType+"&doctor_id="+doctorId+"&pay_type="+payType+"&patient_tel="+patientTel+"&order_category="+orderCategory;
        if (StringUtils.isNoneBlank(payAccount)){
            url+="&pay_accout="+payAccount;
        }
        if (StringUtils.isNoneBlank(pcCallbackUrl)){
            url+="&pc_callback_url="+ URLEncoder.encode(pcCallbackUrl);
        }
        if (StringUtils.isNoneBlank(appCallbackUrl)){
            url+="&app_callback_url="+URLEncoder.encode(appCallbackUrl);
        }
        logger.info("眼科通新增订单接口url:"+url);
        try {
            response = httpClientUtil.get(url,"GBK");
        }catch (Exception e){
            e.printStackTrace();
        }
        logger.info("眼科通新增订单接口:"+response);
        return response;
    }

    /**
     * 更新订单支付状态
     *
     * @param orderNo
     * @param state
     * @return
     */
    public String updateYktOrderStatus(String orderNo,String state){
        String response="";
        String url = yktUrl+"doc_jkzl/update_order_state?order_no="+orderNo+"&state="+state;
        response = httpClientUtil.get(url,"GBK");
        logger.info("更新订单支付状态:"+response);
        return response;
    }


    /**
     * 增加家庭成员
     * @param userId
     * @param idcard
     * @param name
     * @param sex
     * @param birth
     * @param age
     * @param tel
     * @return
     */
    public String addFamily(String userId,String idcard,String name,String sex,String birth,String age,String tel){
        String response="";
        String url = yktUrl+"doc_jkzl/add_family?ass_user_id="+userId+"&id_card="+idcard+"&name="+name+"&sex="+sex
                +"&birth="+birth+"&age="+age+"&tel="+tel+"&medical_card=&illness=本人&clinic_id=";
        response = httpClientUtil.get(url,"GBK");
        logger.info("增加家庭成员:"+response);
        return response;
    }


    /**
     * 获取userId
     * @param tel
     * @return
     */
    public String getUserId(String tel){
        String response="";
        String url = yktUrl+"doc_jkzl/get_user_id_by_tel?tel="+tel;
        response = httpClientUtil.get(url,"GBK");
        logger.info("获取userId:"+response);
        return response;
    }

    /**
     * 获取医生code
     * @param doctorMapping
     * @return
     */
    public String getYktDoctor(String doctorMapping){
        String response="";
        String url = yktUrl+"doc_jkzl/get_ykt_doctorid_by_doctorcode?doctor_code="+doctorMapping;
        response = httpClientUtil.get(url,"GBK");
        logger.info("获取userId:"+response);
        return response;
    }


    /**
     * 查询医生咨询价格
     * @param doctorId
     * @param type
     * @return
     */
    public String GetVasPriceByTypeForJkzl(String doctorId,int type){
        String response="";
        String url = yktUrl_90+"api/Share/GetVasPriceByTypeForJkzl?doctorId="+doctorId+"&type="+type;
        response = httpClientUtil.get(url,"GBK");
        logger.info("获取服务价格:"+response);
        return response;
    }


    /**
     *获取家庭成员信息
     *
     * @param tel
     * @param userId
     * @return
     */
    public String getFamilyList(String tel,String userId){
        String response="";
        String url = yktUrl+"doc_jkzl/get_family_list?";
        if (StringUtils.isNoneBlank(tel)&&StringUtils.isNoneBlank(userId)){
            url+="tel="+tel;
            url+="&user_id="+userId;
        }else if (StringUtils.isNoneBlank(tel)&&!StringUtils.isNoneBlank(userId)){
            url+="tel="+tel;
        }else if (!StringUtils.isNoneBlank(tel)&&StringUtils.isNoneBlank(userId)){
            url+="user_id="+userId;
        }
        response = httpClientUtil.get(url,"GBK");
        logger.info("获取家庭成员信息:"+response);
        return response;
    }


    /**
     * 眼科通登录接口
     * @param tel
     * @param password
     * @return
     */
    public String yktLogin(String tel,String password){
        String response="";
        String url = yktUrl+"user_center/patient_login?patient_account="+tel+"&patient_pwd="+password;
        response = httpClientUtil.get(url,"GBK");
        logger.info("获取眼科通登录信息:"+response);
        return response;
    }



    /**
     * 更新药品订单信息
     * @param orderNo 订单号
     * @param drugorder 药品订单[商城订单编号]
     * @param cfsb 处方识别号
     * @return
     */
    public String updateDrugorderInfo(String orderNo,String drugorder,String cfsb){
        String response="";
        String url = yktUrl+"doc_jkzl/update_drugorder_infor?order_no="+orderNo+"&drugorder="+drugorder+"&cfsb="+cfsb;
        response = httpClientUtil.get(url,"GBK");
        logger.info("更新药品订单信息:"+response);
        return response;
    }


    /**增加处方订单接口
     *
     * drugType	String	药品类型【1，到院 2、到商城】
    orderId	String	订单Id
    userId	String	用户Id
    Shopping	String	药品列表
    commodityName	String	药品名称
    commodityPrice	String	价格
    purchaseQuantity	String	数量
    DrugUnit	String	单位
    MedicineDoctor	String	医生Id
    [{"commodityName":"","commodityPrice":"","DrugUnit":"","MedicineDoctor":""}]


     * @return
     */
    public String addOrder4Jkzl(String drugType,String orderId,String orderNo,String userId,JSONArray array ){
        String response="";
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("drugType",drugType);//药品类型【1，到院 2、到商城】
        jsonObject.put("orderId",orderId);//订单Id
        jsonObject.put("orderNo",orderNo);//订单号
        jsonObject.put("userId",userId);//用户Id
        jsonObject.put("Shopping",array);//药品列表
        String url = "http://www.yanketong.com:90/api/Doctor/AddOrder4Jkzl";
        response = httpClientUtil.sendPost(url,jsonObject.toJSONString());
        logger.info("增加处方订单接口:"+response);
        return response;
    }

    public String GetDoctorInfoByLoginId(String loginId) throws Exception{
        String response = "";
        String url = "http://www.yanketong.com:90/api/doctor/GetDoctorInfoByTel?loginId="+loginId;
        response = httpClientUtil.get(url,"utf-8");
        logger.info("根据电话获取医生信息接口:"+response);
        if (StringUtils.isNoneBlank(response)){
            JSONObject json = JSONObject.parseObject(response);
            if (json.getString("code").equalsIgnoreCase("10000")){
                String verifyCode = json.getJSONObject("value").getString("verifyCode");
                return verifyCode;
            }else {
                throw new Exception("获取失败");
            }
        }else {
            throw new Exception("获取失败");
        }
    }


    /**获取眼科通忘记密码信息
     *
     * @param tel
     * @param password
     * @param vercode
     * @return
     */
    public String forgetPassword(String tel,String password,String vercode){
        String response="";
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("loginid",tel);
        jsonObject.put("password",password);
        jsonObject.put("VerCode",vercode);
        String url = "http://www.yanketong.com:90/api/Patient/ForgotPassword";
        response = httpClientUtil.sendPost(url,jsonObject.toJSONString());
        logger.info("获取眼科通忘记密码信息:"+response);
        return response;
    }
    /**获取眼科通忘记密码信息
     *
     * @param tel
     * @param password
     * @param vercode
     * @return
     */
    public String  updatePatientPassword(String tel,String password,String vercode){
        String response="";
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("loginid",tel);
        jsonObject.put("password",password);
        String url = "http://www.yanketong.com:90/api/Patient/ForgotPassword4Jkzl";
        response = httpClientUtil.sendPost(url,jsonObject.toJSONString());
        logger.info("获取眼科通忘记密码信息:"+response);
        return response;
    }

    /**
     * 同步眼科通数据
     * @param patient
     * @return
     * @throws Exception
     */
    public String registerYkt(String patient) throws Exception {
        String yktId1 = "";
        BasePatientDO basePatientDO  = patientDao.findById(patient);
        if (basePatientDO!=null){
            String userId = basePatientDO.getUserId();
            if (StringUtils.isNoneBlank(userId)){
                String familyList =getFamilyList(null,userId);
                JSONObject object = JSONObject.parseObject(familyList);
                if (object.getString("code").equalsIgnoreCase("200")){
                    JSONObject object1 = object.getJSONObject("data");
                    JSONArray array = object1.getJSONArray("list");
                    if (array!=null&&array.size()!=0){
                        JSONObject jsonObject = array.getJSONObject(0);
                        if (jsonObject!=null){
                            String yktId = jsonObject.getString("ID");
                            yktId1=yktId;
                            basePatientDO.setYktId(yktId);
                            patientDao.save(basePatientDO);
                        }
                    }else {
                        String birdth = IdCardUtil.getBirthdayForIdcardStr(basePatientDO.getIdcard());
                        Integer age = IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard());
                        Integer sex = basePatientDO.getSex();
                        String family = addFamily(userId,basePatientDO.getIdcard(),basePatientDO.getName(),sex.toString(),birdth,age.toString(),basePatientDO.getMobile());
                        JSONObject object2 = JSONObject.parseObject(family);
                        if (object2.getString("code").equalsIgnoreCase("200")){
                            JSONObject object3 = object2.getJSONObject("data");
                            String yktId = object3.getString("ID");
                            yktId1=yktId;
                            basePatientDO.setYktId(yktId);
                            patientDao.save(basePatientDO);
                        }
                    }

                }else {
                    throw new Exception("查询家庭成员失败！");
                }
            }else {
                String response1 = getShortMessage("1",basePatientDO.getMobile());
                JSONObject jsonObject = JSONObject.parseObject(response1);
                if (jsonObject.getString("code").equalsIgnoreCase("10000")){
                    String code = jsonObject.getString("value");
                    String r =getRegisterUser(basePatientDO.getMobile(),"123456",code,"a01522","xmijk","xmijk");
                    JSONObject object4 = JSONObject.parseObject(r);
                    if (object4.getString("code").equalsIgnoreCase("200")){
                        JSONObject object5 = object4.getJSONObject("data");
                        if (object5!=null){
                            userId = object5.getString("ID");
                            basePatientDO.setUserId(userId);
                            patientDao.save(basePatientDO);
                            String familyList =getFamilyList(null,userId);
                            JSONObject object = JSONObject.parseObject(familyList);
                            if (object.getString("code").equalsIgnoreCase("200")){
                                JSONObject object1 = object.getJSONObject("data");
                                JSONArray array = object1.getJSONArray("list");
                                if (array!=null&&array.size()!=0){
                                    JSONObject jsonObject1 = array.getJSONObject(0);
                                    if (jsonObject1!=null){
                                        String yktId = jsonObject1.getString("ID");
                                        yktId1=yktId;
                                        userId = jsonObject1.getString("ASSUSERID");
                                        basePatientDO.setYktId(yktId);
                                        basePatientDO.setUserId(userId);
                                        patientDao.save(basePatientDO);
                                    }
                                }else {
                                    String birdth = IdCardUtil.getBirthdayForIdcardStr(basePatientDO.getIdcard());
                                    Integer age = IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard());
                                    Integer sex = basePatientDO.getSex();
                                    String family = addFamily(userId,basePatientDO.getIdcard(),basePatientDO.getName(),sex.toString(),birdth,age.toString(),basePatientDO.getMobile());
                                    JSONObject object2 = JSONObject.parseObject(family);
                                    if (object2.getString("code").equalsIgnoreCase("200")){
                                        JSONObject object3 = object2.getJSONObject("data");
                                        String yktId = object3.getString("ID");
                                        yktId1=yktId;
                                        basePatientDO.setYktId(yktId);
                                        userId = object3.getString("ASSUSERID");
                                        basePatientDO.setUserId(userId);
                                        patientDao.save(basePatientDO);
                                    }
                                }

                            }else {
                                throw new Exception("查询家庭成员失败！");
                            }
                        }
                    }else {
                        throw new Exception("用户注册失败");
                    }
                }else if (jsonObject.getString("code").equalsIgnoreCase("199")){
                    String familyList =getFamilyList(basePatientDO.getMobile(),null);
                    JSONObject object = JSONObject.parseObject(familyList);
                    if (object.getString("code").equalsIgnoreCase("200")){
                        JSONObject object1 = object.getJSONObject("data");
                        JSONArray array = object1.getJSONArray("list");
                        if (array!=null&&array.size()!=0){
                            JSONObject jsonObject1 = array.getJSONObject(0);
                            if (jsonObject1!=null){
                                String yktId = jsonObject1.getString("ID");
                                yktId1=yktId;
                                userId = jsonObject1.getString("ASSUSERID");
                                basePatientDO.setYktId(yktId);
                                basePatientDO.setUserId(userId);
                                patientDao.save(basePatientDO);
                            }
                        }else {
                            userId=object1.getString("user_id");
                            String birdth = DateUtil.dateToStrShort(IdCardUtil.getBirthdayForIdcard(basePatientDO.getIdcard()));
                            Integer age = IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard());
                            Integer sex = basePatientDO.getSex();
                            String family = addFamily(userId,basePatientDO.getIdcard(),basePatientDO.getName(),sex.toString(),birdth,age.toString(),basePatientDO.getMobile());
                            JSONObject object2 = JSONObject.parseObject(family);
                            if (object2.getString("code").equalsIgnoreCase("200")){
                                JSONObject object3 = object2.getJSONObject("data");
                                String yktId = object3.getString("ID");
                                yktId1=yktId;
                                basePatientDO.setYktId(yktId);
                                userId = object3.getString("ASSUSERID");
                                basePatientDO.setUserId(userId);
                                patientDao.save(basePatientDO);
                            }
                        }
                    }else {
                        throw new Exception("查询家庭成员失败！");
                    }
                }else {
                    throw new Exception("获取验证码失败");
                }
            }
        }
        return yktId1;
    }


    /**
     * 推送眼科通居民消息
     * @param patientId 眼科通id对应patient表里的yktId
     * @param attach 标题
     * @param pushcontent  内容
     * @return
     */
    public String pushNotificationToYktPatient(String patientId,String attach,String pushcontent){
        String response="";
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("patientId",patientId);
        jsonObject.put("attach",attach);
        jsonObject.put("pushcontent",pushcontent);
        String url = "http://www.yanketong.com:90/api/share/PushNotificationToPatient";
        response = httpClientUtil.sendPost(url,jsonObject.toJSONString());
        logger.info("推送眼科通消息:"+response);
        return response;
    }


    /**
     * 眼科通支付
     *
     * @param body
     * @param out_trade_no
     * @param total_fee
     * @param spbill_create_ip
     * @param notify_url
     * @return
     */
    public String getPayCDATA4Jkzl(String body,String out_trade_no,String total_fee,String spbill_create_ip,String notify_url){
        String response="";
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("body",body);
        jsonObject.put("out_trade_no",out_trade_no);
        jsonObject.put("total_fee",total_fee);
        jsonObject.put("spbill_create_ip",spbill_create_ip);
        jsonObject.put("notify_url",notify_url);
        String url = "http://www.yanketong.com:90/api/Doctor/GetPayCDATA4Jkzl";
        response = httpClientUtil.sendPost(url,jsonObject.toJSONString());
        logger.info("眼科通支付:"+response);
        return response;
    }


    /**
     * 根据订单id修改医生ID
     * @param doctorId  医生ID
     * @param orderId   订单ID
     * @return
     */
    public String  updateDoctorIdByOrderId(String doctorId,String orderId){
        String response="";
        String url="http://www.yanketong.com:133/api/doc_jkzl/update_doctorid_by_orderno?";
        url+="order_no="+orderId;
        url+="&doctor_id="+doctorId;
        logger.info("根据订单id修改医生ID接口URL="+url);
        response = httpClientUtil.get(url,"UTF-8");
        logger.info("根据订单id修改医生ID="+response);
        return response;
    }


    /**
     * 医生端眼科通登陆
     * @param loginId 账户
     * @param password 密码
     * @return
     */
    public String DoctorLogin(String loginId,String password){
        String response="";
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("loginId",loginId);//账户
        jsonObject.put("password",password);//密码
        String url = "http://www.yanketong.com:90/api/Doctor/DoctorLogin";
        response = httpClientUtil.sendPost(url,jsonObject.toJSONString());
        logger.info("医生端登陆:"+response);
        return response;
    }
    /*
     *查询眼科通家人关系
     */
    public String findYktFamily(String yktUserId){
        String response="";
        String url="http://www.yanketong.com:133/api/doc_jkzl/get_family_list?";
        url+="user_id="+yktUserId;
        logger.info("查询眼科通家人关系="+url);
        response = httpClientUtil.get(url,"UTF-8");
        logger.info("查询眼科通家人关系结果"+response);
        return response;

    }
    /*
     *删除家人关系
     */
        public String deleteYktFamily(String yktFamilyId){
        String response="";
        String url="http://www.yanketong.com:133/api/patient/delete_family?";
        url+="id="+yktFamilyId;
        logger.info("删除眼科通家人关系="+url);
        response = httpClientUtil.get(url,"UTF-8");
        logger.info("删除眼科通家人关系结果"+response);
        return response;

    }
    //添加家人关系
    public String addYktFamily(String name,String id_card,String sex,String age,String tel,String medical_card,String illness,String clinic_id,String ass_user_id,String birth){
        String response="";
        String url="http://www.yanketong.com:133/api/doc_jkzl/add_family?";
        url+="name="+name;
        url+="&id_card="+id_card;
        url+="&sex="+sex;
        url+="&age="+age;
        url+="&tel="+tel;
        url+="&medical_card="+medical_card;
        url+="&illness="+illness;
        url+="&clinic_id="+clinic_id;
        url+="&ass_user_id="+ass_user_id;
        url+="&birth="+birth;
        logger.info("添加眼科通家人关系="+url);
        response = httpClientUtil.get(url,"UTF-8");
        logger.info("添加眼科通家人关系结果"+response);
        return response;
    }
    //修改家人关系
    public String updateYktFamily(String name,String id_card,String sex,String age,String tel,String medical_card,String illness,String clinic_id,String id,String birth){
        String response="";
        String url="http://www.yanketong.com:133/api/patient/update_family?";
        url+="name="+name;
        url+="&id_card="+id_card;
        url+="&sex="+sex;
        url+="&age="+age;
        url+="&tel="+tel;
        url+="&medical_card="+medical_card;
        url+="&illness="+illness;
        url+="&clinic_id="+clinic_id;
        url+="&id="+id;
        url+="&birth="+birth;
        logger.info("修改眼科通家人关系="+url);
        response = httpClientUtil.get(url,"UTF-8");
        logger.info("修改眼科通家人关系结果"+response);
        return response;
    }
}
