IEnumerator SendData(int weight, string postfix) { yield return(new WaitForSeconds(0.1f)); var client = new FhirClient("http://hapi.fhir.org/baseR4"); Debug.Log("TOAN111: DEVICEINFO:" + DEVICEINFO.ID.STR); Device device = client.Read <Device>("http://hapi.fhir.org/baseR4/Device/" + DEVICEINFO.ID.STR); if (device != null) { Debug.Log("TOAN113: DEVICEINFO:" + DEVICEINFO.ID.STR); //Quantity quantityValue = new Quantity(); Quantity quantityValue; if (device.Property.Count > 0 && device.Property[0].ValueQuantity.Count > 0) { quantityValue = device.Property[0].ValueQuantity[0]; } else { quantityValue = new Quantity(); } quantityValue.Value = (decimal)(weight * 0.005f); quantityValue.System = ("http://unitsofmeasure.org"); quantityValue.Code = postfix; Coding weightCoding = new Coding("http://loinc.org", "29463-7", "Body Weight"); Device.PropertyComponent weightProperty = new Device.PropertyComponent(); CodeableConcept code = new CodeableConcept(); code.Coding.Add(weightCoding); weightProperty.Type = code; weightProperty.ValueQuantity.Add(quantityValue); if (device.Property.Count == 0) { device.Property.Add(weightProperty); } else { device.Property[0] = weightProperty; } var result = client.Update(device); TW.I.AddWarning("", "Updated ID " + result.Id); } else { Debug.Log("TOAN112: DEVICEINFO:" + DEVICEINFO.ID.STR); } }
static void Main(string[] args) { Hl7.Fhir.Rest.FhirClient clientFhir = new Hl7.Fhir.Rest.FhirClient("http://ohcconnect.myhealthpoc.com:9093/org1", false); //Hl7.Fhir.Rest.FhirClient clientFhir = new Hl7.Fhir.Rest.FhirClient("https://r4.test.pyrohealth.net/fhir", false); clientFhir.Timeout = 1000 * 720; // give the call a while to execute (particularly while debugging). try { var res = clientFhir.Get("Patient/8b2179c6-811d-492a-9c8e-6856be319af3"); } catch (Exception exec) { string m = exec.Message; } //string PatientResourceId = string.Empty; ////Add a Patient resource by Update //Patient PatientOne = new Patient(); //PatientOne.Name.Add(HumanName.ForFamily("TestPatient").WithGiven("Test")); //PatientOne.BirthDateElement = new Date("1979-09-30"); //string PatientOneMRNIdentifer = Guid.NewGuid().ToString(); //PatientOne.Identifier.Add(new Identifier(StaticTestData.TestIdentiferSystem, PatientOneMRNIdentifer)); //PatientOne.Gender = AdministrativeGender.Unknown; //Patient PatientResult = null; //try //{ // PatientResult = clientFhir.Create(PatientOne); //} //catch (Exception Exec) //{ // Assert.True(false, "Exception thrown on resource Create: " + Exec.Message); //} //Assert.NotNull(PatientResult, "Resource create by Updated returned resource of null"); //PatientResourceId = PatientResult.Id; //PatientResult = null; var Dev = new Device(); Dev.Property = new List <Device.PropertyComponent>(); var TestProp = new Device.PropertyComponent(); Dev.Property.Add(TestProp); TestProp.Type = new CodeableConcept(); TestProp.Type.Coding = new List <Coding>(); TestProp.Type.Coding.Add(new Coding() { System = "urn:iso:std:iso:11073:10101", Code = "68221" }); TestProp.Type.Text = "MDC_TIME_SYNC_ACCURACY: null"; TestProp.ValueQuantity = new List <Quantity>(); TestProp.ValueQuantity.Add(new Quantity() { Value = 120000000, Code = "us" }); FhirJsonSerializer FhirJsonSerializer = new FhirJsonSerializer(); string JasonDevice = FhirJsonSerializer.SerializeToString(Dev, Hl7.Fhir.Rest.SummaryType.False); //FhirJsonSerializer.Serialize(Resource, jsonwriter, Summary); }