/// <summary> /// Deserialize JSON into a FHIR CodeableConcept /// </summary> public static void DeserializeJsonProperty(this CodeableConcept current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "coding": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"CodeableConcept error reading 'coding' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Coding = new List <Coding>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.Coding v_Coding = new Hl7.Fhir.Model.Coding(); v_Coding.DeserializeJson(ref reader, options); current.Coding.Add(v_Coding); if (!reader.Read()) { throw new JsonException($"CodeableConcept error reading 'coding' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Coding.Count == 0) { current.Coding = null; } break; case "text": if (reader.TokenType == JsonTokenType.Null) { current.TextElement = new FhirString(); reader.Skip(); } else { current.TextElement = new FhirString(reader.GetString()); } break; case "_text": if (current.TextElement == null) { current.TextElement = new FhirString(); } ((Hl7.Fhir.Model.Element)current.TextElement).DeserializeJson(ref reader, options); break; // Complex: CodeableConcept, Export: CodeableConcept, Base: Element default: ((Hl7.Fhir.Model.Element)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }
public DiagnosticReport CreateDiagnosticReport() { Hl7.Fhir.Model.Coding coding = new Hl7.Fhir.Model.Coding { System = "http://loinc.org", Code = "51990-0", Display = "Basic Metabolic Panel" }; List <Hl7.Fhir.Model.Coding> CodingList = new List <Hl7.Fhir.Model.Coding> { coding }; var code = new CodeableConcept { Coding = CodingList }; ResourceReference reff = new ResourceReference { Reference = "Patient/099e7de7-c952-40e2-9b4e-0face78c9d80" }; DiagnosticReport dr = new DiagnosticReport { Code = code, Status = DiagnosticReport.DiagnosticReportStatus.Final, Subject = reff, }; //dr.ResourceType = "DiagnosticReport"; return(dr); }
/// <summary> /// Parse Coding /// </summary> public static Hl7.Fhir.Model.Coding ParseCoding(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Coding existingInstance = null) { Hl7.Fhir.Model.Coding result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Coding(); string currentElementName = reader.CurrentElementName; reader.EnterElement(); while (reader.HasMoreElements()) { var atName = reader.CurrentElementName; // Parse element extension if (atName == "extension") { result.Extension = new List <Hl7.Fhir.Model.Extension>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "extension")) { result.Extension.Add(ExtensionParser.ParseExtension(reader, errors)); } reader.LeaveArray(); } // Parse element _id else if (atName == "_id") { result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id))); } // Parse element system else if (atName == "system") { result.SystemElement = FhirUriParser.ParseFhirUri(reader, errors); } // Parse element code else if (atName == "code") { result.CodeElement = CodeParser.ParseCode(reader, errors); } // Parse element display else if (atName == "display") { result.DisplayElement = FhirStringParser.ParseFhirString(reader, errors); } else { errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader); reader.SkipSubElementsFor(currentElementName); result = null; } } reader.LeaveElement(); return(result); }
public void InvokeLookupCoding() { var client = new FhirClient(testEndpoint); var coding = new Coding("http://hl7.org/fhir/administrative-gender", "male"); var expansion = client.ConceptLookup(coding); // Assert.AreEqual("AdministrativeGender", expansion.GetSingleValue<FhirString>("name").Value); // Returns empty currently on Grahame's server Assert.AreEqual("Male", expansion.GetSingleValue<FhirString>("display").Value); }
public static void SerializeCoding(Hl7.Fhir.Model.Coding value, IFhirWriter writer, bool summary) { writer.WriteStartComplexContent(); // Serialize element _id if (value.LocalIdElement != null) { writer.WritePrimitiveContents("_id", value.LocalIdElement, XmlSerializationHint.Attribute); } // Serialize element extension if (value.Extension != null && !summary && value.Extension.Count > 0) { writer.WriteStartArrayElement("extension"); foreach (var item in value.Extension) { writer.WriteStartArrayMember("extension"); ExtensionSerializer.SerializeExtension(item, writer, summary); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element system if (value.SystemElement != null) { writer.WriteStartElement("system"); FhirUriSerializer.SerializeFhirUri(value.SystemElement, writer, summary); writer.WriteEndElement(); } // Serialize element code if (value.CodeElement != null) { writer.WriteStartElement("code"); CodeSerializer.SerializeCode(value.CodeElement, writer, summary); writer.WriteEndElement(); } // Serialize element display if (value.DisplayElement != null) { writer.WriteStartElement("display"); FhirStringSerializer.SerializeFhirString(value.DisplayElement, writer, summary); writer.WriteEndElement(); } writer.WriteEndComplexContent(); }
public void RenderCoding() { var c = new Coding("http://www.loinc.org/", "23456-5"); Assert.AreEqual("23456-5@http://www.loinc.org/", c.ForDisplay()); c.Display = "Testing rendering"; Assert.AreEqual("23456-5@http://www.loinc.org/ (Testing rendering)", c.ForDisplay()); var c2 = new Coding("http://www.loinc.org/", "12345-6"); var cc = new CodeableConcept(); cc.Coding = new List<Coding>() { c,c2 }; Assert.AreEqual("{23456-5@http://www.loinc.org/ (Testing rendering), 12345-6@http://www.loinc.org/}", cc.ForDisplay()); cc.Text = "Unit test rendering"; Assert.AreEqual("Unit test rendering {23456-5@http://www.loinc.org/ (Testing rendering), 12345-6@http://www.loinc.org/}", cc.ForDisplay()); }
public void TestIsNullOrEmpty_Coding() { var coding = new Coding(); Assert.IsTrue(coding.IsNullOrEmpty()); var uri = new FhirUri(); Assert.IsTrue(uri.IsNullOrEmpty()); coding.SystemElement = uri; Assert.IsTrue(coding.IsNullOrEmpty()); uri.Value = "http://example.org/"; Assert.IsFalse(uri.IsNullOrEmpty()); Assert.IsFalse(coding.IsNullOrEmpty()); Assert.IsFalse((coding as Base).IsNullOrEmpty()); uri.Value = null; Assert.IsTrue(uri.IsNullOrEmpty()); Assert.IsTrue(coding.IsNullOrEmpty()); var extension = new Extension(); Assert.IsTrue(extension.IsNullOrEmpty()); coding.Extension.Add(extension); Assert.IsTrue(coding.IsNullOrEmpty()); var extensionValue = new Coding(null, "test"); Assert.IsFalse(extensionValue.IsNullOrEmpty()); extension.Value = extensionValue; Assert.IsFalse(extension.IsNullOrEmpty()); Assert.IsFalse(coding.IsNullOrEmpty()); Assert.IsFalse((coding as Base).IsNullOrEmpty()); extensionValue.Code = null; Assert.IsTrue(extensionValue.IsNullOrEmpty()); Assert.IsTrue(extension.IsNullOrEmpty()); Assert.IsTrue(coding.IsNullOrEmpty()); coding.Extension.Clear(); Assert.IsTrue(coding.IsNullOrEmpty()); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as CodeableConcept; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (Coding != null) { dest.Coding = new List <Hl7.Fhir.Model.Coding>(Coding.DeepCopy()); } if (TextElement != null) { dest.TextElement = (Hl7.Fhir.Model.FhirString)TextElement.DeepCopy(); } return(dest); }
public override ErrorList Validate() { var result = new ErrorList(); result.AddRange(base.Validate()); if (Coding != null) { Coding.ForEach(elem => result.AddRange(elem.Validate())); } if (TextElement != null) { result.AddRange(TextElement.Validate()); } if (PrimaryElement != null) { result.AddRange(PrimaryElement.Validate()); } return(result); }
public void TestIsNullOrEmpty_List() { var codings = new List <Coding>(); Assert.IsTrue(codings.IsNullOrEmpty()); var coding = new Coding(); Assert.IsTrue(coding.IsNullOrEmpty()); codings.Add(coding); Assert.IsFalse(codings.IsNullOrEmpty()); // Empty values are counted... (but shouldn't occur) // Assert.IsTrue(codings.IsNullOrEmpty()); coding.Code = "test"; Assert.IsFalse(coding.IsNullOrEmpty()); Assert.IsFalse(codings.IsNullOrEmpty()); coding.Code = string.Empty; Assert.IsTrue(coding.IsNullOrEmpty()); Assert.IsFalse(codings.IsNullOrEmpty()); // Empty values are counted... (but shouldn't occur) // Assert.IsTrue(codings.IsNullOrEmpty()); }
/// <summary> /// { system : system1, code: code1, text: display1 }, /// </summary> /// <param name="element"></param> /// <returns></returns> private List <Expression> ToExpressions(FhirModel.Coding element) { if (element == null) { return(null); } var values = new List <IndexValue>(); if (element.Code != null) { values.Add(new IndexValue("code", new StringValue(element.Code))); } if (element.System != null) { values.Add(new IndexValue("system", new StringValue(element.System))); } if (element.Display != null) { values.Add(new IndexValue("text", new StringValue(element.Display))); } return(ListOf(new CompositeValue(values))); }
/// <summary> /// Deserialize JSON into a FHIR Meta /// </summary> public static void DeserializeJsonProperty(this Meta current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "versionId": if (reader.TokenType == JsonTokenType.Null) { current.VersionIdElement = new Id(); reader.Skip(); } else { current.VersionIdElement = new Id(reader.GetString()); } break; case "_versionId": if (current.VersionIdElement == null) { current.VersionIdElement = new Id(); } ((Hl7.Fhir.Model.Element)current.VersionIdElement).DeserializeJson(ref reader, options); break; case "lastUpdated": if (reader.TokenType == JsonTokenType.Null) { current.LastUpdatedElement = new Instant(); reader.Skip(); } else { current.LastUpdatedElement = new Instant(DateTimeOffset.Parse(reader.GetString())); } break; case "_lastUpdated": if (current.LastUpdatedElement == null) { current.LastUpdatedElement = new Instant(); } ((Hl7.Fhir.Model.Element)current.LastUpdatedElement).DeserializeJson(ref reader, options); break; case "source": if (reader.TokenType == JsonTokenType.Null) { current.SourceElement = new FhirUri(); reader.Skip(); } else { current.SourceElement = new FhirUri(reader.GetString()); } break; case "_source": if (current.SourceElement == null) { current.SourceElement = new FhirUri(); } ((Hl7.Fhir.Model.Element)current.SourceElement).DeserializeJson(ref reader, options); break; case "profile": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"Meta error reading 'profile' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.ProfileElement = new List <FhirUri>(); while (reader.TokenType != JsonTokenType.EndArray) { if (reader.TokenType == JsonTokenType.Null) { current.ProfileElement.Add(new FhirUri()); reader.Skip(); } else { current.ProfileElement.Add(new FhirUri(reader.GetString())); } if (!reader.Read()) { throw new JsonException($"Meta error reading 'profile' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.ProfileElement.Count == 0) { current.ProfileElement = null; } break; case "_profile": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"Meta error reading 'profile' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } int i_profile = 0; while (reader.TokenType != JsonTokenType.EndArray) { if (i_profile >= current.ProfileElement.Count) { current.ProfileElement.Add(new FhirUri()); } if (reader.TokenType == JsonTokenType.Null) { reader.Skip(); } else { ((Hl7.Fhir.Model.Element)current.ProfileElement[i_profile++]).DeserializeJson(ref reader, options); } if (!reader.Read()) { throw new JsonException($"Meta error reading 'profile' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } break; case "security": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"Meta error reading 'security' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Security = new List <Coding>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.Coding v_Security = new Hl7.Fhir.Model.Coding(); v_Security.DeserializeJson(ref reader, options); current.Security.Add(v_Security); if (!reader.Read()) { throw new JsonException($"Meta error reading 'security' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Security.Count == 0) { current.Security = null; } break; case "tag": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"Meta error reading 'tag' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Tag = new List <Coding>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.Coding v_Tag = new Hl7.Fhir.Model.Coding(); v_Tag.DeserializeJson(ref reader, options); current.Tag.Add(v_Tag); if (!reader.Read()) { throw new JsonException($"Meta error reading 'tag' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Tag.Count == 0) { current.Tag = null; } break; // Complex: Meta, Export: Meta, Base: Element default: ((Hl7.Fhir.Model.Element)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }
//public static List<Tag> GetFhirTags(this HttpHeaders headers) //{ // IEnumerable<string> tagstrings; // List<Tag> tags = new List<Tag>(); // if (headers.TryGetValues(FhirHeader.CATEGORY, out tagstrings)) // { // foreach (string tagstring in tagstrings) // { // tags.AddRange(HttpUtil.ParseCategoryHeader(tagstring)); // } // } // return tags; //} //public static void SetFhirTags(this HttpHeaders headers, IEnumerable<Tag> tags) //{ // string tagstring = HttpUtil.BuildCategoryHeader(tags); // headers.Add(FhirHeader.CATEGORY, tagstring); //} public static bool EqualTag(Coding coding, Coding other) { return (coding.System == other.System); }
/// <summary> /// Deserialize JSON into a FHIR DataRequirement#CodeFilter /// </summary> public static void DeserializeJsonProperty(this DataRequirement.CodeFilterComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "path": if (reader.TokenType == JsonTokenType.Null) { current.PathElement = new FhirString(); reader.Skip(); } else { current.PathElement = new FhirString(reader.GetString()); } break; case "_path": if (current.PathElement == null) { current.PathElement = new FhirString(); } ((Hl7.Fhir.Model.Element)current.PathElement).DeserializeJson(ref reader, options); break; case "searchParam": if (reader.TokenType == JsonTokenType.Null) { current.SearchParamElement = new FhirString(); reader.Skip(); } else { current.SearchParamElement = new FhirString(reader.GetString()); } break; case "_searchParam": if (current.SearchParamElement == null) { current.SearchParamElement = new FhirString(); } ((Hl7.Fhir.Model.Element)current.SearchParamElement).DeserializeJson(ref reader, options); break; case "valueSet": if (reader.TokenType == JsonTokenType.Null) { current.ValueSetElement = new Canonical(); reader.Skip(); } else { current.ValueSetElement = new Canonical(reader.GetString()); } break; case "_valueSet": if (current.ValueSetElement == null) { current.ValueSetElement = new Canonical(); } ((Hl7.Fhir.Model.Element)current.ValueSetElement).DeserializeJson(ref reader, options); break; case "code": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"CodeFilterComponent error reading 'code' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Code = new List <Coding>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.Coding v_Code = new Hl7.Fhir.Model.Coding(); v_Code.DeserializeJson(ref reader, options); current.Code.Add(v_Code); if (!reader.Read()) { throw new JsonException($"CodeFilterComponent error reading 'code' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Code.Count == 0) { current.Code = null; } break; // Complex: codeFilter, Export: CodeFilterComponent, Base: Element default: ((Hl7.Fhir.Model.Element)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }
public void Write(Definition definition, Coding coding) { string system = (coding.System != null) ? coding.System.ToString() : null; string code = ((coding.Code != null) && (coding.Code != null)) ? coding.Code : null; BsonDocument value = new BsonDocument() { { "system", system, system != null }, { "code", code }, { "display", coding.Display, coding.Display != null } }; document.Write(definition.ParamName, value); }
public void Write(Definition definition, Enum item) { var coding = new Coding(); coding.Code = getEnumLiteral(item); Write(definition, coding); }
/// <summary> /// Filter all ResourceEntries that have a given tag. /// </summary> /// <typeparam name="T">Type of Resource to filter</typeparam> /// <param name="entries">List of resources to filter on</param> /// <param name="tag">Tag to filter Resources on</param> /// <returns>A list of typed ResourceEntries having the given tag, or an empty list if none were found.</returns> public static IEnumerable <T> ByTag <T>(this IEnumerable <Resource> entries, Coding tag) where T : Resource, new() { return(entries.Where(be => be.Meta != null && be.Meta.Tag != null && be.Meta.Tag.Contains(tag) && be is T).Cast <T>()); }
/// <summary> /// Filter all BundleEntries that have a given tag. /// </summary> /// <param name="entries">List of bundle entries to filter on</param> /// <param name="tag">Tag to filter Resources on</param> /// <returns>A list of BundleEntries having the given tag, or an empty list if none were found.</returns> public static IEnumerable <Resource> ByTag(this IEnumerable <Resource> entries, Coding tag) { return(entries.Where(be => be.Meta != null && be.Meta.Tag != null && be.Meta.Tag.Contains(tag))); }
public static bool HasTag(this IEnumerable<Coding> tags, Coding tag) { return tags.Any(t => EqualTag(t, tag)); }
public void Collect(Definition definition, Enum item) { var coding = new Coding(); coding.Code = getEnumLiteral(item); Collect(definition, coding); }
private void button1_Click_2(object sender, EventArgs e) { var endpoint = new Uri("http://fhirtest.uhn.ca/baseDstu2"); var client = new FhirClient(endpoint); // Create new value for observation SampledData val = new SampledData(); CodeableConcept concept = new CodeableConcept(); concept.Coding = new List<Coding>(); if (conversionList.Text.Equals("age")) { val.Data = CurrentMeasurement.age.ToString(); Coding code = new Coding(); code.Code = "410668003"; concept.Coding.Add(code); } else if (conversionList.Text.Equals("bmr")) { val.Data = CurrentMeasurement.bmr.ToString(); Coding code = new Coding(); code.Code = "60621009"; concept.Coding.Add(code); } else if (conversionList.Text.Equals("height")) { val.Data = CurrentMeasurement.height.ToString(); Coding code = new Coding(); code.Code = "60621009"; //SNOMED CT code concept.Coding.Add(code); } else if (conversionList.Text.Equals("m_active_time")) val.Data = CurrentMeasurement.m_active_time.ToString(); else if (conversionList.Text.Equals("m_calories")) val.Data = CurrentMeasurement.m_calories.ToString(); else if (conversionList.Text.Equals("m_distance")) val.Data = CurrentMeasurement.m_distance.ToString(); else if (conversionList.Text.Equals("m_inactive_time")) val.Data = CurrentMeasurement.m_inactive_time.ToString(); else if (conversionList.Text.Equals("m_lcat")) val.Data = CurrentMeasurement.m_lcat.ToString(); else if (conversionList.Text.Equals("m_lcit")) val.Data = CurrentMeasurement.m_lcit.ToString(); else if (conversionList.Text.Equals("m_steps")) val.Data = CurrentMeasurement.m_steps.ToString(); else if (conversionList.Text.Equals("m_total_calories")) val.Data = CurrentMeasurement.m_total_calories.ToString(); else if (conversionList.Text.Equals("s_asleep_time")) val.Data = CurrentMeasurement.s_asleep_time.ToString(); else if (conversionList.Text.Equals("s_awake")) val.Data = CurrentMeasurement.s_awake.ToString(); else if (conversionList.Text.Equals("s_awake_time")) val.Data = CurrentMeasurement.s_awake_time.ToString(); else if (conversionList.Text.Equals("s_awakenings")) val.Data = CurrentMeasurement.s_awakenings.ToString(); else if (conversionList.Text.Equals("s_bedtime")) val.Data = CurrentMeasurement.s_bedtime.ToString(); else if (conversionList.Text.Equals("s_clinical_deep")) val.Data = CurrentMeasurement.s_clinical_deep.ToString(); else if (conversionList.Text.Equals("s_count")) val.Data = CurrentMeasurement.s_count.ToString(); else if (conversionList.Text.Equals("s_duration")) val.Data = CurrentMeasurement.s_duration.ToString(); else if (conversionList.Text.Equals("s_light")) val.Data = CurrentMeasurement.s_light.ToString(); else if (conversionList.Text.Equals("s_quality")) val.Data = CurrentMeasurement.s_quality.ToString(); else if (conversionList.Text.Equals("s_rem")) val.Data = CurrentMeasurement.s_rem.ToString(); else if (conversionList.Text.Equals("weight")) val.Data = CurrentMeasurement.weight.ToString(); else val.Data = "E"; // Error Console.WriteLine("Value data: " + val.Data); ResourceReference dev = new ResourceReference(); dev.Reference = "Device/" + CurrentDevice.Id; ResourceReference pat = new ResourceReference(); pat.Reference = "Patient/" + CurrentPatient.Id; Console.WriteLine("Patient reference: " + pat.Reference); Console.WriteLine("Conversion: " + conversionList.Text); CodeableConcept naam = new CodeableConcept(); naam.Text = conversionList.Text; DateTime date = DateTime.ParseExact(CurrentMeasurement.date, "yyyymmdd", null); Console.WriteLine("" + date.ToString()); var obs = new Observation() {Device = dev, Subject = pat, Value = val, Issued = date, Code = naam, Category = concept, Status = Observation.ObservationStatus.Final}; client.Create(obs); conversionStatus.Text = "Done!"; }
public void CodeableConceptMapTest() { var input = new CodeableConcept(); input.Text = "bla text"; input.Coding = new List<Coding>(); var coding1 = new Coding(); coding1.CodeElement = new Code("bla"); coding1.SystemElement = new FhirUri("http://bla.com"); coding1.DisplayElement = new FhirString("bla display"); var coding2 = new Coding(); coding2.CodeElement = new Code("flit"); coding2.SystemElement = new FhirUri("http://flit.com"); coding2.DisplayElement = new FhirString("flit display"); input.Coding.Add(coding1); input.Coding.Add(coding2); var result = sut.Map(input); Assert.AreEqual(2, result.Count()); //1 with text and 1 with the codings below it //Check wether CodeableConcept.Text is in the result. var textIVs = result.Where(c => c.GetType() == typeof(IndexValue) && (c as IndexValue).Name == "text").ToList(); Assert.AreEqual(1, textIVs.Count()); var textIV = (IndexValue)textIVs.FirstOrDefault(); Assert.IsNotNull(textIV); Assert.AreEqual(1, textIV.Values.Count()); Assert.IsInstanceOfType(textIV.Values[0], typeof(StringValue)); Assert.AreEqual("bla text", (textIV.Values[0] as StringValue).Value); //Check wether both codings are in the result. var codingIVs = result.Where(c => c.GetType() == typeof(IndexValue) && (c as IndexValue).Name == "coding").ToList(); Assert.AreEqual(1, codingIVs.Count()); var codingIV = (IndexValue)codingIVs.First(); var codeIVs = codingIV.Values.Where(c => c.GetType() == typeof(CompositeValue)).ToList(); Assert.AreEqual(2, codeIVs.Count()); var codeIV1 = (CompositeValue)codeIVs[0]; var codeIV2 = (CompositeValue)codeIVs[1]; if (((codeIV1.Components[0] as IndexValue).Values[0] as StringValue).Value == "bla") { CheckCoding(codeIV1, "bla", "http://bla.com", "bla display"); CheckCoding(codeIV2, "flit", "http://flit.com", "flit display"); } else //apparently the codings are in different order in the result. { CheckCoding(codeIV2, "bla", "http://bla.com", "bla display"); CheckCoding(codeIV1, "flit", "http://flit.com", "flit display"); } }
public void CodingMapTest() { var input = new Coding(); input.CodeElement = new Code("bla"); input.SystemElement = new FhirUri("http://bla.com"); input.DisplayElement = new FhirString("bla display"); var result = sut.Map(input); Assert.AreEqual(1, result.Count()); Assert.IsInstanceOfType(result[0], typeof(CompositeValue)); var comp = result[0] as CompositeValue; CheckCoding(comp, "bla", "http://bla.com", "bla display"); }
internal static Practitioner CreatePractitionerResource() { // Create new Practitioner resource Practitioner res = new Practitioner(); // Allocate the logical resource Id - this is what the resource is referenced by res.Id = "41fe704c-18e5-11e5-b60b-1697f925ec7b"; // Add the profile for this resource (from the FGM DMS) Meta metadata = new Meta(); metadata.Profile = new string[] { "urn:fhir.nhs.uk:profile/NHS-FGM-Practitioner" }; res.Meta = metadata; // Add the business idetifier for the SDS User Id res.Identifier = new List<Identifier>(); Identifier id1 = new Identifier("urn:fhir.nhs.uk/id/SDSUserID", "G12345678"); id1.Use = Identifier.IdentifierUse.Official; res.Identifier.Add(id1); // Add the business idetifier for the SDS Role Profile Id Identifier id2 = new Identifier("urn:fhir.nhs.uk/id/SDSRoleProfileID", "PT1234"); id2.Use = Identifier.IdentifierUse.Official; res.Identifier.Add(id2); // Add the name of the practitioner res.Name = HumanName.ForFamily("Wood").WithGiven("Town"); res.Name.Use = HumanName.NameUse.Official; res.Name.Prefix = new String[] { "Dr." }; // Add details about the practitioner's role Practitioner.PractitionerPractitionerRoleComponent pr = new Practitioner.PractitionerPractitionerRoleComponent(); Coding code = new Coding("urn:fhir.nhs.uk:vs/SDSJobRoleName", "R0090"); code.Display = "Hospital Practitioner"; pr.Role = new CodeableConcept(); pr.Role.Coding = new List<Coding>(); pr.Role.Coding.Add(code); // Add details about the practitioner's managing organisation pr.ManagingOrganization = new ResourceReference() { Reference = "Organization/41fe704c-18e5-11e5-b60b-1697f925ec7b" }; res.PractitionerRole.Add(pr); return res; }
public FhirModel.Task GetResource() { var LastUpdated = new DateTimeOffset(2018, 07, 27, 16, 37, 00, new TimeSpan(8, 0, 0)); var Resource = new FhirModel.Task(); Resource.Id = GetResourceId(); IPyroFhirServerCodeSystem.SetProtectedMetaTag(Resource); Resource.Meta.LastUpdated = MasterLastUpdated; Resource.Identifier = new List <FhirModel.Identifier>() { IPyroFhirServerCodeSystem.GetIdentifier(PyroHealthFhirResource.CodeSystems.PyroFhirServer.Codes.ServerStartupTask) }; //Task.Definition =?? Resource.Status = FhirModel.Task.TaskStatus.Ready; Resource.Intent = FhirModel.RequestIntent.Order; Resource.Priority = FhirModel.RequestPriority.Asap; Resource.Code = new FhirModel.CodeableConcept(); FhirModel.Coding LoadFhirSpecResourcesTaskCoding = new FhirModel.Coding(IPyroTask.GetSystem(), IPyroTask.GetCode(CodeSystems.PyroTask.Codes.LoadFhirDefinitionResources)); Resource.Code.Coding.Add(LoadFhirSpecResourcesTaskCoding); Resource.Description = "This task is used by the Pyro FHIR Server to load all the FHIR specification definition resource into the FHIR server instance on the first ever startup."; Resource.Focus = new FhirModel.ResourceReference($"{FhirModel.ResourceType.Device.GetLiteral()}/{IPyroFhirServerDevice.GetResourceId()}"); FhirModel.ResourceReference ServerManagingOrginationReferrence; FhirModel.ResourceReference PyroHealthOrgReference = new FhirModel.ResourceReference($"{FhirModel.ResourceType.Organization.GetLiteral()}/{IPyroHealthOrg.GetResourceId()}"); if (string.IsNullOrWhiteSpace(IGlobalProperties.ThisServersManagingOrganizationResource)) { ServerManagingOrginationReferrence = PyroHealthOrgReference; } else { ServerManagingOrginationReferrence = new FhirModel.ResourceReference(IGlobalProperties.ThisServersManagingOrganizationResource); } Resource.For = ServerManagingOrginationReferrence; Resource.AuthoredOn = new FhirModel.FhirDateTime(LastUpdated).ToString(); Resource.LastModified = new FhirModel.FhirDateTime(LastUpdated).ToString(); Resource.Requester = new FhirModel.Task.RequesterComponent(); Resource.Requester.OnBehalfOf = ServerManagingOrginationReferrence; Resource.Requester.Agent = PyroHealthOrgReference; Resource.PerformerType = new List <FhirModel.CodeableConcept>(); var PerformerTypeCodeableConcept = new FhirModel.CodeableConcept(); Resource.PerformerType.Add(PerformerTypeCodeableConcept); PerformerTypeCodeableConcept.Coding = new List <FhirModel.Coding>(); var PerformerTypeCoding = new FhirModel.Coding(); PerformerTypeCodeableConcept.Coding.Add(PerformerTypeCoding); PerformerTypeCoding.System = "http://hl7.org/fhir/task-performer-type"; PerformerTypeCoding.Code = "scheduler"; PerformerTypeCoding.Display = "Scheduler"; Resource.Owner = PyroHealthOrgReference; Resource.Reason = new FhirModel.CodeableConcept() { Text = "To Load the FHIR Specification base resources into the FHIR server instance" }; Resource.Restriction = new FhirModel.Task.RestrictionComponent() { Repetitions = 0 }; return(Resource); }
public S.Concept ToSystemConcept() { var codes = Coding.Select(c => c.ToSystemCode()); return(new S.Concept(codes, display: Text)); }