=== 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:
julian
2026-06-28 02:50:05 -07:00
parent a19fb90902
commit 586f02a2ca
654 changed files with 5260 additions and 0 deletions
@@ -30,6 +30,7 @@ internal class PatientServiceTest
/// dependencies and pre-configuring common lookup scenarios for units and points of care, including virtual
/// point of care states (Pushed, Moved, Deleted, Cancelled, Recovered, Unknown) used across test cases.
/// </summary>
/// <!-- aidoc:v1 sig=dee8bf2 body=ff2a3d0 -->
[SetUp]
public void Setup()
{
@@ -320,6 +321,7 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that the patient service correctly retrieves a patient from the database by matching the patient number supplied in the API request, returning a patient populated with the expected unit, point of care, and patient number values.
/// </summary>
/// <!-- aidoc:v1 sig=ef29ee9 body=8931a6e -->
[Test]
public async Task Find_Patient_By_APIRequest_Get_Patient_By_PatientNumber()
{
@@ -371,6 +373,7 @@ internal class PatientServiceTest
/// Verifies that <see cref="PatientService.FindPatientByApiRequest"/> creates a new patient record
/// when the requested patient does not exist and the <c>CreatePatientWithOru</c> option is set to <c>true</c>.
/// </summary>
/// <!-- aidoc:v1 sig=06e0a26 body=2d5f690 -->
[Test]
public async Task Find_Patient_By_APIRequest_Not_Exists_CreatePatientWithORU_True_Created_Patient()
{
@@ -445,6 +448,7 @@ internal class PatientServiceTest
/// while the target location is already occupied by another patient, and the <c>CreatePatientWithOru</c>
/// option is enabled, the service creates a new patient in a temporal bed instead of reusing the occupied location.
/// </summary>
/// <!-- aidoc:v1 sig=a57196b body=beeb5bf -->
[Test]
public async Task
Find_Patient_By_APIRequest_Not_Exists_And_Location_Ocuped_CreatePatientWithORU_True_Created_In_Temporal_Bed()
@@ -530,6 +534,7 @@ internal class PatientServiceTest
/// the <see cref="Patient"/> is not created in the temporal bed because <c>CreatePatientWithOru</c> is set to <c>false</c>.
/// Ensures that <c>FindPatientByApiRequest</c> returns <c>null</c> and that the repository's <c>InsertOneAsync</c> is never invoked.
/// </summary>
/// <!-- aidoc:v1 sig=e6921b4 body=35ecb59 -->
[Test]
public async Task Find_Patient_By_APIRequest_Not_Exists_CreatePatientWithORU_False_Not_Created_In_Temporal_Bed()
{
@@ -596,6 +601,7 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that when a patient is found by API request and the patient already exists in a different location in the database, the patient's location is not changed by the lookup operation.
/// </summary>
/// <!-- aidoc:v1 sig=d023325 body=4efbf14 -->
[Test]
public async Task Find_Patient_By_APIRequest_Exists_In_Different_Location_NOT_Changes_Patient_Location()
{
@@ -648,6 +654,7 @@ internal class PatientServiceTest
/// Verifies that an ADT_A01 request correctly inserts a new patient into the specified unit and bed location
/// by ensuring the patient repository is updated with the matching unit, bed, and patient number.
/// </summary>
/// <!-- aidoc:v1 sig=54b6ee5 body=52efd9d -->
[Test]
public async Task ADT_A01_New_Patient_Empty_Bed_Insert_In_Location()
{
@@ -679,6 +686,7 @@ internal class PatientServiceTest
/// Verifies that when an ADT_A01 request for a new patient is processed with an unknown location
/// (i.e., the location mapping resolves to null), the patient is not inserted into the repository.
/// </summary>
/// <!-- aidoc:v1 sig=a7816da body=592765f -->
[Test]
public async Task ADT_A01_New_Patient_Unknown_Location_Insert_Nothing()
{
@@ -708,6 +716,7 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that when an ADT_A01 admission request is received for a new patient targeting a bed that is already in use by an existing patient, the existing patient is moved to the temporal (pushed) bed while the new patient is admitted to the original bed.
/// </summary>
/// <!-- aidoc:v1 sig=f6f4884 body=f0a1e9f -->
[Test]
public async Task ADT_A01_New_Patient_Bed_In_Use_Moves_Existing_Patient_To_Temporal_Bed()
{
@@ -839,6 +848,7 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that when an ADT_A01 (Admit) message is received for a patient whose bed is already in use and whose patient number matches an existing patient, the patient's demographic data is updated while preserving the bed assignment and existing identifiers.
/// </summary>
/// <!-- aidoc:v1 sig=207b25e body=bc34164 -->
[Test]
public async Task ADT_A01_New_Patient_Bed_In_Use_With_Same_Patient_Number_Updates_Demographic_Data()
{
@@ -910,6 +920,10 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that processing an ADT_A05 message for a new patient in a new bed (PatientLocation) results in the patient being updated with the correct unit, point of care, and patient number, and that the point-of-care mapping service is invoked to create the location.
/// </summary>
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
/// "The documentation says 'ADT_A05 message' but the code sets apiRequest.Type = 'ADT_A01', so the test processes an ADT_A01 message, not ADT_A05." -->
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
/// "The documentation claims the test verifies 'that the point-of-care mapping service is invoked to create the location', but there is no Verify call for _poCMappingServiceMock; only a Setup stub is configured, and only the patient repository's Update is verified." -->
[Test]
public async Task ADT_A05_New_Patient_New_Bed_Creates_Location()
{
@@ -944,6 +958,7 @@ internal class PatientServiceTest
/// the existing patient in that bed is moved to a temporal PointOfCare, while the new patient
/// is assigned to the original PointOfCare location.
/// </summary>
/// <!-- aidoc:v1 sig=fbe1c2f body=f3b3776 -->
[Test]
public async Task ADT_A05_New_Patient_Bed_In_Use_Moves_Existing_Patient_To_Temporal_Bed()
{
@@ -1001,6 +1016,7 @@ internal class PatientServiceTest
/// Verifies that when an ADT_A03 (End Visit) message is processed for a patient that does not exist,
/// the patient repository's Update operation is never invoked, ensuring the system takes no action.
/// </summary>
/// <!-- aidoc:v1 sig=569f0a9 body=4815209 -->
[Test]
public async Task ADT_A03_END_VISIT_PATIENT_NOT_EXISTS_DO_NOTHING()
{
@@ -1032,6 +1048,7 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that when an ADT_A03 (End Visit) request is processed for a patient that already exists in the database, the patient record is updated with the deleted Point of Care, the unit identifier is preserved, and the next admission check is triggered for the original Point of Care.
/// </summary>
/// <!-- aidoc:v1 sig=df708cd body=1a6d3f8 -->
[Test]
public async Task ADT_A03_END_VISIT_PATIENT_EXISTS()
{
@@ -1177,6 +1194,7 @@ internal class PatientServiceTest
/// service to resolve the destination location, ensuring the save operation results in a single
/// insert for the new patient.
/// </summary>
/// <!-- aidoc:v1 sig=6bb7428 body=852c38d -->
[Test]
public async Task ADT_A02_TRANSFER_PATIENT_FROM_NOT_EXISTS_BED_TO_BED_SHOULD_CREATE_PATIENT()
{
@@ -1223,6 +1241,7 @@ internal class PatientServiceTest
/// <summary>
/// Tests the ADT_A02 transfer scenario where a patient is transferred from their current bed to a bed that is already occupied by another patient, verifying that the existing patient is moved to a new location, the transferring patient occupies the destination bed, and related discharge and next-admission checks are invoked.
/// </summary>
/// <!-- aidoc:v1 sig=445abff body=64dbe17 -->
[Test]
public async Task ADT_A02_TRANSFER_PATIENT_FROM_BED_TO_IN_USE_BED()
{
@@ -1298,6 +1317,7 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that when an ADT_A02 transfer message is processed for a patient moving from a location with no existing patient to a bed that is already occupied, the previously assigned patient is moved to a temporal bed and the new patient is inserted into the vacated bed.
/// </summary>
/// <!-- aidoc:v1 sig=4d1f5ba body=60f333b -->
[Test]
public async Task
ADT_A02_TRANSFER_PATIENT_FROM_NOT_EXISTS_TO_NOT_EMPTY_BED_SHOULD_CHANGE_LAST_PATIENT_TO_TEMPORTAL_BED()
@@ -1354,6 +1374,7 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that processing an ADT_A02 transfer request for a patient whose patient number already exists in the destination bed updates the existing patient's demographic data instead of creating a new patient record.
/// </summary>
/// <!-- aidoc:v1 sig=33bdcd5 body=a2f7027 -->
[Test]
public async Task
ADT_A02_TRANSFER_PATIENT_FROM_NOT_EXISTS_BED_TO_NOT_EMPTY_BED_WITH_SAME_PATIENT_NUMBER_SHOULD_UPTADE_DEMOGRAPHIC_DATA()
@@ -1411,6 +1432,7 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that processing an ADT_A04 message for a new patient successfully creates and persists a patient record with the expected unit, point of care, and patient number.
/// </summary>
/// <!-- aidoc:v1 sig=5feb5e2 body=5c4855e -->
[Test]
public async Task ADT_A04_New_Patient_Creates_Patient()
{
@@ -1443,6 +1465,7 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that when processing an ADT_A04 request for a new patient with a location whose POC mapping returns null, the patient is not persisted to the repository.
/// </summary>
/// <!-- aidoc:v1 sig=ff36bdc body=a4fb145 -->
[Test]
public async Task ADT_A04_New_Patient_Not_Location_Creates_Patient()
{
@@ -1473,6 +1496,7 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that when an ADT_A08 request is received for a non-existent patient and the <c>CreatePatientWithAdtA08</c> option is enabled, the <see cref="PatientService"/> correctly creates the patient by calling the patient repository's <c>Update</c> method with the expected <c>UnitId</c>, <c>PointOfCareId</c>, and <c>PatientNumber</c> values.
/// </summary>
/// <!-- aidoc:v1 sig=0011533 body=5222130 -->
[Test]
public async Task ADT_A08_No_exist_CreatePatientWithADT_A08_True_Patient_Creates_Patient()
{
@@ -1541,6 +1565,7 @@ internal class PatientServiceTest
/// Verifies that when an ADT_A08 message is processed for a patient that does not exist and the
/// <c>CreatePatientWithAdtA08</c> option is disabled, the patient is not inserted into the repository.
/// </summary>
/// <!-- aidoc:v1 sig=4787677 body=e1846b5 -->
[Test]
public async Task ADT_A08_No_exist_Patient_Not_Creates_Patient()
{
@@ -1608,6 +1633,7 @@ internal class PatientServiceTest
/// and patient creation on ADT_A08 is disabled, the patient is updated rather than created.
/// </summary>
/// <returns>A task that represents the asynchronous test execution.</returns>
/// <!-- aidoc:v1 sig=f8df471 body=e1407e8 -->
[Test]
public async Task ADT_A08_Exist_Patient_Update_Patient()
{
@@ -1681,6 +1707,7 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that processing an ADT_A11 (cancel admit/visit notification) message for an existing patient updates the patient's location to the cancelled point of care, leaving unit, patient number, and identity fields unchanged.
/// </summary>
/// <!-- aidoc:v1 sig=d05b038 body=5bf7535 -->
[Test]
public async Task ADT_A11_Exist_Patient_CANCELLED_Patient()
{
@@ -1757,6 +1784,7 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that when an ADT_A11 (cancel admit/visit notification) request is processed for a non-existent patient, the patient repository's <c>UpdateOneAsync</c> method is never invoked, since there is no existing patient record to update.
/// </summary>
/// <!-- aidoc:v1 sig=cc97dcc body=7db5096 -->
[Test]
public async Task ADT_A11_No_Exist_Patient_Not_CANCELLED_Patient()
{
@@ -1819,6 +1847,7 @@ internal class PatientServiceTest
/// Verifies that processing an ADT_A12 transfer message for a non-existing patient to an empty bed
/// results in the patient being created and assigned to the target bed via the point-of-care mapping.
/// </summary>
/// <!-- aidoc:v1 sig=eb39efa body=6eec376 -->
[Test]
public async Task ADT_A12_TRANSFER_PATIENT_NOT_EXISTS_TO_EMPTY_BED_SHOULD_CREATE_BED()
{
@@ -1852,6 +1881,7 @@ internal class PatientServiceTest
/// creates the bed (represented by a new point of care) and persists the patient's transfer to that
/// new location under the configured unit.
/// </summary>
/// <!-- aidoc:v1 sig=7d75980 body=1a080c9 -->
[Test]
public async Task ADT_A12_TRANSFER_PATIENT_FROM_BED_TO_NOT_EXISTS_BED_SHOULD_CREATE_BED()
{
@@ -1893,6 +1923,7 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that when an ADT_A12 transfer request is processed, the new patient occupying the target bed has their data updated while the displaced patient is relocated to a different point of care, and that the legacy <c>Update</c> method is not invoked.
/// </summary>
/// <!-- aidoc:v1 sig=788fe08 body=89347c8 -->
[Test]
public async Task ADT_A12_TRANSFER_PATIENT_FROM_BED_TO_IN_USE_BED()
{
@@ -1967,6 +1998,7 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that when an ADT_A12 transfer is processed for a patient moving to a bed that is already occupied, the existing patient in that bed is moved to a temporary bed (different Point of Care), and the transferred patient is inserted into the target bed.
/// </summary>
/// <!-- aidoc:v1 sig=b3f2ed3 body=a43a5e5 -->
[Test]
public async Task
ADT_A12_TRANSFER_PATIENT_NOT_EXISTS_TO_NOT_EMPTY_BED_SHOULD_CHANGE_LAST_PATIENT_TO_TEMPORTAL_BED()
@@ -2021,6 +2053,8 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that when an ADT_A13 transfer request is processed for a patient moving to a bed that is already occupied, the previously assigned patient in that bed is moved to a temporal bed while the transferring patient is persisted in the requested location.
/// </summary>
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
/// "Summary claims the previously assigned patient is moved to a temporal bed, but the test only verifies that the transferring patient is updated at the target location; no assertion or mock verifies the prior occupant's relocation to a temporal bed." -->
[Test]
public async Task
ADT_A13_TRANSFER_PATIENT_NOT_EXISTS_TO_NOT_EMPTY_BED_SHOULD_CHANGE_LAST_PATIENT_TO_TEMPORTAL_BED()
@@ -2063,6 +2097,7 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that processing an ADT_A13 transfer request for a patient assigned to a deleted point of care moves the patient to the recovered (temporal) bed location.
/// </summary>
/// <!-- aidoc:v1 sig=d80f16e body=ea343c5 -->
[Test]
public async Task ADT_A13_TRANSFER_PATIENT_NOT_EXISTS_TO_EMPTY_BED_SHOULD_CHANGE_LAST_PATIENT_TO_TEMPORTAL_BED()
{
@@ -2112,6 +2147,7 @@ internal class PatientServiceTest
/// Verifies that processing an ADT_A31 (Update Patient) HL7 request correctly updates the existing patient's demographic
/// information (last name and birth date) while preserving the assigned unit and point of care identifiers.
/// </summary>
/// <!-- aidoc:v1 sig=d30f8e5 body=1a5e43f -->
[Test]
public async Task ADT_A31_Upadate_Patient()
{
@@ -2159,6 +2195,7 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that when an ADT_A31 update request is processed for a patient that does not exist, the patient is not updated. Ensures the repository's Update method is never invoked in the not-found scenario.
/// </summary>
/// <!-- aidoc:v1 sig=c01058d body=e9b1919 -->
[Test]
public async Task ADT_A31_Upadate_Patient_Not_Found_Not_Update()
{
@@ -2191,6 +2228,7 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that when an ADT_A39 merge patient request is processed, the old patient record is deleted after the new patient is resolved through the point-of-care mapping and patient repository lookups.
/// </summary>
/// <!-- aidoc:v1 sig=b442eb3 body=32ea4bf -->
[Test]
public async Task ADT_A39_Merge_Patient()
{
@@ -2246,6 +2284,7 @@ internal class PatientServiceTest
/// Verifies that when an <c>ADT_A39</c> request is processed and the patient is not an old patient (i.e., not a merge case),
/// the <see cref="PatientService.SaveRequest"/> does not delete the existing patient from the repository.
/// </summary>
/// <!-- aidoc:v1 sig=0442333 body=8b45017 -->
[Test]
public async Task ADT_A39_Not_OldPatient_Not_Merge_Patient()
{
@@ -2285,6 +2324,7 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that processing an ADT_A39 (merge patient) request does not result in the deletion of the old patient record, even when the old patient is located by number.
/// </summary>
/// <!-- aidoc:v1 sig=85734e7 body=fdeab08 -->
[Test]
public async Task ADT_A39_Not_Patient_Not_Merge_Patient()
{
@@ -2328,6 +2368,7 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that the patient service correctly handles an ADT_A44 patient merge/update request by locating the existing patient via the old patient number and updating it in the repository with the new patient information.
/// </summary>
/// <!-- aidoc:v1 sig=cd35acc body=16982fd -->
[Test]
public async Task ADT_A44_Upadate_Patient()
{
@@ -2369,6 +2410,7 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that processing an ADT_A44 request for a patient that is not an old patient does not trigger a patient update.
/// </summary>
/// <!-- aidoc:v1 sig=84f3f56 body=0fdeb6d -->
[Test]
public async Task ADT_A44_Not_OldPatient_Not__Upadate_Patient()
{
@@ -2402,6 +2444,7 @@ internal class PatientServiceTest
/// through the patient service by calling <c>SaveRequest</c> with an <c>ApiRequest</c> of type "ICCA" containing four
/// patients located in different points of care, and confirms each one is persisted exactly once via the repository.
/// </summary>
/// <!-- aidoc:v1 sig=db9be10 body=6c05a4c -->
[Test]
public async Task ICCA_Process_No_Patient_BD_Insert_ICCA_Patients()
{
@@ -2470,6 +2513,7 @@ internal class PatientServiceTest
/// <summary>
/// Verifies that when an ICCA patient request is processed and a patient already exists in the database at the same point of care but with a different patient number, the existing patient is updated to the moved point of care and the new ICCA patient is inserted.
/// </summary>
/// <!-- aidoc:v1 sig=844f9ba body=c4fd746 -->
[Test]
public async Task ICCA_Process_Patient_BD_Insert_ICCA_Patient_Pushed_Actual_Patient()
{
@@ -2527,6 +2571,7 @@ internal class PatientServiceTest
/// and the ICCA patients collection is empty, the existing patient is updated with the UNKNOWN
/// PointOfCareId and no new patient is inserted into the repository.
/// </summary>
/// <!-- aidoc:v1 sig=a53cb38 body=a8ccf49 -->
[Test]
public async Task ICCA_Process_Patient_BD_No_Insert_ICCA_Patient_UNKNOWN_Actual_Patient()
{