=== 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:
@@ -19,6 +19,7 @@ namespace adas_core.Application.Services;
|
||||
/// Provides the implementation of the <see cref="IDiagnosisService"/> contract,
|
||||
/// offering diagnosis-related operations as defined by the interface.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=c73da26 -->
|
||||
public class DiagnosisService : IDiagnosisService
|
||||
{
|
||||
private readonly ILocalAuditService _auditService;
|
||||
@@ -104,6 +105,7 @@ public class DiagnosisService : IDiagnosisService
|
||||
/// Archives the specified patient by delegating to the archival routine keyed by the patient's identifier.
|
||||
/// </summary>
|
||||
/// <param name="patient">The patient to be archived. Its <c>Id</c> is used to locate the record to archive.</param>
|
||||
/// <!-- aidoc:v1 sig=0afe718 body=be01ba0 -->
|
||||
public async Task Archive(Patient patient)
|
||||
{
|
||||
await ArchiveByPatientId(patient.Id);
|
||||
@@ -113,6 +115,7 @@ public class DiagnosisService : IDiagnosisService
|
||||
/// Archives all diagnoses associated with the specified patient by copying them to the diagnosis archive repository and then deleting the original records.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier of the patient whose diagnoses will be archived.</param>
|
||||
/// <!-- aidoc:v1 sig=3385472 body=3d03acb -->
|
||||
public async Task ArchiveByPatientId(ObjectId id)
|
||||
{
|
||||
_logger.LogDebug("Archive Diagnoses by Patient Id {id}", id);
|
||||
@@ -130,6 +133,7 @@ public class DiagnosisService : IDiagnosisService
|
||||
/// Deletes all diagnoses associated with the specified patient identifier and records an audit log entry capturing the previous state of the records.
|
||||
/// </summary>
|
||||
/// <param name="id">The unique identifier of the patient whose diagnoses should be deleted.</param>
|
||||
/// <!-- aidoc:v1 sig=09e4e41 body=d64c5ea -->
|
||||
public async Task DeleteByPatientId(ObjectId id)
|
||||
{
|
||||
_logger.LogDebug("Delete Diagnoses by Patient Id {id}", id);
|
||||
@@ -143,6 +147,7 @@ public class DiagnosisService : IDiagnosisService
|
||||
/// </summary>
|
||||
/// <param name="patientId">The unique identifier of the patient whose diagnoses are being retrieved.</param>
|
||||
/// <returns>A task that represents the asynchronous operation, containing a list of <see cref="PatientDiagnosis"/> records for the given patient.</returns>
|
||||
/// <!-- aidoc:v1 sig=4ed162d body=4bb31fe -->
|
||||
public async Task<List<PatientDiagnosis>> GetByPatientId(ObjectId patientId)
|
||||
{
|
||||
var diagnosis = await _diagnosisRepository.GetByPatient(patientId);
|
||||
@@ -156,6 +161,7 @@ public class DiagnosisService : IDiagnosisService
|
||||
/// </summary>
|
||||
/// <param name="apiRequest">The API request to save.</param>
|
||||
/// <returns>A task that represents the asynchronous save operation.</returns>
|
||||
/// <!-- aidoc:v1 sig=3385bba body=5d13d47 -->
|
||||
public Task SaveRequest(ApiRequest apiRequest)
|
||||
{
|
||||
return Task.FromResult(Task.Run(async () => { await SaveRequest(apiRequest, null); }));
|
||||
@@ -166,6 +172,7 @@ public class DiagnosisService : IDiagnosisService
|
||||
/// </summary>
|
||||
/// <param name="apiRequest">The API request instance to persist.</param>
|
||||
/// <returns>A task that represents the asynchronous save operation.</returns>
|
||||
/// <!-- aidoc:v1 sig=a3706aa body=5d13d47 -->
|
||||
public Task SaveRequestAsync(ApiRequest apiRequest)
|
||||
{
|
||||
return Task.FromResult(Task.Run(async () => { await SaveRequest(apiRequest, null); }));
|
||||
@@ -177,6 +184,7 @@ public class DiagnosisService : IDiagnosisService
|
||||
/// <param name="apiRequest">The API request containing the observation codes, values, message time, and optional observation time used to build the diagnosis.</param>
|
||||
/// <param name="patient">The patient associated with the diagnosis, whose identifier is assigned to the new <see cref="PatientDiagnosis"/>.</param>
|
||||
/// <returns>A task that represents the asynchronous insertion of the resulting <see cref="PatientDiagnosis"/>.</returns>
|
||||
/// <!-- aidoc:v1 sig=feeab82 body=75feb1d -->
|
||||
public async Task ProcessDiagnosisObservation(ApiRequest apiRequest, Patient patient)
|
||||
{
|
||||
_logger.LogDebug("INSERT DiagnosisObservation from obsservation");
|
||||
@@ -248,6 +256,7 @@ public class DiagnosisService : IDiagnosisService
|
||||
/// <param name="apiRequest">The API request containing the type, patient identifiers, location, and observation data to be processed.</param>
|
||||
/// <param name="patient">An optional pre-resolved patient; when null, the patient is resolved via the patient service using the request data.</param>
|
||||
/// <exception cref="ApiRequestException">Thrown when both the patient number and the location unit name are missing from the request, or when the request type is not valid for diagnosis processing.</exception>
|
||||
/// <!-- aidoc:v1 sig=272fe2f body=50c8fbd -->
|
||||
public async Task SaveRequest(ApiRequest apiRequest, Patient? patient)
|
||||
{
|
||||
if (patient == null)
|
||||
@@ -319,6 +328,7 @@ public class DiagnosisService : IDiagnosisService
|
||||
/// <param name="diagnosis">The list of patient diagnoses to be processed and inserted.</param>
|
||||
/// <param name="patient">The patient whose identifier is assigned to each diagnosis entry.</param>
|
||||
/// <param name="messageTime">The timestamp assigned to each diagnosis entry during processing.</param>
|
||||
/// <!-- aidoc:v1 sig=2e0a847 body=03c844f -->
|
||||
public async Task ProcessDiagnosis(List<PatientDiagnosis> diagnosis, Patient patient, DateTime messageTime)
|
||||
{
|
||||
_logger.LogDebug("INSERT DiagnosisObservation from diagnosis");
|
||||
@@ -337,6 +347,7 @@ public class DiagnosisService : IDiagnosisService
|
||||
/// <param name="nameId">The name of the identifier field used to locate the records to update.</param>
|
||||
/// <param name="id">The new ObjectId to assign to the matching records.</param>
|
||||
/// <param name="oldId">The existing ObjectId to be replaced in the matching records.</param>
|
||||
/// <!-- aidoc:v1 sig=72ce1ca body=3281a42 -->
|
||||
public async Task UpdateManyObjectId(string nameId, ObjectId id, ObjectId oldId)
|
||||
{
|
||||
await _diagnosisRepository.UpdateManyObjectId(nameId, id, oldId);
|
||||
@@ -347,6 +358,7 @@ public class DiagnosisService : IDiagnosisService
|
||||
/// </summary>
|
||||
/// <param name="id">The unique identifier of the patient whose diagnoses are being requested.</param>
|
||||
/// <returns>A task that represents the asynchronous operation, containing a list of <see cref="PatientDiagnosis"/> records for the given patient.</returns>
|
||||
/// <!-- aidoc:v1 sig=3f1244f body=f584950 -->
|
||||
public async Task<List<PatientDiagnosis>> GetByPatient(ObjectId id)
|
||||
{
|
||||
return await _diagnosisRepository.GetByPatient(id);
|
||||
@@ -357,6 +369,7 @@ public class DiagnosisService : IDiagnosisService
|
||||
/// If the diagnosis cannot be mapped (returns null), the insert and broadcast operations are skipped.
|
||||
/// </summary>
|
||||
/// <param name="diagnosis">The patient diagnosis to insert.</param>
|
||||
/// <!-- aidoc:v1 sig=f1354a6 body=fcec185 -->
|
||||
public async Task Insert(PatientDiagnosis diagnosis)
|
||||
{
|
||||
_logger.LogDebug("Insert {diagnosis}", diagnosis);
|
||||
@@ -374,6 +387,7 @@ public class DiagnosisService : IDiagnosisService
|
||||
/// </summary>
|
||||
/// <param name="diagnosis">The patient diagnosis to be mapped.</param>
|
||||
/// <returns>The mapped <see cref="PatientDiagnosis"/> produced by the calculated observations mapper, or <see langword="null"/> if the diagnosis was ignored.</returns>
|
||||
/// <!-- aidoc:v1 sig=0440056 body=83aaa02 -->
|
||||
private async Task<PatientDiagnosis?> MapDiagnosis(PatientDiagnosis diagnosis)
|
||||
{
|
||||
var diagnosis2 = await _calculatedObservations.Value.Map(diagnosis);
|
||||
@@ -386,6 +400,7 @@ public class DiagnosisService : IDiagnosisService
|
||||
/// Sends a patient diagnosis broadcast to all subscribers whose registered location matches the patient's location (unit, room, and bed). Returns early without broadcasting if the patient cannot be found.
|
||||
/// </summary>
|
||||
/// <param name="diagnosis">The patient diagnosis payload to broadcast to the matching subscribers.</param>
|
||||
/// <!-- aidoc:v1 sig=47e7826 body=f462d51 -->
|
||||
private async Task SendBroadcast(PatientDiagnosis diagnosis)
|
||||
{
|
||||
var patient = await _patientService.Value.FindById(diagnosis.PatientId);
|
||||
@@ -412,6 +427,7 @@ public class DiagnosisService : IDiagnosisService
|
||||
/// </summary>
|
||||
/// <param name="patientId">The unique identifier of the patient whose diagnosis records are to be retrieved.</param>
|
||||
/// <returns>A task that represents the asynchronous operation, containing an asynchronous cursor over the matching <see cref="PatientDiagnosis"/> records.</returns>
|
||||
/// <!-- aidoc:v1 sig=01cba99 body=5a86d75 -->
|
||||
public Task<IAsyncCursor<PatientDiagnosis>> FindByPatientIdAsync(ObjectId patientId)
|
||||
{
|
||||
return _diagnosisRepository.FindByPatientIdAsync(patientId);
|
||||
@@ -424,6 +440,7 @@ public class DiagnosisService : IDiagnosisService
|
||||
/// A broadcast is dispatched asynchronously after a successful insert or update.
|
||||
/// </summary>
|
||||
/// <param name="diagnosis">The patient diagnosis to persist.</param>
|
||||
/// <!-- aidoc:v1 sig=92e37f1 body=456e290 -->
|
||||
public async Task InsertDiagnosis(PatientDiagnosis diagnosis)
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user