private Patient ReadRowCellsIntoPatientObject(Patient patient, IRow row, int cellCount) { List <string> diagnosesNames = new List <string>(); for (int cellCursor = row.FirstCellNum; cellCursor < cellCount; cellCursor++) { if (row.GetCell(cellCursor) != null) { ReadCell(patient, row, cellCursor, diagnosesNames); } } var patientDiagnosisResolver = new PatientDiagnosisResolver(patient, diagnosesNames, _context); patient.PatientDiagnoses = patientDiagnosisResolver.Resolve(); return(patient); }
private void ReadCell(Patient patient, IRow row, PatientSTGQuestionnaireResolver resolver, int cellIndex) { string header = _headers.ElementAt(cellIndex); string newObjectFields = (string)_dictonary[header]; string propertyValue = row.GetCell(cellIndex, MissingCellPolicy.CREATE_NULL_AS_BLANK).ToString(); if (!string.IsNullOrEmpty(propertyValue) && newObjectFields != null && FirstTwoCellsNotEmpty(row)) { var klassAndField = newObjectFields.Split("."); switch (klassAndField[0]) { case "Patient": string propertyName = klassAndField[1]; if (propertyName == "Gender") { if (propertyValue == "2") { propertyValue = "Male"; } else if (propertyValue == "1") { propertyValue = "Female"; } } SetPatientProperty(patient, propertyName, row, cellIndex, propertyValue); break; case "PatientDiagnosis": if (propertyValue == "1") { var diagnosesResolver = new PatientDiagnosisResolver(patient, _context); var diagnoses = diagnosesResolver.ResolveForName(header, "Underlying Diagnosis"); } break; case "PatientSTGQuestionnaire": string columnName = klassAndField[1]; resolver.SetQuestionnaireProperty(columnName, propertyValue); break; } } }