using Gdsi.Config; using Gdsi.Helper; using Gdsi.Model; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static Gdsi.Model.Api2301Request; using static Gdsi.Model.Api2301Result; using static Gdsi.Model.Api2303Result; namespace Gdsi.Domain { public class GdsiApi { private static string api_9001() { string result = ""; var req = new { infno = "9001", msgid = GdsiConfig.fixmedins_code + DateTime.Now.ToString("yyyyMMddHHmmss") + new Random().Next(1, 10000).ToString().PadLeft(4, '0'), mdtrtarea_admvs = GdsiConfig.city_code, insuplc_admdvs = GdsiConfig.city_code, recer_sys_code = "FD0001", dev_no = "", dev_safe_info = "", cainfo = "", signtype = "SM3", infver = "V1.0", opter_type = "2", opter = GdsiConfig.opter, opter_name = GdsiConfig.opter_name, inf_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), fixmedins_code = GdsiConfig.fixmedins_code, fixmedins_name = GdsiConfig.fixmedins_name, sign_no = "", app_id = "", enc_type = "", input = new { signIn = new { opter_no = GdsiConfig.opter, mac = "00-50-56-82-8B-F4", ip = "192.168.30.33" } } }; string strReq = JsonConvert.SerializeObject(req); string strRes = Http.HttpPostByHeader(GdsiConfig.server_url + "9001", strReq); try { JObject jObject = JsonConvert.DeserializeObject(strRes) as JObject; if (jObject["infcode"].ToString() == "0") { if (jObject["output"]["signinoutb"]["sign_no"] == null) { return result; } result = jObject["output"]["signinoutb"]["sign_no"].ToString(); return result; } return result; } catch { return result; } } public static Info api_1101(string qrCode) { Info info = new Info(); string signNo = api_9001(); if ("".Equals(signNo)) { info.Msg = "签到出错"; return info; } var req = new { infno = "1101", msgid = GdsiConfig.fixmedins_code + DateTime.Now.ToString("yyyyMMddHHmmss") + new Random().Next(1, 10000).ToString().PadLeft(4, '0'), mdtrtarea_admvs = GdsiConfig.city_code, insuplc_admdvs = GdsiConfig.city_code, recer_sys_code = "FD0001", dev_no = "", dev_safe_info = "", cainfo = "", signtype = "SM3", infver = "V1.0", opter_type = "2", opter = GdsiConfig.opter, opter_name = GdsiConfig.opter_name, inf_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), fixmedins_code = GdsiConfig.fixmedins_code, fixmedins_name = GdsiConfig.fixmedins_name, sign_no = "", app_id = "", enc_type = "", input = new { data = new { mdtrt_cert_type = "01", mdtrt_cert_no = qrCode, card_sn = "", begntime = "", psn_cert_type = "", certno = "", psn_name = "" } } }; string strReq = JsonConvert.SerializeObject(req); string strRes = Http.HttpPostByHeader(GdsiConfig.server_url + "1101", strReq); try { JObject jObject = JsonConvert.DeserializeObject(strRes) as JObject; if (jObject["infcode"].ToString() == "0") { info.Code = 0; info.Msg = "SUCCESS"; info.Data = new Info.BaseInfo(); info.Data.Name = jObject["output"]["baseinfo"]["psn_name"].ToString(); info.Data.IDNo = jObject["output"]["baseinfo"]["certno"].ToString(); } else { info.Msg = jObject["err_msg"].ToString(); } } catch (Exception ex) { info.Msg = ex.Message; } return info; } /// /// 入院信息变更 /// /// /// public static Api2403Result api_2403(Api2403Request request) { //入参 string strReq = ""; //回参 string strRes = ""; //调用时间 DateTime stime = DateTime.Now; //输出回参 Api2403Result Api2403result = new Api2403Result(); string signNo = api_9001(); //测试 //string signNo = "签到成功"; if ("".Equals(signNo)) { Api2403result.Msg = "签到出错"; return Api2403result; } //签到报文注入 request.sign_no = signNo; strReq = JsonConvert.SerializeObject(request); strRes = Http.HttpPostByHeader(GdsiConfig.server_url + "2403", strReq); //测试数据 //strRes = "{\"output\":null,\"infcode\":0,\"warn_msg\":null,\"cainfo\":null,\"err_msg\":\"success\",\"refmsg_time\":\"20230512105139777\",\"signtype\":null,\"respond_time\":\"20230512105140065\",\"inf_refmsgid\":null}"; //记录回参日志 LogHelper.doJsonRequestLog("api_2403入院信息变更", strReq, strRes, stime); try { Api2403result = JsonConvert.DeserializeObject(strRes); } catch (Exception ex) { Api2403result.Msg = ex.Message; } return Api2403result; } /// /// 住院费用明细撤销 /// /// /// public static Api2302Result api_2302(Api2302Request request) { //入参 string strReq = ""; //回参 string strRes = ""; //调用时间 DateTime stime = DateTime.Now; //输出回参 Api2302Result Api2302result = new Api2302Result(); string signNo = api_9001(); //测试 //string signNo = "签到成功"; if ("".Equals(signNo)) { Api2302result.Msg = "签到出错"; return Api2302result; } //签到报文注入 request.sign_no = signNo; strReq = JsonConvert.SerializeObject(request); strRes = Http.HttpPostByHeader(GdsiConfig.server_url + "2302", strReq); //测试数据 //strRes = "{\"output\":null,\"infcode\":0,\"warn_msg\":null,\"cainfo\":null,\"err_msg\":null,\"refmsg_time\":\"20230512105143632\",\"signtype\":null,\"respond_time\":\"20230512105144479\",\"inf_refmsgid\":\"440000202305121051435628758113\"}"; //记录回参日志 LogHelper.doJsonRequestLog("api_2302住院费用明细撤销", strReq, strRes, stime); try { Api2302result = JsonConvert.DeserializeObject(strRes); } catch (Exception ex) { Api2302result.Msg = ex.Message; } return Api2302result; } /// /// 住院费用明细上传 /// /// /// public static Api2301Result api_2301(Api2301Request request) { //入参 string strReq = ""; //回参 string strRes = ""; //调用时间 DateTime stime = DateTime.Now; //输出回参 Api2301Result Api2301result = new Api2301Result(); string signNo = api_9001(); //测试 //string signNo = "签到成功"; if ("".Equals(signNo)) { Api2301result.Msg = "签到出错"; return Api2301result; } try { #region 每一百次上传费用明细 //赋值list,拿到总传参数据 List feedetailList = request.input.feedetail; //待上传的List(一百条) List NewFeedList = new List(); int lastY = feedetailList.Count / 100; int lastSize = feedetailList.Count % 100; if (lastSize < 100) { lastY += 1; } //定义一个回参集合 List results = new List(); for (int i = 1; i <= lastY; i++) { //这个就是每100条集合 NewFeedList = feedetailList.Skip(100 * (i - 1)).Take(100).ToList(); //置空 strReq = ""; //签到报文注入 request.sign_no = signNo; request.input.feedetail = null; //进行上传或者添加到集合 request.input.feedetail = NewFeedList; strReq = JsonConvert.SerializeObject(request); strRes = ""; strRes = Http.HttpPostByHeader(GdsiConfig.server_url + "2301", strReq); //记录回参日志 LogHelper.doJsonRequestLog("api_2301住院费用明细上传" + "次数:" + i, strReq, strRes, stime); //拿到每次调用返回的回参 Api2301result = JsonConvert.DeserializeObject(strRes); //不等于0都返回失败 if (Api2301result.infcode != "0") { return Api2301result; } for (int K = 0; K < Api2301result.output.result.Count; K++) { //定义一个回参组合 Result resultInfo = new Result(); resultInfo = Api2301result.output.result[K]; results.Add(resultInfo); } } try { Api2301result.output.result = null; Api2301result.output.result= results; return Api2301result; } catch (Exception ex) { //上传失败一次就报错 Api2301result.Msg = ex.Message; return Api2301result; } #endregion } catch (Exception ex) { Api2301result.Msg = ex.Message; return Api2301result; } } /// /// 出院办理 /// /// /// public static Api2402Result api_2402(Api2402Request request) { //入参 string strReq = ""; //回参 string strRes = ""; //调用时间 DateTime stime = DateTime.Now; //输出回参 Api2402Result Api2402result = new Api2402Result(); string signNo = api_9001(); //测试 //string signNo = "签到成功"; if ("".Equals(signNo)) { Api2402result.Msg = "签到出错"; return Api2402result; } //签到报文注入 request.sign_no = signNo; strReq = JsonConvert.SerializeObject(request); strRes = Http.HttpPostByHeader(GdsiConfig.server_url + "2402", strReq); //测试数据 //strRes = "{\"output\":null,\"infcode\":0,\"warn_msg\":null,\"cainfo\":null,\"err_msg\":null,\"refmsg_time\":\"20230512105200604\",\"signtype\":null,\"respond_time\":\"20230512105200844\",\"inf_refmsgid\":\"440000202305121052005628764116\"}"; //记录回参日志 LogHelper.doJsonRequestLog("api_2402出院办理", strReq, strRes, stime); try { Api2402result = JsonConvert.DeserializeObject(strRes); } catch (Exception ex) { Api2402result.Msg = ex.Message; } return Api2402result; } /// /// 住院预结算 /// /// /// public static Api2303Result api_2303(Api2303Request request) { //入参 string strReq = ""; //回参 string strRes = ""; //调用时间 DateTime stime = DateTime.Now; //输出回参 Api2303Result Api2303result = new Api2303Result(); string signNo = api_9001(); //测试 //string signNo = "签到成功"; if ("".Equals(signNo)) { Api2303result.Msg = "签到出错"; return Api2303result; } //签到报文注入 request.sign_no = signNo; strReq = JsonConvert.SerializeObject(request); strRes = Http.HttpPostByHeader(GdsiConfig.server_url + "2303", strReq); //测试数据 //strRes = "{\"output\":{\"setlinfo\":{\"setl_time\":null,\"cvlserv_pay\":1856.42,\"hifdm_pay\":0.0,\"insu_admdvs\":\"441803\",\"med_type\":\"21\",\"psn_pay\":1664.11,\"exp_content\":null,\"begndate\":null,\"hifmi_pay\":0.0,\"psn_no\":\"44181000000005419247\",\"act_pay_dedc\":1200.0,\"medins_setl_id\":\"H44180200009202305121052040104\",\"acct_mulaid_pay\":0,\"clr_way\":null,\"oth_pay\":0.0,\"cashPayamt\":1664.11,\"gend\":\"2\",\"mdtrt_id\":\"563854134\",\"acct_pay\":0.0,\"dedc_std\":1200.0,\"setl_type\":null,\"crt_dedc\":0.0,\"inscp_scp_amt\":12272.57,\"insutype\":\"310\",\"invono\":null,\"psn_part_amt\":1664.11,\"enddate\":null,\"psn_type\":\"12\",\"hifp_pay\":10076.04,\"overlmt_selfpay\":101.5,\"preselfpay_amt\":626.08,\"clr_type\":\"21\",\"othfund_pay\":0.0,\"cvlserv_flag\":\"1\",\"mdtrt_cert_no\":\"441802196912200045\",\"brdy\":\"1969-12-20\",\"naty\":\"01\",\"psn_cash_pay\":1664.11,\"certno\":\"441802196912200045\",\"mdtrt_cert_type\":\"02\",\"balc\":0.0,\"psn_cert_type\":\"01\",\"hifob_pay\":0.0,\"ownpay_hosp_part\":0,\"inscp_amt\":12272.57,\"medfee_sumamt\":13596.57,\"hifes_pay\":0.0,\"fund_pay_sumamt\":11932.46,\"fulamt_ownpay_amt\":596.42,\"hosp_part_amt\":0,\"setl_id\":null,\"maf_pay\":0.0,\"psn_name\":\"陈佩雯\",\"psn_insu_rlts_id\":\"44181000000025111770\",\"clr_optins\":null,\"pool_prop_selfpay\":0.91,\"age\":53.0},\"setldetail\":[{\"fund_pay_type\":\"310100\",\"fund_payamt\":10076.04,\"setl_proc_info\":null,\"crt_payb_lmt_amt\":null,\"inscp_scp_amt\":12272.57,\"fund_pay_type_name\":\"职工基本医疗统筹基金\"},{\"fund_pay_type\":\"320100\",\"fund_payamt\":1856.42,\"setl_proc_info\":null,\"crt_payb_lmt_amt\":null,\"inscp_scp_amt\":12272.57,\"fund_pay_type_name\":\"公务员补助基金\"}]},\"infcode\":0,\"warn_msg\":null,\"cainfo\":null,\"err_msg\":null,\"refmsg_time\":\"20230512105204224\",\"signtype\":null,\"respond_time\":\"20230512105207686\",\"inf_refmsgid\":\"440000202305121052075628758699\"}"; //记录回参日志 LogHelper.doJsonRequestLog("api_2303住院预结算", strReq, strRes, stime); try { Api2303result = JsonConvert.DeserializeObject(strRes); } catch (Exception ex) { Api2303result.Msg = ex.Message; } return Api2303result; } /// /// 住院正式结算 /// /// /// public static Api2304Result api_2304(Api2304Request request) { //入参 string strReq = ""; //回参 string strRes = ""; //调用时间 DateTime stime = DateTime.Now; //输出回参 Api2304Result Api2304result = new Api2304Result(); string signNo = api_9001(); //测试 //string signNo = "签到成功"; if ("".Equals(signNo)) { Api2304result.Msg = "签到出错"; return Api2304result; } //签到报文注入 request.sign_no = signNo; strReq = JsonConvert.SerializeObject(request); strRes = Http.HttpPostByHeader(GdsiConfig.server_url + "2304", strReq); //测试数据 //strRes = "{\"output\":{\"setlinfo\":{\"setl_time\":\"2023-05-12 10:52:08\",\"cvlserv_pay\":1856.42,\"hifdm_pay\":0.0,\"cvlserv_flag\":\"0\",\"med_type\":\"21\",\"exp_content\":null,\"brdy\":\"1969-12-20\",\"naty\":\"01\",\"psn_cash_pay\":1664.11,\"certno\":\"441802196912200045\",\"hifmi_pay\":0.0,\"psn_no\":\"44181000000005419247\",\"act_pay_dedc\":1200.0,\"mdtrt_cert_type\":\"02\",\"balc\":0.0,\"medins_setl_id\":\"H44180200009202305121052040105\",\"psn_cert_type\":\"01\",\"acct_mulaid_pay\":0,\"clr_way\":\"40\",\"hifob_pay\":0.0,\"oth_pay\":0.0,\"ownpay_hosp_part\":0,\"medfee_sumamt\":13596.57,\"hifes_pay\":0.0,\"gend\":\"2\",\"mdtrt_id\":\"563854134\",\"acct_pay\":0.0,\"fund_pay_sumamt\":11932.46,\"fulamt_ownpay_amt\":596.42,\"hosp_part_amt\":0,\"setl_id\":\"483069865\",\"inscp_scp_amt\":12272.57,\"insutype\":\"310\",\"maf_pay\":0.0,\"psn_name\":\"陈佩雯\",\"psn_part_amt\":1664.11,\"clr_optins\":\"441802\",\"pool_prop_selfpay\":0.91,\"psn_type\":\"12\",\"hifp_pay\":10076.04,\"overlmt_selfpay\":101.5,\"preselfpay_amt\":626.08,\"age\":53.0,\"clr_type\":\"21\"},\"setldetail\":[{\"fund_pay_type\":\"310100\",\"fund_payamt\":10076.04,\"setl_proc_info\":null,\"crt_payb_lmt_amt\":null,\"inscp_scp_amt\":12272.57,\"fund_pay_type_name\":\"职工基本医疗统筹基金\"},{\"fund_pay_type\":\"320100\",\"fund_payamt\":1856.42,\"setl_proc_info\":null,\"crt_payb_lmt_amt\":null,\"inscp_scp_amt\":12272.57,\"fund_pay_type_name\":\"公务员补助基金\"}]},\"infcode\":0,\"warn_msg\":null,\"cainfo\":null,\"err_msg\":null,\"refmsg_time\":\"20230512105207961\",\"signtype\":null,\"respond_time\":\"20230512105211872\",\"inf_refmsgid\":\"440000202305121052115628755955\"}"; //记录回参日志 LogHelper.doJsonRequestLog("api_2304住院正式结算", strReq, strRes, stime); try { Api2304result = JsonConvert.DeserializeObject(strRes); } catch (Exception ex) { Api2304result.Msg = ex.Message; } return Api2304result; } } }