/// <summary>Topic list from r 5.</summary>
        /// <param name="t5List">The topics.</param>
        /// <returns>The r4.Parameters.</returns>
        public static r4.Parameters TopicListFromR5(List <r5.SubscriptionTopic> t5List)
        {
            r4.Parameters t4 = new r4.Parameters();

            if (t5List == null)
            {
                return(t4);
            }

            foreach (r5.SubscriptionTopic topic in t5List)
            {
                t4.Add("subscription-topic-canonical", new Canonical(topic.Url));
            }

            return(t4);
        }
        /// <summary>Converts an R5 subscription to another FHIR version.</summary>
        /// <param name="status5">The SubscriptionStatus.</param>
        /// <returns>The desired version of a SubscriptionStatus.</returns>
        public static r4.Parameters StatusFromR5(r5.SubscriptionStatus status5)
        {
            if (status5 == null)
            {
                return(null);
            }

            r4.Parameters status4 = new r4.Parameters();

            status4.Add("subscription", new ResourceReference(Program.UrlForR5ResourceId("Subscription", status5.Subscription.Reference)));
            status4.Add("topic", new FhirUri(status5.Topic));
            status4.Add("events-since-subscription-start", new UnsignedInt((int?)status5.EventsSinceSubscriptionStart));
            status4.Add("events-in-notification", new UnsignedInt(status5.EventsInNotification));

            switch (status5.Status)
            {
            case r5.SubscriptionState.Active:
                status4.Add("status", new Code("active"));
                break;

            case r5.SubscriptionState.Error:
                status4.Add("status", new Code("error"));
                break;

            case r5.SubscriptionState.Off:
                status4.Add("status", new Code("off"));
                break;

            case r5.SubscriptionState.Requested:
                status4.Add("status", new Code("requested"));
                break;

            default:
                break;
            }

            switch (status5.Type)
            {
            case r5.SubscriptionStatus.SubscriptionNotificationType.Handshake:
                status4.Add("type", new Code("handshake"));
                break;

            case r5.SubscriptionStatus.SubscriptionNotificationType.Heartbeat:
                status4.Add("type", new Code("heartbeat"));
                break;

            case r5.SubscriptionStatus.SubscriptionNotificationType.EventNotification:
                status4.Add("type", new Code("event-notification"));
                break;

            case r5.SubscriptionStatus.SubscriptionNotificationType.QueryStatus:
                status4.Add("type", new Code("query-status"));
                break;
            }

            if ((status5.Error != null) && (status5.Error.Count > 0))
            {
                status4.Add("error", status5.Error[status5.Error.Count - 1]);
            }

            return(status4);
        }