Skip to content

LNK-4651: Add Adhoc Type for AdhocReportGeneration - #1345

Merged
arianamihailescu merged 10 commits into
devfrom
LNK-4651-AddHic-Type-for-AdhocReportGeneration
Jan 14, 2026
Merged

LNK-4651: Add Adhoc Type for AdhocReportGeneration#1345
arianamihailescu merged 10 commits into
devfrom
LNK-4651-AddHic-Type-for-AdhocReportGeneration

Conversation

@arianamihailescu

@arianamihailescu arianamihailescu commented Dec 31, 2025

Copy link
Copy Markdown
Contributor

🛠️ Description of Changes

Add AdHoc type for Adhoc reports to track Manual versus Automatic generation

🧪 Testing Performed

Tested locally

🧑‍🔬 Unit Testing

  • I have written or updated unit tests to cover my changes

📓 Documentation Updated

Please update any relevant sections in the project documentation that were impacted by the changes in the PR.

Summary by CodeRabbit

  • New Features

    • Added new "Enter Patients" option for specifying patients when generating reports.
    • Reports now display their ad-hoc type designation (Automatic or Manual).
  • Bug Fixes

    • Improved facility input validation and error handling in the report generation form.
    • Enhanced error messaging when ad-hoc report generation fails.
  • Tests

    • Added comprehensive test coverage for the report generation form component.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Dec 31, 2025

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

This PR introduces ad-hoc report type tracking by adding an AdHocType property to the ReportSchedule entity, implementing automatic detection logic in the report generation listener, updating the factory mapping, and extending the UI to support manual patient entry with appropriate type classification.

Changes

Cohort / File(s) Summary
Backend Entity & Factory Mapping
DotNet/Report/Entities/ReportSchedule.cs, DotNet/Report/Application/Factory/ScheduledReportFactory.cs
Added new nullable AdHocType property to ReportSchedule; updated factory mapping in FromDomain to populate AdHocType from report schedule model.
Report Generation Logic
DotNet/Report/Listeners/GenerateReportListener.cs
Implemented automatic ad-hoc report type detection: sets AdHocType to Automatic when Regenerate is false and no PatientIds provided; otherwise Manual.
Frontend UI Form Template & Component
Web/Admin.UI/src/app/components/reports/generate-report/generate-report-form.component.html, generate-report-form.component.ts
Added "Enter Patients" radio option; updated form control default from fileUpload to manualPatients; hardened facility input trimming and validation; changed onFacilitySelected signature to accept object with facilityId and facilityName; enhanced error handling in ad-hoc report generation flow.
Frontend Form Tests
generate-report-form.component.spec.ts
Added comprehensive test suite covering component initialization, form validation, facility input handling, form submission (success/error), and form reset behavior with mocked services.
Frontend Data Interface & Report Display
Web/Admin.UI/src/app/components/tenant/facility-view/report-view.interface.ts, view-report/view-report.component.html
Added adhocType: string field to IReportListSummary interface; added AdHocType display field to report summary view template.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant UI as Generate Report Form
    participant Listener as GenerateReportListener
    participant Factory as ScheduledReportFactory
    participant Display as View Report Component

    User->>UI: Select "Enter Patients" (manual) or "Use Census (Automatic)"
    UI->>Listener: Create ad-hoc report request with patient selection
    
    rect rgb(200, 220, 255)
    Note over Listener: Determine AdHocType
    Listener->>Listener: Check: Regenerate=false AND no PatientIds?
    alt Automatic pathway
        Listener->>Listener: isAutomatic = true<br/>AdHocType = Automatic
    else Manual pathway
        Listener->>Listener: isAutomatic = false<br/>AdHocType = Manual
    end
    end
    
    Listener->>Factory: Create ScheduledReportListSummary<br/>with AdHocType
    Factory->>Factory: Map reportScheduleModel.AdHocType<br/>to result.AdHocType
    Factory-->>Display: Return mapped summary
    
    Display->>Display: Render AdHocType field
    Display-->>User: Display report with<br/>AdHocType (Manual/Automatic)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • #1206: Both PRs modify GenerateReportListener.cs—the main PR adds AdHocType assignment logic while #1206 changes ReportSchedule ID sourcing, affecting related scheduling operations.
  • #1205: Both PRs modify facility selection in GenerateReportFormComponent—this PR changes the onFacilitySelected signature to use an object shape while #1205 implements autocomplete facility type-ahead functionality.
  • #1163: Both PRs modify GenerateReportListener.cs for ad-hoc report scheduling—this PR adds automatic vs. manual type detection while #1163 changes report ID generation for regenerate behavior.

Suggested reviewers

  • amphillipsLGC
  • dvargaslantana

Poem

🐰 A clever rabbit crafted tracking true,
Which path did the report journey through?
Manual patients or POI list fair,
Now AdHocType records it with care!
From form to listener, factory to display,
Type tracking brightens the reporting day!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and directly summarizes the main change: adding an AdHoc type property to track Manual versus Automatic report generation, which matches the core objective of the PR.
Description check ✅ Passed The description covers the main objective and testing performed, but the unit testing checkbox remains unchecked and documentation section is left as a template prompt without actual updates.
Linked Issues check ✅ Passed The PR successfully implements the requirement to track whether AdHoc reports were generated manually (from UI-entered patient lists) or automatically (from FHIR List resources), through new AdHocType property and logic differentiation.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the AdHoc type tracking feature: property additions, factory mapping, listener logic for type assignment, UI form updates, and test coverage remain focused on the stated objective.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Web/Admin.UI/src/app/components/reports/generate-report/generate-report-form.component.html (1)

98-109: Misleading section heading.

The heading displays "Census Patients" but this section is shown when manualPatients is selected, which is for manual patient entry. Consider renaming the heading to "Manual Patient Entry" or "Enter Patients" to match the radio button label and avoid confusion.

🔎 Proposed fix
     @if (selectedFormControl.value === 'manualPatients') {
       <div>
-        <h3>Census Patients</h3>
+        <h3>Enter Patients</h3>
         <div>
           <mat-form-field appearance="outline">
             <input matInput formControlName="patients" placeholder="Enter comma-delimited string of patients"/>
🧹 Nitpick comments (5)
Web/Admin.UI/src/app/components/tenant/facility-view/report-view.interface.ts (1)

12-12: Consider making adhocType optional and using a union type for type safety.

Since the backend has AdHocType? as nullable and older reports may not have this property, consider:

  1. Making the property optional: adhocType?: string;
  2. Using a union type for better type safety: adhocType?: 'Manual' | 'Automatic';

This prevents runtime errors when displaying reports created before this feature and provides compile-time validation of valid values.

🔎 Proposed refactor
-  adhocType: string;
+  adhocType?: 'Manual' | 'Automatic';
Web/Admin.UI/src/app/components/reports/generate-report/generate-report-form.component.ts (1)

150-158: Consider displaying facility name in the input field for better UX.

Line 155 sets facilityInputControl to facility.facilityId, but users typically expect to see the human-readable facility name in the autocomplete input, not the ID. This could be confusing.

🔎 Proposed change
  onFacilitySelected(selectedValue: { facilityId: string; facilityName: string }) {
    const facility = this.facilities.find(f => f.facilityId === selectedValue.facilityId);
    if (facility) {
      this.facilityIdControl.setValue(facility.facilityId);
-     this.facilityInputControl.setValue(facility.facilityId);
+     this.facilityInputControl.setValue(facility.facilityName);
      this.facilityIdControl.setErrors(null);
    }
  }
Web/Admin.UI/src/app/components/reports/generate-report/generate-report-form.component.spec.ts (3)

4-4: Remove unused import 'async'.

The async function from RxJS is imported but never used (replaced by Angular's waitForAsync on line 23). Additionally, importing async from RxJS is misleading as it's not related to Angular's async testing helper.

🔎 Proposed fix
-import {async, of, throwError} from 'rxjs';
+import {of, throwError} from 'rxjs';

137-152: Verify test expectations match component behavior.

The test expects a { notFound: true } error (line 150) when an invalid facility is entered, but the onFacilityInputBlur method doesn't directly set this error. The error would come from the async facilityExistsValidator.

Ensure:

  1. The mock for checkFacility is properly configured to work with the async validator
  2. The timing allows the async validation to complete before assertions
  3. Consider adding tick() or flushMicrotasks() if needed

180-213: Test validates core submission logic but has timing concerns.

The test correctly validates that:

  • The service is called with the right parameters
  • The lastGeneratedReport is updated on success

However, line 187 has a commented tick(), which might indicate timing issues. For async tests, consider properly managing the asynchronous flow with fakeAsync and tick() or flush() to avoid flaky tests.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 10f1512 and 5d34f05.

📒 Files selected for processing (8)
  • DotNet/Report/Application/Factory/ScheduledReportFactory.cs
  • DotNet/Report/Entities/ReportSchedule.cs
  • DotNet/Report/Listeners/GenerateReportListener.cs
  • Web/Admin.UI/src/app/components/reports/generate-report/generate-report-form.component.html
  • Web/Admin.UI/src/app/components/reports/generate-report/generate-report-form.component.spec.ts
  • Web/Admin.UI/src/app/components/reports/generate-report/generate-report-form.component.ts
  • Web/Admin.UI/src/app/components/tenant/facility-view/report-view.interface.ts
  • Web/Admin.UI/src/app/components/tenant/facility-view/view-report/view-report.component.html
🧰 Additional context used
📓 Path-based instructions (2)
**/*.cs

⚙️ CodeRabbit configuration file

**/*.cs: The HtmlInputSanitizer class's Sanitize() and SanitizeAndRemove() methods should be used when dealing with string query parameters from REST requests.

Files:

  • DotNet/Report/Entities/ReportSchedule.cs
  • DotNet/Report/Application/Factory/ScheduledReportFactory.cs
  • DotNet/Report/Listeners/GenerateReportListener.cs
**

⚙️ CodeRabbit configuration file

**: Pull requests that have "TECH_DEBT" in the title should only contain changes related to typos, unused code, linter/IDE suggestions, swagger specification updates,
and logging improvements. These TECH_DEBT PRs must not affect core functionality. All PRs that are not considered technical debt must include information on what
testing was performed in the description of the PR. If it does not, ask the author to provide details on what testing was performed.
When reviewing code, suggest unit tests using XUnit in the following scenarios:

  • If/Else or Switch/Case blocks are introduced or modified — ensure each branch has a corresponding unit test.
  • Logic that depends on service or interface configuration — suggest tests to validate different implementations are correctly resolved.
  • No network activity (HTTP calls, sockets, etc.) should appear in unit tests. Recommend using mocks (via Moq) for any external communication.
    Large unit tests should be avoided; keeping unit tests small and focused on targeted business logic (i.e. string sanitization)

**: Pull requests that have DOCS in the title should only contain changes related to documentation within the /docs folder or in .md files through-out the code-base. The description
of the PR should specify what documentation was updated. Documentation updates should use EventCatalog.dev structure, where service-specific functionality should be described
in the service's index.mdx (i.e. /services/XXX/index.mdx or /domains/XXX/services/YYY/index.mdx). Configurations that are shared by multiple services should be
reflected in the /docs/docs/config files.

Files:

  • DotNet/Report/Entities/ReportSchedule.cs
  • Web/Admin.UI/src/app/components/tenant/facility-view/view-report/view-report.component.html
  • DotNet/Report/Application/Factory/ScheduledReportFactory.cs
  • Web/Admin.UI/src/app/components/reports/generate-report/generate-report-form.component.html
  • Web/Admin.UI/src/app/components/reports/generate-report/generate-report-form.component.spec.ts
  • DotNet/Report/Listeners/GenerateReportListener.cs
  • Web/Admin.UI/src/app/components/tenant/facility-view/report-view.interface.ts
  • Web/Admin.UI/src/app/components/reports/generate-report/generate-report-form.component.ts
🧠 Learnings (2)
📚 Learning: 2025-09-11T20:18:30.425Z
Learnt from: smailliwcs
Repo: lantanagroup/link-cloud PR: 1070
File: DotNet/Report/KafkaProducers/SubmitPayLoadProducer.cs:51-54
Timestamp: 2025-09-11T20:18:30.425Z
Learning: ReportScheduleModel.ReportTypes is declared as List<string> (non-nullable) with a default value of new List<string>(), so it should never be null in the Report service codebase.

Applied to files:

  • DotNet/Report/Entities/ReportSchedule.cs
  • DotNet/Report/Application/Factory/ScheduledReportFactory.cs
📚 Learning: 2025-03-20T22:11:00.226Z
Learnt from: amphillipsLGC
Repo: lantanagroup/link-cloud PR: 737
File: DotNet/Admin.BFF/Presentation/Endpoints/Aggregation/Handlers/Report/GetReportSummaries.cs:23-23
Timestamp: 2025-03-20T22:11:00.226Z
Learning: The facilityId validation in GetReportSummaries.Handle method in DotNet/Admin.BFF/Presentation/Endpoints/Aggregation/Handlers/Report/GetReportSummaries.cs will be implemented in a future phase of work by amphillipsLGC.

Applied to files:

  • Web/Admin.UI/src/app/components/tenant/facility-view/view-report/view-report.component.html
  • Web/Admin.UI/src/app/components/reports/generate-report/generate-report-form.component.ts
🧬 Code graph analysis (2)
Web/Admin.UI/src/app/components/reports/generate-report/generate-report-form.component.spec.ts (1)
Web/Admin.UI/src/app/components/reports/generate-report/generate-report-form.component.ts (3)
  • facilityIdControl (169-171)
  • startDateControl (177-179)
  • endDateControl (181-183)
Web/Admin.UI/src/app/components/reports/generate-report/generate-report-form.component.ts (2)
Web/Admin.UI/src/app/components/testing/integration-test/integration-test.component.ts (1)
  • facilityIdControl (161-163)
Web/Admin.UI/src/app/interfaces/entity-created-response.model.ts (1)
  • IReportGenerationResponse (7-9)
🪛 GitHub Check: Integration Tests
DotNet/Report/Entities/ReportSchedule.cs

[failure] 26-26:
The type or namespace name 'AdHocType' could not be found (are you missing a using directive or an assembly reference?)


[failure] 26-26:
The type or namespace name 'AdHocType' could not be found (are you missing a using directive or an assembly reference?)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Smoke Test with Docker Compose
  • GitHub Check: Unit Tests for DotNet
  • GitHub Check: Build Documentation
  • GitHub Check: Analyze (csharp)
  • GitHub Check: Analyze (java-kotlin)
🔇 Additional comments (8)
Web/Admin.UI/src/app/components/reports/generate-report/generate-report-form.component.html (1)

79-80: Verify UI behavior aligns with option labels.

The two new radio options are:

  • "Enter Patients" (value: manualPatients) - for manual patient entry
  • "Use Census (Automatic)" (value: censusPatients) - for automatic census-based reports

Ensure that the component logic correctly handles both options and that the form behavior matches user expectations for each selection.

DotNet/Report/Application/Factory/ScheduledReportFactory.cs (1)

22-22: LGTM!

The mapping of AdHocType from the domain model to the summary model is straightforward and consistent with the existing property mappings.

Web/Admin.UI/src/app/components/tenant/facility-view/view-report/view-report.component.html (1)

57-62: LGTM!

The display of the new AdHocType field follows the established pattern for other summary fields and uses appropriate optional chaining to handle null values.

DotNet/Report/Listeners/GenerateReportListener.cs (1)

201-201: LGTM!

The logic for determining isAutomatic correctly distinguishes between automatic (census-based) and manual (provided patient list) report generation:

  • Automatic: when not regenerating AND no patient IDs provided (will fetch from census)
  • Manual: when regenerating OR patient IDs are provided
Web/Admin.UI/src/app/components/reports/generate-report/generate-report-form.component.ts (3)

108-108: LGTM! Default value aligns with manual entry focus.

Changing the default from 'fileUpload' to 'manualPatients' aligns with the PR objective of distinguishing manual versus automatic report generation, making the manual entry path the primary workflow.


229-249: Excellent improvement adding proper error handling.

The addition of structured error handling with user feedback via snackbar significantly improves the user experience. Users will now be informed when report generation fails instead of seeing silent failures.


326-332: LGTM! Return statement fix ensures correct function behavior.

The explicit return statement ensures the parsed patient array is properly returned, fixing what was likely a bug where the function would return undefined.

Web/Admin.UI/src/app/components/reports/generate-report/generate-report-form.component.spec.ts (1)

154-163: Test correctly validates current implementation.

This test properly validates the onFacilitySelected method's behavior, including the explicit error clearing (line 156 of component). The test expectations align with the current implementation.

Note: This test will need updating if the facilityInputControl is changed to display facilityName instead of facilityId (as suggested in the component review).

Comment thread DotNet/Report/Entities/ReportSchedule.cs
Comment thread DotNet/Report/Listeners/GenerateReportListener.cs
@arianamihailescu

Copy link
Copy Markdown
Contributor Author

@coderabbitai generate docstrings

@coderabbitai

coderabbitai Bot commented Jan 12, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Initiated docstring generation; will generate only if new commits exist.

@coderabbitai

coderabbitai Bot commented Jan 12, 2026

Copy link
Copy Markdown
Contributor

Note

Docstrings generation - SUCCESS
Generated docstrings for this pull request at #1367

coderabbitai Bot added a commit that referenced this pull request Jan 12, 2026
Docstrings generation was requested by @arianamihailescu.

* #1345 (comment)

The following files were modified:

* `DotNet/Report/Application/Factory/ScheduledReportFactory.cs`
* `DotNet/Report/Listeners/GenerateReportListener.cs`
@arianamihailescu
arianamihailescu merged commit ec895ff into dev Jan 14, 2026
17 checks passed
@arianamihailescu
arianamihailescu deleted the LNK-4651-AddHic-Type-for-AdhocReportGeneration branch January 14, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants