medicalHistory: deletion when patient is deleted
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
using Application.Services.Database;
|
||||
using Application.Services.Database.PostgreSQL;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Application.Endpoints.MedicalHistories.FileManagement;
|
||||
|
||||
+3
-3
@@ -1,13 +1,13 @@
|
||||
using Application.Services.Database;
|
||||
using Application.Services.Database.MongoDB;
|
||||
using Application.Services.Database.MongoDB;
|
||||
using Application.Services.Database.PostgreSQL;
|
||||
using Core.Entities;
|
||||
|
||||
namespace Application.Endpoints.MedicalHistories.FileManagement;
|
||||
|
||||
public class MedicalHistoryFileManagementHandler
|
||||
{
|
||||
private readonly IMedicalHistoryRepository _medicalHistoryRepository;
|
||||
private readonly IMedicalHistoryMongoDbService _medicalHistoryMongoDbService;
|
||||
private readonly IMedicalHistoryRepository _medicalHistoryRepository;
|
||||
private readonly IPatientRepository _patientRepository;
|
||||
|
||||
public MedicalHistoryFileManagementHandler(IMedicalHistoryRepository medicalHistoryRepository,
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
using Application.Services.Database;
|
||||
using Application.Services.Database.PostgreSQL;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Application.Endpoints.MedicalHistories.FileManagement;
|
||||
|
||||
+15
-23
@@ -1,13 +1,13 @@
|
||||
using Application.Services.Database;
|
||||
using Application.Services.Database.MongoDB;
|
||||
using Application.Services.Database.MongoDB;
|
||||
using Application.Services.Database.PostgreSQL;
|
||||
|
||||
namespace Application.Endpoints.MedicalHistories.ManageAuthorization;
|
||||
|
||||
public class MedicalHistoryManageAuthorizationHandler
|
||||
{
|
||||
private readonly IMedicalHistoryRepository _medicalHistoryRepository;
|
||||
private readonly IDoctorRepository _doctorRepository;
|
||||
private readonly IMedicalHistoryMongoDbService _medicalHistoryMongoDbService;
|
||||
private readonly IMedicalHistoryRepository _medicalHistoryRepository;
|
||||
|
||||
public MedicalHistoryManageAuthorizationHandler(IMedicalHistoryRepository medicalHistoryRepository,
|
||||
IMedicalHistoryMongoDbService medicalHistoryMongoDbService, IDoctorRepository doctorRepository)
|
||||
@@ -41,28 +41,24 @@ public class MedicalHistoryManageAuthorizationHandler
|
||||
|
||||
var documents = await _medicalHistoryMongoDbService.FindAsync<MedicalHistoryAuthorisationModel>(criteria);
|
||||
if (!documents.Any())
|
||||
{
|
||||
return new BaseResponse()
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.NotFound,
|
||||
Message = "Access to medical history not found.",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
var authorisations = documents[0].Authorisation;
|
||||
if (authorisations.Contains(infoDto.ToString()))
|
||||
{
|
||||
return new BaseResponse()
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.Conflict,
|
||||
Message = "Access to medical history already granted.",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
authorisations.Add(infoDto.DoctorId.ToString());
|
||||
var authorizationModel = new MedicalHistoryAuthorisationModel()
|
||||
var authorizationModel = new MedicalHistoryAuthorisationModel
|
||||
{
|
||||
Id = infoDto.MedicalRecordId.ToString(),
|
||||
Authorisation = authorisations
|
||||
@@ -70,7 +66,7 @@ public class MedicalHistoryManageAuthorizationHandler
|
||||
|
||||
await _medicalHistoryMongoDbService.ModifyAsync("_id", infoDto.MedicalRecordId.ToString(), authorizationModel);
|
||||
|
||||
return new BaseResponse()
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.OK,
|
||||
Message = "Access to medical history granted.",
|
||||
@@ -102,28 +98,24 @@ public class MedicalHistoryManageAuthorizationHandler
|
||||
|
||||
var documents = await _medicalHistoryMongoDbService.FindAsync<MedicalHistoryAuthorisationModel>(criteria);
|
||||
if (!documents.Any())
|
||||
{
|
||||
return new BaseResponse()
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.NotFound,
|
||||
Message = "Access to medical history not found.",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
var authorisations = documents[0].Authorisation;
|
||||
if (!authorisations.Contains(infoDto.DoctorId.ToString()))
|
||||
{
|
||||
return new BaseResponse()
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.Conflict,
|
||||
Message = "Access to medical history already revoked.",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
authorisations.Remove(infoDto.DoctorId.ToString());
|
||||
var authorizationModel = new MedicalHistoryAuthorisationModel()
|
||||
var authorizationModel = new MedicalHistoryAuthorisationModel
|
||||
{
|
||||
Id = infoDto.MedicalRecordId.ToString(),
|
||||
Authorisation = authorisations
|
||||
@@ -131,7 +123,7 @@ public class MedicalHistoryManageAuthorizationHandler
|
||||
|
||||
await _medicalHistoryMongoDbService.ModifyAsync("_id", infoDto.MedicalRecordId.ToString(), authorizationModel);
|
||||
|
||||
return new BaseResponse()
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = HttpStatusCodes.OK,
|
||||
Message = "Access to medical history granted.",
|
||||
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
using Application.Services.Database;
|
||||
using Application.Services.Database.PostgreSQL;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Application.Endpoints.MedicalHistories.ManageAuthorization;
|
||||
|
||||
public class MedicalHistoryManageAuthorizationValidation : AbstractValidator<MedicalHistoryManageAuthorizationDoctorDto>
|
||||
{
|
||||
private readonly IMedicalHistoryRepository _medicalHistoryRepository;
|
||||
private readonly IDoctorRepository _doctorRepository;
|
||||
private readonly IMedicalHistoryRepository _medicalHistoryRepository;
|
||||
|
||||
public MedicalHistoryManageAuthorizationValidation(IMedicalHistoryRepository medicalHistoryRepository,
|
||||
IDoctorRepository doctorRepository)
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
public class MedicalHistoryAuthorisationModel
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public List<string> Authorisation { get; set; } = new List<string>();
|
||||
public List<string> Authorisation { get; set; } = new();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using Application.Services.Database;
|
||||
using Application.Services.Database.PostgreSQL;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Application.Endpoints.MedicalHistories;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using Application.Services.Database;
|
||||
using Application.Services.Database.MongoDB;
|
||||
using Application.Services.Database.MongoDB;
|
||||
using Application.Services.Database.PostgreSQL;
|
||||
using Core.Entities;
|
||||
|
||||
namespace Application.Endpoints.MedicalHistories;
|
||||
|
||||
public class MedicalHistoryHandler
|
||||
{
|
||||
private readonly IMedicalHistoryRepository _medicalHistoryRepository;
|
||||
private readonly IMedicalHistoryMongoDbService _medicalHistoryMongoDbService;
|
||||
private readonly IMedicalHistoryRepository _medicalHistoryRepository;
|
||||
private readonly IPatientRepository _patientRepository;
|
||||
|
||||
public MedicalHistoryHandler(IMedicalHistoryRepository medicalHistoryRepository,
|
||||
@@ -80,7 +80,7 @@ public class MedicalHistoryHandler
|
||||
UserId = medicalHistoryCreateDto.UserId,
|
||||
Content = medicalHistoryCreateDto.Content
|
||||
};
|
||||
|
||||
|
||||
var medicalHistoryId = medicalHistory.Id;
|
||||
var newMedicalHistory = new MedicalHistoryAuthorisationModel
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Application.Services.Database;
|
||||
using Application.Services.Database.PostgreSQL;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Application.Endpoints.MedicalHistories;
|
||||
|
||||
Reference in New Issue
Block a user