class R4ProgramStageMetadataToFhirQuestionnaireTransformer extends AbstractProgramStageMetadataToFhirQuestionnaireTransformer<Questionnaire> {

    @Override
    protected boolean transformInternal( @Nonnull FhirClient fhirClient, @Nonnull DhisToFhirTransformerContext context, @Nonnull RuleInfo<ProgramStageMetadataRule> ruleInfo, @Nonnull Map<String, Object> scriptVariables,
        @Nonnull AccessibleScriptedDhisMetadata input, @Nonnull IBaseResource output )
    {
        final ProgramStage dhisProgramStage = (ProgramStage) input.getDhisResource();
        final Questionnaire fhirQuestionnaire = (Questionnaire) output;

        fhirQuestionnaire.setUrl( dhisProgramStage.getId() );
        fhirQuestionnaire.setTitle( dhisProgramStage.getName() );
        fhirQuestionnaire.setStatus( Enumerations.PublicationStatus.ACTIVE );
        fhirQuestionnaire.setDescription( dhisProgramStage.getDescription() );
        fhirQuestionnaire.setItem( null );

        dhisProgramStage.getDataElements().forEach( dataElement -> {
            final QuestionnaireItemType type = convertValueType( dataElement.getElement().getValueType() );

            if ( type != null )
            {
                final QuestionnaireItemComponent itemComponent = fhirQuestionnaire.addItem();

                itemComponent.setLinkId( dataElement.getElementId() );
                itemComponent.setText( dataElement.getElement().getName() );
                itemComponent.setRequired( dataElement.isCompulsory() );
                itemComponent.setType( type );

                ValueTypeExtensionUtils.setValue( itemComponent, dataElement.getElement().getValueType(), getTypeFactory() );

                if ( dataElement.getElement().isOptionSetValue() )
                {
                    dataElement.getElement().getOptionSet().getOptions().forEach( option -> itemComponent.addAnswerOption().setValue(
                        new Coding().setCode( option.getCode() ).setDisplay( option.getName() ) ) );
                }
            }
        } );

        return true;
    }

    public  R4ProgramStageMetadataToFhirQuestionnaireTransformer( @Nonnull ScriptExecutor scriptExecutor, @Nonnull LockManager lockManager, @Nonnull SystemRepository systemRepository, @Nonnull FhirResourceRepository fhirResourceRepository,
        @Nonnull FhirDhisAssignmentRepository fhirDhisAssignmentRepository, @Nonnull OrganizationUnitService organizationUnitService );

}