class R4FhirCarePlanToEnrollmentTransformer extends AbstractFhirCarePlanToEnrollmentTransformer {

    @Override
    protected void transformInternal( @Nonnull FhirToDhisTransformerContext context, @Nonnull RuleInfo<EnrollmentRule> ruleInfo, @Nonnull Map<String, Object> scriptVariables, @Nonnull FhirResourceMapping fhirResourceMapping,
        @Nonnull Program program, @Nonnull IBaseResource carePlan, @Nonnull ScriptedTrackedEntityInstance scriptedTrackedEntityInstance, @Nonnull WritableScriptedEnrollment scriptedEnrollment ) throws TransformerException
    {
        final CarePlan fhirCarePlan = (CarePlan) carePlan;
        final Enrollment enrollment = (Enrollment) scriptedEnrollment.getDhisResource();

        enrollment.setProgramId( program.getId() );
        enrollment.setStatus( convertStatus( fhirCarePlan.getStatus() ) );
        enrollment.setOrgUnitId( getOrgUnitId( context, ruleInfo, fhirResourceMapping.getImpEnrollmentOrgLookupScript(), scriptVariables )
            .orElseThrow( () -> new TransformerMappingException( "Care plan contains location that cannot be mapped." ) ) );
        enrollment.setTrackedEntityInstanceId( scriptedTrackedEntityInstance.getId() );

        final Date enrollmentDate = fhirCarePlan.getPeriod().getStart();
        enrollment.setEnrollmentDate( enrollmentDate == null ? null :
            ZonedDateTime.ofInstant( enrollmentDate.toInstant(), zoneId ) );

        final Date incidentDate = IncidentDateExtensionUtils.getValue( fhirCarePlan );
        enrollment.setIncidentDate( incidentDate == null ? null : ZonedDateTime.ofInstant( incidentDate.toInstant(), zoneId ) );

        enrollment.setModified();
    }

    public  R4FhirCarePlanToEnrollmentTransformer( @Nonnull ScriptExecutor scriptExecutor, @Nonnull TrackedEntityMetadataService trackedEntityMetadataService, @Nonnull TrackedEntityService trackedEntityService,
        @Nonnull TrackedEntityRuleRepository trackedEntityRuleRepository, @Nonnull OrganizationUnitService organizationUnitService, @Nonnull ProgramMetadataService programMetadataService, @Nonnull EnrollmentService enrollmentService,
        @Nonnull FhirResourceMappingRepository resourceMappingRepository, @Nonnull FhirDhisAssignmentRepository fhirDhisAssignmentRepository, @Nonnull ScriptExecutionContext scriptExecutionContext, @Nonnull ValueConverter valueConverter );

}