Beispiel #1
0
        /// <summary>
        /// Deserialize JSON into a FHIR CompartmentDefinition
        /// </summary>
        public static void DeserializeJson(this CompartmentDefinition current, ref Utf8JsonReader reader, JsonSerializerOptions options)
        {
            string propertyName;

            while (reader.Read())
            {
                if (reader.TokenType == JsonTokenType.EndObject)
                {
                    return;
                }

                if (reader.TokenType == JsonTokenType.PropertyName)
                {
                    propertyName = reader.GetString();
                    if (Hl7.Fhir.Serialization.FhirSerializerOptions.Debug)
                    {
                        Console.WriteLine($"CompartmentDefinition >>> CompartmentDefinition.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    reader.Read();
                    current.DeserializeJsonProperty(ref reader, options, propertyName);
                }
            }

            throw new JsonException($"CompartmentDefinition: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
        }
Beispiel #2
0
        private static void AddCompartmentActiveTag(CompartmentDefinition CompartDef)
        {
            if (CompartDef.Meta == null)
            {
                CompartDef.Meta = new Meta();
            }
            if (CompartDef.Meta.Tag == null)
            {
                CompartDef.Meta.Tag = new List <Coding>();
            }
            var PyroCodeSystem = PyroHealthInformation.PyroServerCodeSystem.GetCodeSystem();
            var PyroActiveCode = PyroCodeSystem.Concept.Single(x => x.Code == PyroHealthInformation.PyroServerCodeSystem.Codes.ActiveCompartment.GetPyroLiteral());

            CompartDef.Meta.Tag.Add(new Coding(PyroCodeSystem.Url, PyroActiveCode.Code, PyroActiveCode.Display));
        }
Beispiel #3
0
        public IResourceServiceOutcome SetInActive(OperationClass OperationClass, IRequestMeta RequestMeta, string FhirId)
        {
            ResourceServiceOutcome = IResourceServiceOutcomeFactory.CreateResourceServiceOutcome();
            CompartmentDefinition CompartDef = GetCompartmentResource(FhirId);

            if (CompartDef != null)
            {
                var DbServiceCompartment = IServiceCompartmentRepository.GetServiceCompartmentByFhirId(CompartDef.Id);
                if (DbServiceCompartment != null)
                {
                    IServiceCompartmentRepository.DeleteServiceCompartment(DbServiceCompartment.Code);
                    ClearCompartmentCache(DbServiceCompartment.Code);
                }
                //Regadless of the Compartment being there or not we return NoContent when it is deleted.
                ResourceServiceOutcome.HttpStatusCode        = System.Net.HttpStatusCode.NoContent;
                ResourceServiceOutcome.FhirResourceId        = null;
                ResourceServiceOutcome.LastModified          = null;
                ResourceServiceOutcome.IsDeleted             = null;
                ResourceServiceOutcome.OperationType         = RestEnum.CrudOperationType.Delete;
                ResourceServiceOutcome.ResourceVersionNumber = null;
                ResourceServiceOutcome.RequestUri            = RequestMeta.PyroRequestUri.FhirRequestUri;
                ResourceServiceOutcome.SuccessfulTransaction = true;
                return(ResourceServiceOutcome);
            }
            else
            {
                //Not CompartmentDefinition Resource found
                ResourceServiceOutcome.ResourceResult = Common.Tools.FhirOperationOutcomeSupport.Create(OperationOutcome.IssueSeverity.Fatal, OperationOutcome.IssueType.NotSupported,
                                                                                                        $"The resource id supplied to the ${FhirOperationEnum.OperationType.xSetCompartmentActive.GetPyroLiteral()} operation was not found in the server at: {ResourceType.CompartmentDefinition.GetLiteral()}/{FhirId}");
                ResourceServiceOutcome.HttpStatusCode        = System.Net.HttpStatusCode.NotFound;
                ResourceServiceOutcome.FhirResourceId        = null;
                ResourceServiceOutcome.LastModified          = null;
                ResourceServiceOutcome.IsDeleted             = null;
                ResourceServiceOutcome.OperationType         = RestEnum.CrudOperationType.Read;
                ResourceServiceOutcome.ResourceVersionNumber = null;
                ResourceServiceOutcome.RequestUri            = RequestMeta.PyroRequestUri.FhirRequestUri;
                ResourceServiceOutcome.HttpStatusCode        = System.Net.HttpStatusCode.NotFound;
                ResourceServiceOutcome.SuccessfulTransaction = true;
                return(ResourceServiceOutcome);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Serialize a FHIR CompartmentDefinition into JSON
        /// </summary>
        public static void SerializeJson(this CompartmentDefinition current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            writer.WriteString("resourceType", "CompartmentDefinition");
            // Complex: CompartmentDefinition, Export: CompartmentDefinition, Base: DomainResource (DomainResource)
            ((Hl7.Fhir.Model.DomainResource)current).SerializeJson(writer, options, false);

            writer.WriteString("url", current.UrlElement.Value);

            if (current.VersionElement != null)
            {
                if (!string.IsNullOrEmpty(current.VersionElement.Value))
                {
                    writer.WriteString("version", current.VersionElement.Value);
                }
                if (current.VersionElement.HasExtensions() || (!string.IsNullOrEmpty(current.VersionElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_version", false, current.VersionElement.Extension, current.VersionElement.ElementId);
                }
            }

            writer.WriteString("name", current.NameElement.Value);

            writer.WriteString("status", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.StatusElement.Value));

            if (current.ExperimentalElement != null)
            {
                if (current.ExperimentalElement.Value != null)
                {
                    writer.WriteBoolean("experimental", (bool)current.ExperimentalElement.Value);
                }
                if (current.ExperimentalElement.HasExtensions() || (!string.IsNullOrEmpty(current.ExperimentalElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_experimental", false, current.ExperimentalElement.Extension, current.ExperimentalElement.ElementId);
                }
            }

            if (current.DateElement != null)
            {
                if (!string.IsNullOrEmpty(current.DateElement.Value))
                {
                    writer.WriteString("date", current.DateElement.Value);
                }
                if (current.DateElement.HasExtensions() || (!string.IsNullOrEmpty(current.DateElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_date", false, current.DateElement.Extension, current.DateElement.ElementId);
                }
            }

            if (current.PublisherElement != null)
            {
                if (!string.IsNullOrEmpty(current.PublisherElement.Value))
                {
                    writer.WriteString("publisher", current.PublisherElement.Value);
                }
                if (current.PublisherElement.HasExtensions() || (!string.IsNullOrEmpty(current.PublisherElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_publisher", false, current.PublisherElement.Extension, current.PublisherElement.ElementId);
                }
            }

            if ((current.Contact != null) && (current.Contact.Count != 0))
            {
                writer.WritePropertyName("contact");
                writer.WriteStartArray();
                foreach (ContactDetail val in current.Contact)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if (current.Description != null)
            {
                if (!string.IsNullOrEmpty(current.Description.Value))
                {
                    writer.WriteString("description", current.Description.Value);
                }
                if (current.Description.HasExtensions() || (!string.IsNullOrEmpty(current.Description.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_description", false, current.Description.Extension, current.Description.ElementId);
                }
            }

            if ((current.UseContext != null) && (current.UseContext.Count != 0))
            {
                writer.WritePropertyName("useContext");
                writer.WriteStartArray();
                foreach (UsageContext val in current.UseContext)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if (current.Purpose != null)
            {
                if (!string.IsNullOrEmpty(current.Purpose.Value))
                {
                    writer.WriteString("purpose", current.Purpose.Value);
                }
                if (current.Purpose.HasExtensions() || (!string.IsNullOrEmpty(current.Purpose.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_purpose", false, current.Purpose.Extension, current.Purpose.ElementId);
                }
            }

            writer.WriteString("code", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.CodeElement.Value));

            writer.WriteBoolean("search", (bool)current.SearchElement.Value);

            if ((current.Resource != null) && (current.Resource.Count != 0))
            {
                writer.WritePropertyName("resource");
                writer.WriteStartArray();
                foreach (CompartmentDefinition.ResourceComponent val in current.Resource)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Beispiel #5
0
        /// <summary>
        /// Deserialize JSON into a FHIR CompartmentDefinition
        /// </summary>
        public static void DeserializeJsonProperty(this CompartmentDefinition current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "url":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.UrlElement = new FhirUri();
                    reader.Skip();
                }
                else
                {
                    current.UrlElement = new FhirUri(reader.GetString());
                }
                break;

            case "_url":
                if (current.UrlElement == null)
                {
                    current.UrlElement = new FhirUri();
                }
                ((Hl7.Fhir.Model.Element)current.UrlElement).DeserializeJson(ref reader, options);
                break;

            case "version":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.VersionElement = new FhirString();
                    reader.Skip();
                }
                else
                {
                    current.VersionElement = new FhirString(reader.GetString());
                }
                break;

            case "_version":
                if (current.VersionElement == null)
                {
                    current.VersionElement = new FhirString();
                }
                ((Hl7.Fhir.Model.Element)current.VersionElement).DeserializeJson(ref reader, options);
                break;

            case "name":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.NameElement = new FhirString();
                    reader.Skip();
                }
                else
                {
                    current.NameElement = new FhirString(reader.GetString());
                }
                break;

            case "_name":
                if (current.NameElement == null)
                {
                    current.NameElement = new FhirString();
                }
                ((Hl7.Fhir.Model.Element)current.NameElement).DeserializeJson(ref reader, options);
                break;

            case "status":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.PublicationStatus>();
                    reader.Skip();
                }
                else
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.PublicationStatus>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.PublicationStatus>(reader.GetString()));
                }
                break;

            case "_status":
                if (current.StatusElement == null)
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.PublicationStatus>();
                }
                ((Hl7.Fhir.Model.Element)current.StatusElement).DeserializeJson(ref reader, options);
                break;

            case "experimental":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.ExperimentalElement = new FhirBoolean();
                    reader.Skip();
                }
                else
                {
                    current.ExperimentalElement = new FhirBoolean(reader.GetBoolean());
                }
                break;

            case "_experimental":
                if (current.ExperimentalElement == null)
                {
                    current.ExperimentalElement = new FhirBoolean();
                }
                ((Hl7.Fhir.Model.Element)current.ExperimentalElement).DeserializeJson(ref reader, options);
                break;

            case "date":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.DateElement = new FhirDateTime();
                    reader.Skip();
                }
                else
                {
                    current.DateElement = new FhirDateTime(reader.GetString());
                }
                break;

            case "_date":
                if (current.DateElement == null)
                {
                    current.DateElement = new FhirDateTime();
                }
                ((Hl7.Fhir.Model.Element)current.DateElement).DeserializeJson(ref reader, options);
                break;

            case "publisher":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.PublisherElement = new FhirString();
                    reader.Skip();
                }
                else
                {
                    current.PublisherElement = new FhirString(reader.GetString());
                }
                break;

            case "_publisher":
                if (current.PublisherElement == null)
                {
                    current.PublisherElement = new FhirString();
                }
                ((Hl7.Fhir.Model.Element)current.PublisherElement).DeserializeJson(ref reader, options);
                break;

            case "contact":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"CompartmentDefinition error reading 'contact' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Contact = new List <ContactDetail>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.ContactDetail v_Contact = new Hl7.Fhir.Model.ContactDetail();
                    v_Contact.DeserializeJson(ref reader, options);
                    current.Contact.Add(v_Contact);

                    if (!reader.Read())
                    {
                        throw new JsonException($"CompartmentDefinition error reading 'contact' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Contact.Count == 0)
                {
                    current.Contact = null;
                }
                break;

            case "description":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.Description = new Markdown();
                    reader.Skip();
                }
                else
                {
                    current.Description = new Markdown(reader.GetString());
                }
                break;

            case "_description":
                if (current.Description == null)
                {
                    current.Description = new Markdown();
                }
                ((Hl7.Fhir.Model.Element)current.Description).DeserializeJson(ref reader, options);
                break;

            case "useContext":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"CompartmentDefinition error reading 'useContext' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.UseContext = new List <UsageContext>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.UsageContext v_UseContext = new Hl7.Fhir.Model.UsageContext();
                    v_UseContext.DeserializeJson(ref reader, options);
                    current.UseContext.Add(v_UseContext);

                    if (!reader.Read())
                    {
                        throw new JsonException($"CompartmentDefinition error reading 'useContext' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.UseContext.Count == 0)
                {
                    current.UseContext = null;
                }
                break;

            case "purpose":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.Purpose = new Markdown();
                    reader.Skip();
                }
                else
                {
                    current.Purpose = new Markdown(reader.GetString());
                }
                break;

            case "_purpose":
                if (current.Purpose == null)
                {
                    current.Purpose = new Markdown();
                }
                ((Hl7.Fhir.Model.Element)current.Purpose).DeserializeJson(ref reader, options);
                break;

            case "code":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.CodeElement = new Code <Hl7.Fhir.Model.CompartmentType>();
                    reader.Skip();
                }
                else
                {
                    current.CodeElement = new Code <Hl7.Fhir.Model.CompartmentType>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.CompartmentType>(reader.GetString()));
                }
                break;

            case "_code":
                if (current.CodeElement == null)
                {
                    current.CodeElement = new Code <Hl7.Fhir.Model.CompartmentType>();
                }
                ((Hl7.Fhir.Model.Element)current.CodeElement).DeserializeJson(ref reader, options);
                break;

            case "search":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.SearchElement = new FhirBoolean();
                    reader.Skip();
                }
                else
                {
                    current.SearchElement = new FhirBoolean(reader.GetBoolean());
                }
                break;

            case "_search":
                if (current.SearchElement == null)
                {
                    current.SearchElement = new FhirBoolean();
                }
                ((Hl7.Fhir.Model.Element)current.SearchElement).DeserializeJson(ref reader, options);
                break;

            case "resource":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"CompartmentDefinition error reading 'resource' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Resource = new List <CompartmentDefinition.ResourceComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.CompartmentDefinition.ResourceComponent v_Resource = new Hl7.Fhir.Model.CompartmentDefinition.ResourceComponent();
                    v_Resource.DeserializeJson(ref reader, options);
                    current.Resource.Add(v_Resource);

                    if (!reader.Read())
                    {
                        throw new JsonException($"CompartmentDefinition error reading 'resource' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Resource.Count == 0)
                {
                    current.Resource = null;
                }
                break;

            // Complex: CompartmentDefinition, Export: CompartmentDefinition, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Beispiel #6
0
        public IResourceServiceOutcome SetActive(OperationClass OperationClass, IRequestMeta RequestMeta, string FhirId)
        {
            if (OperationClass == null)
            {
                throw new NullReferenceException("OperationClass cannot be null.");
            }
            if (IResourceServices == null)
            {
                throw new NullReferenceException("ResourceServices cannot be null.");
            }
            if (RequestMeta == null)
            {
                throw new NullReferenceException("RequestMeta cannot be null.");
            }
            if (RequestMeta.PyroRequestUri == null)
            {
                throw new NullReferenceException("RequestUri cannot be null.");
            }
            if (RequestMeta.RequestHeader == null)
            {
                throw new NullReferenceException("RequestHeaders cannot be null.");
            }
            if (RequestMeta.SearchParameterGeneric == null)
            {
                throw new NullReferenceException("SearchParameterGeneric cannot be null.");
            }

            ResourceServiceOutcome = IResourceServiceOutcomeFactory.CreateResourceServiceOutcome();

            CompartmentDefinition CompartDef = GetCompartmentResource(FhirId);

            if (CompartDef != null)
            {
                if (CompartDef.Status != PublicationStatus.Active)
                {
                    ResourceServiceOutcome.ResourceResult = Common.Tools.FhirOperationOutcomeSupport.Create(OperationOutcome.IssueSeverity.Fatal, OperationOutcome.IssueType.NotSupported,
                                                                                                            $"The {ResourceType.CompartmentDefinition.GetLiteral()} resource status must be {PublicationStatus.Active.GetLiteral()}. The resource supplied has a status of {CompartDef.Status.GetLiteral()}.");
                    ResourceServiceOutcome.HttpStatusCode        = System.Net.HttpStatusCode.BadRequest;
                    ResourceServiceOutcome.SuccessfulTransaction = true;
                    return(ResourceServiceOutcome);
                }
                if (string.IsNullOrWhiteSpace(CompartDef.Id))
                {
                    ResourceServiceOutcome.ResourceResult = Common.Tools.FhirOperationOutcomeSupport.Create(OperationOutcome.IssueSeverity.Fatal, OperationOutcome.IssueType.NotSupported,
                                                                                                            $"The {ResourceType.CompartmentDefinition.GetLiteral()} resource must have a resource id.");
                    ResourceServiceOutcome.HttpStatusCode        = System.Net.HttpStatusCode.BadRequest;
                    ResourceServiceOutcome.SuccessfulTransaction = true;
                    return(ResourceServiceOutcome);
                }

                if (CompartDef.Url.StartsWith(HL7OrgUrl) || CompartDef.Url.StartsWith(PyroOrgUrl))
                {
                    DtoServiceCompartment NewServiceCompartment = new DtoServiceCompartment();
                    NewServiceCompartment.CompartmentDefinitionResourceId      = CompartDef.Id;
                    NewServiceCompartment.CompartmentDefinitionResourceVersion = CompartDef.Meta.VersionId;
                    NewServiceCompartment.Code         = CompartDef.Code.GetLiteral();
                    NewServiceCompartment.LastUpdated  = DateTimeOffset.Now;
                    NewServiceCompartment.Name         = CompartDef.Name;
                    NewServiceCompartment.Title        = CompartDef.Title;
                    NewServiceCompartment.Url          = CompartDef.Url;
                    NewServiceCompartment.ResourceList = new List <DtoServiceCompartmentResource>();
                    foreach (var ResourceComponent in CompartDef.Resource)
                    {
                        List <Search.DtoServiceSearchParameterLight> SupportedSerachParamList = IServiceSearchParameterCache.GetSearchParameterForResource(ResourceComponent.Code.GetLiteral());
                        if (ResourceComponent.Param.Count() == 0)
                        {
                            var CompatmentResource = new DtoServiceCompartmentResource()
                            {
                                Code = ResourceComponent.Code.GetLiteral(),
                                // '*' means no paramerter, which means all Resource of this type
                                //are in the compartment.
                                //If there is no 'ResourceComponent' at all then that Resources type and all its instances
                                //are not in the compartment
                                Param = "*"
                            };
                            NewServiceCompartment.ResourceList.Add(CompatmentResource);
                        }

                        foreach (var Param in ResourceComponent.Param)
                        {
                            //The Resource param value equals {def} then thnis shoudl be the same Resource as that of the Compartment its self
                            //in this case there are no search parameters
                            if (Param.ToLower() == "{def}")
                            {
                                if (ResourceComponent.Code.GetLiteral() != CompartDef.Code.GetLiteral())
                                {
                                    ResourceServiceOutcome.ResourceResult = Common.Tools.FhirOperationOutcomeSupport.Create(OperationOutcome.IssueSeverity.Fatal, OperationOutcome.IssueType.NotSupported,
                                                                                                                            $"The {ResourceType.CompartmentDefinition.GetLiteral()} resource has a search parameter that has a value of '{{def}}' which should indicate that this Resource is the target of the Compatment it's self, Yet they do not match, Compartment is: '{ResourceComponent.Code.GetLiteral()}' and '{{def}}' parametrer is found for ResourceType {ResourceComponent.Code.GetLiteral()}");
                                    ResourceServiceOutcome.HttpStatusCode        = System.Net.HttpStatusCode.BadRequest;
                                    ResourceServiceOutcome.SuccessfulTransaction = true;
                                    return(ResourceServiceOutcome);
                                }
                            }
                            else
                            {
                                var FoundParam = SupportedSerachParamList.SingleOrDefault(x => x.Name == Param.Split('.')[0].Split(':')[0]);
                                if (FoundParam != null)
                                {
                                    if (FoundParam.Type != SearchParamType.Reference)
                                    {
                                        ResourceServiceOutcome.ResourceResult = Common.Tools.FhirOperationOutcomeSupport.Create(OperationOutcome.IssueSeverity.Fatal, OperationOutcome.IssueType.NotSupported,
                                                                                                                                $"The {ResourceType.CompartmentDefinition.GetLiteral()} resource has a search parameter that is not a Reference search parameter type. The parameter in question is '{Param}' for the resource '{ResourceComponent.Code.GetLiteral()}'");
                                        ResourceServiceOutcome.HttpStatusCode        = System.Net.HttpStatusCode.BadRequest;
                                        ResourceServiceOutcome.SuccessfulTransaction = true;
                                        return(ResourceServiceOutcome);
                                    }
                                }
                                else
                                {
                                    ResourceServiceOutcome.ResourceResult = Common.Tools.FhirOperationOutcomeSupport.Create(OperationOutcome.IssueSeverity.Fatal, OperationOutcome.IssueType.NotSupported,
                                                                                                                            $"The {ResourceType.CompartmentDefinition.GetLiteral()} resource has a search parameter that is not supported by the server. The parameter in question is '{Param}' for the resource '{ResourceComponent.Code.GetLiteral()}'");
                                    ResourceServiceOutcome.HttpStatusCode        = System.Net.HttpStatusCode.BadRequest;
                                    ResourceServiceOutcome.SuccessfulTransaction = true;
                                    return(ResourceServiceOutcome);
                                }

                                var CompatmentResource = new DtoServiceCompartmentResource()
                                {
                                    Code  = ResourceComponent.Code.GetLiteral(),
                                    Param = Param
                                };
                                NewServiceCompartment.ResourceList.Add(CompatmentResource);
                            }
                        }
                    }

                    //Commit or Update the compartment
                    NewServiceCompartment = IServiceCompartmentRepository.UpdateServiceCompartment(NewServiceCompartment);
                    ClearCompartmentCache(NewServiceCompartment.Code);
                    AddCompartmentActiveTag(CompartDef);

                    //Commit CompartmentDefinition with Active tag, disable triggers on doing so as the triggers will block
                    //the update.
                    IRequestMeta RequestMetaUpdateCompartmentDef = IRequestMetaFactory.CreateRequestMeta().Set($"{FHIRAllTypes.CompartmentDefinition}/{CompartDef.Id}");
                    IResourceServices.TriggersActive = false;
                    var IResourceServicesOutcome = IResourceServices.Put(CompartDef.Id, CompartDef, RequestMetaUpdateCompartmentDef);
                    IResourceServices.TriggersActive = true;

                    ResourceServiceOutcome.HttpStatusCode        = System.Net.HttpStatusCode.OK;
                    ResourceServiceOutcome.IsDeleted             = false;
                    ResourceServiceOutcome.OperationType         = RestEnum.CrudOperationType.Update;
                    ResourceServiceOutcome.SuccessfulTransaction = true;
                    return(ResourceServiceOutcome);
                }
                else
                {
                    ResourceServiceOutcome.ResourceResult = Common.Tools.FhirOperationOutcomeSupport.Create(OperationOutcome.IssueSeverity.Fatal, OperationOutcome.IssueType.NotSupported,
                                                                                                            $"The {ResourceType.CompartmentDefinition.GetLiteral()} resource url property must start with either: '{HL7OrgUrl}' or '{PyroOrgUrl}'. The resource supplied has a url property of '{CompartDef.Url}'.");
                    ResourceServiceOutcome.HttpStatusCode        = System.Net.HttpStatusCode.BadRequest;
                    ResourceServiceOutcome.SuccessfulTransaction = true;
                    return(ResourceServiceOutcome);
                }
            }
            else
            {
                //Not CompartmentDefinition Resource found
                ResourceServiceOutcome.ResourceResult = Common.Tools.FhirOperationOutcomeSupport.Create(OperationOutcome.IssueSeverity.Fatal, OperationOutcome.IssueType.NotSupported,
                                                                                                        $"The resource id supplied to the ${FhirOperationEnum.OperationType.xSetCompartmentActive.GetPyroLiteral()} operation was not found in the server at: {ResourceType.CompartmentDefinition.GetLiteral()}/{FhirId}");
                ResourceServiceOutcome.HttpStatusCode        = System.Net.HttpStatusCode.NotFound;
                ResourceServiceOutcome.FhirResourceId        = null;
                ResourceServiceOutcome.LastModified          = null;
                ResourceServiceOutcome.IsDeleted             = null;
                ResourceServiceOutcome.OperationType         = RestEnum.CrudOperationType.Read;
                ResourceServiceOutcome.ResourceVersionNumber = null;
                ResourceServiceOutcome.RequestUri            = RequestMeta.PyroRequestUri.FhirRequestUri;
                ResourceServiceOutcome.HttpStatusCode        = System.Net.HttpStatusCode.NotFound;
                ResourceServiceOutcome.SuccessfulTransaction = true;
                return(ResourceServiceOutcome);
            }
        }