class R4ProgramMetadataToFhirPlanDefinitionTransformer extends AbstractProgramMetadataToFhirPlanDefinitionTransformer<PlanDefinition> {

    @Override
    protected boolean transformInternal( @Nonnull FhirClient fhirClient, @Nonnull DhisToFhirTransformerContext context, @Nonnull RuleInfo<ProgramMetadataRule> ruleInfo, @Nonnull Map<String, Object> scriptVariables,
        @Nonnull AccessibleScriptedDhisMetadata input, @Nonnull IBaseResource output )
    {
        final Program dhisProgram = (Program) input.getDhisResource();
        final PlanDefinition fhirPlanDefinition = (PlanDefinition) output;

        if ( !addSubjectResourceType( dhisProgram, fhirPlanDefinition ) )
        {
            return false;
        }

        fhirPlanDefinition.setUrl( dhisProgram.getId() );
        fhirPlanDefinition.setName( dhisProgram.getCode() );
        fhirPlanDefinition.setTitle( dhisProgram.getName() );
        fhirPlanDefinition.setStatus( Enumerations.PublicationStatus.ACTIVE );
        fhirPlanDefinition.setDescription( dhisProgram.getDescription() );
        fhirPlanDefinition.setAction( null );

        dhisProgram.getStages().forEach( dhisProgramStage -> {
            final PlanDefinitionActionComponent action = fhirPlanDefinition.addAction();

            action.setId( dhisProgramStage.getId() );
            action.setTitle( dhisProgramStage.getName() );
            action.setDescription( dhisProgramStage.getDescription() );
            action.setCardinalityBehavior( dhisProgramStage.isRepeatable() ?
                PlanDefinition.ActionCardinalityBehavior.MULTIPLE : PlanDefinition.ActionCardinalityBehavior.SINGLE );
            action.setDefinition( new CanonicalType( FhirResourceType.QUESTIONNAIRE.getResourceTypeName() + "/" + dhisProgramStage.getId() ) );
        } );

        return true;
    }

    public  R4ProgramMetadataToFhirPlanDefinitionTransformer( @Nonnull ScriptExecutor scriptExecutor, @Nonnull LockManager lockManager, @Nonnull SystemRepository systemRepository, @Nonnull FhirResourceRepository fhirResourceRepository,
        @Nonnull FhirDhisAssignmentRepository fhirDhisAssignmentRepository, @Nonnull OrganizationUnitService organizationUnitService,
        @Nonnull TrackedEntityMetadataService trackedEntityMetadataService, @Nonnull TrackedEntityRuleRepository trackedEntityRuleRepository );

}