Table of Contents

Class ProfileService

Namespace
Core.CliniCore.Service
Assembly
Core.CliniCore.dll

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

patientRepo IPatientRepository
physicianRepo IPhysicianRepository
adminRepo IAdministratorRepository
credentialRepo ICredentialRepository
appointmentRepo IAppointmentRepository
clinicalDocRepo IClinicalDocumentRepository

Properties

Count

Gets the total count of all profiles

public int Count { get; }

Property Value

int

Methods

AddProfile(IUserProfile)

Adds a profile to the appropriate repository based on its type

public bool AddProfile(IUserProfile profile)

Parameters

profile IUserProfile

Returns

bool

AssignPatientToPhysician(Guid, Guid, bool)

Establishes a physician-patient relationship

public bool AssignPatientToPhysician(Guid patientId, Guid physicianId, bool setPrimary = false)

Parameters

patientId Guid
physicianId Guid
setPrimary bool

Returns

bool

GetAllAdministrators()

Gets all administrator profiles

public IEnumerable<AdministratorProfile> GetAllAdministrators()

Returns

IEnumerable<AdministratorProfile>

GetAllPatients()

Gets all patient profiles

public IEnumerable<PatientProfile> GetAllPatients()

Returns

IEnumerable<PatientProfile>

GetAllPhysicians()

Gets all physician profiles

public IEnumerable<PhysicianProfile> GetAllPhysicians()

Returns

IEnumerable<PhysicianProfile>

GetAllProfiles()

Gets all profiles in the system

public IEnumerable<IUserProfile> GetAllProfiles()

Returns

IEnumerable<IUserProfile>

GetPatientPhysicians(Guid)

Gets all physicians for a patient (those who have this patient in their list)

public IEnumerable<PhysicianProfile> GetPatientPhysicians(Guid patientId)

Parameters

patientId Guid

Returns

IEnumerable<PhysicianProfile>

GetPhysicianPatients(Guid)

Gets all patients for a physician

public IEnumerable<PatientProfile> GetPhysicianPatients(Guid physicianId)

Parameters

physicianId Guid

Returns

IEnumerable<PatientProfile>

GetProfileById(Guid)

Gets a profile by ID, checking all profile types

public IUserProfile? GetProfileById(Guid profileId)

Parameters

profileId Guid

Returns

IUserProfile

GetProfileByUsername(string)

Gets a profile by username, checking all profile types

public IUserProfile? GetProfileByUsername(string username)

Parameters

username string

Returns

IUserProfile

GetProfilesByRole(UserRole)

Gets all profiles with a specific role

public IEnumerable<IUserProfile> GetProfilesByRole(UserRole role)

Parameters

role UserRole

Returns

IEnumerable<IUserProfile>

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

ProfileServiceStatistics

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

profileId Guid

Returns

string

SearchByName(string)

Searches for profiles by name across all profile types

public IEnumerable<IUserProfile> SearchByName(string searchTerm)

Parameters

searchTerm string

Returns

IEnumerable<IUserProfile>

UpdateProfile(IUserProfile)

Updates a profile in the appropriate repository based on its type

public bool UpdateProfile(IUserProfile profile)

Parameters

profile IUserProfile

Returns

bool

UsernameExists(string)

Checks if a username exists across all profile types

public bool UsernameExists(string username)

Parameters

username string

Returns

bool