his接口

最近開發一個醫院信息系統的接口
首先是醫療的基本知識 門診 醫生 科室 費用 藥品,這些都是在數據庫裏。
須要兩個接口一個是手機端 一個是其餘平臺進行轉診html

 

主要的技術是這些
手機端主要是
webservices TaoguWebService.asmx
主要就是 我提供接口
1 從傳入的json 獲得傳入實體類 
2 經過傳入實體類在sql中查詢
3 查詢結果給傳出的實體類 轉化成json返回

       /// <summary>
        /// 1.13 BSC_013 查詢病人就診信息 ok
        /// </summary>
        /// <param name="HospitalID"></param>
        /// <returns></returns>
        [WebMethod]
        public string getPatientStatus(string hospitalId, string jsonparams)
        {
            hospitalId = getHospitalId(hospitalId);

            var inObject = JsonConvert.DeserializeObject<Invisit>(jsonparams);

            if (inObject == null)
            {
                var jon1 = new { code = "1", codeDesc = "請傳HIS系統中的患者Id" };
                string json1 = JsonConvert.SerializeObject(jon1);
                return json1;
            }
            else
            {
                if (string.IsNullOrEmpty(inObject.patientIdFromHIS) &&
                    (string.IsNullOrEmpty(inObject.timeStart) || string.IsNullOrEmpty(inObject.timeEnd)))
                {
                    var jon1 = new { code = "1", codeDesc = "請傳HIS系統中的患者Id" };
                    string json1 = JsonConvert.SerializeObject(jon1);
                    return json1;
                }
            }

            var dt = TaoguBLL.getPatientStatus(hospitalId, inObject.patientIdFromHIS, inObject.timeStart, inObject.timeEnd);

            List<OutVisit> ls = new List<OutVisit>();
            foreach (System.Data.DataRow dr in dt.Rows)
            {
                OutVisit outObject = new OutVisit();
                outObject.hospitalIdFromHIS = dr["HospitalID"].ToString();
                outObject.patientIdFromHis = dr["PatientID"].ToString();
                outObject.name = dr["PatientName"].ToString();
                outObject.regServiceNo = dr["visitNo"].ToString();
                outObject.deptIdFromHIS = dr["Dept"].ToString();

                outObject.deptName = dr["DeptName"].ToString();
                outObject.doctorIdFromHIS = dr["Doctor"].ToString();
                outObject.doctorName = dr["Name"].ToString();
                outObject.regServiceType = dr["title"].ToString();
                outObject.regDate = dr["VisitDate"].ToString();

                outObject.patientStatus = dr["RegistStatus"].ToString();
                outObject.regLoc = "";

                ls.Add(outObject);
            }
            var jon = new { ListPatientStatus = ls };
            string json = JsonConvert.SerializeObject(jon);
            return json;

            //string json = JsonConvert.SerializeObject(ls);
            //return json;
        }

其餘平臺主要是對xml的解析 主要是我調用其餘平臺接口
HandlerSXZZ.ashx
1 從html端獲得入參 調用cs代碼
2 入參轉化成對象 對象再轉化成xml 調用別人的webservice
3 返回的xml 轉化成json 返回給html
4 js將返回的json轉化成js對象 修改界面

function a() {
                                            //debugger;


                                            b = $("#ZZBH").val();
                                            if (!b) {
                                                alert("請填寫編號");
                                                return;
                                            }

                                            var obj = {};
                                            obj.ZZBH = b;

                                            c = Sys.Serialization.JavaScriptSerializer.serialize(obj);

                                            $.ajax({
                                                type: "post",
                                                url: "../WebService/ReferralService/HandlerSXZZ.ashx",
                                                data: { dowork: "cxhzzzxx", indata: c },
                                                dataType: "text",
                                                beforeSend: function (XMLHttpRequest) {

                                                },
                                                complete: function () { },
                                                success: function (data) {
                                                    //alert(data);
                                                    //debugger;
                                                    var Outdata = Sys.Serialization.JavaScriptSerializer.deserialize(data);
                                                    var Outcxhzzzxx = Outdata.response.DUALREFERRALNEW;
                                                    //alert(Outcxhzzzxx.HZXXXM);

                                                    //姓名
                                                    $("#txt_Name").val(Outcxhzzzxx.HZXXXM);
                                                    //病人ID
                                                    $("#txt_PatientID").val(Outcxhzzzxx.HZZSYH);
                                                    //轉出機構
                                                    $("#txt_TransferHospital").val(Outcxhzzzxx.ZCYLJGZZJGMC);
                                                    //轉出醫生
                                                    $("#txt_TransferDoctor").val(Outcxhzzzxx.ZZYSMC);

                                                },
                                                error: function (XMLHttpRequest, textStatus, errorThrown) {
                                                    alert(XMLHttpRequest.responseText);
                                                }
                                            });

                                        }

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");

            //dcInfo dcinfo = new ReferralService.dcInfo();

            dcMsg dcmsg = new ReferralService.dcMsg();

            //ImplementSXZZ interfaceSXZZ = new ImplementSXZZ();
            ImplementTest interfaceSXZZ = new ImplementTest();

            string indata = context.Request["indata"].ToString();

            switch (context.Request["dowork"].ToString())
            {
                case "cxhzzzxx":
                    var indcInfo = JsonConvert.DeserializeObject<Incxhzzzxx>(indata);
                    //var indcMsg = JsonConvert.DeserializeObject<Incxhzzzxx>(indata);

                    var dcInfo = new { request = new { objectList = new { DUALREFERRALNEW = indcInfo } } };

                    var json = JsonConvert.SerializeObject(dcInfo);

                    var indcinfo = CommonSXZZ.Json2Xml(json);

                    dcmsg.bussinessCode = "DR_011";
                    var dcMsg = new { request = new { header = dcmsg } };
                    //dcinfo.DUALREFERRALNEW = inObject;

                    json = JsonConvert.SerializeObject(dcMsg);
                    var indcmsg = CommonSXZZ.Json2Xml(json);

                    //調用主方法
                    string returnjson = interfaceSXZZ.cxhzzzxx(indcmsg, indcinfo);

                    string returnstring = CommonSXZZ.Xml2Json(returnjson);

                    context.Response.Write(returnstring);

                    break;

                default:
                    break;
            }
        }

    public class CommonSXZZ
    {

        public static string Json2Xml(string sJson)
        {

            XmlDocument doc2 = JsonConvert.DeserializeXmlNode(sJson);
            return doc2.InnerXml.ToString();

        }
        public static string Xml2Json(string xml)
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);
            string json = Newtonsoft.Json.JsonConvert.SerializeXmlNode(doc);
            return json;
        }


    }
相關文章
相關標籤/搜索