api cu adaugare/revocare acces
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using Application.Endpoints;
|
||||
using Application.Endpoints.MedicalHistories;
|
||||
using Application.Endpoints.MedicalHistories.FileManagement;
|
||||
using Application.Endpoints.MedicalHistories.ManageAuthorization;
|
||||
using Application.Services.Database;
|
||||
using Application.Services.Database.MongoDB;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -13,19 +15,23 @@ public class MedicalHistoryController : ControllerBase
|
||||
private readonly IMedicalHistoryRepository _medicalHistoryRepository;
|
||||
private readonly IMedicalHistoryMongoDbService _medicalHistoryMongoDbService;
|
||||
private readonly IPatientRepository _patientRepository;
|
||||
private readonly IDoctorRepository _doctorRepository;
|
||||
|
||||
public MedicalHistoryController(IMedicalHistoryRepository medicalHistoryRepository,
|
||||
IPatientRepository patientRepository, IMedicalHistoryMongoDbService mongoDbService)
|
||||
IPatientRepository patientRepository, IMedicalHistoryMongoDbService mongoDbService,
|
||||
IDoctorRepository doctorRepository)
|
||||
{
|
||||
_medicalHistoryRepository = medicalHistoryRepository;
|
||||
_patientRepository = patientRepository;
|
||||
_medicalHistoryMongoDbService = mongoDbService;
|
||||
_doctorRepository = doctorRepository;
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public async Task<ActionResult<BaseResponse>> GetAsync(Guid id)
|
||||
{
|
||||
var handler = new MedicalHistoryHandler(_medicalHistoryRepository, _patientRepository, _medicalHistoryMongoDbService);
|
||||
var handler = new MedicalHistoryFileManagementHandler(_medicalHistoryRepository, _patientRepository,
|
||||
_medicalHistoryMongoDbService);
|
||||
var response = await handler.HandleGet(id);
|
||||
return StatusCode(response.StatusCode, response);
|
||||
}
|
||||
@@ -33,7 +39,8 @@ public class MedicalHistoryController : ControllerBase
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<BaseResponse>> GetAllDoctors()
|
||||
{
|
||||
var handler = new MedicalHistoryHandler(_medicalHistoryRepository, _patientRepository, _medicalHistoryMongoDbService);
|
||||
var handler = new MedicalHistoryFileManagementHandler(_medicalHistoryRepository, _patientRepository,
|
||||
_medicalHistoryMongoDbService);
|
||||
var response = await handler.HandleGetAll();
|
||||
return StatusCode(response.StatusCode, response);
|
||||
}
|
||||
@@ -41,7 +48,8 @@ public class MedicalHistoryController : ControllerBase
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<BaseResponse>> PostAsync(MedicalHistoryCreateDto medicalHistoryCreateDto)
|
||||
{
|
||||
var handler = new MedicalHistoryHandler(_medicalHistoryRepository, _patientRepository, _medicalHistoryMongoDbService);
|
||||
var handler = new MedicalHistoryFileManagementHandler(_medicalHistoryRepository, _patientRepository,
|
||||
_medicalHistoryMongoDbService);
|
||||
var response = await handler.HandleCreate(medicalHistoryCreateDto);
|
||||
return StatusCode(response.StatusCode, response);
|
||||
}
|
||||
@@ -49,7 +57,8 @@ public class MedicalHistoryController : ControllerBase
|
||||
[HttpPut]
|
||||
public async Task<ActionResult<BaseResponse>> UpdateAsync(MedicalHistoryUpdateDto medicalHistoryUpdateDto)
|
||||
{
|
||||
var handler = new MedicalHistoryHandler(_medicalHistoryRepository, _patientRepository, _medicalHistoryMongoDbService);
|
||||
var handler = new MedicalHistoryFileManagementHandler(_medicalHistoryRepository, _patientRepository,
|
||||
_medicalHistoryMongoDbService);
|
||||
var response = await handler.HandleUpdate(medicalHistoryUpdateDto).ConfigureAwait(false);
|
||||
return StatusCode(response.StatusCode, response);
|
||||
}
|
||||
@@ -57,16 +66,30 @@ public class MedicalHistoryController : ControllerBase
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<ActionResult<BaseResponse>> DeleteAsync(Guid id)
|
||||
{
|
||||
var handler = new MedicalHistoryHandler(_medicalHistoryRepository, _patientRepository, _medicalHistoryMongoDbService);
|
||||
var handler = new MedicalHistoryFileManagementHandler(_medicalHistoryRepository, _patientRepository,
|
||||
_medicalHistoryMongoDbService);
|
||||
var response = await handler.HandleDelete(id);
|
||||
return StatusCode(response.StatusCode, response);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
[HttpPut("grant_access")]
|
||||
public async Task<ActionResult<BaseResponse>> GrantAccessToMedicalHistory(GrantAccessMedicalHistoryDto)
|
||||
public async Task<ActionResult<BaseResponse>> GrantAccessToMedicalHistory(
|
||||
MedicalHistoryManageAuthorizationDoctorDto infoDto)
|
||||
{
|
||||
return NotFound();
|
||||
var handler = new MedicalHistoryManageAuthorizationHandler(_medicalHistoryRepository,
|
||||
_medicalHistoryMongoDbService, _doctorRepository);
|
||||
var response = await handler.HandleGrantDoctorAccess(infoDto);
|
||||
return StatusCode(response.StatusCode, response);
|
||||
}
|
||||
|
||||
[HttpPut("revoke_access")]
|
||||
public async Task<ActionResult<BaseResponse>> RevokeAccessToMedicalHistory(
|
||||
MedicalHistoryManageAuthorizationDoctorDto infoDto)
|
||||
{
|
||||
var handler = new MedicalHistoryManageAuthorizationHandler(_medicalHistoryRepository,
|
||||
_medicalHistoryMongoDbService, _doctorRepository);
|
||||
var response = await handler.HandleRevokeDoctorAccess(infoDto);
|
||||
return StatusCode(response.StatusCode, response);
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
"MongoDBConnection": "mongodb+srv://andrei_cerbu:andrei@cluster0.v80skg6.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0"
|
||||
},
|
||||
"HealthcareManagerDatabase": {
|
||||
"Name":"HealthcareManager",
|
||||
"Name": "HealthcareManager",
|
||||
"MedicalRecordCollectionName": "MedicalHistory",
|
||||
"ChatCollectionName": "Chat"
|
||||
},
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -10,7 +10,7 @@
|
||||
"MongoDBConnection": "mongodb+srv://andrei_cerbu:andrei@cluster0.v80skg6.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0"
|
||||
},
|
||||
"HealthcareManagerDatabase": {
|
||||
"Name":"HealthcareManager",
|
||||
"Name": "HealthcareManager",
|
||||
"MedicalRecordCollectionName": "MedicalHistory",
|
||||
"ChatCollectionName": "Chat"
|
||||
},
|
||||
|
||||
@@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("API")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+61a55fa7353346bdad2d677f0ec3c044c3aa87d5")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b4eca98e0a616e4db63ed57610d69f27f43f4765")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("API")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("API")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -1 +1 @@
|
||||
9384050dd4f92ebe3a80d1f56d1515196db26fe72de654a1ee0d4041a1b7e633
|
||||
ff25e4eabd78a6c8257b3187d0c0a6d7ce9f93113ce81c3dc173c29363b6a20a
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/61a55fa7353346bdad2d677f0ec3c044c3aa87d5/*"}}
|
||||
{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/b4eca98e0a616e4db63ed57610d69f27f43f4765/*"}}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace Application.Endpoints.MedicalHistories;
|
||||
namespace Application.Endpoints.MedicalHistories.FileManagement;
|
||||
|
||||
public class MedicalHistoryCreateDto
|
||||
{
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
using Application.Services.Database;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Application.Endpoints.MedicalHistories;
|
||||
namespace Application.Endpoints.MedicalHistories.FileManagement;
|
||||
|
||||
public class MedicalHistoryCreateValidation : AbstractValidator<MedicalHistoryCreateDto>
|
||||
{
|
||||
+4
-4
@@ -2,15 +2,15 @@
|
||||
using Application.Services.Database.MongoDB;
|
||||
using Core.Entities;
|
||||
|
||||
namespace Application.Endpoints.MedicalHistories;
|
||||
namespace Application.Endpoints.MedicalHistories.FileManagement;
|
||||
|
||||
public class MedicalHistoryHandler
|
||||
public class MedicalHistoryFileManagementHandler
|
||||
{
|
||||
private readonly IMedicalHistoryRepository _medicalHistoryRepository;
|
||||
private readonly IMedicalHistoryMongoDbService _medicalHistoryMongoDbService;
|
||||
private readonly IPatientRepository _patientRepository;
|
||||
|
||||
public MedicalHistoryHandler(IMedicalHistoryRepository medicalHistoryRepository,
|
||||
public MedicalHistoryFileManagementHandler(IMedicalHistoryRepository medicalHistoryRepository,
|
||||
IPatientRepository patientRepository, IMedicalHistoryMongoDbService medicalHistoryMongoDbService)
|
||||
{
|
||||
_medicalHistoryRepository = medicalHistoryRepository;
|
||||
@@ -80,7 +80,7 @@ public class MedicalHistoryHandler
|
||||
UserId = medicalHistoryCreateDto.UserId,
|
||||
Content = medicalHistoryCreateDto.Content
|
||||
};
|
||||
|
||||
|
||||
var medicalHistoryId = medicalHistory.Id;
|
||||
var newMedicalHistory = new MedicalHistoryAuthorisationModel
|
||||
{
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace Application.Endpoints.MedicalHistories;
|
||||
namespace Application.Endpoints.MedicalHistories.FileManagement;
|
||||
|
||||
public class MedicalHistoryUpdateDto
|
||||
{
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
using Application.Services.Database;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Application.Endpoints.MedicalHistories;
|
||||
namespace Application.Endpoints.MedicalHistories.FileManagement;
|
||||
|
||||
public class MedicalHistoryUpdateValidation : AbstractValidator<MedicalHistoryUpdateDto>
|
||||
{
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
namespace Application.Endpoints.MedicalHistories.ManageAuthorization;
|
||||
|
||||
public class MedicalHistoryManageAuthorizationDoctorDto
|
||||
{
|
||||
public Guid MedicalRecordId { get; set; }
|
||||
public Guid DoctorId { get; set; }
|
||||
}
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
using Application.Services.Database;
|
||||
using Application.Services.Database.MongoDB;
|
||||
using Core.Entities;
|
||||
|
||||
namespace Application.Endpoints.MedicalHistories.ManageAuthorization;
|
||||
|
||||
public class MedicalHistoryManageAuthorizationHandler
|
||||
{
|
||||
private readonly IMedicalHistoryRepository _medicalHistoryRepository;
|
||||
private readonly IDoctorRepository _doctorRepository;
|
||||
private readonly IMedicalHistoryMongoDbService _medicalHistoryMongoDbService;
|
||||
|
||||
public MedicalHistoryManageAuthorizationHandler(IMedicalHistoryRepository medicalHistoryRepository,
|
||||
IMedicalHistoryMongoDbService medicalHistoryMongoDbService, IDoctorRepository doctorRepository)
|
||||
{
|
||||
_medicalHistoryRepository = medicalHistoryRepository;
|
||||
_medicalHistoryMongoDbService = medicalHistoryMongoDbService;
|
||||
_doctorRepository = doctorRepository;
|
||||
}
|
||||
|
||||
public async Task<BaseResponse> HandleGrantDoctorAccess(MedicalHistoryManageAuthorizationDoctorDto infoDto)
|
||||
{
|
||||
var validation = new MedicalHistoryManageAuthorizationValidation(_medicalHistoryRepository, _doctorRepository);
|
||||
var validationResult = await validation.ValidateAsync(infoDto);
|
||||
|
||||
if (!validationResult.IsValid)
|
||||
{
|
||||
var firstError = validationResult.Errors.FirstOrDefault();
|
||||
var errorCode = int.TryParse(firstError.ErrorCode, out var code) ? code : -1;
|
||||
var errorMessage = firstError.ErrorMessage;
|
||||
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = errorCode,
|
||||
Message = errorMessage,
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
var criteria = new List<(string, string)>();
|
||||
criteria.Add(("_id", infoDto.MedicalRecordId.ToString()));
|
||||
|
||||
var documents = await _medicalHistoryMongoDbService.FindAsync<MedicalHistoryAuthorisationModel>(criteria);
|
||||
if (!documents.Any())
|
||||
{
|
||||
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()
|
||||
{
|
||||
StatusCode = HttpStatusCodes.Conflict,
|
||||
Message = "Access to medical history already granted.",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
authorisations.Add(infoDto.DoctorId.ToString());
|
||||
var authorizationModel = new MedicalHistoryAuthorisationModel()
|
||||
{
|
||||
Id = infoDto.MedicalRecordId.ToString(),
|
||||
Authorisation = authorisations
|
||||
};
|
||||
|
||||
await _medicalHistoryMongoDbService.ModifyAsync("_id", infoDto.MedicalRecordId.ToString(), authorizationModel);
|
||||
|
||||
return new BaseResponse()
|
||||
{
|
||||
StatusCode = HttpStatusCodes.OK,
|
||||
Message = "Access to medical history granted.",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<BaseResponse> HandleRevokeDoctorAccess(MedicalHistoryManageAuthorizationDoctorDto infoDto)
|
||||
{
|
||||
var validation = new MedicalHistoryManageAuthorizationValidation(_medicalHistoryRepository, _doctorRepository);
|
||||
var validationResult = await validation.ValidateAsync(infoDto);
|
||||
|
||||
if (!validationResult.IsValid)
|
||||
{
|
||||
var firstError = validationResult.Errors.FirstOrDefault();
|
||||
var errorCode = int.TryParse(firstError.ErrorCode, out var code) ? code : -1;
|
||||
var errorMessage = firstError.ErrorMessage;
|
||||
|
||||
return new BaseResponse
|
||||
{
|
||||
StatusCode = errorCode,
|
||||
Message = errorMessage,
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
var criteria = new List<(string, string)>();
|
||||
criteria.Add(("_id", infoDto.MedicalRecordId.ToString()));
|
||||
|
||||
var documents = await _medicalHistoryMongoDbService.FindAsync<MedicalHistoryAuthorisationModel>(criteria);
|
||||
if (!documents.Any())
|
||||
{
|
||||
return new BaseResponse()
|
||||
{
|
||||
StatusCode = HttpStatusCodes.NotFound,
|
||||
Message = "Access to medical history not found.",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
var authorisations = documents[0].Authorisation;
|
||||
Console.WriteLine(authorisations);
|
||||
if (!authorisations.Contains(infoDto.DoctorId.ToString()))
|
||||
{
|
||||
return new BaseResponse()
|
||||
{
|
||||
StatusCode = HttpStatusCodes.Conflict,
|
||||
Message = "Access to medical history already revoked.",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
authorisations.Remove(infoDto.DoctorId.ToString());
|
||||
var authorizationModel = new MedicalHistoryAuthorisationModel()
|
||||
{
|
||||
Id = infoDto.MedicalRecordId.ToString(),
|
||||
Authorisation = authorisations
|
||||
};
|
||||
|
||||
await _medicalHistoryMongoDbService.ModifyAsync("_id", infoDto.MedicalRecordId.ToString(), authorizationModel);
|
||||
|
||||
return new BaseResponse()
|
||||
{
|
||||
StatusCode = HttpStatusCodes.OK,
|
||||
Message = "Access to medical history granted.",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
using Application.Services.Database;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Application.Endpoints.MedicalHistories.ManageAuthorization;
|
||||
|
||||
public class MedicalHistoryManageAuthorizationValidation : AbstractValidator<MedicalHistoryManageAuthorizationDoctorDto>
|
||||
{
|
||||
private readonly IMedicalHistoryRepository _medicalHistoryRepository;
|
||||
private readonly IDoctorRepository _doctorRepository;
|
||||
|
||||
public MedicalHistoryManageAuthorizationValidation(IMedicalHistoryRepository medicalHistoryRepository,
|
||||
IDoctorRepository doctorRepository)
|
||||
{
|
||||
RuleFor(x => x.MedicalRecordId)
|
||||
.NotEmpty().WithMessage("Id is required").WithErrorCode(HttpStatusCodes.BadRequest.ToString())
|
||||
.MustAsync(BeExistingMedicalHistoryRecord).WithMessage("Medical history record does not exist")
|
||||
.WithErrorCode(HttpStatusCodes.NotFound.ToString());
|
||||
|
||||
RuleFor(x => x.DoctorId)
|
||||
.NotEmpty().WithMessage("Id is required.").WithErrorCode(HttpStatusCodes.BadRequest.ToString())
|
||||
.MustAsync(IsDoctorRegistered).WithMessage("Doctor is not registered in system")
|
||||
.WithErrorCode(HttpStatusCodes.NotFound.ToString());
|
||||
|
||||
_medicalHistoryRepository = medicalHistoryRepository;
|
||||
_doctorRepository = doctorRepository;
|
||||
}
|
||||
|
||||
private async Task<bool> BeExistingMedicalHistoryRecord(Guid guid, CancellationToken token)
|
||||
{
|
||||
var record = await _medicalHistoryRepository.GetByIdAsync(guid);
|
||||
return record != null;
|
||||
}
|
||||
|
||||
private async Task<bool> IsDoctorRegistered(Guid id, CancellationToken cancellationToken)
|
||||
{
|
||||
var doctor = await _doctorRepository.GetByIdAsync(id);
|
||||
return doctor != null;
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,13 @@ namespace Application.Services.Database.MongoDB;
|
||||
|
||||
public interface IMedicalHistoryMongoDbService
|
||||
{
|
||||
IMongoCollection<MedicalHistoryAuthorisationModel> GetCollection<MedicalHistoryAuthorisationModel>();
|
||||
IMongoCollection<T> GetCollection<T>();
|
||||
|
||||
Task<List<MedicalHistoryAuthorisationModel>> FindAsync<MedicalHistoryAuthorisationModel>(List<(string FieldName, string Value)> criteria);
|
||||
Task<List<T>> FindAsync<T>(List<(string FieldName, string Value)> criteria);
|
||||
|
||||
Task AddAsync<MedicalHistoryAuthorisationModel>(MedicalHistoryAuthorisationModel document);
|
||||
Task AddAsync<T>(T document);
|
||||
|
||||
Task ModifyAsync<MedicalHistoryAuthorisationModel>(string keyField, string keyValue, MedicalHistoryAuthorisationModel document);
|
||||
Task ModifyAsync<T>(string keyField, string keyValue, T document);
|
||||
|
||||
Task DeleteAsync<MedicalHistoryAuthorisationModel>(string keyField, string keyValue);
|
||||
Task DeleteAsync<T>(string keyField, string keyValue);
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Application")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+61a55fa7353346bdad2d677f0ec3c044c3aa87d5")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b4eca98e0a616e4db63ed57610d69f27f43f4765")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("Application")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("Application")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -1 +1 @@
|
||||
ca8d9dbfc6e022b60b63524e70a3acb8ce1eaa86a2b066fce9c4864553b6125d
|
||||
78ff498bf54e9d999affcd9081c61dde8845fd1e78f6485753e0ca4436dc7cdc
|
||||
|
||||
@@ -1 +1 @@
|
||||
e99f7362e6da84368608067cdbb0c281eef010bca303f59d33c712edf6a9964f
|
||||
003e629f8ad4defbd9bc4b4a250b4753763e3945de1c7fb70b833ff828554693
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/61a55fa7353346bdad2d677f0ec3c044c3aa87d5/*"}}
|
||||
{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/b4eca98e0a616e4db63ed57610d69f27f43f4765/*"}}
|
||||
Binary file not shown.
Binary file not shown.
@@ -30,12 +30,14 @@ public static class DependencyInjection
|
||||
|
||||
// Extract MongoDB database names
|
||||
var healthcareManagerDatabaseName = configuration.GetValue<string>("HealthcareManagerDatabase:Name");
|
||||
var medicalHistoryCollectionName = configuration.GetValue<string>("HealthcareManagerDatabase:MedicalRecordCollectionName");
|
||||
var medicalHistoryCollectionName =
|
||||
configuration.GetValue<string>("HealthcareManagerDatabase:MedicalRecordCollectionName");
|
||||
var chatCollectionName = configuration.GetValue<string>("HealthcareManagerDatabase:ChatCollectionName");
|
||||
|
||||
// Register MongoDB services
|
||||
services.AddSingleton<IMedicalHistoryMongoDbService>(serviceProvider =>
|
||||
new MedicalHistoryMongoDbService(mongoDbConnectionString, healthcareManagerDatabaseName, medicalHistoryCollectionName));
|
||||
new MedicalHistoryMongoDbService(mongoDbConnectionString, healthcareManagerDatabaseName,
|
||||
medicalHistoryCollectionName));
|
||||
|
||||
services.AddSingleton<IChatMongoDbService>(serviceProvider =>
|
||||
new ChatMongoDbService(mongoDbConnectionString, healthcareManagerDatabaseName, chatCollectionName));
|
||||
@@ -47,7 +49,7 @@ public static class DependencyInjection
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
|
||||
private static string ExtractMongoDbDatabaseName(string connectionString)
|
||||
{
|
||||
var connectionStringBuilder = new MongoUrlBuilder(connectionString);
|
||||
|
||||
@@ -4,10 +4,10 @@ namespace Infrastructure.Services.MongoDB;
|
||||
|
||||
public class ChatMongoDbService : MongoDbService, IChatMongoDbService
|
||||
{
|
||||
public ChatMongoDbService(string connectionString, string databaseName, string collectionName)
|
||||
public ChatMongoDbService(string connectionString, string databaseName, string collectionName)
|
||||
: base(connectionString, databaseName, collectionName)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Implement additional methods specific to Chat database if needed
|
||||
}
|
||||
@@ -4,10 +4,10 @@ namespace Infrastructure.Services.MongoDB;
|
||||
|
||||
public class MedicalHistoryMongoDbService : MongoDbService, IMedicalHistoryMongoDbService
|
||||
{
|
||||
public MedicalHistoryMongoDbService(string connectionString, string databaseName, string collectionName)
|
||||
public MedicalHistoryMongoDbService(string connectionString, string databaseName, string collectionName)
|
||||
: base(connectionString, databaseName, collectionName)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Implement additional methods specific to Medical History database if needed
|
||||
}
|
||||
@@ -14,7 +14,7 @@ namespace Infrastructure.Services.MongoDB
|
||||
{
|
||||
_databaseName = databaseName;
|
||||
_collectionName = collectionName;
|
||||
|
||||
|
||||
Console.WriteLine($"Connection string: {connectionString}");
|
||||
Console.WriteLine($"Database Name: {databaseName}");
|
||||
Console.WriteLine($"Collection Name: {collectionName}");
|
||||
@@ -23,12 +23,12 @@ namespace Infrastructure.Services.MongoDB
|
||||
settings.ServerApi = new ServerApi(ServerApiVersion.V1);
|
||||
_database = new MongoClient(settings);
|
||||
|
||||
try
|
||||
try
|
||||
{
|
||||
var result = _database.GetDatabase("admin").RunCommand<BsonDocument>(new BsonDocument("ping", 1));
|
||||
Console.WriteLine("Pinged your deployment. You successfully connected to MongoDB!");
|
||||
}
|
||||
catch (Exception ex)
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
}
|
||||
@@ -71,4 +71,4 @@ namespace Infrastructure.Services.MongoDB
|
||||
await collection.DeleteOneAsync(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Infrastructure")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+61a55fa7353346bdad2d677f0ec3c044c3aa87d5")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b4eca98e0a616e4db63ed57610d69f27f43f4765")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("Infrastructure")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("Infrastructure")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -1 +1 @@
|
||||
08604fac7a3083586b55565c1ab1f39ea8637dd70dd31c4daa6a7693d2108c04
|
||||
8b677799af22dda0302ef21ae1f9e90a373b1470f2b8b3c1bb091bfa2a802d38
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/61a55fa7353346bdad2d677f0ec3c044c3aa87d5/*"}}
|
||||
{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/b4eca98e0a616e4db63ed57610d69f27f43f4765/*"}}
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user