public static async Task<List<Medication>> GetMedicationDataForPatientAsync(string patientId, FhirClient client) { var mySearch = new SearchParams(); mySearch.Parameters.Add(new Tuple<string, string>("patient", patientId)); try { //Query the fhir server with search parameters, we will retrieve a bundle var searchResultResponse = await Task.Run(() => client.Search<Hl7.Fhir.Model.MedicationOrder>(mySearch)); //There is an array of "entries" that can return. Get a list of all the entries. return searchResultResponse .Entry .AsParallel() //as parallel since we are making network requests .Select(entry => { var medOrders = client.Read<MedicationOrder>("MedicationOrder/" + entry.Resource.Id); var safeCast = (medOrders?.Medication as ResourceReference)?.Reference; if (string.IsNullOrWhiteSpace(safeCast)) return null; return client.Read<Medication>(safeCast); }) .Where(a => a != null) .ToList(); //tolist to force the queries to occur now } catch (AggregateException e) { throw e.Flatten(); } catch (FhirOperationException) { // if we have issues we likely got a 404 and thus have no medication orders... return new List<Medication>(); } }
public void TestUpdate() { ResourceIdentity identity1 = ResourceIdentity.Build("Patient", "2"); ResourceIdentity identity2 = ResourceIdentity.Build("Device", "2"); ResourceIdentity identity3 = ResourceIdentity.Build("Observation", "2"); try { Patient patient = fhirClient.Read <Patient>(identity1); Assert.Fail(); } catch (Exception ex) { Assert.IsTrue(ex.Message.Contains("Operation was unsuccessful, and returned status 403")); } try { Device device = fhirClient.Read <Device>(identity2); Assert.Fail(); } catch (Exception ex) { Assert.IsTrue(ex.Message.Contains("Operation was unsuccessful, and returned status 403")); } try { Observation observation = fhirClient.Read <Observation>(identity3); Assert.Fail(); } catch (Exception ex) { Assert.IsTrue(ex.Message.Contains("Operation was unsuccessful, and returned status 403")); } }
public ActionResult ShowPatientVersion(string id) { var conn = new FhirClient("http://localhost:8080/baseR4"); conn.PreferredFormat = ResourceFormat.Json; Patient patient = conn.Read <Patient>("Patient/" + id); var patientList = new List <PatientEdit>(); PatientEdit newPatient = new PatientEdit(); newPatient.surname = patient.Name[0].Family; newPatient.birthDate = patient.BirthDate; newPatient.mStatus = patient.MaritalStatus.Text; newPatient.id = patient.Id; newPatient.version = patient.Meta.VersionId; int versions = int.Parse(newPatient.version); for (int i = 1; i <= versions; i++) { PatientEdit vPatient = new PatientEdit(); UriBuilder uriBuilder = new UriBuilder("http://localhost:8080/baseR4"); uriBuilder.Path = "Patient/" + id + "/_history/" + i; Patient resultResource = conn.Read <Patient>(uriBuilder.Uri); vPatient.surname = resultResource.Name[0].Family; vPatient.birthDate = resultResource.BirthDate; vPatient.mStatus = resultResource.MaritalStatus.Text; vPatient.version = resultResource.Meta.VersionId; vPatient.modDate = Convert.ToDateTime(resultResource.Meta.LastUpdated.ToString()); patientList.Add(vPatient); } return(View(patientList)); }
public void Read() { FhirClient client = new FhirClient(testEndpoint); var loc = client.Read<Location>("Location/1"); Assert.IsNotNull(loc); Assert.AreEqual("Den Burg", loc.Resource.Address.City); string version = new ResourceIdentity(loc.SelfLink).VersionId; Assert.IsNotNull(version); string id = new ResourceIdentity(loc.Id).Id; Assert.AreEqual("1", id); try { var random = client.Read(new Uri("Location/45qq54", UriKind.Relative)); Assert.Fail(); } catch (FhirOperationException) { Assert.IsTrue(client.LastResponseDetails.Result == HttpStatusCode.NotFound); } var loc2 = client.Read<Location>(ResourceIdentity.Build("Location","1", version)); Assert.IsNotNull(loc2); Assert.AreEqual(FhirSerializer.SerializeBundleEntryToJson(loc), FhirSerializer.SerializeBundleEntryToJson(loc2)); var loc3 = client.Read<Location>(loc.SelfLink); Assert.IsNotNull(loc3); Assert.AreEqual(FhirSerializer.SerializeBundleEntryToJson(loc), FhirSerializer.SerializeBundleEntryToJson(loc3)); }
public void XmlAccept() { client.PreferredFormat = ContentType.ResourceFormat.Xml; client.UseFormatParam = false; client.Read <Patient>("1"); HttpTests.AssertResourceResponseConformsTo(client, client.PreferredFormat); }
public void WhenResourceRead() { var createdModelOnTheServer = _fhirClient.Create(_observation); var domainResource = _fhirClient.Read <DomainResource>($"{_observation.GetType().Name}/{createdModelOnTheServer.Id}"); Assert.NotNull(domainResource); AssertHelper.CheckStatusCode(HttpStatusCode.OK, _fhirClient.LastResult.Status); }
public ActionResult ShowResourceVersion(string rId, string id) { var conn = new FhirClient("http://localhost:8080/baseR4"); conn.PreferredFormat = ResourceFormat.Json; Patient patient = conn.Read <Patient>("Patient/" + id); UriBuilder uriBuilder = new UriBuilder("http://localhost:8080/baseR4"); uriBuilder.Path = "Patient/" + patient.Id; Resource resultResource = conn.InstanceOperation(uriBuilder.Uri, "everything"); var resourceList = new List <Details>(); if (resultResource is Bundle) { Bundle resultBundle = resultResource as Bundle; while (resultBundle != null) { foreach (var i in resultBundle.Entry) { Details element = new Details(); switch (i.Resource.TypeName) { case "Observation": Observation observation = (Observation)i.Resource; if (observation.Id == rId) { element.id = observation.Id; element.resourceName = "Observation"; element.reason = observation.Code.Text; element.version = observation.Meta.VersionId; int versions = int.Parse(element.version); for (int j = 1; j <= versions; j++) { Details vPatient = new Details(); UriBuilder uriBuilder1 = new UriBuilder("http://localhost:8080/baseR4"); uriBuilder1.Path = "Observation/" + element.id + "/_history/" + j; Observation resultResource1 = conn.Read <Observation>(uriBuilder1.Uri); vPatient.id = resultResource1.Id; vPatient.reason = resultResource1.Code.Text; vPatient.date = Convert.ToDateTime(resultResource1.Effective.ToString()); vPatient.version = resultResource1.Meta.VersionId; vPatient.modDate = Convert.ToDateTime(resultResource1.Meta.LastUpdated.ToString()); resourceList.Add(vPatient); } } break; } } resultBundle = conn.Continue(resultBundle, PageDirection.Next); } } return(View(resourceList)); }
public void GetTestDataPerson() { var pat = client.Read <Patient>("1"); HttpTests.AssertHttpOk(client); HttpTests.AssertValidResourceContentTypePresent(client); HttpTests.AssertLastModifiedPresent(client); HttpTests.AssertContentLocationPresentAndValid(client); }
public string GetMedicationOrder(string medicationOrderID) { var medicationOrderResource = fhirClient.Read <Hl7.Fhir.Model.MedicationOrder>("MedicationOrder/" + medicationOrderID); string returnName = String.Empty; // medicationOrderResource.Medication = new CodeableConcept(); //var test = medicationOrderResource.Medication.GetExtensionValue<Coding>("medicationCodeableConcept"); //The difficulty here is that this is considered a custom element and there is no model for it. //So just return the patient the resource is bound to return(medicationOrderResource.Patient.Reference); }
protected void Page_Load(object sender, EventArgs e) { var client = new FhirClient("http://spark.furore.com/fhir"); var patient = client.Read<Patient>("Patient/1"); lblFirstPatient.Text = String.Concat("Identifier : ", patient.Resource.Identifier.First<Identifier>().Value); var obeservation = client.Read<Patient>("Patient/1"); lblFirstObservation.Text = String.Concat("Identifier : ", obeservation.Resource.Identifier.First<Identifier>().Value); //pat.Resource.Name.Add(HumanName.ForFamily("Kramer") // .WithGiven("Ewout")); //client.Update<Patient>(pat); }
public async Task <PatientModel> PatientByIdAsync(Action <Exception> errorAction, string patientId) { return(await Task.Run(() => { try { return new PatientModel(client.Read <Patient>($"Patient/{patientId}")); } catch (Exception e) { DispatcherHelper.CheckBeginInvokeOnUI(() => errorAction(e)); return null; } })); }
public void ReadRelative() { FhirClient client = new FhirClient(testEndpoint); var loc = client.Read <Location>(new Uri("Location/1", UriKind.Relative)); Assert.IsNotNull(loc); Assert.AreEqual("Den Burg", loc.Address.City); var ri = ResourceIdentity.Build(testEndpoint, "Location", "1"); loc = client.Read <Location>(ri); Assert.IsNotNull(loc); Assert.AreEqual("Den Burg", loc.Address.City); }
public static Patient ReadPatient(string patientId) { Patient responsePatient = new Patient(); try { LogToFile("Read Patient"); string location = $"Patient/{patientId}"; LogToFile("Request: \n\n" + location); FhirClient fhirClient = new FhirClient(FhirClientEndPoint); responsePatient = fhirClient.Read <Patient>(location); LogToFile("Response: "); var responsePatientXml = FhirSerializer.SerializeResourceToXml(responsePatient); LogToFile(XDocument.Parse(responsePatientXml).ToString()); } catch (Exception ex) { LogToFile(ex.ToString()); } return(responsePatient); }
public Model.Resource ReadResourceArtifact(Uri artifactId) { if (artifactId == null) { throw Error.ArgumentNull("artifactId"); } if (!artifactId.IsAbsoluteUri) { Error.Argument("artifactId", "Uri must be absolute"); } var id = new ResourceIdentity(artifactId); var client = new FhirClient(id.Endpoint); client.Timeout = 5000; //ms try { var artifactEntry = client.Read(id); return(artifactEntry != null ? artifactEntry.Resource : null); } catch { return(null); } }
public void CallsCallbacks() { FhirClient client = new FhirClient(testEndpoint); bool calledBefore = false; HttpStatusCode?status = null; Resource res = null; Bundle.BundleEntryTransactionResponseComponent interaction = null; client.OnBeforeRequest += (sender, e) => calledBefore = true; client.OnAfterResponse += (sender, e) => { res = e.Resource; status = e.RawResponse.StatusCode; interaction = e.Interaction; }; client.Read <Patient>("Patient/1"); Assert.IsTrue(calledBefore); Assert.IsNotNull(status); Assert.IsNotNull(res); Assert.IsTrue(res is Patient); Assert.IsTrue(interaction.GetBodyAsText().Contains("<Patient")); Assert.AreEqual("application/xml+fhir; charset=UTF-8", interaction.GetHeaders().Single(t => t.Item1 == "Content-Type").Item2); }
/// <summary> /// Setting Global Patient object _patientInfo /// </summary> public void InitialisePatient(string id) { try { isExceptionEncountered = false; Patient pt = _fc.Read <Patient>(ResourceIdentity.Build("Patient", id)); Generalinformation = new PDInformation(pt); setPatientDetectedIssues(); getPatientAllergies(); getPatientCurrentConditions(); } catch (FhirOperationException foe) { isExceptionEncountered = true; ExceptionIssues = foe.Outcome.Issue; } catch (Exception ex) { isExceptionEncountered = true; OperationOutcome.IssueComponent ic = new OperationOutcome.IssueComponent(); ic.Diagnostics = ex.Message; ExceptionIssues.Add(ic); } }
// Let's request the conformance statement from the SMART on FHIR API server and // find out the endpoint URLs for the authorization server //public ActionResult FraminghamCalculator(CernerFullConnectionInformationViewModel cfcivm) //Models.ViewModels.Patient viewPatient) public FraminghamCalculatorViewModel FraminghamCalculator(CernerFullConnectionInformationViewModel cfcivm) //Models.ViewModels.Patient viewPatient) { ViewBag.Message = "Framingham Calculator"; var client = new FhirClient(cfcivm.ServiceUrl) { PreferredFormat = ResourceFormat.Json };; client.OnBeforeRequest += (object sender, BeforeRequestEventArgs e) => { e.RawRequest.Headers.Add("Authorization", "Bearer " + cfcivm.AccessToken); }; var identity = ResourceIdentity.Build("Patient", cfcivm.PatientId); Hl7.Fhir.Model.Patient viewPatient = client.Read <Hl7.Fhir.Model.Patient>(identity); //Get those values we don't know how to retrive yet. FraminghamCalculatorPatient Fcp = PhillFCM(0); Fcp.LastName = viewPatient.Name[viewPatient.Name.Count - 1].FamilyElement[0].ToString(); Fcp.FirstName = viewPatient.Name[viewPatient.Name.Count - 1].GivenElement[0].ToString(); Fcp.Gender = viewPatient.Gender.ToString(); Fcp.Age = Convert.ToDateTime(viewPatient.BirthDate).Age(); #region Get HDL //Now we get some real data like the HDL FraminghamCalculator fc = new FraminghamCalculator(Fcp); fc.FhirClient = client; string loinc_hdl = "2085-9"; string loinc_ldl = "13457-7"; string loinc_Cholesterol_Total = "9830-1"; string loinc_cholesterol = "2093-3"; string loinc_Triglycerides = "2571-8"; string loinc_SystolicBP = "8480-6"; string loinc_DiastolicBP = "8462-4"; BloodPressureValue bpv = fc.GetLatestBloodPressureValue(cfcivm.PatientId, loinc_SystolicBP); CholesterolValue cv_hdl = fc.GetLatestCholesterolValue(cfcivm.PatientId, loinc_hdl); CholesterolValue cv_total = fc.GetLatestCholesterolValue(cfcivm.PatientId, loinc_cholesterol); #endregion Get HDL Fcp.SystolicBP = (int)bpv.Value; Fcp.HDL = (int)cv_hdl.Value; Fcp.TotalCholesterol = (int)cv_total.Value; FraminghamCalculatorViewModel vm = new FraminghamCalculatorViewModel(); vm.FraminghamScore = fc.DoCalculation(); vm.FCM = Fcp; return(vm); }
public void CreateAndFullRepresentation() { FhirClient client = new FhirClient(testEndpoint); client.ReturnFullResource = true; // which is also the default var pat = client.Read <Patient>("Patient/example"); pat.Id = null; pat.Identifier.Clear(); var patC = client.Create <Patient>(pat); Assert.IsNotNull(patC); client.ReturnFullResource = false; patC = client.Create <Patient>(pat); Assert.IsNull(patC); if (client.LastBody != null) { var returned = client.LastBodyAsResource; Assert.IsTrue(returned is OperationOutcome); } }
public Patient GetClient() { FhirClient client = new FhirClient("http://localhost:54240/"); // http://vonk.fire.ly Patient patient = client.Read <Patient>("Patient/rvrbk"); // Patient/example return(patient); }
public void Boundary_HL7FHIR_REST() { var client = new FhirClient("https://aseecest3fhirservice.azurewebsites.net/"); //var k = new Fhir //client.PreferredFormat = ResourceFormat.Unknown; // client.UseFormatParam = true; //depends on the sever format in url or in header (default) // client.ReturnFullResource = false; //Give minimal response client.Timeout = 120000; // The timeout is set in milliseconds, with a default of 100000 //var location_A = new Uri("https://vonk.fire.ly/Patient/58689c4c-daf4-450b-a1ca-7c1846bb65b5"); //var pat_A = client.Read<Patient>(location_A); // or //var pat_A = client.Read<Patient>("Patient/58689c4c-daf4-450b-a1ca-7c1846bb65b5"); var pat_A = client.Read <Patient>("Patient/5425b28a-7d57-4edb-9700-58bbecc52fc1"); //b46b6f29-fb93-4929-a760-ee722cb37f94 // Read a specific version of a Patient resource with technical id '32' and version id '4' //var location_B = new Uri("http://vonk.fire.ly/Patient/32/_history/4"); //var pat_B = client.Read<Patient>(location_B); // or //var pat_B = client.Read<Patient>("Patient/32/_history/4"); var pat_C = makeAPatient();//Go to makeAPAtient at study the code setting up at HL7 FHIR Patient! //pat_C.Telecom = pat_A.Telecom; //The client.Create call below will throw an exception Hint se error.txt file // Your error correcting code // goes here !! Requires some knowlegde about Patient class! var created_pat = client.Create(pat_C); //After succesfully Create, retrive the patient ID from created_pat, and use the ID to retrieve the patient in Postman/AdvancedRESTClient // client.Delete(created_pat);//Clean up the test. Check result in Postman/AdvancedRESTClient }
public Patient ReadHl7FHIRPatientByID(string id) { var location = new Uri("https://aseecest3fhirservice.azurewebsites.net/Patient/" + id); var patient = client.Read <Patient>(location); return(patient); }
public IEnumerable <Patient> GetAllPatients() { var patients = new List <Patient>(); var patientsExist = true; var i = 1; while (patientsExist) { try { var patient = _client.Read <Patient>(i.ToString()); patients.Add(patient.Resource); i++; } catch (FhirOperationException) { patientsExist = false; } } return(patients); }
public ActionResult EditMedicationRequest([Bind] EditMedicationRequest request, string patientID) { bool status = false; string Message = ""; //SPRAWDZENIE DANYCH if (ModelState.IsValid) { //PODŁĄCZENIE KLIENTA var client = new FhirClient("http://localhost:8080/baseR4"); client.PreferredFormat = ResourceFormat.Json; //PRZEKAZANIE DANYCH MedicationRequest original = client.Read <MedicationRequest>("MedicationRequest/" + request.ID); (original.Medication as CodeableConcept).Text = request.Reason; Dosage dosage = new Dosage(); dosage.Text = request.Instruction; original.DosageInstruction.Add(dosage); //UPDATE client.Update(original); Message = "Your item successfully UPDATE"; status = true; } else { Message = "You haven't got right model"; } ViewBag.ID = patientID; ViewBag.Status = status; ViewBag.Message = Message; return(View(request)); }
public static IElementNavigator GetPatient(string id) { var client = new FhirClient("http://vonk.furore.com"); var patient = client.Read <Patient>($"Patient/{id}"); return(patient.GetNavigator()); }
public ActionResult EditMedicationRequest(string id, string type, string patientID) { //POŁĄCZENIE Z KLIENTEM var client = new FhirClient("http://localhost:8080/baseR4"); client.PreferredFormat = ResourceFormat.Json; ViewBag.ID = patientID; if (type == "MedicationRequest") { //WYSZUKANIE ZASOBU MedicationRequest request = client.Read <MedicationRequest>("MedicationRequest/" + id); EditMedicationRequest mrequest = new EditMedicationRequest(); //PRZEKAZANIE DANYCH mrequest.Reason = (request.Medication as CodeableConcept).Text; if (request.DosageInstruction.Count() > 0) { mrequest.Instruction = request.DosageInstruction[0].Text; } else { mrequest.Instruction = ""; } mrequest.ID = request.Id; return(View(mrequest)); } ViewBag.Message = "Some Error until Redirect"; return(View()); }
public ActionResult EditPatient(string id, string type) { //PODŁĄCZENIE KLIENTA var client = new FhirClient("http://localhost:8080/baseR4"); client.PreferredFormat = ResourceFormat.Json; ViewBag.ID = id; if (type == "Patient") { //WYSZUKANIE ZASOBU Patient patient = client.Read <Patient>("Patient/" + id); EditPatient myPatient = new EditPatient(); //PRZEKAZANIE DANYCH myPatient.Name = patient.Name[0].Given.FirstOrDefault(); myPatient.Surname = patient.Name[0].Family; myPatient.Address = patient.Address[0].Text; myPatient.ID = patient.Id; return(View(myPatient)); } ViewBag.Message = "Some Error until Redirect"; return(View()); }
//id - od którego id zacząć szukać pacjenta (niektóre id zawierają puste elementy) //direction - 1: zwiększaj id -1: zmniejszaj id public Patient patientById(int id, int direction) { String url = FhirClientEndPoint + "Patient/" + id; Patient patient = null; Boolean gotPatient = false; while (!gotPatient) { try { patient = _client.Read <Patient>(url); gotPatient = true; } catch (Hl7.Fhir.Rest.FhirOperationException) { id = id + direction * 1; url = FhirClientEndPoint + "Patient/" + id; } catch (System.Net.WebException) { } //pomiń pacjentów, którzy nie mają imienia try { String name = patient.Name.First().Family; } catch (System.NullReferenceException) { id = id + direction * 1; url = FhirClientEndPoint + "Patient/" + id; gotPatient = false; } catch (System.InvalidOperationException) { id = id + direction * 1; url = FhirClientEndPoint + "Patient/" + id; gotPatient = false; } } return(patient); }
private void lstTestResults_SelectedIndexChanged(object sender, EventArgs e) { if (lstTestResults.SelectedItems.Count == 1) { string diagnosticReportId = lstTestResults.SelectedItems[0].Text; string fhirRef = $"DiagnosticReport/{diagnosticReportId}"; DiagnosticReport diagnosticReport = client.Read <DiagnosticReport>(fhirRef); _htmlPanel.Text = diagnosticReport.Text.Div; //cboObservations.Items.Clear(); Dictionary <string, string> obsDictionary = new Dictionary <string, string>(); foreach (Resource resource in diagnosticReport.Contained) { if (resource.TypeName == "Observation") { Observation observation = (Observation)resource; CodeableConcept firstOrDefault = observation.Category.FirstOrDefault(); Coding orDefault = firstOrDefault?.Coding.FirstOrDefault(); if (orDefault != null && (firstOrDefault != null && orDefault.Code == "laboratory")) { string observationCode = observation.Code.Coding.FirstOrDefault().Code; string observationDisplay = observation.Code.Coding.FirstOrDefault().Display; if (!obsDictionary.ContainsKey(observationCode)) { obsDictionary.Add(observationCode, observationDisplay); } } } } cboObservations.DataSource = new BindingSource(obsDictionary, null); cboObservations.DisplayMember = "Value"; cboObservations.ValueMember = "Key"; } }
public void RequestFullResource() { var client = new FhirClient(testEndpoint); var minimal = false; client.OnBeforeRequest += (object s, BeforeRequestEventArgs e) => e.RawRequest.Headers["Prefer"] = minimal ? "return=minimal" : "return=representation"; var result = client.Read <Patient>("Patient/example"); Assert.IsNotNull(result); result.Id = null; result.Meta = null; client.ReturnFullResource = true; minimal = false; var posted = client.Create(result); Assert.IsNotNull(posted, "Patient example not found"); minimal = true; // simulate a server that does not return a body, even if ReturnFullResource = true posted = client.Create(result); Assert.IsNotNull(posted, "Did not return a resource, even when ReturnFullResource=true"); client.ReturnFullResource = false; minimal = true; posted = client.Create(result); Assert.IsNull(posted); }
public void ReadTags() { FhirClient client = new FhirClient(testEndpoint); var tags = new List <Tag>() { new Tag("http://readtag.nu.nl", Tag.FHIRTAGSCHEME_GENERAL, "readTagTest") }; var identity = ResourceIdentity.Build("Location", "1"); client.AffixTags(identity, tags); var affixedEntry = client.Read(identity); IEnumerable <Tag> list; //BP/EK: Our server can't yet do this (as noted above in the history test) // list = client.WholeSystemTags(); // Assert.IsTrue(list.Any(t => t.Equals(tags.First()))); list = client.TypeTags <Location>(); Assert.IsTrue(list.Any(t => t.Equals(tags.First()))); list = client.Tags(affixedEntry.SelfLink); Assert.IsTrue(list.Any(t => t.Equals(tags.First()))); // BP: Furore server having issues with this at present (17 April 2014) // causes the test to fail client.DeleteTags(affixedEntry.SelfLink, tags); //TODO: verify tags have really been removed. Should generate random tag so this is repeatable }
public ActionResult EditObservation([Bind] EditObservation observation, string patientID) //TODO: czy tu nie trzeba exclude czasem? { bool status = false; string Message = ""; //SPRAWDZENIE MODELU if (ModelState.IsValid) { //PODŁĄCZENIE DO KLIENTA var client = new FhirClient("http://localhost:8080/baseR4"); client.PreferredFormat = ResourceFormat.Json; //PRZEKAZANIE DANYCH Observation original = client.Read <Observation>("Observation/" + observation.ID); original.Code.Text = observation.Reason; original.Status = observation.Status; //UPDATE client.Update(original); Message = "Your item successfully UPDATE"; status = true; } else { Message = "You haven't got right model"; } ViewBag.ID = patientID; ViewBag.Status = status; ViewBag.Message = Message; return(View(observation)); }
public async static Task<Tuple<List<Medication>, Hl7.Fhir.Model.Patient>> GetMedicationDetails(string id, ApplicationUserManager userManager) { Tuple<List<Medication>, Hl7.Fhir.Model.Patient> tup; using (var dbcontext = new ApplicationDbContext()) { // Should be FhirID var user = await userManager.FindByIdAsync(id); if (user == null) { return null; } var client = new FhirClient(Constants.HapiFhirServerBase); if (string.IsNullOrWhiteSpace(user.FhirPatientId)) { var result = client.Create(new Hl7.Fhir.Model.Patient() { }); user.FhirPatientId = result.Id; await userManager.UpdateAsync(user); } var patient = client.Read<Hl7.Fhir.Model.Patient>(Constants.PatientBaseUrl + user.FhirPatientId); tup= new Tuple<List<Medication>, Patient>(await EhrBase.GetMedicationDataForPatientAsync(user.FhirPatientId, client), patient); return tup; } }
public void CreateEditDelete() { FhirClient client = new FhirClient(testEndpoint); client.OnBeforeRequest += Compression_OnBeforeRequestZipOrDeflate; // client.CompressRequestBody = true; var pat = client.Read <Patient>("Patient/example"); pat.Id = null; pat.Identifier.Clear(); pat.Identifier.Add(new Identifier("http://hl7.org/test/2", "99999")); var fe = client.Create(pat); // Create as we are not providing the ID to be used. Assert.IsNotNull(fe); Assert.IsNotNull(fe.Id); Assert.IsNotNull(fe.Meta.VersionId); createdTestPatientUrl = fe.ResourceIdentity(); fe.Identifier.Add(new Identifier("http://hl7.org/test/2", "3141592")); var fe2 = client.Update(fe); Assert.IsNotNull(fe2); Assert.AreEqual(fe.Id, fe2.Id); Assert.AreNotEqual(fe.ResourceIdentity(), fe2.ResourceIdentity()); Assert.AreEqual(2, fe2.Identifier.Count); fe.Identifier.Add(new Identifier("http://hl7.org/test/3", "3141592")); var fe3 = client.Update(fe); Assert.IsNotNull(fe3); Assert.AreEqual(3, fe3.Identifier.Count); client.Delete(fe3); try { // Get most recent version fe = client.Read <Patient>(fe.ResourceIdentity().WithoutVersion()); Assert.Fail(); } catch (FhirOperationException ex) { Assert.AreEqual(HttpStatusCode.Gone, ex.Status); //"410" } }
void Start() { var client = new FhirClient("http://hapi.fhir.org/baseR4"); var pat_A = client.Read <Patient>("Patient/1425399"); Debug.Log("TOAN100:" + pat_A.Name[0].Family); s = pat_A.Name[0].Family; }
public void InvokeExpandParameterValueSet() { var client = new FhirClient(testEndpoint); var vs = client.Read<ValueSet>("ValueSet/administrative-gender"); var vsX = client.ExpandValueSet(vs); Assert.IsTrue(vs.Expansion.Contains.Any()); }
public void ReadWithFormat() { FhirClient client = new FhirClient(testEndpoint); client.UseFormatParam = true; client.PreferredFormat = ResourceFormat.Json; var loc = client.Read<Patient>("Patient/1"); Assert.IsNotNull(loc); }
public void ReadWithFormat() { FhirClient client = new FhirClient(testEndpoint); client.UseFormatParam = true; client.PreferredFormat = ResourceFormat.Json; var loc = client.Read("Patient/1"); Assert.AreEqual(ResourceFormat.Json, ContentType.GetResourceFormatFromContentType(client.LastResponseDetails.ContentType)); }
public void ClientForPPT() { var client = new FhirClient(new Uri("http://hl7connect.healthintersections.com.au/svc/fhir/patient/")); // Note patient is a ResourceEntry<Patient>, not a Patient var patEntry = client.Read<Patient>("1"); var pat = patEntry.Resource; pat.Name.Add(HumanName.ForFamily("Kramer").WithGiven("Ewout")); client.Update<Patient>(patEntry); }
public void CreateEditDelete() { var furore = new Organization { Name = "Furore", Identifier = new List<Identifier> { new Identifier("http://hl7.org/test/1", "3141") }, Telecom = new List<Contact> { new Contact { System = Contact.ContactSystem.Phone, Value = "+31-20-3467171" } } }; FhirClient client = new FhirClient(testEndpoint); var tags = new List<Tag> { new Tag("http://nu.nl/testname", Tag.FHIRTAGNS, "TestCreateEditDelete") }; var fe = client.Create(furore,tags); Assert.IsNotNull(furore); Assert.IsNotNull(fe); Assert.IsNotNull(fe.Id); Assert.IsNotNull(fe.SelfLink); Assert.AreNotEqual(fe.Id,fe.SelfLink); Assert.IsNotNull(fe.Tags); Assert.AreEqual(1, fe.Tags.Count()); Assert.AreEqual(fe.Tags.First(), tags[0]); createdTestOrganization = fe.Id; fe.Resource.Identifier.Add(new Identifier("http://hl7.org/test/2", "3141592")); var fe2 = client.Update(fe); Assert.IsNotNull(fe2); Assert.AreEqual(fe.Id, fe2.Id); Assert.AreNotEqual(fe.SelfLink, fe2.SelfLink); Assert.IsNotNull(fe2.Tags); Assert.AreEqual(1, fe2.Tags.Count()); Assert.AreEqual(fe2.Tags.First(), tags[0]); client.Delete(fe2.Id); try { fe = client.Read<Organization>(ResourceLocation.GetIdFromResourceId(fe.Id)); Assert.Fail(); } catch { Assert.IsTrue(client.LastResponseDetails.Result == HttpStatusCode.Gone); } Assert.IsNull(fe); }
public void Read() { FhirClient client = new FhirClient(testEndpoint); var loc = client.Read<Location>("Location/1"); Assert.IsNotNull(loc); Assert.AreEqual("Den Burg", loc.Address.City); Assert.AreEqual("1", loc.Id); Assert.IsNotNull(loc.Meta.VersionId); var loc2 = client.Read<Location>(ResourceIdentity.Build("Location", "1", loc.Meta.VersionId)); Assert.IsNotNull(loc2); Assert.AreEqual(loc2.Id, loc.Id); Assert.AreEqual(loc2.Meta.VersionId, loc.Meta.VersionId); try { var random = client.Read<Location>(new Uri("Location/45qq54", UriKind.Relative)); Assert.Fail(); } catch (FhirOperationException) { Assert.AreEqual(HttpStatusCode.NotFound.ToString(), client.LastResult.Status); } var loc3 = client.Read<Location>(ResourceIdentity.Build("Location", "1", loc.Meta.VersionId)); Assert.IsNotNull(loc3); Assert.AreEqual(FhirSerializer.SerializeResourceToJson(loc), FhirSerializer.SerializeResourceToJson(loc3)); var loc4 = client.Read<Location>(loc.ResourceIdentity()); Assert.IsNotNull(loc4); Assert.AreEqual(FhirSerializer.SerializeResourceToJson(loc), FhirSerializer.SerializeResourceToJson(loc4)); }
public Hl7.Fhir.Model.Resource LoadConformanceResourceByUrl(string url) { if (url == null) throw Error.ArgumentNull("identifier"); var id = new ResourceIdentity(url); var client = new FhirClient(id.BaseUri); client.Timeout = 5000; //ms try { return client.Read<Resource>(id); } catch(FhirOperationException) { return null; } }
private void btnStart_Click(object sender, EventArgs e) { // Choose your preferred FHIR server or add your own // More at http://wiki.hl7.org/index.php?title=Publicly_Available_FHIR_Servers_for_testing //var client = new FhirClient("http://fhir2.healthintersections.com.au/open"); var client = new FhirClient("http://spark.furore.com/fhir"); //var client = new FhirClient("http://fhirtest.uhn.ca/baseDstu2"); //var client = new FhirClient("https://fhir-open-api-dstu2.smarthealthit.org/"); try { var obs = client.Read<Observation>("Observation/example"); txtDisplay.Text = "Observation read, id: " + obs.Id; } catch (Exception err) { txtError.Lines = new string[] { "An error has occurred:", err.Message }; } }
public Model.Resource ReadResourceArtifact(Uri artifactId) { if (artifactId == null) throw Error.ArgumentNull("artifactId"); if (!artifactId.IsAbsoluteUri) Error.Argument("artifactId", "Uri must be absolute"); var id = new ResourceIdentity(artifactId); var client = new FhirClient(id.Endpoint); client.Timeout = 5000; //ms try { var artifactEntry = client.Read(id); return artifactEntry != null ? artifactEntry.Resource : null; } catch { return null; } }
public void CallsCallbacks() { FhirClient client = new FhirClient(testEndpoint); bool calledBefore=false; HttpStatusCode? status=null; byte[] body = null; byte[] bodyOut = null; client.OnBeforeRequest += (sender, e) => { calledBefore = true; bodyOut = e.Body; }; client.OnAfterResponse += (sender, e) => { body = e.Body; status = e.RawResponse.StatusCode; }; var pat = client.Read<Patient>("Patient/1"); Assert.IsTrue(calledBefore); Assert.IsNotNull(status); Assert.IsNotNull(body); var bodyText = HttpToEntryExtensions.DecodeBody(body, Encoding.UTF8); Assert.IsTrue(bodyText.Contains("<Patient")); calledBefore = false; client.Create(pat); Assert.IsTrue(calledBefore); Assert.IsNotNull(bodyOut); bodyText = HttpToEntryExtensions.DecodeBody(body, Encoding.UTF8); Assert.IsTrue(bodyText.Contains("<Patient")); }
public void ManipulateMeta() { FhirClient client = new FhirClient(testEndpoint); var pat = FhirParser.ParseResourceFromXml(File.ReadAllText(@"TestData\TestPatient.xml")); var key = new Random().Next(); pat.Id = "NetApiMetaTestPatient" + key; var meta = new Meta(); meta.ProfileElement.Add(new FhirUri("http://someserver.org/fhir/Profile/XYZ1-" + key)); meta.Security.Add(new Coding("http://mysystem.com/sec", "1234-" + key)); meta.Tag.Add(new Coding("http://mysystem.com/tag", "sometag1-" + key)); pat.Meta = meta; //Before we begin, ensure that our new tags are not actually used when doing System Meta() var wsm = client.Meta(); Assert.IsFalse(wsm.Meta.Profile.Contains("http://someserver.org/fhir/Profile/XYZ1-" + key)); Assert.IsFalse(wsm.Meta.Security.Select(c => c.Code + "@" + c.System).Contains("1234-" + key + "@http://mysystem.com/sec")); Assert.IsFalse(wsm.Meta.Tag.Select(c => c.Code + "@" + c.System).Contains("sometag1-" + key + "@http://mysystem.com/tag")); Assert.IsFalse(wsm.Meta.Profile.Contains("http://someserver.org/fhir/Profile/XYZ2-" + key)); Assert.IsFalse(wsm.Meta.Security.Select(c => c.Code + "@" + c.System).Contains("5678-" + key + "@http://mysystem.com/sec")); Assert.IsFalse(wsm.Meta.Tag.Select(c => c.Code + "@" + c.System).Contains("sometag2-" + key + "@http://mysystem.com/tag")); // First, create a patient with the first set of meta var pat2 = client.Create(pat); var loc = pat2.ResourceIdentity(testEndpoint); // Meta should be present on created patient verifyMeta(pat2.Meta, false,key); // Should be present when doing instance Meta() var par = client.Meta(loc); verifyMeta(par.Meta, false,key); // Should be present when doing type Meta() par = client.Meta(ResourceType.Patient); verifyMeta(par.Meta, false,key); // Should be present when doing System Meta() par = client.Meta(); verifyMeta(par.Meta, false,key); // Now add some additional meta to the patient var newMeta = new Meta(); newMeta.ProfileElement.Add(new FhirUri("http://someserver.org/fhir/Profile/XYZ2-" + key)); newMeta.Security.Add(new Coding("http://mysystem.com/sec", "5678-" + key)); newMeta.Tag.Add(new Coding("http://mysystem.com/tag", "sometag2-" + key)); client.AddMeta(loc, newMeta); var pat3 = client.Read<Patient>(loc); // New and old meta should be present on instance verifyMeta(pat3.Meta, true, key); // New and old meta should be present on Meta() par = client.Meta(loc); verifyMeta(par.Meta, true, key); // New and old meta should be present when doing type Meta() par = client.Meta(ResourceType.Patient); verifyMeta(par.Meta, true, key); // New and old meta should be present when doing system Meta() par = client.Meta(); verifyMeta(par.Meta, true, key); // Now, remove those new meta tags client.DeleteMeta(loc, newMeta); // Should no longer be present on instance var pat4 = client.Read<Patient>(loc); verifyMeta(pat4.Meta, false, key); // Should no longer be present when doing instance Meta() par = client.Meta(loc); verifyMeta(par.Meta, false, key); // Should no longer be present when doing type Meta() par = client.Meta(ResourceType.Patient); verifyMeta(par.Meta, false, key); // clear out the client that we created, no point keeping it around client.Delete(pat4); // Should no longer be present when doing System Meta() par = client.Meta(); verifyMeta(par.Meta, false, key); }
public void CreateEditDelete() { var pat = (Patient)FhirParser.ParseResourceFromXml(File.ReadAllText(@"TestData\TestPatient.xml")); var key = new Random().Next(); pat.Id = "NetApiCRUDTestPatient" + key; FhirClient client = new FhirClient(testEndpoint); var fe = client.Create(pat); Assert.IsNotNull(fe); Assert.IsNotNull(fe.Id); Assert.IsNotNull(fe.Meta.VersionId); createdTestPatientUrl = fe.ResourceIdentity(); fe.Identifier.Add(new Identifier("http://hl7.org/test/2", "3141592")); var fe2 = client.Update(fe); Assert.IsNotNull(fe2); Assert.AreEqual(fe.Id, fe2.Id); Assert.AreNotEqual(fe.ResourceIdentity(), fe2.ResourceIdentity()); Assert.AreEqual(2, fe2.Identifier.Count); fe.Identifier.Add(new Identifier("http://hl7.org/test/3", "3141592")); var fe3 = client.Update(fe); Assert.IsNotNull(fe3); Assert.AreEqual(3, fe3.Identifier.Count); client.Delete(fe3); try { // Get most recent version fe = client.Read<Patient>(fe.ResourceIdentity().WithoutVersion()); Assert.Fail(); } catch { Assert.IsTrue(client.LastResult.Status == HttpStatusCode.Gone.ToString()); } }
public void ReadRelative() { FhirClient client = new FhirClient(testEndpoint); var loc = client.Read<Location>(new Uri("Location/1", UriKind.Relative)); Assert.IsNotNull(loc); Assert.AreEqual("Den Burg", loc.Address.City); var ri = ResourceIdentity.Build(testEndpoint, "Location", "1"); loc = client.Read<Location>(ri); Assert.IsNotNull(loc); Assert.AreEqual("Den Burg", loc.Address.City); }
public void TestReceiveHtmlIsHandled() { var client = new FhirClient("http://spark.furore.com/"); // an address that returns html try { var pat = client.Read<Patient>("Patient/1"); Assert.Fail("Failed to throw an Exception on illegal body"); } catch (FormatException fe) { if (!fe.Message.Contains("a valid FHIR xml/json body type was expected") && !fe.Message.Contains("not recognized as either xml or json")) Assert.Fail("Failed to recognize invalid body contents"); } catch (Exception) { Assert.Fail("Failed to throw FormatException on illegal body"); } }
public void RequestFullResource() { var client = new FhirClient(testEndpoint); var minimal = false; client.OnBeforeRequest += (object s, BeforeRequestEventArgs e) => e.RawRequest.Headers["Prefer"] = minimal ? "return=minimal" : "return=representation"; var result = client.Read<Patient>("Patient/example"); Assert.IsNotNull(result); result.Id = null; result.Meta = null; client.ReturnFullResource = true; minimal = false; var posted = client.Create(result); Assert.IsNotNull(posted, "Patient example not found"); minimal = true; // simulate a server that does not return a body, even if ReturnFullResource = true posted = client.Create(result); Assert.IsNotNull(posted, "Did not return a resource, even when ReturnFullResource=true"); client.ReturnFullResource = false; minimal = true; posted = client.Create(result); Assert.IsNull(posted); }
public void FhirVersionIsChecked() { var testEndpointDSTU2 = new Uri("http://spark-dstu2.furore.com/fhir"); var testEndpointDSTU1 = new Uri("http://spark.furore.com/fhir"); var testEndpointDSTU22 = new Uri("http://fhirtest.uhn.ca/baseDstu2"); var testEndpointDSTU23 = new Uri("http://fhir-dev.healthintersections.com.au/open"); var client = new FhirClient(testEndpointDSTU1); Patient p; try { client = new FhirClient(testEndpointDSTU23, verifyFhirVersion: true); p = client.Read<Patient>("Patient/example"); } catch (NotSupportedException) { //Client uses 1.0.1, server states 1.0.0-7104 } client = new FhirClient(testEndpointDSTU23); p = client.Read<Patient>("Patient/example"); //client = new FhirClient(testEndpointDSTU2); //p = client.Read<Patient>("Patient/example"); //p = client.Read<Patient>("Patient/example"); //client = new FhirClient(testEndpointDSTU22, verifyFhirVersion:true); //p = client.Read<Patient>("Patient/example"); //p = client.Read<Patient>("Patient/example"); client = new FhirClient(testEndpointDSTU1); try { p = client.Read<Patient>("Patient/example"); Assert.Fail("Reading a DSTU1 example using DSTU2 parsers should have failed"); } catch (FormatException) { // OK } }
public void CreateAndFullRepresentation() { FhirClient client = new FhirClient(testEndpoint); client.ReturnFullResource = true; // which is also the default var pat = client.Read<Patient>("Patient/example"); pat.Id = null; pat.Identifier.Clear(); var patC = client.Create<Patient>(pat); Assert.IsNotNull(patC); client.ReturnFullResource = false; patC = client.Create<Patient>(pat); Assert.IsNull(patC); if (client.LastBody != null) { var returned = client.LastBodyAsResource; Assert.IsTrue(returned is OperationOutcome); } }
public void StackOverflow() { var client = new FhirClient("http://spark.furore.com/fhir"); var pat = client.Read<Patient>("Patient/1"); }
public void CreateEditDelete() { var furore = new Organization { Name = "Furore", Identifier = new List<Identifier> { new Identifier("http://hl7.org/test/1", "3141") }, Telecom = new List<Contact> { new Contact { System = Contact.ContactSystem.Phone, Value = "+31-20-3467171" } } }; FhirClient client = new FhirClient(testEndpoint); var tags = new List<Tag> { new Tag("http://nu.nl/testname", Tag.FHIRTAGSCHEME_GENERAL, "TestCreateEditDelete") }; var fe = client.Create<Organization>(furore, tags:tags, refresh: true); Assert.IsNotNull(furore); Assert.IsNotNull(fe); Assert.IsNotNull(fe.Id); Assert.IsNotNull(fe.SelfLink); Assert.AreNotEqual(fe.Id, fe.SelfLink); Assert.IsNotNull(fe.Tags); Assert.AreEqual(1, fe.Tags.Count(), "Tag count on new organization record don't match"); Assert.AreEqual(fe.Tags.First(), tags[0]); createdTestOrganizationUrl = fe.Id; fe.Resource.Identifier.Add(new Identifier("http://hl7.org/test/2", "3141592")); var fe2 = client.Update(fe, refresh: true); Assert.IsNotNull(fe2); Assert.AreEqual(fe.Id, fe2.Id); Assert.AreNotEqual(fe.SelfLink, fe2.SelfLink); Assert.AreEqual(2, fe2.Resource.Identifier.Count); Assert.IsNotNull(fe2.Tags); Assert.AreEqual(1, fe2.Tags.Count(), "Tag count on updated organization record don't match"); Assert.AreEqual(fe2.Tags.First(), tags[0]); fe.Resource.Identifier.Add(new Identifier("http://hl7.org/test/3", "3141592")); var fe3 = client.Update(fe2.Id, fe.Resource, refresh: true); Assert.IsNotNull(fe3); Assert.AreEqual(3, fe3.Resource.Identifier.Count); client.Delete(fe3); try { // Get most recent version fe = client.Read<Organization>(new ResourceIdentity(fe.Id)); Assert.Fail(); } catch { Assert.IsTrue(client.LastResponseDetails.Result == HttpStatusCode.Gone); } }
public void ReadTags() { FhirClient client = new FhirClient(testEndpoint); var tags = new List<Tag>() { new Tag("http://readtag.nu.nl", Tag.FHIRTAGSCHEME_GENERAL, "readTagTest") }; var identity = ResourceIdentity.Build("Location", "1"); client.AffixTags(identity, tags); var affixedEntry = client.Read(identity); IEnumerable<Tag> list; //BP/EK: Our server can't yet do this (as noted above in the history test) // list = client.WholeSystemTags(); // Assert.IsTrue(list.Any(t => t.Equals(tags.First()))); list = client.TypeTags<Location>(); Assert.IsTrue(list.Any(t => t.Equals(tags.First()))); list = client.Tags(affixedEntry.SelfLink); Assert.IsTrue(list.Any(t => t.Equals(tags.First()))); // BP: Furore server having issues with this at present (17 April 2014) // causes the test to fail client.DeleteTags(affixedEntry.SelfLink, tags); //TODO: verify tags have really been removed. Should generate random tag so this is repeatable }
public void CreateAndFullRepresentation() { FhirClient client = new FhirClient(testEndpoint); client.ReturnFullResource = true; // which is also the default var pat = client.Read<Patient>("Patient/example"); ResourceIdentity ri = pat.ResourceIdentity().WithBase(client.Endpoint); pat.Id = null; pat.Identifier.Clear(); var patC = client.Create<Patient>(pat); Assert.IsNotNull(patC); client.ReturnFullResource = false; patC = client.Create<Patient>(pat); Assert.IsNull(patC); if (client.LastBody != null) { var returned = client.LastBodyAsResource; Assert.IsTrue(returned is OperationOutcome); } // Now validate this resource client.ReturnFullResource = true; // which is also the default Parameters p = new Parameters(); // p.Add("mode", new FhirString("create")); p.Add("resource", pat); OperationOutcome ooI = (OperationOutcome)client.InstanceOperation(ri.WithoutVersion(), "validate", p); Assert.IsNotNull(ooI); }
public void ReadCallsHookedEvents() { FhirClient client = new FhirClient(testEndpoint); bool hitBeforeRequest = false; bool hitAfterRequest = false; client.OnBeforeRequest += (o,p) => hitBeforeRequest = true; client.OnAfterResponse += (o,p) => hitAfterRequest = true; var loc = client.Read("Patient/1"); Assert.IsTrue(hitBeforeRequest); Assert.IsTrue(hitAfterRequest); }
//Test for github issue https://github.com/ewoutkramer/fhir-net-api/issues/145 public void Create_ObservationWithValueAsSimpleQuantity_ReadReturnsValueAsQuantity() { FhirClient client = new FhirClient(testEndpoint); var observation = new Observation(); observation.Status = Observation.ObservationStatus.Preliminary; observation.Code = new CodeableConcept("http://loinc.org", "2164-2"); observation.Value = new SimpleQuantity() { System = "http://unitsofmeasure.org", Value = 23, Code = "mg", Unit = "miligram" }; observation.BodySite = new CodeableConcept("http://snomed.info/sct", "182756003"); var fe = client.Create(observation); fe = client.Read<Observation>(fe.ResourceIdentity().WithoutVersion()); Assert.IsInstanceOfType(fe.Value, typeof(Quantity)); }
public void CreateEditDelete() { FhirClient client = new FhirClient(testEndpoint); var pat = client.Read<Patient>("Patient/example"); pat.Id = null; pat.Identifier.Clear(); pat.Identifier.Add(new Identifier("http://hl7.org/test/2", "99999")); var fe = client.Create(pat); Assert.IsNotNull(fe); Assert.IsNotNull(fe.Id); Assert.IsNotNull(fe.Meta.VersionId); createdTestPatientUrl = fe.ResourceIdentity(); fe.Identifier.Add(new Identifier("http://hl7.org/test/2", "3141592")); var fe2 = client.Update(fe); Assert.IsNotNull(fe2); Assert.AreEqual(fe.Id, fe2.Id); Assert.AreNotEqual(fe.ResourceIdentity(), fe2.ResourceIdentity()); Assert.AreEqual(2, fe2.Identifier.Count); fe.Identifier.Add(new Identifier("http://hl7.org/test/3", "3141592")); var fe3 = client.Update(fe); Assert.IsNotNull(fe3); Assert.AreEqual(3, fe3.Identifier.Count); client.Delete(fe3); try { // Get most recent version fe = client.Read<Patient>(fe.ResourceIdentity().WithoutVersion()); Assert.Fail(); } catch { Assert.IsTrue(client.LastResult.Status == "410"); } }
[TestMethod,Ignore]//returns 500: validation of slices is not done yet. public void InvokeResourceValidation() { var client = new FhirClient(testEndpoint); var pat = client.Read<Patient>("Patient/patient-uslab-example1"); var vresult = client.ValidateResource(pat, null, new FhirUri("http://hl7.org/fhir/StructureDefinition/uslab-patient")); Assert.IsTrue(vresult.Success()); }
[TestMethod]//returns 500: validation of slices is not done yet. public void InvokeResourceValidation() { var client = new FhirClient(testEndpoint); var pat = client.Read<Patient>("Patient/patient-uslab-example1"); try { var vresult = client.ValidateResource(pat, null, new FhirUri("http://hl7.org/fhir/StructureDefinition/uslab-patient")); Assert.Fail("Should have resulted in 400"); } catch(FhirOperationException fe) { Assert.AreEqual(System.Net.HttpStatusCode.BadRequest, fe.Status); Assert.IsTrue(fe.Outcome.Issue.Where(i => i.Severity == OperationOutcome.IssueSeverity.Error).Any()); } }