public async Task <PatientDTO> EditDiagnosis(PatientDiagnosisDTO diagnosis) { var patient = await _patients.FindOneAndUpdateAsync(p => p.PatientId == diagnosis.PatientId && p.Diagnosis.Any(d => d.Id == diagnosis.Id), Builders <Patient> .Update.Set(p => p.Diagnosis.ElementAt(-1), diagnosis.ConvertToModel())); return(patient.ConvertToDTO()); }
public async Task <bool> AddDiagnosis(PatientDiagnosisDTO diagnosis) { var update = Builders <Patient> .Update.CurrentDate("LastModified").AddToSet(p => p.Diagnosis, diagnosis.ConvertToModel()); var res = await _patients.UpdateOneAsync(p => p.PatientId == diagnosis.PatientId, update); return(res.IsAcknowledged); }