public async Task <bool> Update(PatientAggregate patient, CancellationToken token) { await Delete(patient.Id, token); await Add(patient, token); return(true); }
public async Task <string> Handle(AddPatientCommand command, CancellationToken cancellationToken) { var patientAddresses = command.PatientAddress == null ? null : new PatientAddress { Country = command.PatientAddress.Country, StreetNumber = command.PatientAddress.StreetNumber, Street = command.PatientAddress.Street, PostalCode = command.PatientAddress.PostalCode, Coordinates = command.PatientAddress.Coordinates }; var contactInformations = command.ContactInformations == null ? new List <PatientContactInformation>() : command.ContactInformations.Select(_ => new PatientContactInformation { Type = _.Type, Value = _.Value }).ToList(); var img = ConvertImage(command.Base64EncodedImage); var id = Guid.NewGuid().ToString(); var relativePath = string.Empty; if (img != null) { relativePath = $"images/patient-{id}.png"; var logoUrl = Path.Combine(_options.RootPath, Path.Combine("images", $"patient-{id}.png")); await System.IO.File.WriteAllBytesAsync(logoUrl, img, cancellationToken); } var patient = PatientAggregate.New(id, command.Firstname, command.Lastname, command.NationalIdentityNumber, command.Gender, command.BirthDate, relativePath, command.EidCardNumber, command.EidCardValidity, patientAddresses, contactInformations); var streamName = patient.GetStreamName(); await _commitAggregateHelper.Commit(patient, streamName, Constants.QueueNames.Patient); return(id); }
public static GetPatientQueryResult ToResult(this PatientAggregate patient) { return(new GetPatientQueryResult { Id = patient.Id, Birthdate = patient.BirthDate, Firstname = patient.Firstname, Lastname = patient.Lastname, Niss = patient.NationalIdentityNumber, LogoUrl = patient.LogoUrl, CreateDateTime = patient.CreateDateTime, UpdateDateTime = patient.UpdateDateTime, EidCardNumber = patient.EidCardNumber, EidCardValidity = patient.EidCardValidity, Gender = patient.Gender, ContactInformations = patient.ContactInformations.Select(_ => new ContactInformationResult { Type = _.Type, Value = _.Value }).ToList(), Address = patient.Address == null ? new AddressResult() : new AddressResult { Coordinates = patient.Address.Coordinates, Country = patient.Address.Country, PostalCode = patient.Address.PostalCode, Street = patient.Address.Street, StreetNumber = patient.Address.StreetNumber } }); }
public async Task Handle(PatientAddedEvent message, CancellationToken token) { var patient = PatientAggregate.New(new List <DomainEvent> { message }); await _patientCommandRepository.Add(patient, token); await _patientCommandRepository.Commit(token); }
public Task <bool> Add(PatientAggregate patient, CancellationToken token) { _patients.Add((PatientAggregate)patient.Clone()); return(Task.FromResult(true)); }
public static GetPharmaceuticalPrescriptionResult ToResult(this PharmaceuticalPrescriptionResult prescription, PatientAggregate patient, List <AmpResult> ampLst) { return(new GetPharmaceuticalPrescriptionResult { Id = prescription.Id, CreateDateTime = prescription.CreateDateTime, EndExecutionDate = prescription.EndExecutionDate, PrescriptionType = (int)prescription.PrescriptionType, Prescriber = new GetPharmaceuticalPrescriptionResult.PrescriberResult { Birthdate = DateTime.UtcNow, Firstname = "John", Lastname = "Doe", INAMINumber = "123456" }, Patient = new GetPharmaceuticalPrescriptionResult.PatientResult { Birthdate = patient.BirthDate, Firstname = patient.Firstname, Lastname = patient.Lastname, Niss = patient.NationalIdentityNumber }, Medications = prescription.Medications.Select(_ => new GetPharmaceuticalPrescriptionResult.MedicationResult { InstructionForPatient = _.InstructionForPatient, InstructionForReimbursement = _.InstructionForReimbursement, MedicationPackage = new GetPharmaceuticalPrescriptionResult.MedicationPackageResult { PackageCode = _.PackageCode, Translations = ampLst.SelectMany(_ => _.Names).Select(a => new TranslationResult { Language = a.Language, Value = a.Value }).ToList() }, Posology = _.Posology == null || _.Posology.Type.Code != PosologyTypes.FreeText.Code ? null : new GetPharmaceuticalPrescriptionResult.PosologyFreeTextResult { Content = ((PharmaceuticalPrescriptionFreeTextPosologyResult)_.Posology).Content } }).ToList() }); }