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 ResolveAccountAsync(string accountId, CancellationToken ct); Task GetAsync(AuthorizedPatientContext scope, CancellationToken ct); } public interface ProfileCommands { Task CreateAsync(string trustedAccountId, CreatePatientRequest request, CancellationToken ct); Task UpdateAsync(AuthorizedPatientContext scope, UpdatePatientRequest request, CancellationToken ct); } public sealed class ProfileAlreadyExistsException : Exception;