Class ProfileService
Service for managing user profiles across all profile types. Provides cross-cutting operations that span multiple repositories.
Design Notes:
- This is a facade over the individual profile repositories
- Use specific repositories (IPatientRepository, etc.) for type-specific operations
- Use ProfileService for operations that need to work across profile types
public class ProfileService
- Inheritance
-
ProfileService
- Inherited Members
Constructors
ProfileService(IPatientRepository, IPhysicianRepository, IAdministratorRepository, ICredentialRepository?, IAppointmentRepository?, IClinicalDocumentRepository?)
Service for managing user profiles across all profile types. Provides cross-cutting operations that span multiple repositories.
Design Notes:
- This is a facade over the individual profile repositories
- Use specific repositories (IPatientRepository, etc.) for type-specific operations
- Use ProfileService for operations that need to work across profile types
public ProfileService(IPatientRepository patientRepo, IPhysicianRepository physicianRepo, IAdministratorRepository adminRepo, ICredentialRepository? credentialRepo = null, IAppointmentRepository? appointmentRepo = null, IClinicalDocumentRepository? clinicalDocRepo = null)
Parameters
patientRepoIPatientRepositoryphysicianRepoIPhysicianRepositoryadminRepoIAdministratorRepositorycredentialRepoICredentialRepositoryappointmentRepoIAppointmentRepositoryclinicalDocRepoIClinicalDocumentRepository
Properties
Count
Gets the total count of all profiles
public int Count { get; }
Property Value
Methods
AddProfile(IUserProfile)
Adds a profile to the appropriate repository based on its type
public bool AddProfile(IUserProfile profile)
Parameters
profileIUserProfile
Returns
AssignPatientToPhysician(Guid, Guid, bool)
Establishes a physician-patient relationship
public bool AssignPatientToPhysician(Guid patientId, Guid physicianId, bool setPrimary = false)
Parameters
Returns
GetAllAdministrators()
Gets all administrator profiles
public IEnumerable<AdministratorProfile> GetAllAdministrators()
Returns
GetAllPatients()
Gets all patient profiles
public IEnumerable<PatientProfile> GetAllPatients()
Returns
GetAllPhysicians()
Gets all physician profiles
public IEnumerable<PhysicianProfile> GetAllPhysicians()
Returns
GetAllProfiles()
Gets all profiles in the system
public IEnumerable<IUserProfile> GetAllProfiles()
Returns
GetPatientPhysicians(Guid)
Gets all physicians for a patient (those who have this patient in their list)
public IEnumerable<PhysicianProfile> GetPatientPhysicians(Guid patientId)
Parameters
patientIdGuid
Returns
GetPhysicianPatients(Guid)
Gets all patients for a physician
public IEnumerable<PatientProfile> GetPhysicianPatients(Guid physicianId)
Parameters
physicianIdGuid
Returns
GetProfileById(Guid)
Gets a profile by ID, checking all profile types
public IUserProfile? GetProfileById(Guid profileId)
Parameters
profileIdGuid
Returns
GetProfileByUsername(string)
Gets a profile by username, checking all profile types
public IUserProfile? GetProfileByUsername(string username)
Parameters
usernamestring
Returns
GetProfilesByRole(UserRole)
Gets all profiles with a specific role
public IEnumerable<IUserProfile> GetProfilesByRole(UserRole role)
Parameters
roleUserRole
Returns
GetProfilesByType<T>()
Gets all profiles of a specific type
public IEnumerable<T> GetProfilesByType<T>() where T : class, IUserProfile
Returns
- IEnumerable<T>
Type Parameters
T
GetStatistics()
Gets statistics about profile counts
public ProfileServiceStatistics GetStatistics()
Returns
RemoveProfile(Guid)
Removes a profile from the appropriate repository. Returns null on success, or an error message explaining why deletion failed. Also removes associated credentials when successful.
public string? RemoveProfile(Guid profileId)
Parameters
profileIdGuid
Returns
SearchByName(string)
Searches for profiles by name across all profile types
public IEnumerable<IUserProfile> SearchByName(string searchTerm)
Parameters
searchTermstring
Returns
UpdateProfile(IUserProfile)
Updates a profile in the appropriate repository based on its type
public bool UpdateProfile(IUserProfile profile)
Parameters
profileIUserProfile
Returns
UsernameExists(string)
Checks if a username exists across all profile types
public bool UsernameExists(string username)
Parameters
usernamestring