コード例 #1
0
ファイル: ResourceTriggerService.cs プロジェクト: eug48/Pyro
        private ITriggerOutcome ProcessTrigger(RestEnum.CrudOperationType CrudOperationType, TriggerRaisedType TriggerRaised, string ResourceId, FHIRAllTypes ResourceType, Resource Resource = null)
        {
            switch (ResourceType)
            {
            case FHIRAllTypes.CompartmentDefinition:
                return(ITriggerCompartmentDefinition.ProcessTrigger(CrudOperationType, TriggerRaised, ResourceId, ResourceType, Resource));

            default:
                //Return Contiune if no trigger processing required.
                return(new TriggerOutcome()
                {
                    TriggerOutcomeResult = TriggerOutcome.TriggerOutcomeType.Contiune
                });
            }
        }
コード例 #2
0
        private ITriggerOutcome ProcessUpdateOrDelete(RestEnum.CrudOperationType crudOperationType, ResourceTriggerService.TriggerRaisedType triggerRaised, string resourceId, FHIRAllTypes resourceType, Resource resource)
        {
            //Get any Compartment with the same FhirId
            var ServiceCompartment = IServiceCompartmentRepository.GetServiceCompartmentByFhirId(resourceId);

            if (ServiceCompartment != null)
            {
                string Message = "Error Message Not Set";
                if (crudOperationType == RestEnum.CrudOperationType.Update)
                {
                    //If so do not allow the update
                    Message = $"The {FHIRAllTypes.CompartmentDefinition.GetLiteral()} resource cannot be updated because it is an active Compartment in the server. " +
                              $"You must first set this compartment to Inactive before you can updated this resource. " +
                              $"To do this you will need to call the server Operation ${FhirOperationEnum.OperationType.xSetCompartmentInActive.GetPyroLiteral()} on this resource instance. " +
                              $"For example '[base]/{FHIRAllTypes.CompartmentDefinition.GetLiteral()}/{resourceId}/${FhirOperationEnum.OperationType.xSetCompartmentInActive.GetPyroLiteral()}' " +
                              $"Once Inactive you will then be able to update this resource in the server. " +
                              $"Caution should be taken as active Compartments affect how users interact with the server and the resources they have access to. " +
                              $"To re-activate the Compartment after updating you must call the Operation ${FhirOperationEnum.OperationType.xSetCompartmentActive.GetPyroLiteral()}. " +
                              $"For example '[base]/{FHIRAllTypes.CompartmentDefinition.GetLiteral()}/{resourceId}/${FhirOperationEnum.OperationType.xSetCompartmentActive.GetPyroLiteral()}' ";
                }
                else if (crudOperationType == RestEnum.CrudOperationType.Delete)
                {
                    Message = $"The {FHIRAllTypes.CompartmentDefinition.GetLiteral()} resource cannot be deleted because it is an active Compartment in the server. " +
                              $"You must first set this compartment to Inactive before you can delete this resource. " +
                              $"To do this you will need to call the server Operation ${FhirOperationEnum.OperationType.xSetCompartmentInActive.GetPyroLiteral()} on this resource instance. " +
                              $"For example '[base]/{FHIRAllTypes.CompartmentDefinition.GetLiteral()}/{resourceId}/${FhirOperationEnum.OperationType.xSetCompartmentInActive.GetPyroLiteral()}' " +
                              $"Once Inactive you will then be able to delete this resource from the server. " +
                              $"Caution should be taken as active Compartments affect how users interact with the server and the resources they have access to.";
                }
                var ReturnOperationOutcome = FhirOperationOutcomeSupport.Create(OperationOutcome.IssueSeverity.Error, OperationOutcome.IssueType.BusinessRule, Message);
                var TriggerOutcome         = new TriggerOutcome();
                TriggerOutcome.HttpStatusCode       = System.Net.HttpStatusCode.Conflict;
                TriggerOutcome.TriggerOutcomeResult = TriggerOutcome.TriggerOutcomeType.Report;
                TriggerOutcome.Resource             = ReturnOperationOutcome;
                return(TriggerOutcome);
            }
            else
            {
                //the Compartmentdefinition is not active so can be Updated or deleted, if updating then ensure
                //the active tags are not present and remove if they are
                RemoveActiveCompartmentTag(resource);
            }

            return(new TriggerOutcome()
            {
                TriggerOutcomeResult = TriggerOutcome.TriggerOutcomeType.Contiune
            });
        }
コード例 #3
0
 public ITriggerOutcome ProcessTrigger(RestEnum.CrudOperationType CrudOperationType, ResourceTriggerService.TriggerRaisedType TriggerRaised, string ResourceId, FHIRAllTypes ResourceType, Resource Resource = null)
 {
     if ((CrudOperationType == RestEnum.CrudOperationType.Update || CrudOperationType == RestEnum.CrudOperationType.Delete) && TriggerRaised == ResourceTriggerService.TriggerRaisedType.BeforeCommit)
     {
         return(ProcessUpdateOrDelete(CrudOperationType, TriggerRaised, ResourceId, ResourceType, Resource));
     }
     else if (CrudOperationType == RestEnum.CrudOperationType.Create && TriggerRaised == ResourceTriggerService.TriggerRaisedType.BeforeCommit)
     {
         RemoveActiveCompartmentTag(Resource);
         return(new TriggerOutcome()
         {
             TriggerOutcomeResult = TriggerOutcome.TriggerOutcomeType.Contiune
         });
     }
     else
     {
         return(new TriggerOutcome()
         {
             TriggerOutcomeResult = TriggerOutcome.TriggerOutcomeType.Contiune
         });
     }
 }
コード例 #4
0
ファイル: ResourceTriggerService.cs プロジェクト: eug48/Pyro
 /// <summary>
 /// Primarily used for Create & Update actions where a Resource is given in the API call
 /// Previous resource version can be sccourced from the database by version if required
 /// </summary>
 /// <param name="CrudOperationType"></param>
 /// <param name="Resource"></param>
 public ITriggerOutcome Trigger(RestEnum.CrudOperationType CrudOperationType, TriggerRaisedType TriggerRaised, Resource Resource)
 {
     return(ProcessTrigger(CrudOperationType, TriggerRaised, Resource.Id, ResourceNameResolutionSupport.GetResourceFhirAllType(Resource.ResourceType), Resource));
 }
コード例 #5
0
ファイル: ResourceTriggerService.cs プロジェクト: eug48/Pyro
 /// <summary>
 /// Primarily used for Delete actions as their is no Resource given in the API call
 /// However services can scource the resource being deleted from the database
 /// </summary>
 /// <param name="CrudOperationType"></param>
 /// <param name="ResourceId"></param>
 /// <param name="ResourceType"></param>
 public ITriggerOutcome Trigger(RestEnum.CrudOperationType CrudOperationType, TriggerRaisedType TriggerRaised, string ResourceId, FHIRAllTypes ResourceType)
 {
     return(ProcessTrigger(CrudOperationType, TriggerRaised, ResourceId, ResourceType));
 }