protected Prescription(PrescriptionIdentifier identifier, HealthcareProvider prescriber, Patient patient, HealthFacility healthFacility, Alpha2LanguageCode languageCode, PrescriptionStatus status, DateTime createdOn, DateTime?delivrableAt = null, EntityState entityState = EntityState.Added, IEnumerable <IDomainEvent> events = null) : base(entityState, events) { Condition.Requires(identifier, nameof(identifier)).IsNotNull(); Condition.Requires(prescriber, nameof(prescriber)).IsNotNull(); Condition.Requires(patient, nameof(patient)).IsNotNull(); Condition.Requires(healthFacility, nameof(healthFacility)).IsNotNull(); Condition.Requires(status, nameof(status)).IsNotNull(); Condition.Requires(languageCode, nameof(languageCode)).IsNotNull(); this.Identifier = identifier; this.Prescriber = prescriber; this.Patient = patient; this.HealthFacility = healthFacility; this.Status = status; this.CreatedOn = createdOn; this.DelivrableAt = delivrableAt; this.LanguageCode = languageCode; }
public static PharmaceuticalPrescription Create(PrescriptionIdentifier identifier, HealthcareProvider prescriber, Patient patient, HealthFacility healthFacility, IEnumerable <PrescribedMedication> prescribedMedications, DateTime createdOn, Alpha2LanguageCode languageCode, DateTime?delivrableAt = null) { var prescription = new PharmaceuticalPrescription ( identifier, prescriber, patient, healthFacility, prescribedMedications, languageCode, PrescriptionStatus.Created, createdOn, delivrableAt ); prescription.AddEvent(new PharmaceuticalPrescriptionCreated(identifier.Identifier, createdOn)); return(prescription); }
public static PharmaceuticalPrescription Create(PrescriptionIdentifier identifier, HealthcareProvider prescriber, Patient patient, HealthFacility healthFacility, IEnumerable <PrescribedMedication> prescribedMedications, Alpha2LanguageCode languageCode, DateTime?delivrableAt = null) { return(Create(identifier, prescriber, patient, healthFacility, prescribedMedications, DateTime.Now, languageCode, delivrableAt)); }
public IActionResult Update(HealthcareProvider healthcareProvider) { var result = _healthcareProviderService.Update(healthcareProvider); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
private string generateJwtToken(HealthcareProvider account) { var tokenHandler = new JwtSecurityTokenHandler(); var key = Encoding.ASCII.GetBytes(_appSettings.Secret); var tokenDescriptor = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(new[] { new Claim("id", account.Id.ToString()) }), Expires = DateTime.UtcNow.AddMinutes(15), SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature) }; var token = tokenHandler.CreateToken(tokenDescriptor); return(tokenHandler.WriteToken(token)); }
private HealthProviderEntryDto MapToREMDto(HealthcareProvider niemEntry) { var result = new HealthProviderEntryDto { FirstName = niemEntry.PersonGivenName, LastName = niemEntry.PersonSurName, IsHcProfessional = niemEntry.IsHealthcareProfessional, OrganizationName = niemEntry.OrganizationName, Specialization = (niemEntry.PersonRoleCategoryText != null && niemEntry.PersonRoleCategoryText.Count > 0) ? niemEntry.PersonRoleCategoryText[0] : null, Mail = niemEntry.ElectronicAddressText, TelephoneNumber = (niemEntry.TelephoneNumberFullID != null && niemEntry.TelephoneNumberFullID.Count > 0) ? niemEntry.TelephoneNumberFullID[0] : null }; return(result); }
public IActionResult RevokeToken(RevokeTokenRequest model) { // accept token from request body or cookie var token = model.Token ?? Request.Cookies["refreshToken"]; if (string.IsNullOrEmpty(token)) { return(BadRequest(new { message = "Token is required" })); } // users can revoke their own tokens and admins can revoke any tokens if (!HealthcareProvider.OwnsToken(token) && Account.Role != Role.Admin) { return(Unauthorized(new { message = "Unauthorized" })); } _accountService.RevokeToken(token, ipAddress()); return(Ok(new { message = "Token revoked" })); }
public PharmaceuticalPrescription(PrescriptionIdentifier identifier, HealthcareProvider prescriber, Patient patient, HealthFacility healthFacility, IEnumerable <PrescribedMedication> prescribedMedications, Alpha2LanguageCode languageCode, PrescriptionStatus status, DateTime createdOn, DateTime?delivrableAt = null, EntityState entityState = EntityState.Added, IEnumerable <IDomainEvent> events = null) : base(identifier, prescriber, patient, healthFacility, languageCode, status, createdOn, delivrableAt, entityState, events) { Condition.Requires(prescribedMedications, nameof(prescribedMedications)) .IsNotNull() .IsNotEmpty() .DoesNotContain(null); this.PrescribedMedications.AddRange(prescribedMedications); }
private void sendPasswordResetEmail(HealthcareProvider account, string origin) { string message; if (!string.IsNullOrEmpty(origin)) { var resetUrl = $"{origin}/healthcareprovider/reset-password?token={account.ResetToken}"; message = $@"<p>Please click the below link to reset your password, the link will be valid for 1 day:</p> <p><a href=""{resetUrl}"">{resetUrl}</a></p>"; } else { message = $@"<p>Please use the below token to reset your password with the <code>/healthcareprovider/reset-password</code> api route:</p> <p><code>{account.ResetToken}</code></p>"; } _emailService.Send( to: account.Email, subject: "Africanbiomedtests - Reset Password", html: $@"<h4>Reset Password Email</h4> {message}" ); }
private void sendVerificationEmail(HealthcareProvider account, string origin) { string message; if (!string.IsNullOrEmpty(origin)) { var verifyUrl = $"{origin}/healthcareprovider/verify-email?token={account.VerificationToken}"; message = $@"<p>Please click the below link to verify your email address:</p> <p><a href=""{verifyUrl}"">{verifyUrl}</a></p>"; } else { message = $@"<p>Please use the below token to verify your email address with the <code>/healthcareprovider/verify-email</code> api route:</p> <p><code>{account.VerificationToken}</code></p>"; } _emailService.Send( to: account.Email, subject: "Africanbiomedtests Sign-up Verification - Verify Email", html: $@"<h4>Verify Email</h4> <p>Thanks for registering!</p> {message}" ); }
private void removeOldRefreshTokens(HealthcareProvider account) { account.RefreshTokens.RemoveAll(x => !x.IsActive && x.Created.AddDays(_appSettings.RefreshTokenTTL) <= DateTime.UtcNow); }
public IResult Update(HealthcareProvider healthcareProvider) { _healthcareProviderDal.Update(healthcareProvider); return(new Result(true, Messages.Updated)); }
public IResult Add(HealthcareProvider healthcareProvider) { _healthcareProviderDal.Add(healthcareProvider); return(new Result(true, Messages.Added)); }