public bool EnviaBundle(RndsBundle bundle) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls; ServicePointManager.Expect100Continue = true; ServicePointManager.ServerCertificateValidationCallback = (a, b, c, d) => { return(true); }; try { var http = (HttpWebRequest)WebRequest.Create($"{UrlEnvioBundle}"); http.KeepAlive = true; http.Accept = "*.*"; http.Method = "POST"; http.ContentType = "application/json"; http.ServerCertificateValidationCallback = (a, b, c, d) => { return(true); }; string bundleJson = bundle.GetJsonString(); var bundleBytes = Encoding.UTF8.GetBytes(bundleJson); http.ContentLength = bundleBytes.Length; using (var sw = http.GetRequestStream()) { sw.Write(bundleBytes, 0, bundleBytes.Length); sw.Flush(); } using (var resp = (HttpWebResponse)http.GetResponse()) { if (resp.StatusCode == HttpStatusCode.Created) { bundle.ContentLocation = resp.Headers[HttpResponseHeader.ContentLocation]; return(true); } } } catch (Exception ex) { } return(false); }
private void button2_Click(object sender, EventArgs e) { var bundle = new RndsBundle(); var id = "b01b7081ecc348c194e797d0399d83a2"; // Guid.NewGuid().ToString("N"); bundle.BundleId = id; bundle.BundleIdValue = id; bundle.AuthorId = "00394544000185"; bundle.PatientId = "700500572752652"; bundle.ResultValueType = RndsResultValueType.Quantity; bundle.ResultQuantityValue = 2; bundle.ResultQualityValue = ""; bundle.ReferenceRange = "1 - Detectável; 2 - Não detectável; 3 - Inconclusivo"; bundle.SUSGroup = "0202"; bundle.ExamCode = "94507-1"; bundle.Method = "Imunoensaio enz."; var cl = new Hl7Client(); cl.EnviaBundle(bundle); }