public IEnumerable<TimelineEntry> GetTimelineForPatient(string patientIdentifier)
        {
            var timeline = new List<TimelineEntry>();

            var matchingEncounters = _client.Search(ResourceType.Encounter, "subject.identifier", patientIdentifier);
            var matchingAlerts = _client.Search(ResourceType.Alert, "subject.identifier", patientIdentifier);

            ProcessAlerts(timeline, matchingAlerts);
            ProcessEncounters(timeline, matchingEncounters);

            return timeline.OrderBy(x => x.StartTime).ThenBy(x => x.EndTime);
        }
        private String describeInvariants(List<Profile.ElementDefinitionConstraintComponent> constraints)
        {
            if (constraints == null || !constraints.Any())
                return null;

            StringBuilder s = new StringBuilder();

            if (constraints.Count > 0)
            {
                s.Append("<b>Defined on this element</b><br/>\r\n");

                var b = false;

                foreach (var inv in constraints.OrderBy(constr => constr.Key))
                {
                    if (b)
                        s.Append("<br/>");
                    else
                        b = true;

                    s.Append("<b title=\"Formal Invariant Identifier\">Inv-" + inv.Key + "</b>: " + WebUtility.HtmlEncode(inv.Human) +
                            " (xpath: " + WebUtility.HtmlEncode(inv.Xpath) + ")");
                }
            }

            return s.ToString();
        }