private CompoundResultReading <decimal?> CreateTestReadingforaDecimalValue(CustomerEventReadingEntity testReadingEntity, int readingId, List <StandardFindingTestReadingEntity> standardFindingTestReadingEntities, decimal?value)
        {
            StandardFindingTestReadingEntity standardFindingTestReading = null;

            if (testReadingEntity.StandardFindingTestReadingId != null)
            {
                standardFindingTestReading =
                    standardFindingTestReadingEntities.Find(standardFindingTestReadingEntity =>
                                                            (standardFindingTestReadingEntity.ReadingId == readingId) &&
                                                            (testReadingEntity.StandardFindingTestReadingId == standardFindingTestReadingEntity.StandardFindingTestReadingId)
                                                            );
            }

            var testReading = new CompoundResultReading <decimal?>(testReadingEntity.CustomerEventReadingId)
            {
                Label         = (ReadingLabels)readingId,
                Reading       = value,
                ReadingSource = testReadingEntity.IsManual
                                    ? ReadingSource.Manual
                                    : ReadingSource.Automatic,
                RecorderMetaData = new DataRecorderMetaData
                {
                    DataRecorderCreator  = new OrganizationRoleUser(testReadingEntity.CreatedByOrgRoleUserId),
                    DateCreated          = testReadingEntity.CreatedOn,
                    DataRecorderModifier = testReadingEntity.UpdatedByOrgRoleUserId.HasValue ? new OrganizationRoleUser(testReadingEntity.UpdatedByOrgRoleUserId.Value) : null,
                    DateModified         = testReadingEntity.UpdatedOn
                }
            };

            decimal testReadingValue = 0;
            var     allFindings      = new TestResultService().GetAllStandardFindings <decimal?>((int)TestType.Hemoglobin, readingId);

            if (testReadingEntity.Value != null && decimal.TryParse(testReadingEntity.Value, out testReadingValue))
            {
                var findings = (new TestResultService()).GetMultipleCalculatedStandardFinding(decimal.Round(testReadingValue, 1), (int)TestType.Hemoglobin, readingId);
                var finding  = findings.FirstOrDefault();

                if (findings.Count() == 1)
                {
                    testReading.Finding = new StandardFinding <decimal?>(Convert.ToInt64(testReadingEntity.StandardFindingTestReadingId == null ? finding : standardFindingTestReading.StandardFindingId));
                }
                else if (findings.Count() > 1)
                {
                    var avFindings = allFindings.FindAll(f => f.Label.ToLower().IndexOf(_toCheckFor) == 0);
                    finding             = findings.FirstOrDefault(f => avFindings.Select(av => av.Id).Contains(f));
                    testReading.Finding = new StandardFinding <decimal?>(Convert.ToInt64(testReadingEntity.StandardFindingTestReadingId == null ? finding : standardFindingTestReading.StandardFindingId));
                }
            }
            else if (testReadingEntity.StandardFindingTestReadingId != null)
            {
                testReading.Finding = new StandardFinding <decimal?>(standardFindingTestReading.StandardFindingId);
            }

            if (testReading.Finding != null)
            {
                testReading.Finding = allFindings.Find(standardFinding => standardFinding.Id == testReading.Finding.Id);
            }

            return(testReading);
        }
Esempio n. 2
0
 /// <summary> setups the sync logic for member _standardFindingTestReading</summary>
 /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
 private void SetupSyncStandardFindingTestReading(IEntity2 relatedEntity)
 {
     if (_standardFindingTestReading != relatedEntity)
     {
         DesetupSyncStandardFindingTestReading(true, true);
         _standardFindingTestReading = (StandardFindingTestReadingEntity)relatedEntity;
         base.PerformSetupSyncRelatedEntity(_standardFindingTestReading, new PropertyChangedEventHandler(OnStandardFindingTestReadingPropertyChanged), "StandardFindingTestReading", CustomerEventTestStandardFindingEntity.Relations.StandardFindingTestReadingEntityUsingStandardFindingTestReadingId, true, new string[] {  });
     }
 }
Esempio n. 3
0
        /// <summary> Initializes the class members</summary>
        protected virtual void InitClassMembers()
        {
            _customerEventScreeningTests = null;
            _standardFindingTestReading  = null;

            PerformDependencyInjection();

            // __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers
            // __LLBLGENPRO_USER_CODE_REGION_END
            OnInitClassMembersComplete();
        }
Esempio n. 4
0
        private static CompoundResultReading <decimal?> CreateTestReadingforaDecimalValue(CustomerEventReadingEntity testReadingEntity, int readingId,
                                                                                          List <StandardFindingTestReadingEntity> standardFindingTestReadingEntities, decimal?value)
        {
            StandardFindingTestReadingEntity standardFindingTestReading = null;

            if (testReadingEntity.StandardFindingTestReadingId != null)
            {
                standardFindingTestReading = standardFindingTestReadingEntities.Find(standardFindingTestReadingEntity => (standardFindingTestReadingEntity.ReadingId == readingId) &&
                                                                                     (testReadingEntity.StandardFindingTestReadingId == standardFindingTestReadingEntity.StandardFindingTestReadingId));
            }

            var testReading = new CompoundResultReading <decimal?>(testReadingEntity.CustomerEventReadingId)
            {
                Label            = (ReadingLabels)readingId,
                Reading          = value,
                ReadingSource    = testReadingEntity.IsManual ? ReadingSource.Manual : ReadingSource.Automatic,
                RecorderMetaData = new DataRecorderMetaData
                {
                    DataRecorderCreator  = new OrganizationRoleUser(testReadingEntity.CreatedByOrgRoleUserId),
                    DateCreated          = testReadingEntity.CreatedOn,
                    DataRecorderModifier = testReadingEntity.UpdatedByOrgRoleUserId.HasValue ? new OrganizationRoleUser(testReadingEntity.UpdatedByOrgRoleUserId.Value) : null,
                    DateModified         = testReadingEntity.UpdatedOn
                }
            };


            if (value != null)
            {
                testReading.Finding = new StandardFinding <decimal?>(Convert.ToInt64(testReadingEntity.StandardFindingTestReadingId == null ? (new TestResultService()).GetCalculatedStandardFinding(decimal.Round(value.Value, 1), (int)TestType.Lipid, readingId) : standardFindingTestReading.StandardFindingId));
            }
            else if (testReadingEntity.StandardFindingTestReadingId != null)
            {
                testReading.Finding = new StandardFinding <decimal?>(standardFindingTestReading.StandardFindingId);
            }

            if (testReading.Finding != null)
            {
                testReading.Finding = new TestResultService().GetAllStandardFindings <decimal?>((int)TestType.Lipid, readingId).Find(standardFinding => standardFinding.Id == testReading.Finding.Id);
            }

            return(testReading);
        }
Esempio n. 5
0
        protected CustomerEventTestStandardFindingEntity(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            if (SerializationHelper.Optimization != SerializationOptimization.Fast)
            {
                _customerEventScreeningTests = (CustomerEventScreeningTestsEntity)info.GetValue("_customerEventScreeningTests", typeof(CustomerEventScreeningTestsEntity));
                if (_customerEventScreeningTests != null)
                {
                    _customerEventScreeningTests.AfterSave += new EventHandler(OnEntityAfterSave);
                }
                _standardFindingTestReading = (StandardFindingTestReadingEntity)info.GetValue("_standardFindingTestReading", typeof(StandardFindingTestReadingEntity));
                if (_standardFindingTestReading != null)
                {
                    _standardFindingTestReading.AfterSave += new EventHandler(OnEntityAfterSave);
                }

                base.FixupDeserialization(FieldInfoProviderSingleton.GetInstance());
            }

            // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
            // __LLBLGENPRO_USER_CODE_REGION_END
        }
Esempio n. 6
0
 /// <summary> Removes the sync logic for member _standardFindingTestReading</summary>
 /// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param>
 /// <param name="resetFKFields">if set to true it will also reset the FK fields pointing to the related entity</param>
 private void DesetupSyncStandardFindingTestReading(bool signalRelatedEntity, bool resetFKFields)
 {
     base.PerformDesetupSyncRelatedEntity(_standardFindingTestReading, new PropertyChangedEventHandler(OnStandardFindingTestReadingPropertyChanged), "StandardFindingTestReading", CustomerEventTestStandardFindingEntity.Relations.StandardFindingTestReadingEntityUsingStandardFindingTestReadingId, true, signalRelatedEntity, "CustomerEventTestStandardFinding", resetFKFields, new int[] { (int)CustomerEventTestStandardFindingFieldIndex.StandardFindingTestReadingId });
     _standardFindingTestReading = null;
 }
Esempio n. 7
0
        public override TestResult CreateActualTestResult(CustomerEventScreeningTestsEntity customerEventScreeningTestsEntity)
        {
            //var testResult = new LiverTestResult();

            var customerEventReadingEntities = customerEventScreeningTestsEntity.CustomerEventReading.ToList();

            var standardFindingTestReadingEntities =
                customerEventScreeningTestsEntity.
                StandardFindingTestReadingCollectionViaCustomerEventReading;

            var testResult = new LiverTestResult(customerEventScreeningTestsEntity.CustomerEventScreeningTestId);

            var astData = customerEventReadingEntities.Where(
                customerEventReading => customerEventReading.TestReading.ReadingId == (int)ReadingLabels.AST).SingleOrDefault();

            if (astData != null)
            {
                StandardFindingTestReadingEntity standardFindingTestReading = null;
                if (astData.StandardFindingTestReadingId != null)
                {
                    standardFindingTestReading =
                        standardFindingTestReadingEntities.ToList().Find(standardFindingTestReadingEntity =>
                                                                         (standardFindingTestReadingEntity.ReadingId ==
                                                                          (int)ReadingLabels.AST) &&
                                                                         (astData.
                                                                          StandardFindingTestReadingId ==
                                                                          standardFindingTestReadingEntity.
                                                                          StandardFindingTestReadingId)
                                                                         );
                }

                testResult.AST = new CompoundResultReading <int?>(astData.CustomerEventReadingId)
                {
                    Label   = ReadingLabels.AST,
                    Reading = !string.IsNullOrEmpty(astData.Value)
                                                        ? (int?)Convert.ToInt32(astData.Value)
                                                        : null,
                    ReadingSource = astData.IsManual
                                                             ? ReadingSource.Manual
                                                             : ReadingSource.Automatic
                };

                int astValue = 0;
                if (astData.Value != null && int.TryParse(astData.Value, out astValue) == true)
                {
                    testResult.AST.Finding = new StandardFinding <int?>(
                        Convert.ToInt64(
                            astData.StandardFindingTestReadingId == null
                                                                 ?
                            (new TestResultService()).
                            GetCalculatedStandardFinding(astValue,
                                                         (int)TestType.Liver, (int)ReadingLabels.AST)
                                                                 : standardFindingTestReading.StandardFindingId));
                }
                else if (astData.StandardFindingTestReadingId != null)
                {
                    testResult.AST.Finding = new StandardFinding <int?>(standardFindingTestReading.StandardFindingId);
                }

                if (testResult.AST.Finding != null)
                {
                    testResult.AST.Finding = new TestResultService().GetAllStandardFindings <int?>((int)TestType.Liver,
                                                                                                   (int)ReadingLabels.AST).Find(standardFinding => standardFinding.Id == testResult.AST.Finding.Id);
                }
            }

            var altData = customerEventReadingEntities.Where(
                customerEventReading => customerEventReading.TestReading.ReadingId == (int)ReadingLabels.ALT).SingleOrDefault();

            if (altData != null)
            {
                StandardFindingTestReadingEntity standardFindingTestReading = null;
                if (altData.StandardFindingTestReadingId != null)
                {
                    standardFindingTestReading =
                        standardFindingTestReadingEntities.ToList().Find(standardFindingTestReadingEntity =>
                                                                         (standardFindingTestReadingEntity.ReadingId ==
                                                                          (int)ReadingLabels.ALT) &&
                                                                         (altData.
                                                                          StandardFindingTestReadingId ==
                                                                          standardFindingTestReadingEntity.
                                                                          StandardFindingTestReadingId)
                                                                         );
                }

                testResult.ALT = new CompoundResultReading <int?>(altData.CustomerEventReadingId)
                {
                    Label   = ReadingLabels.ALT,
                    Reading = !string.IsNullOrEmpty(altData.Value)
                                                        ? (int?)Convert.ToInt32(altData.Value)
                                                        : null,
                    ReadingSource = altData.IsManual
                                                             ? ReadingSource.Manual
                                                             : ReadingSource.Automatic
                };

                int altValue = 0;
                if (altData.Value != null && int.TryParse(altData.Value, out altValue) == true)
                {
                    testResult.ALT.Finding = new StandardFinding <int?>(
                        Convert.ToInt64(
                            altData.StandardFindingTestReadingId == null
                                                                 ?
                            (new TestResultService()).
                            GetCalculatedStandardFinding(altValue,
                                                         (int)TestType.Liver, (int)ReadingLabels.ALT)
                                                                 : standardFindingTestReading.StandardFindingId));
                }
                else if (altData.StandardFindingTestReadingId != null)
                {
                    testResult.ALT.Finding = new StandardFinding <int?>(standardFindingTestReading.StandardFindingId);
                }

                if (testResult.ALT.Finding != null)
                {
                    testResult.ALT.Finding = new TestResultService().GetAllStandardFindings <int?>((int)TestType.Liver,
                                                                                                   (int)ReadingLabels.ALT).Find(standardFinding => standardFinding.Id == testResult.ALT.Finding.Id);
                }
            }
            return(testResult);
        }