diff --git a/backend/API/Controllers/MedicalHistoryController.cs b/backend/API/Controllers/MedicalHistoryController.cs index b8628a7..d56a1db 100644 --- a/backend/API/Controllers/MedicalHistoryController.cs +++ b/backend/API/Controllers/MedicalHistoryController.cs @@ -1,6 +1,7 @@ using Application.Endpoints; using Application.Endpoints.MedicalHistories; using Application.Services.Database; +using Application.Services.Database.MongoDB; using Microsoft.AspNetCore.Mvc; namespace API.Controllers; @@ -10,21 +11,21 @@ namespace API.Controllers; public class MedicalHistoryController : ControllerBase { private readonly IMedicalHistoryRepository _medicalHistoryRepository; - private readonly IMongoDbService _mongoDbService; + private readonly IMedicalHistoryMongoDbService _medicalHistoryMongoDbService; private readonly IPatientRepository _patientRepository; public MedicalHistoryController(IMedicalHistoryRepository medicalHistoryRepository, - IPatientRepository patientRepository, IMongoDbService mongoDbService) + IPatientRepository patientRepository, IMedicalHistoryMongoDbService mongoDbService) { _medicalHistoryRepository = medicalHistoryRepository; _patientRepository = patientRepository; - _mongoDbService = mongoDbService; + _medicalHistoryMongoDbService = mongoDbService; } [HttpGet("{id}")] public async Task> GetAsync(Guid id) { - var handler = new MedicalHistoryHandler(_medicalHistoryRepository, _patientRepository, _mongoDbService); + var handler = new MedicalHistoryHandler(_medicalHistoryRepository, _patientRepository, _medicalHistoryMongoDbService); var response = await handler.HandleGet(id); return StatusCode(response.StatusCode, response); } @@ -32,7 +33,7 @@ public class MedicalHistoryController : ControllerBase [HttpGet] public async Task> GetAllDoctors() { - var handler = new MedicalHistoryHandler(_medicalHistoryRepository, _patientRepository, _mongoDbService); + var handler = new MedicalHistoryHandler(_medicalHistoryRepository, _patientRepository, _medicalHistoryMongoDbService); var response = await handler.HandleGetAll(); return StatusCode(response.StatusCode, response); } @@ -40,7 +41,7 @@ public class MedicalHistoryController : ControllerBase [HttpPost] public async Task> PostAsync(MedicalHistoryCreateDto medicalHistoryCreateDto) { - var handler = new MedicalHistoryHandler(_medicalHistoryRepository, _patientRepository, _mongoDbService); + var handler = new MedicalHistoryHandler(_medicalHistoryRepository, _patientRepository, _medicalHistoryMongoDbService); var response = await handler.HandleCreate(medicalHistoryCreateDto); return StatusCode(response.StatusCode, response); } @@ -48,7 +49,7 @@ public class MedicalHistoryController : ControllerBase [HttpPut] public async Task> UpdateAsync(MedicalHistoryUpdateDto medicalHistoryUpdateDto) { - var handler = new MedicalHistoryHandler(_medicalHistoryRepository, _patientRepository, _mongoDbService); + var handler = new MedicalHistoryHandler(_medicalHistoryRepository, _patientRepository, _medicalHistoryMongoDbService); var response = await handler.HandleUpdate(medicalHistoryUpdateDto).ConfigureAwait(false); return StatusCode(response.StatusCode, response); } @@ -56,7 +57,7 @@ public class MedicalHistoryController : ControllerBase [HttpDelete("{id}")] public async Task> DeleteAsync(Guid id) { - var handler = new MedicalHistoryHandler(_medicalHistoryRepository, _patientRepository, _mongoDbService); + var handler = new MedicalHistoryHandler(_medicalHistoryRepository, _patientRepository, _medicalHistoryMongoDbService); var response = await handler.HandleDelete(id); return StatusCode(response.StatusCode, response); } diff --git a/backend/API/appsettings.json b/backend/API/appsettings.json index f2efee1..1d53258 100644 --- a/backend/API/appsettings.json +++ b/backend/API/appsettings.json @@ -7,7 +7,12 @@ }, "ConnectionStrings": { "HealthcareManagerDatabase": "Host=surus.db.elephantsql.com;Database=newbwuyu;Username=newbwuyu;Password=0end9Ixqo9PeTE4HVslX7_FVwruEhFf-;", - "MongoDBDatabase": "mongodb+srv://andrei_cerbu:andrei_cerbu@cluster0.v80skg6.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0" + "MongoDBConnection": "mongodb+srv://andrei_cerbu:andrei@cluster0.v80skg6.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0" + }, + "HealthcareManagerDatabase": { + "Name":"HealthcareManager", + "MedicalRecordCollectionName": "MedicalHistory", + "ChatCollectionName": "Chat" }, "ApiKeySettings": { "ApiKey": "testapikey" diff --git a/backend/API/bin/Debug/net8.0/API.dll b/backend/API/bin/Debug/net8.0/API.dll index b3baeba..7f1157a 100644 Binary files a/backend/API/bin/Debug/net8.0/API.dll and b/backend/API/bin/Debug/net8.0/API.dll differ diff --git a/backend/API/bin/Debug/net8.0/API.exe b/backend/API/bin/Debug/net8.0/API.exe index 44b6d99..8f171b5 100644 Binary files a/backend/API/bin/Debug/net8.0/API.exe and b/backend/API/bin/Debug/net8.0/API.exe differ diff --git a/backend/API/bin/Debug/net8.0/API.pdb b/backend/API/bin/Debug/net8.0/API.pdb index b1245ea..03c9e62 100644 Binary files a/backend/API/bin/Debug/net8.0/API.pdb and b/backend/API/bin/Debug/net8.0/API.pdb differ diff --git a/backend/API/bin/Debug/net8.0/Application.dll b/backend/API/bin/Debug/net8.0/Application.dll index dfab3d0..7a8b24f 100644 Binary files a/backend/API/bin/Debug/net8.0/Application.dll and b/backend/API/bin/Debug/net8.0/Application.dll differ diff --git a/backend/API/bin/Debug/net8.0/Application.pdb b/backend/API/bin/Debug/net8.0/Application.pdb index 44a5acb..9acaaf3 100644 Binary files a/backend/API/bin/Debug/net8.0/Application.pdb and b/backend/API/bin/Debug/net8.0/Application.pdb differ diff --git a/backend/API/bin/Debug/net8.0/Infrastructure.dll b/backend/API/bin/Debug/net8.0/Infrastructure.dll index 852a191..3c7b6d1 100644 Binary files a/backend/API/bin/Debug/net8.0/Infrastructure.dll and b/backend/API/bin/Debug/net8.0/Infrastructure.dll differ diff --git a/backend/API/bin/Debug/net8.0/Infrastructure.pdb b/backend/API/bin/Debug/net8.0/Infrastructure.pdb index fba4fca..7fe98f5 100644 Binary files a/backend/API/bin/Debug/net8.0/Infrastructure.pdb and b/backend/API/bin/Debug/net8.0/Infrastructure.pdb differ diff --git a/backend/API/bin/Debug/net8.0/appsettings.json b/backend/API/bin/Debug/net8.0/appsettings.json index f2efee1..1d53258 100644 --- a/backend/API/bin/Debug/net8.0/appsettings.json +++ b/backend/API/bin/Debug/net8.0/appsettings.json @@ -7,7 +7,12 @@ }, "ConnectionStrings": { "HealthcareManagerDatabase": "Host=surus.db.elephantsql.com;Database=newbwuyu;Username=newbwuyu;Password=0end9Ixqo9PeTE4HVslX7_FVwruEhFf-;", - "MongoDBDatabase": "mongodb+srv://andrei_cerbu:andrei_cerbu@cluster0.v80skg6.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0" + "MongoDBConnection": "mongodb+srv://andrei_cerbu:andrei@cluster0.v80skg6.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0" + }, + "HealthcareManagerDatabase": { + "Name":"HealthcareManager", + "MedicalRecordCollectionName": "MedicalHistory", + "ChatCollectionName": "Chat" }, "ApiKeySettings": { "ApiKey": "testapikey" diff --git a/backend/API/obj/Debug/net8.0/API.AssemblyInfo.cs b/backend/API/obj/Debug/net8.0/API.AssemblyInfo.cs index 3e3b283..9029da5 100644 --- a/backend/API/obj/Debug/net8.0/API.AssemblyInfo.cs +++ b/backend/API/obj/Debug/net8.0/API.AssemblyInfo.cs @@ -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+b48d5ee19e5228d9bcb979f2140f996fe7a12723")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+61a55fa7353346bdad2d677f0ec3c044c3aa87d5")] [assembly: System.Reflection.AssemblyProductAttribute("API")] [assembly: System.Reflection.AssemblyTitleAttribute("API")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/backend/API/obj/Debug/net8.0/API.AssemblyInfoInputs.cache b/backend/API/obj/Debug/net8.0/API.AssemblyInfoInputs.cache index 7d5b8c0..f53a41e 100644 --- a/backend/API/obj/Debug/net8.0/API.AssemblyInfoInputs.cache +++ b/backend/API/obj/Debug/net8.0/API.AssemblyInfoInputs.cache @@ -1 +1 @@ -2a4e1c7096998582acfb9acc87d23cdf43dae534213aaa9d36839c4312b69e45 +9384050dd4f92ebe3a80d1f56d1515196db26fe72de654a1ee0d4041a1b7e633 diff --git a/backend/API/obj/Debug/net8.0/API.csproj.AssemblyReference.cache b/backend/API/obj/Debug/net8.0/API.csproj.AssemblyReference.cache index 7460a14..8ebbf02 100644 Binary files a/backend/API/obj/Debug/net8.0/API.csproj.AssemblyReference.cache and b/backend/API/obj/Debug/net8.0/API.csproj.AssemblyReference.cache differ diff --git a/backend/API/obj/Debug/net8.0/API.dll b/backend/API/obj/Debug/net8.0/API.dll index b3baeba..7f1157a 100644 Binary files a/backend/API/obj/Debug/net8.0/API.dll and b/backend/API/obj/Debug/net8.0/API.dll differ diff --git a/backend/API/obj/Debug/net8.0/API.pdb b/backend/API/obj/Debug/net8.0/API.pdb index b1245ea..03c9e62 100644 Binary files a/backend/API/obj/Debug/net8.0/API.pdb and b/backend/API/obj/Debug/net8.0/API.pdb differ diff --git a/backend/API/obj/Debug/net8.0/API.sourcelink.json b/backend/API/obj/Debug/net8.0/API.sourcelink.json index 78afa33..ecec2f0 100644 --- a/backend/API/obj/Debug/net8.0/API.sourcelink.json +++ b/backend/API/obj/Debug/net8.0/API.sourcelink.json @@ -1 +1 @@ -{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/b48d5ee19e5228d9bcb979f2140f996fe7a12723/*"}} \ No newline at end of file +{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/61a55fa7353346bdad2d677f0ec3c044c3aa87d5/*"}} \ No newline at end of file diff --git a/backend/API/obj/Debug/net8.0/apphost.exe b/backend/API/obj/Debug/net8.0/apphost.exe index 44b6d99..8f171b5 100644 Binary files a/backend/API/obj/Debug/net8.0/apphost.exe and b/backend/API/obj/Debug/net8.0/apphost.exe differ diff --git a/backend/API/obj/Debug/net8.0/ref/API.dll b/backend/API/obj/Debug/net8.0/ref/API.dll index 0065d2b..d3bf7c3 100644 Binary files a/backend/API/obj/Debug/net8.0/ref/API.dll and b/backend/API/obj/Debug/net8.0/ref/API.dll differ diff --git a/backend/API/obj/Debug/net8.0/refint/API.dll b/backend/API/obj/Debug/net8.0/refint/API.dll index 0065d2b..d3bf7c3 100644 Binary files a/backend/API/obj/Debug/net8.0/refint/API.dll and b/backend/API/obj/Debug/net8.0/refint/API.dll differ diff --git a/backend/Application/Endpoints/Doctors/Profile/DoctorProfileHandler.cs b/backend/Application/Endpoints/Doctors/Profile/DoctorProfileHandler.cs index 8799afb..7dfe33e 100644 --- a/backend/Application/Endpoints/Doctors/Profile/DoctorProfileHandler.cs +++ b/backend/Application/Endpoints/Doctors/Profile/DoctorProfileHandler.cs @@ -46,7 +46,7 @@ public class DoctorProfileHandler return new BaseResponse { - StatusCode = HttpStatusCodes.NotFound, + StatusCode = HttpStatusCodes.NoContent, Message = "Doctors not found", Data = null }; diff --git a/backend/Application/Endpoints/MedicalHistories/MedicalHistoryAuthorisationModel.cs b/backend/Application/Endpoints/MedicalHistories/MedicalHistoryAuthorisationModel.cs index e13c31d..32f2c67 100644 --- a/backend/Application/Endpoints/MedicalHistories/MedicalHistoryAuthorisationModel.cs +++ b/backend/Application/Endpoints/MedicalHistories/MedicalHistoryAuthorisationModel.cs @@ -2,6 +2,6 @@ public class MedicalHistoryAuthorisationModel { - public Guid Id { get; set; } - public List Authorisation { get; set; } = new List(); + public string Id { get; set; } + public List Authorisation { get; set; } = new List(); } \ No newline at end of file diff --git a/backend/Application/Endpoints/MedicalHistories/MedicalHistoryHandler.cs b/backend/Application/Endpoints/MedicalHistories/MedicalHistoryHandler.cs index db6181b..0edc3ec 100644 --- a/backend/Application/Endpoints/MedicalHistories/MedicalHistoryHandler.cs +++ b/backend/Application/Endpoints/MedicalHistories/MedicalHistoryHandler.cs @@ -1,4 +1,5 @@ using Application.Services.Database; +using Application.Services.Database.MongoDB; using Core.Entities; namespace Application.Endpoints.MedicalHistories; @@ -6,15 +7,15 @@ namespace Application.Endpoints.MedicalHistories; public class MedicalHistoryHandler { private readonly IMedicalHistoryRepository _medicalHistoryRepository; - private readonly IMongoDbService _mongoDbService; + private readonly IMedicalHistoryMongoDbService _medicalHistoryMongoDbService; private readonly IPatientRepository _patientRepository; public MedicalHistoryHandler(IMedicalHistoryRepository medicalHistoryRepository, - IPatientRepository patientRepository, IMongoDbService mongoDbService) + IPatientRepository patientRepository, IMedicalHistoryMongoDbService medicalHistoryMongoDbService) { _medicalHistoryRepository = medicalHistoryRepository; _patientRepository = patientRepository; - _mongoDbService = mongoDbService; + _medicalHistoryMongoDbService = medicalHistoryMongoDbService; } public async Task HandleGetAll() @@ -30,7 +31,7 @@ public class MedicalHistoryHandler return new BaseResponse { - StatusCode = HttpStatusCodes.NotFound, + StatusCode = HttpStatusCodes.NoContent, Message = "Medical histories not found", Data = null }; @@ -79,19 +80,16 @@ public class MedicalHistoryHandler UserId = medicalHistoryCreateDto.UserId, Content = medicalHistoryCreateDto.Content }; - - await _medicalHistoryRepository.AddAsync(medicalHistory); - - //TODO add to MongoDB - + var medicalHistoryId = medicalHistory.Id; var newMedicalHistory = new MedicalHistoryAuthorisationModel { - Id = medicalHistoryId, - Authorisation = new List() + Id = medicalHistoryId.ToString(), + Authorisation = new List() }; - await _mongoDbService.AddAsync("MedicalHistory", newMedicalHistory); + await _medicalHistoryMongoDbService.AddAsync(newMedicalHistory); + await _medicalHistoryRepository.AddAsync(medicalHistory); return new BaseResponse { @@ -143,6 +141,8 @@ public class MedicalHistoryHandler Data = null }; + await _medicalHistoryMongoDbService.DeleteAsync("_id", id.ToString()); + await _medicalHistoryRepository.DeleteAsync(medicalRecord); //TODO delete from MongoDB diff --git a/backend/Application/Endpoints/Patients/Profile/PatientProfileHandler.cs b/backend/Application/Endpoints/Patients/Profile/PatientProfileHandler.cs index 749af92..db0d106 100644 --- a/backend/Application/Endpoints/Patients/Profile/PatientProfileHandler.cs +++ b/backend/Application/Endpoints/Patients/Profile/PatientProfileHandler.cs @@ -46,7 +46,7 @@ public class PatientProfileHandler return new BaseResponse { - StatusCode = HttpStatusCodes.NotFound, + StatusCode = HttpStatusCodes.NoContent, Message = "Patients not found", Data = null }; diff --git a/backend/Application/Services/Database/IMongoDbServices.cs b/backend/Application/Services/Database/IMongoDbServices.cs deleted file mode 100644 index b12d38d..0000000 --- a/backend/Application/Services/Database/IMongoDbServices.cs +++ /dev/null @@ -1,12 +0,0 @@ -using MongoDB.Driver; - -namespace Application.Services.Database; - -public interface IMongoDbService -{ - IMongoCollection GetCollection(string collectionName); - Task> FindAsync(string collectionName, List<(string FieldName, string Value)> criteria); - Task AddAsync(string collectionName, T document); - Task ModifyAsync(string collectionName, string keyField, string keyValue, T document); - Task DeleteAsync(string collectionName, string keyField, string keyValue); -} \ No newline at end of file diff --git a/backend/Application/Services/Database/MongoDB/IChatHistoryMongoDbService.cs b/backend/Application/Services/Database/MongoDB/IChatHistoryMongoDbService.cs new file mode 100644 index 0000000..d308787 --- /dev/null +++ b/backend/Application/Services/Database/MongoDB/IChatHistoryMongoDbService.cs @@ -0,0 +1,6 @@ +namespace Application.Services.Database.MongoDB; + +public interface IChatMongoDbService +{ + // Additional methods specific to Chat database +} \ No newline at end of file diff --git a/backend/Application/Services/Database/MongoDB/IMedicalHistoryMongoDbService.cs b/backend/Application/Services/Database/MongoDB/IMedicalHistoryMongoDbService.cs new file mode 100644 index 0000000..6920a99 --- /dev/null +++ b/backend/Application/Services/Database/MongoDB/IMedicalHistoryMongoDbService.cs @@ -0,0 +1,17 @@ +using Application.Endpoints.MedicalHistories; +using MongoDB.Driver; + +namespace Application.Services.Database.MongoDB; + +public interface IMedicalHistoryMongoDbService +{ + IMongoCollection GetCollection(); + + Task> FindAsync(List<(string FieldName, string Value)> criteria); + + Task AddAsync(MedicalHistoryAuthorisationModel document); + + Task ModifyAsync(string keyField, string keyValue, MedicalHistoryAuthorisationModel document); + + Task DeleteAsync(string keyField, string keyValue); +} \ No newline at end of file diff --git a/backend/Application/Services/Database/IConversation.cs b/backend/Application/Services/Database/PostgreSQL/IConversation.cs similarity index 100% rename from backend/Application/Services/Database/IConversation.cs rename to backend/Application/Services/Database/PostgreSQL/IConversation.cs diff --git a/backend/Application/Services/Database/IDoctors.cs b/backend/Application/Services/Database/PostgreSQL/IDoctors.cs similarity index 100% rename from backend/Application/Services/Database/IDoctors.cs rename to backend/Application/Services/Database/PostgreSQL/IDoctors.cs diff --git a/backend/Application/Services/Database/IMedicalHistory.cs b/backend/Application/Services/Database/PostgreSQL/IMedicalHistory.cs similarity index 100% rename from backend/Application/Services/Database/IMedicalHistory.cs rename to backend/Application/Services/Database/PostgreSQL/IMedicalHistory.cs diff --git a/backend/Application/Services/Database/IPatients.cs b/backend/Application/Services/Database/PostgreSQL/IPatients.cs similarity index 100% rename from backend/Application/Services/Database/IPatients.cs rename to backend/Application/Services/Database/PostgreSQL/IPatients.cs diff --git a/backend/Application/bin/Debug/net8.0/Application.dll b/backend/Application/bin/Debug/net8.0/Application.dll index dfab3d0..7a8b24f 100644 Binary files a/backend/Application/bin/Debug/net8.0/Application.dll and b/backend/Application/bin/Debug/net8.0/Application.dll differ diff --git a/backend/Application/bin/Debug/net8.0/Application.pdb b/backend/Application/bin/Debug/net8.0/Application.pdb index 44a5acb..9acaaf3 100644 Binary files a/backend/Application/bin/Debug/net8.0/Application.pdb and b/backend/Application/bin/Debug/net8.0/Application.pdb differ diff --git a/backend/Application/obj/Debug/net8.0/Application.AssemblyInfo.cs b/backend/Application/obj/Debug/net8.0/Application.AssemblyInfo.cs index 454a24f..9e74a7f 100644 --- a/backend/Application/obj/Debug/net8.0/Application.AssemblyInfo.cs +++ b/backend/Application/obj/Debug/net8.0/Application.AssemblyInfo.cs @@ -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+b48d5ee19e5228d9bcb979f2140f996fe7a12723")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+61a55fa7353346bdad2d677f0ec3c044c3aa87d5")] [assembly: System.Reflection.AssemblyProductAttribute("Application")] [assembly: System.Reflection.AssemblyTitleAttribute("Application")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/backend/Application/obj/Debug/net8.0/Application.AssemblyInfoInputs.cache b/backend/Application/obj/Debug/net8.0/Application.AssemblyInfoInputs.cache index b15c5dc..9944b37 100644 --- a/backend/Application/obj/Debug/net8.0/Application.AssemblyInfoInputs.cache +++ b/backend/Application/obj/Debug/net8.0/Application.AssemblyInfoInputs.cache @@ -1 +1 @@ -e01bb5cb416ac609d6eb58b4e5e6dea85ea3572d0845400409f93dd3761941e3 +ca8d9dbfc6e022b60b63524e70a3acb8ce1eaa86a2b066fce9c4864553b6125d diff --git a/backend/Application/obj/Debug/net8.0/Application.csproj.CoreCompileInputs.cache b/backend/Application/obj/Debug/net8.0/Application.csproj.CoreCompileInputs.cache index fba9cb9..2f0a718 100644 --- a/backend/Application/obj/Debug/net8.0/Application.csproj.CoreCompileInputs.cache +++ b/backend/Application/obj/Debug/net8.0/Application.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -747e745a68129206db481649de2eb8593ffa6704b63c0c2bd731c9a83a9d670a +e99f7362e6da84368608067cdbb0c281eef010bca303f59d33c712edf6a9964f diff --git a/backend/Application/obj/Debug/net8.0/Application.dll b/backend/Application/obj/Debug/net8.0/Application.dll index dfab3d0..7a8b24f 100644 Binary files a/backend/Application/obj/Debug/net8.0/Application.dll and b/backend/Application/obj/Debug/net8.0/Application.dll differ diff --git a/backend/Application/obj/Debug/net8.0/Application.pdb b/backend/Application/obj/Debug/net8.0/Application.pdb index 44a5acb..9acaaf3 100644 Binary files a/backend/Application/obj/Debug/net8.0/Application.pdb and b/backend/Application/obj/Debug/net8.0/Application.pdb differ diff --git a/backend/Application/obj/Debug/net8.0/Application.sourcelink.json b/backend/Application/obj/Debug/net8.0/Application.sourcelink.json index 78afa33..ecec2f0 100644 --- a/backend/Application/obj/Debug/net8.0/Application.sourcelink.json +++ b/backend/Application/obj/Debug/net8.0/Application.sourcelink.json @@ -1 +1 @@ -{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/b48d5ee19e5228d9bcb979f2140f996fe7a12723/*"}} \ No newline at end of file +{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/61a55fa7353346bdad2d677f0ec3c044c3aa87d5/*"}} \ No newline at end of file diff --git a/backend/Application/obj/Debug/net8.0/ref/Application.dll b/backend/Application/obj/Debug/net8.0/ref/Application.dll index 6ed7e90..af6d07f 100644 Binary files a/backend/Application/obj/Debug/net8.0/ref/Application.dll and b/backend/Application/obj/Debug/net8.0/ref/Application.dll differ diff --git a/backend/Application/obj/Debug/net8.0/refint/Application.dll b/backend/Application/obj/Debug/net8.0/refint/Application.dll index 6ed7e90..af6d07f 100644 Binary files a/backend/Application/obj/Debug/net8.0/refint/Application.dll and b/backend/Application/obj/Debug/net8.0/refint/Application.dll differ diff --git a/backend/Infrastructure/InfrastructureDI.cs b/backend/Infrastructure/InfrastructureDI.cs index 440940c..15b22b8 100644 --- a/backend/Infrastructure/InfrastructureDI.cs +++ b/backend/Infrastructure/InfrastructureDI.cs @@ -1,4 +1,5 @@ using Application.Services.Database; +using Application.Services.Database.MongoDB; using Application.Services.HashingAlgorithms; using Infrastructure.Data; using Infrastructure.Services.HashingAlgorithms; @@ -7,6 +8,7 @@ using Infrastructure.Services.PostgreSQL; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using MongoDB.Driver; namespace Infrastructure; @@ -24,8 +26,19 @@ public static class DependencyInjection services.AddScoped(); // MongoDB Service - var mongoDbConnection = configuration.GetConnectionString("MongoDBDatabase"); - services.AddSingleton(serviceProvider => new MongoDbService(mongoDbConnection)); + var mongoDbConnectionString = configuration.GetValue("ConnectionStrings:MongoDBConnection"); + + // Extract MongoDB database names + var healthcareManagerDatabaseName = configuration.GetValue("HealthcareManagerDatabase:Name"); + var medicalHistoryCollectionName = configuration.GetValue("HealthcareManagerDatabase:MedicalRecordCollectionName"); + var chatCollectionName = configuration.GetValue("HealthcareManagerDatabase:ChatCollectionName"); + + // Register MongoDB services + services.AddSingleton(serviceProvider => + new MedicalHistoryMongoDbService(mongoDbConnectionString, healthcareManagerDatabaseName, medicalHistoryCollectionName)); + + services.AddSingleton(serviceProvider => + new ChatMongoDbService(mongoDbConnectionString, healthcareManagerDatabaseName, chatCollectionName)); // Other Services @@ -34,4 +47,10 @@ public static class DependencyInjection return services; } + + private static string ExtractMongoDbDatabaseName(string connectionString) + { + var connectionStringBuilder = new MongoUrlBuilder(connectionString); + return connectionStringBuilder.DatabaseName; + } } \ No newline at end of file diff --git a/backend/Infrastructure/Services/MongoDB/ChatMongoDbService.cs b/backend/Infrastructure/Services/MongoDB/ChatMongoDbService.cs new file mode 100644 index 0000000..c9f9af9 --- /dev/null +++ b/backend/Infrastructure/Services/MongoDB/ChatMongoDbService.cs @@ -0,0 +1,13 @@ +using Application.Services.Database.MongoDB; + +namespace Infrastructure.Services.MongoDB; + +public class ChatMongoDbService : MongoDbService, IChatMongoDbService +{ + public ChatMongoDbService(string connectionString, string databaseName, string collectionName) + : base(connectionString, databaseName, collectionName) + { + } + + // Implement additional methods specific to Chat database if needed +} \ No newline at end of file diff --git a/backend/Infrastructure/Services/MongoDB/MedicalHistoryMongoDbService.cs b/backend/Infrastructure/Services/MongoDB/MedicalHistoryMongoDbService.cs new file mode 100644 index 0000000..7560990 --- /dev/null +++ b/backend/Infrastructure/Services/MongoDB/MedicalHistoryMongoDbService.cs @@ -0,0 +1,13 @@ +using Application.Services.Database.MongoDB; + +namespace Infrastructure.Services.MongoDB; + +public class MedicalHistoryMongoDbService : MongoDbService, IMedicalHistoryMongoDbService +{ + public MedicalHistoryMongoDbService(string connectionString, string databaseName, string collectionName) + : base(connectionString, databaseName, collectionName) + { + } + + // Implement additional methods specific to Medical History database if needed +} \ No newline at end of file diff --git a/backend/Infrastructure/Services/MongoDB/MongoDBServices.cs b/backend/Infrastructure/Services/MongoDB/MongoDBServices.cs index 6f89dfc..6af5e45 100644 --- a/backend/Infrastructure/Services/MongoDB/MongoDBServices.cs +++ b/backend/Infrastructure/Services/MongoDB/MongoDBServices.cs @@ -1,61 +1,74 @@ using Application.Services.Database; -using MongoDB.Bson; using MongoDB.Driver; +using MongoDB.Bson; -namespace Infrastructure.Services.MongoDB; - -public class MongoDbService : IMongoDbService +namespace Infrastructure.Services.MongoDB { - private readonly IMongoDatabase _database; - - public MongoDbService(string connectionString) + public class MongoDbService { - var settings = MongoClientSettings.FromConnectionString(connectionString); - settings.ServerApi = new ServerApi(ServerApiVersion.V1); - var _database = new MongoClient(settings); - - try { - var result = _database.GetDatabase("admin").RunCommand(new BsonDocument("ping", 1)); - Console.WriteLine("Pinged your deployment. You successfully connected to MongoDB!"); - } catch (Exception ex) { - Console.WriteLine(ex); + private readonly IMongoClient _database; + private readonly string _databaseName; + private readonly string _collectionName; + + public MongoDbService(string connectionString, string databaseName, string collectionName) + { + _databaseName = databaseName; + _collectionName = collectionName; + + Console.WriteLine($"Connection string: {connectionString}"); + Console.WriteLine($"Database Name: {databaseName}"); + Console.WriteLine($"Collection Name: {collectionName}"); + + var settings = MongoClientSettings.FromConnectionString(connectionString); + settings.ServerApi = new ServerApi(ServerApiVersion.V1); + _database = new MongoClient(settings); + + try + { + var result = _database.GetDatabase("admin").RunCommand(new BsonDocument("ping", 1)); + Console.WriteLine("Pinged your deployment. You successfully connected to MongoDB!"); + } + catch (Exception ex) + { + Console.WriteLine(ex); + } + } + + public IMongoCollection GetCollection() + { + return _database.GetDatabase(_databaseName).GetCollection(_collectionName); + } + + public async Task> FindAsync(List<(string FieldName, string Value)> criteria) + { + var collection = _database.GetDatabase(_databaseName).GetCollection(_collectionName); + + var filters = new List>(); + foreach (var (FieldName, Value) in criteria) filters.Add(Builders.Filter.Eq(FieldName, Value)); + + var combinedFilter = Builders.Filter.And(filters); + + return await collection.Find(combinedFilter).ToListAsync(); + } + + public async Task AddAsync(T document) + { + var collection = _database.GetDatabase(_databaseName).GetCollection(_collectionName); + await collection.InsertOneAsync(document); + } + + public async Task ModifyAsync(string keyField, string keyValue, T document) + { + var collection = _database.GetDatabase(_databaseName).GetCollection(_collectionName); + var filter = Builders.Filter.Eq(keyField, keyValue); + await collection.ReplaceOneAsync(filter, document, new ReplaceOptions { IsUpsert = true }); + } + + public async Task DeleteAsync(string keyField, string keyValue) + { + var collection = _database.GetDatabase(_databaseName).GetCollection(_collectionName); + var filter = Builders.Filter.Eq(keyField, keyValue); + await collection.DeleteOneAsync(filter); } } - - public IMongoCollection GetCollection(string collectionName) - { - return _database.GetCollection(collectionName); - } - - public async Task> FindAsync(string collectionName, List<(string FieldName, string Value)> criteria) - { - var collection = _database.GetCollection(collectionName); - - var filters = new List>(); - foreach (var (FieldName, Value) in criteria) filters.Add(Builders.Filter.Eq(FieldName, Value)); - - var combinedFilter = Builders.Filter.And(filters); - - return await collection.Find(combinedFilter).ToListAsync(); - } - - public async Task AddAsync(string collectionName, T document) - { - var collection = _database.GetCollection(collectionName); - await collection.InsertOneAsync(document); - } - - public async Task ModifyAsync(string collectionName, string keyField, string keyValue, T document) - { - var collection = _database.GetCollection(collectionName); - var filter = Builders.Filter.Eq(keyField, keyValue); - await collection.ReplaceOneAsync(filter, document, new ReplaceOptions { IsUpsert = true }); - } - - public async Task DeleteAsync(string collectionName, string keyField, string keyValue) - { - var collection = _database.GetCollection(collectionName); - var filter = Builders.Filter.Eq(keyField, keyValue); - await collection.DeleteOneAsync(filter); - } -} \ No newline at end of file +} diff --git a/backend/Infrastructure/bin/Debug/net8.0/Application.dll b/backend/Infrastructure/bin/Debug/net8.0/Application.dll index dfab3d0..7a8b24f 100644 Binary files a/backend/Infrastructure/bin/Debug/net8.0/Application.dll and b/backend/Infrastructure/bin/Debug/net8.0/Application.dll differ diff --git a/backend/Infrastructure/bin/Debug/net8.0/Application.pdb b/backend/Infrastructure/bin/Debug/net8.0/Application.pdb index 44a5acb..9acaaf3 100644 Binary files a/backend/Infrastructure/bin/Debug/net8.0/Application.pdb and b/backend/Infrastructure/bin/Debug/net8.0/Application.pdb differ diff --git a/backend/Infrastructure/bin/Debug/net8.0/Infrastructure.dll b/backend/Infrastructure/bin/Debug/net8.0/Infrastructure.dll index 852a191..3c7b6d1 100644 Binary files a/backend/Infrastructure/bin/Debug/net8.0/Infrastructure.dll and b/backend/Infrastructure/bin/Debug/net8.0/Infrastructure.dll differ diff --git a/backend/Infrastructure/bin/Debug/net8.0/Infrastructure.pdb b/backend/Infrastructure/bin/Debug/net8.0/Infrastructure.pdb index fba4fca..7fe98f5 100644 Binary files a/backend/Infrastructure/bin/Debug/net8.0/Infrastructure.pdb and b/backend/Infrastructure/bin/Debug/net8.0/Infrastructure.pdb differ diff --git a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.AssemblyInfo.cs b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.AssemblyInfo.cs index def11b8..8997d0f 100644 --- a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.AssemblyInfo.cs +++ b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.AssemblyInfo.cs @@ -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+b48d5ee19e5228d9bcb979f2140f996fe7a12723")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+61a55fa7353346bdad2d677f0ec3c044c3aa87d5")] [assembly: System.Reflection.AssemblyProductAttribute("Infrastructure")] [assembly: System.Reflection.AssemblyTitleAttribute("Infrastructure")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.AssemblyInfoInputs.cache b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.AssemblyInfoInputs.cache index 1d89c38..ab571e5 100644 --- a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.AssemblyInfoInputs.cache +++ b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.AssemblyInfoInputs.cache @@ -1 +1 @@ -1eff5085180ba5a7e0c455493bf156ab7c10e42899382b41bdf7799d2b2ca6d6 +08604fac7a3083586b55565c1ab1f39ea8637dd70dd31c4daa6a7693d2108c04 diff --git a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.csproj.AssemblyReference.cache b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.csproj.AssemblyReference.cache index 972d114..016f292 100644 Binary files a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.csproj.AssemblyReference.cache and b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.csproj.AssemblyReference.cache differ diff --git a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.csproj.CoreCompileInputs.cache b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.csproj.CoreCompileInputs.cache index 3d9c060..b8d6b84 100644 --- a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.csproj.CoreCompileInputs.cache +++ b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -8ecca766b80ccc6e510e107ea1369b5001c45e66e3507ff5e47c4d13fae048e4 +39d9df72cda14e46450bf8a8087069ed85d06562c962bd2ab07df607c60c7cf4 diff --git a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.dll b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.dll index 852a191..3c7b6d1 100644 Binary files a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.dll and b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.dll differ diff --git a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.pdb b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.pdb index fba4fca..7fe98f5 100644 Binary files a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.pdb and b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.pdb differ diff --git a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.sourcelink.json b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.sourcelink.json index 78afa33..ecec2f0 100644 --- a/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.sourcelink.json +++ b/backend/Infrastructure/obj/Debug/net8.0/Infrastructure.sourcelink.json @@ -1 +1 @@ -{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/b48d5ee19e5228d9bcb979f2140f996fe7a12723/*"}} \ No newline at end of file +{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/61a55fa7353346bdad2d677f0ec3c044c3aa87d5/*"}} \ No newline at end of file diff --git a/backend/Infrastructure/obj/Debug/net8.0/ref/Infrastructure.dll b/backend/Infrastructure/obj/Debug/net8.0/ref/Infrastructure.dll index 47925d7..6ccecea 100644 Binary files a/backend/Infrastructure/obj/Debug/net8.0/ref/Infrastructure.dll and b/backend/Infrastructure/obj/Debug/net8.0/ref/Infrastructure.dll differ diff --git a/backend/Infrastructure/obj/Debug/net8.0/refint/Infrastructure.dll b/backend/Infrastructure/obj/Debug/net8.0/refint/Infrastructure.dll index 47925d7..6ccecea 100644 Binary files a/backend/Infrastructure/obj/Debug/net8.0/refint/Infrastructure.dll and b/backend/Infrastructure/obj/Debug/net8.0/refint/Infrastructure.dll differ