Report Template Service
Component Detail
Service Layer
medium complexity
mobile
1
Dependencies
1
Dependents
0
Entities
0
Integrations
Description
Fetches and manages the active report template configuration from the backend endpoint /api/v1/report-templates, allowing organization administrators to control field visibility and labels per organization. Coordinates between the form screen and the repository for local caching, and handles submission of completed home visit reports including creation of coordinator task records for 'way forward' entries.
report-template-service
Responsibilities
- Fetch active report template from /api/v1/report-templates for the current organization
- Delegate template caching to ReportTemplateRepository for offline support
- Submit completed home visit report data to the backend and create linked coordinator task records
- Expose template field configuration (visibility, labels) to the form screen
- Handle API errors and fallback to cached templates when offline
Interfaces
getActiveTemplate(organizationId): Future<ReportTemplate>
submitHomeVisitReport(activityId, reportData): Future<Report>
createCoordinatorTask(activityId, wayForwardText): Future<CoordinatorTask>
refreshTemplate(organizationId): Future<void>
getFieldConfig(templateId, fieldId): TemplateFieldConfig
isTemplateAvailableOffline(organizationId): bool
validateReportData(reportData): ValidationResult