This commit is contained in:
andrei-mihnea-cerbu
2024-04-08 02:31:05 +03:00
parent 61a55fa735
commit b4eca98e0a
57 changed files with 185 additions and 105 deletions
@@ -46,7 +46,7 @@ public class DoctorProfileHandler
return new BaseResponse
{
StatusCode = HttpStatusCodes.NotFound,
StatusCode = HttpStatusCodes.NoContent,
Message = "Doctors not found",
Data = null
};
@@ -2,6 +2,6 @@
public class MedicalHistoryAuthorisationModel
{
public Guid Id { get; set; }
public List<Guid> Authorisation { get; set; } = new List<Guid>();
public string Id { get; set; }
public List<string> Authorisation { get; set; } = new List<string>();
}
@@ -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<BaseResponse> 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<Guid>()
Id = medicalHistoryId.ToString(),
Authorisation = new List<string>()
};
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<MedicalHistoryAuthorisationModel>("_id", id.ToString());
await _medicalHistoryRepository.DeleteAsync(medicalRecord);
//TODO delete from MongoDB
@@ -46,7 +46,7 @@ public class PatientProfileHandler
return new BaseResponse
{
StatusCode = HttpStatusCodes.NotFound,
StatusCode = HttpStatusCodes.NoContent,
Message = "Patients not found",
Data = null
};
@@ -1,12 +0,0 @@
using MongoDB.Driver;
namespace Application.Services.Database;
public interface IMongoDbService
{
IMongoCollection<T> GetCollection<T>(string collectionName);
Task<List<T>> FindAsync<T>(string collectionName, List<(string FieldName, string Value)> criteria);
Task AddAsync<T>(string collectionName, T document);
Task ModifyAsync<T>(string collectionName, string keyField, string keyValue, T document);
Task DeleteAsync<T>(string collectionName, string keyField, string keyValue);
}
@@ -0,0 +1,6 @@
namespace Application.Services.Database.MongoDB;
public interface IChatMongoDbService
{
// Additional methods specific to Chat database
}
@@ -0,0 +1,17 @@
using Application.Endpoints.MedicalHistories;
using MongoDB.Driver;
namespace Application.Services.Database.MongoDB;
public interface IMedicalHistoryMongoDbService
{
IMongoCollection<MedicalHistoryAuthorisationModel> GetCollection<MedicalHistoryAuthorisationModel>();
Task<List<MedicalHistoryAuthorisationModel>> FindAsync<MedicalHistoryAuthorisationModel>(List<(string FieldName, string Value)> criteria);
Task AddAsync<MedicalHistoryAuthorisationModel>(MedicalHistoryAuthorisationModel document);
Task ModifyAsync<MedicalHistoryAuthorisationModel>(string keyField, string keyValue, MedicalHistoryAuthorisationModel document);
Task DeleteAsync<MedicalHistoryAuthorisationModel>(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+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")]
@@ -1 +1 @@
e01bb5cb416ac609d6eb58b4e5e6dea85ea3572d0845400409f93dd3761941e3
ca8d9dbfc6e022b60b63524e70a3acb8ce1eaa86a2b066fce9c4864553b6125d
@@ -1 +1 @@
747e745a68129206db481649de2eb8593ffa6704b63c0c2bd731c9a83a9d670a
e99f7362e6da84368608067cdbb0c281eef010bca303f59d33c712edf6a9964f
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/b48d5ee19e5228d9bcb979f2140f996fe7a12723/*"}}
{"documents":{"C:\\Users\\Andrei Cerbu\\Documents\\FACULTATE\\CC-FinalProj\\*":"https://raw.githubusercontent.com/andrei-mihnea-cerbu/CC-FinalProj/61a55fa7353346bdad2d677f0ec3c044c3aa87d5/*"}}