=== Summary: 675 files | 7 generated | 484 fresh | 4605 untracked | 4268 adopted | 355 marked | 466 validated-ok | 2+0 stale (sig+body) | 0 skipped | 0 failed | elapsed 11:08:11.442 (40091.44s) ===
This commit is contained in:
@@ -22,6 +22,7 @@ namespace adas_core.Application.Services;
|
||||
/// This service acts as the default in-memory or infrastructure-backed implementation
|
||||
/// of the discharge operations defined by <see cref="IDischargeService"/>.
|
||||
/// </remarks>
|
||||
/// <!-- aidoc:v1 sig=61bd286 -->
|
||||
public class DischargeService : IDischargeService
|
||||
{
|
||||
private readonly ILocalAuditService _auditService;
|
||||
@@ -80,6 +81,10 @@ public class DischargeService : IDischargeService
|
||||
/// discharge status), and otherwise falls back to deleting the discharge by its identifier.
|
||||
/// </summary>
|
||||
/// <param name="discharge">The discharge entity to be deleted.</param>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=mentions_removed_behavior
|
||||
/// "The summary describes validation of MedicalDischarge, AdminDischarge, and discharge status, but the entire validation block is commented out; the method only calls DeleteDischargeByIdAsync." -->
|
||||
/// <!-- aidoc-review:v1 severity=high kind=stale_summary
|
||||
/// "The documented behavior of validating and 'falling back' to deletion by id does not match the actual code, which unconditionally deletes by id." -->
|
||||
public async Task DeleteDischargeAsync(Discharge discharge)
|
||||
{
|
||||
//var patient = await _patientServiceLazy.Value.FindById(discharge.PatientId);
|
||||
@@ -97,6 +102,7 @@ public class DischargeService : IDischargeService
|
||||
/// Deletes a discharge record by its identifier. If the discharge is not found, an error is logged and the operation is skipped; otherwise the record is removed, an audit log entry is created, and a delete broadcast is sent.
|
||||
/// </summary>
|
||||
/// <param name="dischargeId">The unique identifier of the discharge to delete.</param>
|
||||
/// <!-- aidoc:v1 sig=0e0285f body=b646cb5 -->
|
||||
public async Task DeleteDischargeByIdAsync(ObjectId dischargeId)
|
||||
{
|
||||
try
|
||||
@@ -132,6 +138,7 @@ public class DischargeService : IDischargeService
|
||||
/// </summary>
|
||||
/// <param name="unitId">The identifier of the unit whose discharge records will be counted.</param>
|
||||
/// <returns>A task representing the asynchronous operation, containing the total number of discharges for the given unit.</returns>
|
||||
/// <!-- aidoc:v1 sig=da93389 body=a6241d6 -->
|
||||
public async Task<long> CountDischargesByUnitId(ObjectId unitId)
|
||||
{
|
||||
return await _dischargeRepository.CountByUnitId(unitId);
|
||||
@@ -146,6 +153,7 @@ public class DischargeService : IDischargeService
|
||||
/// information if a point of care is linked; otherwise the discharge as stored.</returns>
|
||||
/// <exception cref="NotFoundException">Thrown when no discharge is found for the specified
|
||||
/// <paramref name="dischargeId"/>.</exception>
|
||||
/// <!-- aidoc:v1 sig=12c2e8b body=3015bf8 -->
|
||||
public async Task<Discharge?> GetDischargeByIdAsync(ObjectId dischargeId)
|
||||
{
|
||||
var result = await _dischargeRepository.FindById(dischargeId) ??
|
||||
@@ -163,6 +171,7 @@ public class DischargeService : IDischargeService
|
||||
/// Asynchronously retrieves all discharge records from the repository.
|
||||
/// </summary>
|
||||
/// <returns>A task that represents the asynchronous operation, containing an enumerable collection of <see cref="Discharge"/> records.</returns>
|
||||
/// <!-- aidoc:v1 sig=f526f77 body=05958d1 -->
|
||||
public async Task<IEnumerable<Discharge>> GetDischargesAsync()
|
||||
{
|
||||
return await _dischargeRepository.FindAll();
|
||||
@@ -173,6 +182,7 @@ public class DischargeService : IDischargeService
|
||||
/// </summary>
|
||||
/// <param name="patientId">The unique identifier of the patient whose discharge record should be retrieved.</param>
|
||||
/// <returns>A <see cref="Discharge"/> object populated with patient location information when a point of care is associated, or <c>null</c> if no discharge is found or an error occurs.</returns>
|
||||
/// <!-- aidoc:v1 sig=9c55b11 body=305bfa7 -->
|
||||
public async Task<Discharge?> GetDischargeByPatientId(ObjectId patientId)
|
||||
{
|
||||
try
|
||||
@@ -202,6 +212,7 @@ public class DischargeService : IDischargeService
|
||||
/// <param name="discharge">The discharge entity to be inserted.</param>
|
||||
/// <returns>The persisted <see cref="Discharge"/> entity retrieved from the repository after insertion.</returns>
|
||||
/// <exception cref="ConflictException">Thrown when the inserted discharge cannot be found by its identifier, indicating that the creation failed.</exception>
|
||||
/// <!-- aidoc:v1 sig=5b13f28 body=682f5de -->
|
||||
public async Task<Discharge?> InsertDischarge(Discharge discharge)
|
||||
{
|
||||
await _dischargeRepository.InsertOneAsync(discharge);
|
||||
@@ -220,6 +231,7 @@ public class DischargeService : IDischargeService
|
||||
/// </summary>
|
||||
/// <param name="location">The patient location used to look up the associated discharge record.</param>
|
||||
/// <returns>A <see cref="Discharge"/> if one is found for the given location; otherwise, <c>null</c> when an error occurs.</returns>
|
||||
/// <!-- aidoc:v1 sig=d6f8db9 body=ac06f0e -->
|
||||
public async Task<Discharge?> GetDischargeByLocation(PatientLocation location)
|
||||
{
|
||||
try
|
||||
@@ -240,6 +252,7 @@ public class DischargeService : IDischargeService
|
||||
/// </summary>
|
||||
/// <param name="poc">The point of care identifier used to look up the discharge record.</param>
|
||||
/// <returns>A <see cref="Discharge"/> with the patient location populated when available, or <c>null</c> if the discharge is not found or an error occurs.</returns>
|
||||
/// <!-- aidoc:v1 sig=add61b9 body=16738ca -->
|
||||
public async Task<Discharge?> GetDischargeByPointOfCareId(ObjectId poc)
|
||||
{
|
||||
try
|
||||
@@ -269,6 +282,7 @@ public class DischargeService : IDischargeService
|
||||
/// <param name="location">The ObjectId identifying the point of care (location) whose discharge record should be retrieved.</param>
|
||||
/// <param name="dataLocale">The locale used to localize the discharge data when the associated unit is found.</param>
|
||||
/// <returns>A <see cref="Task{Discharge}"/> containing the localized discharge, the unmodified discharge when its unit cannot be found, or <c>null</c> when no discharge exists for the specified location.</returns>
|
||||
/// <!-- aidoc:v1 sig=4f9546e body=52d6c63 -->
|
||||
public async Task<Discharge?> GetDischargeByPointOfCareIdWithLocale(ObjectId location, LocaleEnum dataLocale)
|
||||
{
|
||||
var discharge = await GetDischargeByPointOfCareId(location);
|
||||
@@ -284,6 +298,7 @@ public class DischargeService : IDischargeService
|
||||
/// </summary>
|
||||
/// <param name="discharge">The discharge entity to be updated.</param>
|
||||
/// <exception cref="ConflictException">Thrown when no discharge is found with the specified identifier, preventing the update from proceeding.</exception>
|
||||
/// <!-- aidoc:v1 sig=93dfb9f body=eba9c68 -->
|
||||
public async Task UpdateDischargeAsync(Discharge discharge)
|
||||
{
|
||||
var oldDischarge = await GetDischargeByIdAsync(discharge.Id) ??
|
||||
@@ -300,6 +315,10 @@ public class DischargeService : IDischargeService
|
||||
/// </summary>
|
||||
/// <param name="apiRequest">The API request containing the discharge payload and the operation type to perform.</param>
|
||||
/// <!-- aidoc:v1 sig=229d8cd body=acbd395 -->
|
||||
/// <!-- aidoc-review:v1 severity=medium kind=stale_summary
|
||||
/// "The summary does not mention that the patient is always updated via _patientServiceLazy.Value.Update(apiRequest.Discharge.Patient) before the switch on apiRequest.Type is evaluated." -->
|
||||
/// <!-- aidoc-review:v1 severity=medium kind=wrong_summary
|
||||
/// "The summary states the method 'logs an error when the discharge or patient is null', but when apiRequest.Discharge?.Patient is null the method simply returns silently without logging anything." -->
|
||||
public async Task SaveRequest(ApiRequest apiRequest)
|
||||
{
|
||||
try
|
||||
@@ -367,6 +386,7 @@ public class DischargeService : IDischargeService
|
||||
/// </summary>
|
||||
/// <param name="apiRequest">The API request to save.</param>
|
||||
/// <returns>A task that completes when the request has been saved.</returns>
|
||||
/// <!-- aidoc:v1 sig=a3706aa body=c8d77ba -->
|
||||
public Task SaveRequestAsync(ApiRequest apiRequest)
|
||||
{
|
||||
return Task.FromResult(Task.Run(async () => { await SaveRequest(apiRequest); }));
|
||||
@@ -378,6 +398,7 @@ public class DischargeService : IDischargeService
|
||||
/// </summary>
|
||||
/// <param name="discharge">The discharge whose point of care is used to locate matching subscribers and whose data is sent in the broadcast.</param>
|
||||
/// <param name="operation">The operation type associated with the outgoing message sent to each subscriber.</param>
|
||||
/// <!-- aidoc:v1 sig=f5450d6 body=93e2063 -->
|
||||
public async void SendDischargeBroadcast(Discharge discharge, OperationType operation)
|
||||
{
|
||||
try
|
||||
@@ -419,6 +440,7 @@ public class DischargeService : IDischargeService
|
||||
/// <param name="opt">The master list update options to apply to the discharges.</param>
|
||||
/// <param name="unitList">The collection of units whose associated discharges will be updated.</param>
|
||||
/// <param name="typeName">The name of the master list type used to target the update.</param>
|
||||
/// <!-- aidoc:v1 sig=b539b7b body=09153b7 -->
|
||||
public async Task UpdatePatientMasterListItemChange(UpdateOptionMasterListDto opt, IEnumerable<Unit> unitList,
|
||||
string typeName)
|
||||
{
|
||||
@@ -440,6 +462,8 @@ public class DischargeService : IDischargeService
|
||||
/// <param name="opt">The option list entry to be removed from the patient master list.</param>
|
||||
/// <param name="unitList">The collection of units whose identifiers are used to scope the deletion.</param>
|
||||
/// <param name="typeName">The name of the master list type/category to which the option belongs.</param>
|
||||
/// <!-- aidoc-review:v1 severity=low kind=wrong_summary
|
||||
/// "Summary's parenthetical '(only when the updated discharge record is found)' reads as applying to both the audit log creation and the broadcasting, but in the code the audit log is always created for every discharge while only the broadcast is gated by the dischargeUpdated != null check." -->
|
||||
public async Task DeletePatientMasterListItem(OptionList opt, IEnumerable<Unit> unitList, string typeName)
|
||||
{
|
||||
var unitIds = unitList.Select(x => x.Id).ToList();
|
||||
@@ -457,6 +481,7 @@ public class DischargeService : IDischargeService
|
||||
/// Asynchronously deletes all discharge records associated with the specified unit identifier by delegating the operation to the discharge repository.
|
||||
/// </summary>
|
||||
/// <param name="unitId">The unique identifier of the unit whose discharge records should be removed.</param>
|
||||
/// <!-- aidoc:v1 sig=0d2c782 body=6f86d40 -->
|
||||
public async Task DeleteDischargesByUnitId(ObjectId unitId)
|
||||
{
|
||||
await _dischargeRepository.DeleteByUnitId(unitId);
|
||||
@@ -471,6 +496,7 @@ public class DischargeService : IDischargeService
|
||||
/// <param name="discharge">Discharge instance whose option names may be translated in place.</param>
|
||||
/// <param name="locale">Target locale used to load the appropriate master list; when set to <see cref="LocaleEnum.Default"/>, the discharge is returned without changes.</param>
|
||||
/// <returns>The same <paramref name="discharge"/> instance, with translated option names when a matching locale-specific entry is found.</returns>
|
||||
/// <!-- aidoc:v1 sig=f16a2d5 body=4eee788 -->
|
||||
private async Task<Discharge> GetDischargeWithLocale(Unit? unit, Discharge discharge, LocaleEnum locale)
|
||||
{
|
||||
if (unit == null)
|
||||
|
||||
Reference in New Issue
Block a user