public void ShallReturnPractitioner() { var xml = XDocument.Load("C-CDA_R2-1_CCD.xml"); var element = xml.Root.CdaElement("author")?.CdaElement("assignedAuthor"); var result = new PractitionerParser().FromXml(element); result.Should().NotBeNull(); // Shall have id result.Id.Should().NotBeNullOrEmpty(); // US-Core Shall have identifier result.Identifier.Count.Should().BeGreaterThan(0); result.Identifier.All(i => !string.IsNullOrEmpty(i.System)).Should().BeTrue(); // US-Core Shall have name result.Name.Count.Should().Be(1); result.Name.All(n => !string.IsNullOrEmpty(n.Family)).Should().BeTrue(); }
/// <summary> /// Get a collection of practitioner given parameter /// </summary> /// <param name="para"> a string of content to be filtered </param> /// <returns> a collection of practitioner </returns> public async Task <IEnumerable <IPractitioner> > GetPractitionersAsync(string para = "") { var responseString = await client.GetStringAsync(PRACTITIONER_PAGE + para); var jObject = JObject.Parse(responseString); var practitioners = new List <IPractitioner>(); var array = jObject["entry"].Children <JObject>(); // Parsing the data in each json entry and add them into the practitioner list foreach (var o in array) { PractitionerParser practitionerParser = new PractitionerParser(); var toParse = (JObject)o["resource"]; // Certain practitioner does not have address so only include those have address var checkProperty = toParse.ContainsKey("address"); if (checkProperty) { practitioners.Add(practitionerParser.Parse(toParse)); } } return(practitioners); }
public void NullElementShallReturnNull() { var result = new PractitionerParser().FromXml(null); result.Should().BeNull(); }