67 lines
1.7 KiB
C#
67 lines
1.7 KiB
C#
using adas_core.Application.Repositories.Interfaces;
|
|
using adas_core.Domain.Models.AppSettings;
|
|
using adas_core.Domain.Models.MongoModels;
|
|
using Microsoft.Extensions.Options;
|
|
using MongoDB.Bson;
|
|
using MongoDB.Driver;
|
|
|
|
namespace adas_core.Infrastructure.Repositories;
|
|
|
|
public class PatientCarePlanRepository : MongoRepository<PatientCarePlan>, IPatientCarePlanRepository
|
|
{
|
|
#region Properties
|
|
|
|
private readonly ApiSettings _apiSettings;
|
|
|
|
#endregion
|
|
|
|
#region Update
|
|
|
|
public async Task UpdateManyObjectId(string patientid, ObjectId patientId, ObjectId oldId)
|
|
{
|
|
await UpdateManyObjectIdAsync(patientid, patientId, oldId);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
|
|
|
|
public PatientCarePlanRepository(
|
|
IOptions<ApiSettings> apiSettings,
|
|
IMongoDatabase database
|
|
) : base(database)
|
|
{
|
|
_apiSettings = apiSettings.Value;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Read
|
|
|
|
public override string GetCollectionName()
|
|
{
|
|
return _apiSettings.PatientCarePlan ?? "patients_care_plan";
|
|
}
|
|
|
|
public async Task<List<PatientCarePlan>> FindByPatientId(ObjectId patientId)
|
|
{
|
|
var result = await Collection.FindAsync(Builders<PatientCarePlan>.Filter.Eq(p => p.PatientId, patientId));
|
|
return result.ToList();
|
|
}
|
|
|
|
public async Task<List<PatientCarePlan>> FindByUserId(ObjectId userId)
|
|
{
|
|
var result = await Collection.FindAsync(Builders<PatientCarePlan>.Filter.Eq(p => p.UserId, userId));
|
|
return result.ToList();
|
|
}
|
|
|
|
public async Task<List<PatientCarePlan>> FindAll()
|
|
{
|
|
var result = await Collection.Find(Builders<PatientCarePlan>.Filter.Empty).ToListAsync();
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
} |