public PcpResultExportModel SetBoneMassData(PcpResultExportModel model, AwvBoneMassTestResult testResult, bool useBlankValue = false)
        {
            if (testResult.EstimatedTScore != null)
            {
                if (testResult.EstimatedTScore.Reading != null)
                {
                    model.BoneMassEstimatedTScore = testResult.EstimatedTScore.Reading.Value.ToString();
                }

                if (testResult.EstimatedTScore.Finding != null)
                {
                    model.BoneMassResult = testResult.EstimatedTScore.Finding.Label;
                }
            }

            model.BoneMassUnabletoScreen = testResult.UnableScreenReason != null && testResult.UnableScreenReason.Count > 0 ? PcpResultExportHelper.YesString : (useBlankValue ? "" : PcpResultExportHelper.NoString);

            if ((testResult.ResultStatus != null && testResult.ResultStatus.SelfPresent) || (testResult.PhysicianInterpretation != null && testResult.PhysicianInterpretation.IsCritical))
            {
                model.BoneMassCritical = PcpResultExportHelper.YesString;
            }
            else if (!useBlankValue)
            {
                model.BoneMassCritical = PcpResultExportHelper.NoString;
            }

            if (testResult.PhysicianInterpretation != null)
            {
                model.BoneMassPhysicianNotes = testResult.PhysicianInterpretation.Remarks;
            }

            return(model);
        }
Ejemplo n.º 2
0
        public override TestResult CreateActualTestResult(CustomerEventScreeningTestsEntity customerEventScreeningTestsEntity)
        {
            var customerEventReadingEntities = customerEventScreeningTestsEntity.CustomerEventReading.ToList();

            var testResult = new AwvBoneMassTestResult(customerEventScreeningTestsEntity.CustomerEventScreeningTestId);

            if (customerEventScreeningTestsEntity.TestMedia != null && customerEventScreeningTestsEntity.TestMedia.Count > 0)
            {
                var fileEntityCollection = customerEventScreeningTestsEntity.FileCollectionViaTestMedia.ToList();
                var testMediaEntity      = customerEventScreeningTestsEntity.TestMedia.FirstOrDefault();

                testResult.ResultImage = new ResultMedia(testMediaEntity.MediaId)
                {
                    File          = GetFileObjectfromEntity(testMediaEntity.FileId, fileEntityCollection),
                    Thumbnail     = testMediaEntity.ThumbnailFileId != null ? new File(testMediaEntity.ThumbnailFileId.Value) : null,
                    ReadingSource = testMediaEntity.IsManual ? ReadingSource.Manual : ReadingSource.Automatic
                };
            }

            var tScoreReadingEntity = customerEventReadingEntities.
                                      Where(customerEventReading => customerEventReading.TestReading.ReadingId == (int)ReadingLabels.EstimatedTScore).FirstOrDefault();

            if (tScoreReadingEntity != null)
            {
                testResult.EstimatedTScore = new CompoundResultReading <decimal?>(tScoreReadingEntity.CustomerEventReadingId)
                {
                    Reading          = (!string.IsNullOrEmpty(tScoreReadingEntity.Value) ? (decimal?)Convert.ToSingle(tScoreReadingEntity.Value) : null),
                    ReadingSource    = tScoreReadingEntity.IsManual ? ReadingSource.Manual : ReadingSource.Automatic,
                    Label            = ReadingLabels.EstimatedTScore,
                    RecorderMetaData = new DataRecorderMetaData
                    {
                        DataRecorderCreator  = new OrganizationRoleUser(tScoreReadingEntity.CreatedByOrgRoleUserId),
                        DateCreated          = tScoreReadingEntity.CreatedOn,
                        DataRecorderModifier = tScoreReadingEntity.UpdatedByOrgRoleUserId.HasValue ? new OrganizationRoleUser(tScoreReadingEntity.UpdatedByOrgRoleUserId.Value) : null,
                        DateModified         = tScoreReadingEntity.UpdatedOn
                    }
                };


                // TODO : This code should be moved to a Coordinator/Service.
                float testReadingValue = 0;
                if (tScoreReadingEntity.StandardFindingTestReadingId != null)
                {
                    var standardFindingReadingEntity = customerEventScreeningTestsEntity.StandardFindingTestReadingCollectionViaCustomerEventReading.ToList().Find(stdFindingTestReading =>
                                                                                                                                                                   stdFindingTestReading.TestId == (int)TestType.AwvBoneMass && stdFindingTestReading.ReadingId == (int)ReadingLabels.EstimatedTScore);

                    if (standardFindingReadingEntity != null)
                    {
                        testResult.EstimatedTScore.Finding = new StandardFinding <decimal?>(standardFindingReadingEntity.StandardFindingId);
                    }
                }
                else if (tScoreReadingEntity.Value != null && float.TryParse(tScoreReadingEntity.Value, out testReadingValue))
                {
                    testResult.EstimatedTScore.Finding = new StandardFinding <decimal?>((new TestResultService()).
                                                                                        GetCalculatedStandardFinding((decimal?)testReadingValue,
                                                                                                                     (int)TestType.AwvBoneMass, (int)ReadingLabels.EstimatedTScore));
                }

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

            return(testResult);
        }