class R4EnrollmentToFhirCarePlanTransformer extends AbstractEnrollmentToFhirCarePlanTransformer {

    @Override
    protected boolean transformInternal( @Nonnull FhirClient fhirClient, @Nonnull DhisToFhirTransformerContext context, @Nonnull RuleInfo<EnrollmentRule> ruleInfo, @Nonnull Map<String, Object> scriptVariables,
        @Nonnull ScriptedEnrollment input, @Nonnull IBaseResource output, @Nonnull IBaseResource trackedEntityResource )
    {
        final Enrollment enrollment = (Enrollment) input.getDhisResource();
        final CarePlan fhirCarePlan = (CarePlan) output;
        final String planDefinitionUri = FhirResourceType.PLAN_DEFINITION.withId( enrollment.getProgramId() );

        fhirCarePlan.setInstantiatesUri( Collections.singletonList( new UriType( planDefinitionUri ) ) );
        fhirCarePlan.setInstantiatesCanonical( Collections.singletonList( new CanonicalType( planDefinitionUri ) ) );

        fhirCarePlan.setIntent( CarePlan.CarePlanIntent.PLAN );
        fhirCarePlan.setStatus( convertStatus( enrollment.getStatus() ) );

        LocationExtensionUtils.setValue( fhirCarePlan, createAssignedFhirReference( context, ruleInfo, scriptVariables,
            DhisResourceType.ORGANIZATION_UNIT, enrollment.getOrgUnitId(), FhirResourceType.LOCATION ) );
        fhirCarePlan.setSubject( new Reference( trackedEntityResource.getIdElement() ) );

        fhirCarePlan.setPeriod( null );
        fhirCarePlan.getPeriod().setStart( Date.from( enrollment.getEnrollmentDate().toInstant() ) );
        IncidentDateExtensionUtils.setValue( fhirCarePlan, enrollment.getIncidentDate() == null ? null :
            Date.from( enrollment.getIncidentDate().toInstant() ), ResourceFactory::createType );

        return true;
    }

    public  R4EnrollmentToFhirCarePlanTransformer( @Nonnull ScriptExecutor scriptExecutor, @Nonnull LockManager lockManager, @Nonnull SystemRepository systemRepository, @Nonnull FhirResourceRepository fhirResourceRepository,
        @Nonnull FhirResourceMappingRepository resourceMappingRepository, @Nonnull FhirDhisAssignmentRepository fhirDhisAssignmentRepository, @Nonnull TrackedEntityMetadataService trackedEntityMetadataService,
        @Nonnull TrackedEntityRuleRepository trackedEntityRuleRepository, @Nonnull ProgramMetadataService programMetadataService );

}