public DatasetInstanceValueListDto GetElementValuesForPatient(long patientId, string datasetName, string elementName, int records) { var encounters = _unitOfWork.Repository <Encounter>().Queryable() .Where(e => e.Patient.Id == patientId) .OrderByDescending(e => e.EncounterDate).Take(records); var datasetElement = _unitOfWork.Repository <DatasetElement>().Queryable() .SingleOrDefault(de => de.ElementName == elementName && de.DatasetCategoryElements.Any(dce => dce.DatasetCategory.Dataset.DatasetName == datasetName)); var model = new DatasetInstanceValueListDto() { DatasetElement = datasetElement }; if (datasetElement != null) { foreach (Encounter encounter in encounters) { var val = GetValueForElement(_unitOfWork.Repository <DatasetInstance>().Queryable().SingleOrDefault(di => di.ContextID == encounter.Id), datasetElement); var modelItem = new DatasetInstanceValueListItem() { Value = !String.IsNullOrWhiteSpace(val) ? val : "NO VALUE", ValueDate = encounter.EncounterDate }; model.Values.Add(modelItem); } } return(model); }
public DatasetInstanceValueList GetElementValuesForPatient(Patient patient, DatasetElement element, int records) { var encounters = _unitOfWork.Repository <Encounter>().Queryable().Where(e => e.Patient.Id == patient.Id).OrderByDescending(e => e.EncounterDate).Take(records); var model = new DatasetInstanceValueList() { DatasetElement = element }; foreach (Encounter encounter in encounters) { var val = GetValueForElement(_unitOfWork.Repository <DatasetInstance>().Queryable().SingleOrDefault(di => di.ContextID == encounter.Id), element); var modelItem = new DatasetInstanceValueListItem() { Value = !String.IsNullOrWhiteSpace(val) ? val : "NO VALUE", ValueDate = encounter.EncounterDate }; model.Values.Add(modelItem); } return(model); }