23 lines
1.1 KiB
C#
23 lines
1.1 KiB
C#
using System.Runtime.CompilerServices;
|
|
[assembly: InternalsVisibleTo("HealthApp")]
|
|
namespace HealthApp.Contracts;
|
|
// Only the API/access assembly issues this request-local capability after policy checks.
|
|
public sealed class AuthorizedPatientContext
|
|
{
|
|
internal AuthorizedPatientContext(Guid patientId, bool canWrite) { PatientId = patientId; CanWrite = canWrite; }
|
|
public Guid PatientId { get; }
|
|
public bool CanWrite { get; }
|
|
public void RequireWrite() { if (!CanWrite) throw new UnauthorizedAccessException("Read-only scope."); }
|
|
}
|
|
public interface ProfileQueries
|
|
{
|
|
Task<Guid?> ResolveAccountAsync(string accountId, CancellationToken ct);
|
|
Task<PatientDto?> GetAsync(AuthorizedPatientContext scope, CancellationToken ct);
|
|
}
|
|
public interface ProfileCommands
|
|
{
|
|
Task<PatientDto> CreateAsync(string trustedAccountId, CreatePatientRequest request, CancellationToken ct);
|
|
Task<PatientDto?> UpdateAsync(AuthorizedPatientContext scope, UpdatePatientRequest request, CancellationToken ct);
|
|
}
|
|
public sealed class ProfileAlreadyExistsException : Exception;
|