コード例 #1
0
        private void SetPatientMeasurementProperty(PatientMeasurement measurement,
                                                   PulmonaryFunctionTestResovler resolver,
                                                   string propertyName,
                                                   string propertyValue,
                                                   IRow row,
                                                   int cellCursor)
        {
            Type         type         = measurement.GetType();
            PropertyInfo propertyInfo = type.GetProperty(propertyName);
            DateTime     dateRowValue;

            try
            {
                if (propertyInfo != null && propertyInfo.PropertyType == typeof(DateTime))
                {
                    dateRowValue = row.GetCell(cellCursor).DateCellValue;
                    propertyInfo.SetValue(measurement, dateRowValue);
                }
                else if (propertyInfo.PropertyType == typeof(int?) || propertyInfo.PropertyType == typeof(int))
                {
                    int propertyIntValue = Int32.Parse(propertyValue);
                    propertyInfo.SetValue(measurement, propertyIntValue);
                }
                else if (propertyInfo.PropertyType == typeof(DateTime) || propertyInfo.PropertyType == typeof(DateTime?))
                {
                    propertyInfo.
                    SetValue(measurement, Convert.ChangeType(propertyValue, typeof(DateTime)), null);
                }
                else if (propertyInfo.PropertyType == typeof(Decimal) || propertyInfo.PropertyType == typeof(Decimal?))
                {
                    decimal propertyDecValue     = (decimal)Convert.ChangeType(propertyValue, typeof(Decimal));
                    var     propertyDecMultValue = propertyDecValue * 100;

                    if (propertyName == "Height")
                    {
                        resolver.Height = propertyDecValue;
                    }
                    propertyInfo.SetValue(measurement, propertyDecMultValue, null);
                }
                else
                {
                    propertyInfo.
                    SetValue(measurement, Convert.ChangeType(propertyValue, propertyInfo.PropertyType), null);
                }
            }
            catch (InvalidOperationException ex)
            {
                propertyInfo.SetValue(measurement, null);
            }
        }
コード例 #2
0
        private Patient ReadCellsForPatient(Patient patient, IRow row, int cellCount)
        {
            var measurement = new PatientMeasurement();

            measurement.PatientId = patient.ID;
            var pftResolver = new PulmonaryFunctionTestResovler();

            for (int cellCursor = 0; cellCursor < cellCount; cellCursor++)
            {
                if (row.GetCell(cellCursor, MissingCellPolicy.CREATE_NULL_AS_BLANK) != null)
                {
                    ReadCell(patient, measurement, row, pftResolver, cellCursor);
                }
            }
            var pfts = pftResolver.ResolvePFTs(_context, patient);

            _context.PatientPulmonaryFunctionTests.AddRange(pfts);
            return(patient);
        }
コード例 #3
0
        private void ReadCell(Patient patient,
                              PatientMeasurement measurement,
                              IRow row,
                              PulmonaryFunctionTestResovler pftResolver,
                              int cellCursor)
        {
            string header          = _headers.ElementAt(cellCursor);
            string newObjectFields = (string)_dictonary[header];
            string propertyValue   = row.GetCell(cellCursor, MissingCellPolicy.CREATE_NULL_AS_BLANK).ToString();

            if (!string.IsNullOrEmpty(propertyValue) && newObjectFields != null)
            {
                var klassAndField = newObjectFields.Split(".");
                switch (klassAndField[0])
                {
                case "Patient":
                    string propertyName = klassAndField[1];
                    if (propertyValue.Length > 7 && propertyName == "NhsNumber")
                    {
                        propertyValue = propertyValue.Remove(0, 7);
                    }

                    SetPatientProperty(patient, propertyName, row, cellCursor, propertyValue);
                    break;

                case "PatientMeasurement":
                    propertyName = klassAndField[1];
                    SetPatientMeasurementProperty(measurement, pftResolver, propertyName, propertyValue, row, cellCursor);
                    break;

                case "Calculator":
                    propertyName = klassAndField[1];
                    if (propertyName == "Age")
                    {
                        pftResolver.Age = propertyValue;
                    }
                    else if (propertyName == "DLCOValue")
                    {
                        pftResolver.DLCOValue = propertyValue;
                    }
                    else if (propertyName == "FEV1Value")
                    {
                        pftResolver.FEV1Value = propertyValue;
                    }
                    else if (propertyName == "KCOValue")
                    {
                        pftResolver.KCOValue = propertyValue;
                    }
                    else if (propertyName == "FVCValue")
                    {
                        pftResolver.FVCValue = propertyValue;
                    }
                    else if (propertyName == "VAValue")
                    {
                        pftResolver.VAValue = propertyValue;
                    }
                    else if (propertyName == "DateTaken")
                    {
                        pftResolver.DateTaken = propertyValue;
                        measurement.DateTaken = (DateTime)Convert.ChangeType(propertyValue, typeof(DateTime));
                    }
                    break;
                }
            }
        }