示例#1
0
        /// <summary>
        /// Удалить выделенную операцию
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            try
            {
                int currentNumber = OperationList.CurrentCellAddress.Y;
                if (currentNumber < 0)
                {
                    MessageBox.Show("Нет выделенных записей", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                OperationClass operationInfo = GetSelectedOperation();
                if (operationInfo.OpenedOperationViewForm != null && !operationInfo.OpenedOperationViewForm.IsDisposed)
                {
                    MessageBox.Show("Данная операция заблокирована для удаления,\r\nтак как она в данный момент редактируется.\r\nЗакройте окно просмотра информации по данной операции\r\nи попробуйте ещё раз.", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    operationInfo.OpenedOperationViewForm.Focus();
                    return;
                }

                if (DialogResult.Yes == MessageBox.Show("Вы уверены, что хотите удалить все данные об операции " + OperationList.Rows[currentNumber].Cells[1].Value + "?\r\nДанная операция необратима.", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    _patientInfo.DeleteOperation(Convert.ToInt32(OperationList.Rows[currentNumber].Cells[0].Value));
                }

                ShowOperations();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
        /// <summary>
        /// Положить введённые данные в операцию и пациента
        /// </summary>
        /// <param name="operationInfo">Информация про операцию</param>
        /// <param name="patientInfo">Информация о пациенте</param>
        private void PutDataToOperationAndPatient(OperationClass operationInfo, PatientClass patientInfo)
        {
            operationInfo.BeforeOperationEpicrisisIsDairyEnabled = checkBoxDnevnik.Checked;

            operationInfo.BeforeOperationEpicrisisADFirst     = (int)numericUpDownADFirst.Value;
            operationInfo.BeforeOperationEpicrisisADSecond    = (int)numericUpDownADSecond.Value;
            operationInfo.BeforeOperationEpicrisisBreath      = comboBoxBreath.Text;
            operationInfo.BeforeOperationEpicrisisChDD        = (int)numericUpDownChDD.Value;
            operationInfo.BeforeOperationEpicrisisComplaints  = textBoxComplaints.Text;
            operationInfo.BeforeOperationEpicrisisState       = comboBoxState.Text;
            operationInfo.BeforeOperationEpicrisisHeartRhythm = comboBoxHeartRhythm.Text;
            operationInfo.BeforeOperationEpicrisisHeartSounds = comboBoxHeartSounds.Text;
            operationInfo.BeforeOperationEpicrisisPulse       = (int)numericUpDownPulse.Value;
            operationInfo.BeforeOperationEpicrisisStLocalis   = textBoxStLocalis.Text;
            operationInfo.BeforeOperationEpicrisisStomach     = textBoxStomach.Text;
            operationInfo.BeforeOperationEpicrisisStool       = textBoxStool.Text;
            operationInfo.BeforeOperationEpicrisisTemperature = textBoxTemperature.Text;
            operationInfo.BeforeOperationEpicrisisUrination   = textBoxUrination.Text;
            operationInfo.BeforeOperationEpicrisisWheeze      = textBoxWheeze.Text;

            patientInfo.IsTreatmentPlanActiveInOperationProtocol = checkBoxPlan.Checked;
            patientInfo.TreatmentPlanInspection = comboBoxInspectionPlan.Text;
            patientInfo.TreatmentPlanDate       = dateTimePickerDatePlan.Value;

            operationInfo.BeforeOperationEpicrisisIsAntibioticProphylaxisExist = checkBoxAntibioticProphylaxis.Checked;
            operationInfo.BeforeOperationEpicrisisAntibioticProphylaxis        = comboBoxAntibioticProphylaxis.Text;

            operationInfo.OperationCourse = textBoxOperationCourse.Text.TrimEnd(new[] { '\r', '\n' });
        }
示例#3
0
        /// <summary>
        /// Редактировать выделенную операцию
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonView_Click(object sender, EventArgs e)
        {
            int currentNumber = OperationList.CurrentCellAddress.Y;

            if (currentNumber < 0)
            {
                MessageBox.Show("Нет выделенных записей", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            OperationClass selectedOperation = GetSelectedOperation();

            if (selectedOperation.OpenedOperationViewForm == null || selectedOperation.OpenedOperationViewForm.IsDisposed)
            {
                selectedOperation.OpenedOperationViewForm = new OperationViewForm(this, _dbEngine, selectedOperation, _patientInfo)
                {
                    MdiParent = MdiParent
                };
                selectedOperation.OpenedOperationViewForm.Show();
            }
            else
            {
                selectedOperation.OpenedOperationViewForm.Focus();
            }
        }
 public ISearchParametersServiceOutcome ProcessOperationSearchParameters(
     ISearchParameterGeneric SearchParameterGeneric,
     SearchParameterServiceType SearchParameterServiceType,
     OperationClass OperationClass)
 {
     return(ProcessSearchParameters(SearchParameterGeneric, SearchParameterServiceType, null, OperationClass));
 }
示例#5
0
        public void Test_HISearchMedicareNumber()
        {
            IResourceServiceOutcomeFactory IResourceServiceOutcomeFactory = CommonTestSetup.TestSetupMocks.GetIResourceServiceOutcomeFactory();
            IPyroFhirUriFactory            IPyroFhirUriFactory            = CommonTestSetup.TestSetupMocks.GetIPyroFhirUriFactory();
            IResourceServices     IResourceServices     = GetIResourceServices();
            IGlobalProperties     IGlobalProperties     = CommonTestSetup.TestSetupMocks.GetIGlobalProperties();
            IHiServiceApi         IHiServiceApi         = GetMokIHiServiceApi();
            IMedicareNumberParser IMedicareNumberParser = new MedicareNumberParser();
            IIndividualHealthcareIdentifierParser IIndividualHealthcareIdentifierParser = new IndividualHealthcareIdentifierParser();
            IDVANumberParser    IDVANumberParser   = new DVANumberParser();
            IRequestMetaFactory RequestMetaFactory = CommonTestSetup.TestSetupMocks.GetIRequestMetaFactory();
            INationalHealthcareIdentifierInfo INationalHealthcareIdentifierInfo = new NationalHealthcareIdentifierInfo();
            IMedicareNumberInfo IMedicareNumberInfo = new MedicareNumberInfo();

            Common.PyroHealthFhirResource.CodeSystems.IPyroFhirServer IPyroFhirServerCodeSystem = new Common.PyroHealthFhirResource.CodeSystems.PyroFhirServer();


            IHISearchOrValidateOperation IHISearchOrValidateOperationService = new IHISearchOrValidateOperation(
                IResourceServiceOutcomeFactory,
                IResourceServices,
                IGlobalProperties,
                IHiServiceApi,
                RequestMetaFactory,
                IMedicareNumberParser,
                IIndividualHealthcareIdentifierParser,
                IDVANumberParser,
                INationalHealthcareIdentifierInfo,
                IMedicareNumberInfo,
                IPyroFhirServerCodeSystem);

            OperationClass OperationClass = new OperationClass()
            {
                Scope = Common.Enum.FhirOperationEnum.OperationScope.Resource,
                Type  = Common.Enum.FhirOperationEnum.OperationType.xIHISearchOrValidate
            };

            //var SearchParameterGeneric = new Common.Search.SearchParameterGeneric();

            var PyroRequestUri = CommonTestSetup.TestSetupMocks.GetIPyroRequestUriFactory().CreateFhirRequestUri();

            PyroRequestUri.FhirRequestUri = CommonTestSetup.TestSetupMocks.GetIPyroRequestUriFactory().CreateFhirRequestUri().FhirRequestUri = new Pyro.Common.Tools.UriSupport.PyroFhirUri(CommonTestSetup.TestSetupMocks.GetIPrimaryServiceRootCache());
            PyroRequestUri.FhirRequestUri.Parse($"{StaticTestData.FhirEndpoint()}/{ResourceType.Patient.GetLiteral()}/{Common.Enum.FhirOperationEnum.OperationType.xIHISearchOrValidate.GetPyroLiteral()}");
            IRequestMeta RequestMeta = RequestMetaFactory.CreateRequestMeta();

            RequestMeta.PyroRequestUri         = PyroRequestUri;
            RequestMeta.RequestHeader          = CommonTestSetup.TestSetupMocks.GetIRequestHeaderFactory().CreateRequestHeader();
            RequestMeta.SearchParameterGeneric = CommonTestSetup.TestSetupMocks.GetISearchParameterGenericFactory().CreateDtoSearchParameterGeneric();

            Parameters ParametersResource = GenerateRequestParametersResource();

            IResourceServiceOutcome ResourceServiceOutcome = IHISearchOrValidateOperationService.IHISearchOrValidate(
                OperationClass,
                ParametersResource,
                RequestMeta
                );

            Assert.NotNull(ResourceServiceOutcome.ResourceResult);
            Assert.AreEqual(ResourceType.Parameters.GetLiteral(), ResourceServiceOutcome.ResourceResult.TypeName);
        }
示例#6
0
        private void buttonDocuments_Click(object sender, EventArgs e)
        {
            var tempOperationInfo = new OperationClass(_operationInfo);
            var tempPatientInfo   = new PatientClass(_patientInfo);

            PutDataToOperationAndPatient(tempOperationInfo, tempPatientInfo);

            new WordExportEngine(_dbEngine).ExportOperationProtocol(tempOperationInfo, tempPatientInfo);
        }
示例#7
0
        public OperationProtocolForm(OperationClass operationInfo, PatientClass patientInfo, DbEngine dbEngine)
        {
            _stopSaveParameters = true;

            InitializeComponent();

            _dbEngine      = dbEngine;
            _operationInfo = operationInfo;
            _patientInfo   = patientInfo;
        }
        public OperationClass Parse(ref OperationClass a)
        {
            bool isExpressionNotEnded = true;

            while ((l < expression.Length) && isExpressionNotEnded)
            {
                ParseNextPart(ref a, ref isExpressionNotEnded);
            }
            return(a);
        }
        public IResourceServiceOutcome Initialize(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();



            var ResourceRepository = IRepositorySwitcher.GetRepository(FHIRAllTypes.Patient);



            List <Resource> ResourceList = new List <Resource>();

            if (ResourceList.Count > 0)
            {
                Bundle TransactionBundle  = GenerateTransactionBundle(ResourceList);
                var    CurrentRequestMeta = IRequestMetaFactory.CreateRequestMeta().Set($"{FHIRAllTypes.Bundle.GetLiteral()}/{TransactionBundle.Id}");
                IResourceServiceOutcome ResourceServiceOutcome = IBundleTransactionOperation.Transact(TransactionBundle, CurrentRequestMeta);
                return(ResourceServiceOutcome);
            }


            //  var OutCome = IResourceServices.Put(Res.Id, Res, CurrentRequestMeta);

            //var ResourceRepository = IRepositorySwitcher.GetRepository(FHIRAllTypes.Patient);


            return(ResourceServiceOutcome);
        }
示例#10
0
        /// <summary>
        /// Закрыть форму
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonOK_Click(object sender, EventArgs e)
        {
            bool isOperationViewFormOpened = false;
            var  openedOperationForm       = new OperationClass();

            foreach (OperationClass oc in _patientInfo.Operations)
            {
                if (oc.OpenedOperationViewForm != null && !oc.OpenedOperationViewForm.IsDisposed)
                {
                    openedOperationForm       = oc;
                    isOperationViewFormOpened = true;
                    break;
                }
            }

            if (isOperationViewFormOpened)
            {
                MessageBox.Show("Вы не можете закрыть эту форму, пока не закроете все формы \"Просмотр данных об операции\"", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                openedOperationForm.OpenedOperationViewForm.Focus();
                return;
            }

            if (_addNewOperationForm != null && !_addNewOperationForm.IsDisposed)
            {
                MessageBox.Show("Вы не можете закрыть эту форму, пока не закроете форму \"Добавление операции\"", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                _addNewOperationForm.Focus();
                return;
            }

            bool isOperationProtocolFormOpened = false;

            foreach (OperationClass oc in _patientInfo.Operations)
            {
                if (oc.OpenedOperationProtocolForm != null && !oc.OpenedOperationProtocolForm.IsDisposed)
                {
                    openedOperationForm           = oc;
                    isOperationProtocolFormOpened = true;
                    break;
                }
            }

            if (isOperationProtocolFormOpened)
            {
                MessageBox.Show("Вы не можете закрыть эту форму, пока не закроете формы \"Протокол операции\"", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                openedOperationForm.OpenedOperationProtocolForm.Focus();
                return;
            }

            _isFormClosingByButton = true;
            Close();
        }
示例#11
0
        /// <summary>
        /// Положить введённые данные в операцию
        /// </summary>
        /// <param name="operationInfo">Данные про операцию</param>
        private void PutDataToOperation(OperationClass operationInfo)
        {
            operationInfo.Name            = textBoxName.Text;
            operationInfo.Assistents      = MultilineStringToList(textBoxAssistents.Text);
            operationInfo.Surgeons        = MultilineStringToList(textBoxSurgeons.Text);
            operationInfo.ScrubNurse      = comboBoxScrubNurse.Text;
            operationInfo.SheAnaesthetist = comboBoxSheAnestethist.Text;
            operationInfo.HeAnaesthetist  = comboBoxHeAnestethist.Text;
            operationInfo.Orderly         = comboBoxOrderly.Text;

            operationInfo.DataOfOperation      = dateTimePickerDataOfOperation.Value;
            operationInfo.StartTimeOfOperation = dateTimePickerStartTimeOfOperation.Value;
            operationInfo.EndTimeOfOperation   = dateTimePickerEndTimeOfOperation.Value;
        }
        public void SetTwoDimenDrawer(string xfunc, string yfunc, string tlowbound, string tupbound)
        {
            ParsedExp parser = new ParsedExp();

            parser.InsertExpression(xfunc);
            XFunc = parser.ExpTree();
            parser.InsertExpression(yfunc);
            YFunc = parser.ExpTree();
            parser.InsertExpression(tlowbound);
            TLowerBound = parser.ExpTree();
            parser.InsertExpression(tupbound);
            THigherBound       = parser.ExpTree();
            FragmentationDepth = 200;
        }
        public void SetTwoDimenComplexDrawer(string xz, string yz, string xc, string yc)
        {
            ParsedExp parser = new ParsedExp();

            parser.InsertExpression(xz);
            XFunc = parser.ExpTree();
            parser.InsertExpression(yz);
            YFunc = parser.ExpTree();
            parser.InsertExpression(xc);
            CXFunc = parser.ExpTree();
            parser.InsertExpression(yc);
            CYFunc     = parser.ExpTree();
            Iterations = 50;
        }
示例#14
0
        public OperationViewForm(OperationForm operationForm, DbEngine dbEngine, OperationClass operationInfo, PatientClass patientInfo)
        {
            _stopSaveParameters = true;
            InitializeComponent();

            _dbEngine      = dbEngine;
            _patientInfo   = patientInfo;
            _operationForm = operationForm;

            PutObjectsToComboBox(_dbEngine.OrderlyList.ToArray(), comboBoxOrderly);
            PutObjectsToComboBox(_dbEngine.ScrubNurseList.ToArray(), comboBoxScrubNurse);
            PutObjectsToComboBox(_dbEngine.HeAnestethistList.ToArray(), comboBoxHeAnestethist);
            PutObjectsToComboBox(_dbEngine.SheAnestethistList.ToArray(), comboBoxSheAnestethist);

            if (operationInfo == null)
            {
                Text           = "Добавление операции";
                _operationInfo = new OperationClass();

                textBoxSurgeons.Text        = _dbEngine.ConfigEngine.OperationViewFormTextBoxSurgeons;
                textBoxAssistents.Text      = _dbEngine.ConfigEngine.OperationViewFormTextBoxAssistents;
                comboBoxHeAnestethist.Text  = _dbEngine.ConfigEngine.OperationViewFormTextBoxHeAnestethist;
                comboBoxSheAnestethist.Text = _dbEngine.ConfigEngine.OperationViewFormTextBoxSheAnestethist;
                comboBoxScrubNurse.Text     = _dbEngine.ConfigEngine.OperationViewFormComboBoxScrubNurse;
                comboBoxOrderly.Text        = _dbEngine.ConfigEngine.OperationViewFormComboBoxOrderly;
            }
            else
            {
                Text           = "Просмотр данных об операции";
                _operationInfo = operationInfo;

                _saveOperationInfo = new OperationClass(operationInfo);

                textBoxName.Text            = _operationInfo.Name;
                textBoxAssistents.Text      = ListToMultilineString(_operationInfo.Assistents);
                textBoxSurgeons.Text        = ListToMultilineString(_operationInfo.Surgeons);
                comboBoxScrubNurse.Text     = _operationInfo.ScrubNurse;
                comboBoxSheAnestethist.Text = _operationInfo.SheAnaesthetist;
                comboBoxHeAnestethist.Text  = _operationInfo.HeAnaesthetist;
                comboBoxOrderly.Text        = _operationInfo.Orderly;

                dateTimePickerDataOfOperation.Value      = _operationInfo.DataOfOperation;
                dateTimePickerStartTimeOfOperation.Value = _operationInfo.StartTimeOfOperation;
                dateTimePickerEndTimeOfOperation.Value   = _operationInfo.EndTimeOfOperation;
            }
        }
        public void SetThreeDimenDrawer(string zfunc, string xlowbound, string xupbound, string ylowbound, string yupbound)
        {
            ParsedExp parser = new ParsedExp();

            parser.InsertExpression(zfunc);
            ZFunc = parser.ExpTree();
            parser.InsertExpression(xlowbound);
            XLowerBound = parser.ExpTree();
            parser.InsertExpression(xupbound);
            XHigherBound = parser.ExpTree();
            parser.InsertExpression(ylowbound);
            YLowerBound = parser.ExpTree();
            parser.InsertExpression(yupbound);
            YHigherBound        = parser.ExpTree();
            XFragmentationDepth = 50;
            YFragmentationDepth = 50;
        }
示例#16
0
        private string OpTypeToString(OperationClass opclass, OperationType optype)
        {
            switch (opclass)
            {
            case OperationClass.File:
            case OperationClass.Process:
            case OperationClass.Registry:
                switch (optype)
                {
                case OperationType.Create:
                    return("Create");

                case OperationType.Destroy:
                    return((opclass == OperationClass.Process) ? "Exit" : "Delete");

                case OperationType.Rename:
                    return("Rename");

                case OperationType.Write:
                    return("Modify");

                default:
                    return("Unknown");
                }

            case OperationClass.Packet:
                switch (optype)
                {
                case OperationType.Create:
                    return("Connect");

                case OperationType.Destroy:
                    return("Disconnect");

                case OperationType.Write:
                    return("Transmit");

                default:
                    return("Unknown");
                }

            default:
                return("Unknown");
            }
        }
示例#17
0
        private bool Add(T t, string newContent, OperationClass operationClass, out long tableOperationID)
        {
            try
            {
                InitializeTabele();

                Type   objTye     = typeof(T);
                string oldContent = t.ToJson();
                var    entity     = new Log_TableOperation();
                entity.TableID    = TableId;
                entity.TableName  = objTye.Name;
                entity.ClientID   = (int)OperationClient.Web;
                entity.ClientName = OperationClient.Web.ToString();
                entity.ClassID    = ((int)operationClass).ToByte();
                entity.ClassName  = operationClass.ToString();
                entity.OldContent = oldContent;
                entity.NewContent = newContent;
                entity.Account    = Account;
                entity.NickName   = NickName;
                entity.IpAdress   = Net.Ip;
                entity.State      = false;
                if (!string.IsNullOrEmpty(PrimaryKey))
                {
                    SortedDictionary <string, string> arrPrimaryKeyValue = new SortedDictionary <string, string>();
                    string[] arrPrimaryKey = PrimaryKey.Split(",");
                    foreach (var item in arrPrimaryKey)
                    {
                        PropertyInfo p = objTye.GetProperty(item);
                        object       primaryKeyValue = p.GetValue(t, null);
                        if (primaryKeyValue != null)
                        {
                            arrPrimaryKeyValue.Add(item, primaryKeyValue.ToString());
                        }
                    }
                    entity.PrimaryKeyValue = ToPrimaryKeyValue(arrPrimaryKeyValue);
                }
                return(TableOperationService.SaveTableOperation(entity, out tableOperationID));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#18
0
        private string OpClassToString(OperationClass opclass)
        {
            switch (opclass)
            {
            case OperationClass.File:
                return("File");

            case OperationClass.Packet:
                return("Network");

            case OperationClass.Process:
                return("Process");

            case OperationClass.Registry:
                return("Registry");

            default:
                return("Unknown");
            }
        }
示例#19
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);
            }
        }
示例#20
0
        public Event(string procName, string userName, string imgPath,
                     string opPath, DateTime time, long flags, long pid, long ppid,
                     long tid, OperationClass opClass, OperationType opType)
        {
            ProcessName = procName;
            UserName    = userName;
            ImagePath   = imgPath;

            OperationPath = opPath;

            Time  = time;
            Flags = flags;

            Pid  = pid;
            Ppid = ppid;
            Tid  = tid;

            OpClass = opClass;
            OpType  = opType;

            id = ++commonId;
        }
示例#21
0
        public override void AddToList()
        {
            var myList = OperationClass.OperationList;

            myList.Add(new MyNumber(OperationClass, OperationClass.ActualNumber));
            myList.Add(this);

            //Sprawdzanie czy wartość już jest wpisana w liste operacji
            int lenght = myList.Count;

            if (lenght > 2)
            {
                //Sprawdzamy czy poprzednia operacja to SingleOperation jeśli tak to usuwamy dodaną wyżej wyliczoną zmienną
                if (myList[lenght - 3] is SingleOperation)
                {
                    myList.RemoveAt(lenght - 2);
                }
            }
            //Do pliku zapisujemy dopiero od drugiej operacji
            //if(myList.Count > 2)
            OperationClass.SaveToFile(new string[] { myList[myList.Count - 2].StringToFile, myList[myList.Count - 1].StringToFile });
            OperationClass.RefreashActNumber = true;
        }
示例#22
0
        /// <summary>
        /// Открыть форму с протоколом операции
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonProtocol_Click(object sender, EventArgs e)
        {
            if (OperationList.CurrentCellAddress.Y < 0)
            {
                MessageBox.Show("Нет выделенных записей", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            OperationClass operationInfo = GetSelectedOperation();

            if (operationInfo.OpenedOperationProtocolForm == null || operationInfo.OpenedOperationProtocolForm.IsDisposed)
            {
                operationInfo.OpenedOperationProtocolForm = new OperationProtocolForm(operationInfo, _patientInfo, _dbEngine)
                {
                    MdiParent = MdiParent
                };
                operationInfo.OpenedOperationProtocolForm.Show();
            }
            else
            {
                operationInfo.OpenedOperationProtocolForm.Focus();
            }
        }
示例#23
0
        public IResourceServiceOutcome Process(
            string OperationName, Resource Resource, IRequestMeta RequestMeta)
        {
            if (string.IsNullOrWhiteSpace(OperationName))
            {
                throw new NullReferenceException("OperationName cannot be null.");
            }
            if (RequestMeta == null)
            {
                throw new NullReferenceException("RequestMeta cannot be null.");
            }
            if (RequestMeta.PyroRequestUri == null)
            {
                throw new NullReferenceException("PyroRequestUri cannot be null.");
            }
            if (RequestMeta.RequestHeader == null)
            {
                throw new NullReferenceException("RequestHeaders cannot be null.");
            }
            if (RequestMeta.SearchParameterGeneric == null)
            {
                throw new NullReferenceException("SearchPrameterGeneric cannot be null.");
            }

            IResourceServiceOutcome ResourceServiceOutcome = IResourceServiceOutcomeFactory.CreateResourceServiceOutcome();

            ISearchParameterService         SearchService = ISearchParameterServiceFactory.CreateSearchParameterService();
            ISearchParametersServiceOutcome SearchParametersServiceOutcome = SearchService.ProcessBaseSearchParameters(RequestMeta.SearchParameterGeneric);

            if (SearchParametersServiceOutcome.FhirOperationOutcome != null)
            {
                ResourceServiceOutcome.ResourceResult = SearchParametersServiceOutcome.FhirOperationOutcome;
                ResourceServiceOutcome.HttpStatusCode = SearchParametersServiceOutcome.HttpStatusCode;
                ResourceServiceOutcome.FormatMimeType = SearchParametersServiceOutcome.SearchParameters.Format;
                return(ResourceServiceOutcome);
            }

            var OperationDic = FhirOperationEnum.GetOperationTypeByString();

            if (!OperationDic.ContainsKey(OperationName))
            {
                string Message = $"The base operation named ${OperationName} is not supported by the server.";
                ResourceServiceOutcome.ResourceResult        = Common.Tools.FhirOperationOutcomeSupport.Create(Hl7.Fhir.Model.OperationOutcome.IssueSeverity.Error, Hl7.Fhir.Model.OperationOutcome.IssueType.NotSupported, Message);
                ResourceServiceOutcome.FormatMimeType        = SearchParametersServiceOutcome.SearchParameters.Format;
                ResourceServiceOutcome.HttpStatusCode        = System.Net.HttpStatusCode.BadRequest;
                ResourceServiceOutcome.SuccessfulTransaction = false;
                return(ResourceServiceOutcome);
            }

            var            Op             = OperationDic[OperationName];
            OperationClass OperationClass = OperationClassFactory.OperationClassList.SingleOrDefault(x => x.Scope == FhirOperationEnum.OperationScope.Base && x.Type == Op);

            if (OperationClass == null)
            {
                string Message = $"The base operation named ${OperationName} is not supported by the server as a service base operation type.";
                ResourceServiceOutcome.ResourceResult        = Common.Tools.FhirOperationOutcomeSupport.Create(Hl7.Fhir.Model.OperationOutcome.IssueSeverity.Error, Hl7.Fhir.Model.OperationOutcome.IssueType.NotSupported, Message);
                ResourceServiceOutcome.FormatMimeType        = SearchParametersServiceOutcome.SearchParameters.Format;
                ResourceServiceOutcome.HttpStatusCode        = System.Net.HttpStatusCode.BadRequest;
                ResourceServiceOutcome.SuccessfulTransaction = false;
                return(ResourceServiceOutcome);
            }

            switch (OperationClass.Type)
            {
            case FhirOperationEnum.OperationType.ServerIndexesDeleteHistoryIndexes:
            {
                IDeleteHistoryIndexesOperation DeleteManyHistoryIndexesService = ICommonFactory.CreateDeleteHistoryIndexesOperation();
                return(DeleteManyHistoryIndexesService.DeleteMany(RequestMeta.PyroRequestUri, RequestMeta.SearchParameterGeneric, Resource));
            }

            case FhirOperationEnum.OperationType.ServerIndexesSet:
            {
                IServerSearchParameterOperation ServerSearchParameterService = IServerSearchParameterServiceFactory.CreateServerSearchParameterService();
                return(ServerSearchParameterService.ProcessSet(RequestMeta.PyroRequestUri, RequestMeta.SearchParameterGeneric, Resource));
            }

            case FhirOperationEnum.OperationType.ServerSearchParameterIndexReport:
            {
                IServerSearchParameterOperation ServerSearchParameterService = IServerSearchParameterServiceFactory.CreateServerSearchParameterService();
                return(ServerSearchParameterService.ProcessReport(RequestMeta.PyroRequestUri, RequestMeta.SearchParameterGeneric, Resource));
            }

            case FhirOperationEnum.OperationType.ServerIndexesIndex:
            {
                IServerSearchParameterOperation ServerSearchParameterService = IServerSearchParameterServiceFactory.CreateServerSearchParameterService();
                return(ServerSearchParameterService.ProcessIndex(RequestMeta.PyroRequestUri, RequestMeta.SearchParameterGeneric, Resource));
            }

            case FhirOperationEnum.OperationType.ConnectathonAnswer:
            {
                IConnectathonAnswerOperation ConnectathonAnswerService = ICommonFactory.CreateConnectathonAnswerOperation();
                return(ConnectathonAnswerService.Process(RequestMeta.PyroRequestUri, RequestMeta.SearchParameterGeneric, Resource));
            }

            case FhirOperationEnum.OperationType.ServerResourceReport:
            {
                IResourceReportOperation ServerResourceReportService = ICommonFactory.CreateResourceReportOperation();
                return(ServerResourceReportService.Process(RequestMeta.SearchParameterGeneric));
            }

            default:
                throw new System.ComponentModel.InvalidEnumArgumentException(OperationClass.Type.GetPyroLiteral(), (int)OperationClass.Type, typeof(FhirOperationEnum.OperationType));
            }
        }
示例#24
0
        public IResourceServiceOutcome Process(string OperationName, Resource Resource, IRequestMeta RequestMeta)
        {
            if (string.IsNullOrWhiteSpace(OperationName))
            {
                throw new NullReferenceException("OperationName cannot be null.");
            }
            if (Resource == null)
            {
                throw new NullReferenceException("Resource 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 (ICommonFactory == null)
            {
                throw new NullReferenceException("ICommonFactory cannot be null.");
            }
            if (RequestMeta.SearchParameterGeneric == null)
            {
                throw new NullReferenceException("SearchParameterGeneric cannot be null.");
            }

            IResourceServiceOutcome ResourceServiceOutcome = IResourceServiceOutcomeFactory.CreateResourceServiceOutcome();

            ISearchParameterService         SearchService = ISearchParameterServiceFactory.CreateSearchParameterService();
            ISearchParametersServiceOutcome SearchParametersServiceOutcome = SearchService.ProcessBaseSearchParameters(RequestMeta.SearchParameterGeneric);

            if (SearchParametersServiceOutcome.FhirOperationOutcome != null)
            {
                ResourceServiceOutcome.ResourceResult = SearchParametersServiceOutcome.FhirOperationOutcome;
                ResourceServiceOutcome.HttpStatusCode = SearchParametersServiceOutcome.HttpStatusCode;
                ResourceServiceOutcome.FormatMimeType = SearchParametersServiceOutcome.SearchParameters.Format;
                return(ResourceServiceOutcome);
            }

            var OperationDic = FhirOperationEnum.GetOperationTypeByString();

            if (!OperationDic.ContainsKey(Pyro.Common.Tools.StringSupport.ToLowerFast(OperationName)))
            {
                string Message = $"The resource operation named ${OperationName} is not supported by the server.";
                ResourceServiceOutcome.ResourceResult        = Common.Tools.FhirOperationOutcomeSupport.Create(Hl7.Fhir.Model.OperationOutcome.IssueSeverity.Error, Hl7.Fhir.Model.OperationOutcome.IssueType.NotSupported, Message);
                ResourceServiceOutcome.FormatMimeType        = SearchParametersServiceOutcome.SearchParameters.Format;
                ResourceServiceOutcome.HttpStatusCode        = System.Net.HttpStatusCode.BadRequest;
                ResourceServiceOutcome.SuccessfulTransaction = false;
                return(ResourceServiceOutcome);
            }

            var            Op             = OperationDic[Pyro.Common.Tools.StringSupport.ToLowerFast(OperationName)];
            OperationClass OperationClass = OperationClassFactory.OperationClassList.SingleOrDefault(x => x.Scope == FhirOperationEnum.OperationScope.Resource && x.Type == Op);

            if (OperationClass == null)
            {
                string Message = $"The resource operation named ${OperationName} is not supported by the server as a resource service operation type.";
                ResourceServiceOutcome.ResourceResult        = Common.Tools.FhirOperationOutcomeSupport.Create(Hl7.Fhir.Model.OperationOutcome.IssueSeverity.Error, Hl7.Fhir.Model.OperationOutcome.IssueType.NotSupported, Message);
                ResourceServiceOutcome.FormatMimeType        = SearchParametersServiceOutcome.SearchParameters.Format;
                ResourceServiceOutcome.HttpStatusCode        = System.Net.HttpStatusCode.BadRequest;
                ResourceServiceOutcome.SuccessfulTransaction = false;
                return(ResourceServiceOutcome);
            }

            switch (OperationClass.Type)
            {
            case FhirOperationEnum.OperationType.Validate:
            {
                IFhirValidateOperation FhirValidateOperation = ICommonFactory.CreateFhirValidateOperation();
                return(FhirValidateOperation.ValidateResource(OperationClass, Resource, RequestMeta));
            }

            case FhirOperationEnum.OperationType.xIHISearchOrValidate:
            {
                IIHISearchOrValidateOperation IHISearchOrValidateOperation = ICommonFactory.CreateIHISearchOrValidateOperation();
                return(IHISearchOrValidateOperation.IHISearchOrValidate(OperationClass, Resource, RequestMeta));
            }

            default:
                throw new System.ComponentModel.InvalidEnumArgumentException(OperationClass.Type.GetPyroLiteral(), (int)OperationClass.Type, typeof(FhirOperationEnum.OperationType));
            }
        }
        public IResourceServiceOutcome ValidateResource(OperationClass OperationClass, Resource Resource, IRequestMeta RequestMeta)
        {
            if (OperationClass == null)
            {
                throw new NullReferenceException("OperationClass cannot be null.");
            }
            if (Resource == null)
            {
                throw new NullReferenceException("Resource 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("RequestHeader cannot be null.");
            }
            if (RequestMeta.SearchParameterGeneric == null)
            {
                throw new NullReferenceException("SearchParameterGeneric cannot be null.");
            }
            if (IResourceServices == null)
            {
                throw new NullReferenceException("ResourceServices cannot be null.");
            }
            if (IFhirValidationSupport == null)
            {
                throw new NullReferenceException("IFhirValidationSupport cannot be null.");
            }


            IssueList = new List <OperationOutcome.IssueComponent>();

            ResourceServiceOutcome = IResourceServiceOutcomeFactory.CreateResourceServiceOutcome();

            ISearchParametersServiceOutcome SearchParametersServiceOutcome = ParseUrlSearchParameters(RequestMeta.SearchParameterGeneric, OperationClass);

            FormatMimeType = SearchParametersServiceOutcome.SearchParameters.Format;
            if (SearchParametersServiceOutcome.FhirOperationOutcome != null)
            {
                IssueList.AddRange(SearchParametersServiceOutcome.FhirOperationOutcome.Issue);
                return(FinalResourceServiceOutcome(IssueList));
            }

            //Get ValidationOperationItems from URL
            ValidationOperationItems ValidationOperationItemsFromUrl = new ValidationOperationItems();

            ObtainOperationItemsFromSearchParameters(SearchParametersServiceOutcome, ValidationOperationItemsFromUrl);

            //Get ValidationOperationItems from Parameter Resource
            ValidationOperationItems ValidationOperationItemsFromParametersResource = new ValidationOperationItems();

            if (Resource.ResourceType == ResourceType.Parameters)
            {
                ValidationOperationItemsFromParametersResource = ValidateParameterResource(Resource as Parameters);
            }
            else
            {
                ValidationOperationItemsFromUrl.ResourceToValidate = Resource;
            }

            ValidationOperationItems FinalValidationOperationItems = ConsoladateValidationOperationItems(ValidationOperationItemsFromUrl, ValidationOperationItemsFromParametersResource);

            if (FinalValidationOperationItems == null)
            {
                return(FinalResourceServiceOutcome(IssueList));
            }

            if (FinalValidationOperationItems.ValidationMode == ResourceValidationModeType.Delete)
            {
                var OpOutCome = Common.Tools.FhirOperationOutcomeSupport.Create(OperationOutcome.IssueSeverity.Error, OperationOutcome.IssueType.NotSupported,
                                                                                $"A mode parameter equal to 'delete' can only be used against a Resource instance URL.");
                IssueList.AddRange(OpOutCome.Issue);
                return(FinalResourceServiceOutcome(IssueList));
            }
            else if (FinalValidationOperationItems.ResourceToValidate != null)
            {
                if (!CheckResourceEndpointMatchesResourceToBeValidated(FinalValidationOperationItems.ResourceToValidate.ResourceType, RequestMeta.PyroRequestUri))
                {
                    return(FinalResourceServiceOutcome(IssueList));
                }

                if (FinalValidationOperationItems.FhirRequestUriProfileUri != null)
                {
                    OperationOutcome ProfileValidationOpOutCome = PerformValidation(FinalValidationOperationItems);
                    PerformModeValidation(ProfileValidationOpOutCome, FinalValidationOperationItems, RequestMeta);
                    IssueList.AddRange(ProfileValidationOpOutCome.Issue);
                    return(FinalResourceServiceOutcome(IssueList));
                }
                else
                {
                    OperationOutcome ModeValidationOpOutCome = new OperationOutcome();
                    PerformModeValidation(ModeValidationOpOutCome, FinalValidationOperationItems, RequestMeta);
                    // There is no profile given to validate against.
                    var OpOutCome = Common.Tools.FhirOperationOutcomeSupport.Create(OperationOutcome.IssueSeverity.Error, OperationOutcome.IssueType.NotSupported,
                                                                                    $"The Resource provided for validation '{FinalValidationOperationItems.ResourceToValidate.ResourceType.GetLiteral()}' must match the resource endpoint in the URL '{RequestMeta.PyroRequestUri.FhirRequestUri.ResourseName}'");
                    IssueList.AddRange(OpOutCome.Issue);
                    return(FinalResourceServiceOutcome(IssueList));
                }
            }
            else
            {
                var OpOutCome = Common.Tools.FhirOperationOutcomeSupport.Create(OperationOutcome.IssueSeverity.Error, OperationOutcome.IssueType.NotSupported,
                                                                                $"No Resource provided for validation, if mode equal (None, Create or Update) then a Resource must be provided to validate against.");
                IssueList.AddRange(OpOutCome.Issue);
                return(FinalResourceServiceOutcome(IssueList));
            }
        }
示例#26
0
 public static string GetOperationClassName(OperationClass cls, bool shorten = false)
 {
     return(shorten ? operation_names_short[(uint)cls] : operation_names[(uint)cls]);
 }
        private List <DtoServiceSearchParameterLight> GetSupportedSearchParameters(SearchParameterServiceType SearchParameterServiceType, OperationClass OperationClass, string ResourceType)
        {
            List <DtoServiceSearchParameterLight> DtoSupportedServiceSearchParameterList = new List <DtoServiceSearchParameterLight>();

            //For non Resource URL values, e.g _format, _summary
            if ((SearchParameterServiceType & SearchParameterServiceType.Base) == SearchParameterServiceType.Base)
            {
                DtoSupportedServiceSearchParameterList.AddRange(ServiceSearchParameterFactory.BaseSearchParameters());
            }
            //For Bundle URL Parameters e.g page, _sort
            if ((SearchParameterServiceType & SearchParameterServiceType.Bundle) == SearchParameterServiceType.Bundle)
            {
                DtoSupportedServiceSearchParameterList.AddRange(ServiceSearchParameterFactory.BundleSearchParameters());
            }

            //For $Operation URL Parameters e.g profile, mode
            if ((SearchParameterServiceType & SearchParameterServiceType.Operation) == SearchParameterServiceType.Operation)
            {
                DtoSupportedServiceSearchParameterList.AddRange(ServiceSearchParameterFactory.OperationSearchParameters(OperationClass));
            }

            //For Resource search parameters
            if ((SearchParameterServiceType & SearchParameterServiceType.Resource) == SearchParameterServiceType.Resource)
            {
                DtoSupportedServiceSearchParameterList.AddRange(IServiceSearchParameterCache.GetSearchParameterForResource(ResourceType));
            }

            return(DtoSupportedServiceSearchParameterList);
        }
        private List <DtoServiceSearchParameterLight> GetSupportedSearchParameters(SearchParameterServiceType SearchParameterServiceType, OperationClass OperationClass, FHIRAllTypes?ResourceType)
        {
            string ResourceString = string.Empty;

            if (ResourceType.HasValue)
            {
                ResourceString = ResourceType.Value.GetLiteral();
            }
            return(GetSupportedSearchParameters(SearchParameterServiceType, OperationClass, ResourceString));
        }
        public ISearchParametersServiceOutcome ProcessSearchParameters(
            ISearchParameterGeneric SearchParameterGeneric,
            SearchParameterServiceType SearchParameterServiceType,
            FHIRAllTypes?ResourceType,
            OperationClass OperationClass)
        {
            if (SearchParameterServiceType == SearchParameterServiceType.None)
            {
                throw new NullReferenceException("Server error: SearchParameterServiceType can not be 'None'.");
            }

            if (SearchParameterGeneric == null)
            {
                throw new NullReferenceException("Server error: SearchParameterGeneric can not be null.");
            }

            if (((SearchParameterServiceType & SearchParameterServiceType.Resource) == SearchParameterServiceType.Resource) &&
                ResourceType == null)
            {
                throw new NullReferenceException("Server error: ResourceType can not be null when enum SearchParameterServiceType is set to Resource.");
            }

            if (((SearchParameterServiceType & SearchParameterServiceType.Operation) == SearchParameterServiceType.Operation) &&
                OperationClass == null)
            {
                throw new NullReferenceException("Server error: OperationClass can not be null when enum SearchParameterServiceType is set to Operation.");
            }

            _ResourceType               = ResourceType;
            _OperationClass             = OperationClass;
            _SearchParameterServiceType = SearchParameterServiceType;

            _SearchParametersServiceOutcome = ISearchParametersServiceOutcomeFactory.CreateSearchParametersServiceOutcome();
            _SearchParametersServiceOutcome.SearchParameters = new PyroSearchParameters();
            _SearchParametersServiceOutcome.SearchParameters.ResourceTarget                = _ResourceType;
            _SearchParametersServiceOutcome.SearchParameters.SearchParametersList          = new List <ISearchParameterBase>();
            _SearchParametersServiceOutcome.SearchParameters.UnspportedSearchParameterList = new List <UnspportedSearchParameter>();
            _SearchParametersServiceOutcome.SearchParameters.CountOfRecordsRequested       = SearchParameterGeneric.Count;
            _SearchParametersServiceOutcome.SearchParameters.SummaryType = SearchParameterGeneric.SummaryType;

            //Parse Include and RevInclude parameters
            ProcessIncludeSearchParameters(SearchParameterGeneric.Include);
            ProcessIncludeSearchParameters(SearchParameterGeneric.RevInclude);

            foreach (var Parameter in SearchParameterGeneric.ParameterList)
            {
                //We will just ignore an empty parameter such as this last '&' URL?family=Smith&given=John&
                if (Parameter.Item1 + Parameter.Item2 != string.Empty)
                {
                    if (Parameter.Item1.Contains(SearchParams.SEARCH_CHAINSEPARATOR))
                    {
                        ChainSearchProcessing(Parameter);
                    }
                    else
                    {
                        NormalSearchProcessing(Parameter);
                    }
                }
            }

            //resolve Sort order parameters
            if (SearchParameterGeneric.Sort != null)
            {
                _SearchParametersServiceOutcome.SearchParameters.SortList = new List <PyroSearchParameters.Sort>();
                foreach (var SortItem in SearchParameterGeneric.Sort)
                {
                    string SearchParameterName = SortItem.Item1.Trim();
                    DtoServiceSearchParameterLight oSupportedSearchParameter = _DtoSupportedSearchParametersList.SingleOrDefault(x => x.Name == SearchParameterName);
                    _SearchParametersServiceOutcome.SearchParameters.SortList.Add(new PyroSearchParameters.Sort()
                    {
                        Value = oSupportedSearchParameter, SortOrderType = SortItem.Item2
                    });
                }
            }

            return(_SearchParametersServiceOutcome);
        }
        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();

            Hl7.Fhir.Model.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;
                    this.IResourceTriggerService.TriggersActive = false;
                    var IResourceServicesOutcome = IResourceServices.Put(CompartDef.Id, CompartDef, RequestMetaUpdateCompartmentDef);
                    this.IResourceTriggerService.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);
            }
        }