class R4FhirQuestionnaireResponseToProgramStageTransformer extends AbstractFhirQuestionnaireResponseToProgramStageTransformer {

    @Nonnull
    protected EventStatus convertStatus( @Nonnull QuestionnaireResponse questionnaireResponse )
    {
        try
        {
            final EventStatus eventStatus = EventStatusExtensionUtils.getValue( questionnaireResponse );

            if ( eventStatus != null )
            {
                return eventStatus;
            }
        }
        catch ( IllegalArgumentException e )
        {
            throw new TransformerDataException( e.getMessage() );
        }

        final QuestionnaireResponseStatus questionnaireResponseStatus = questionnaireResponse.getStatus();

        if ( questionnaireResponseStatus == null )
        {
            throw new TransformerDataException( "No questionnaire response status has been given." );
        }

        switch ( questionnaireResponseStatus )
        {
            case COMPLETED:
                return EventStatus.COMPLETED;
            case INPROGRESS:
                return EventStatus.ACTIVE;
            default:
                throw new TransformerDataException( "Questionnaire response status is not allowed: " + questionnaireResponseStatus );
        }
    }

    public  R4FhirQuestionnaireResponseToProgramStageTransformer( @Nonnull ScriptExecutor scriptExecutor, @Nonnull TrackedEntityMetadataService trackedEntityMetadataService, @Nonnull TrackedEntityService trackedEntityService,
        @Nonnull TrackedEntityRuleRepository trackedEntityRuleRepository, @Nonnull OrganizationUnitService organizationUnitService, @Nonnull ProgramMetadataService programMetadataService, @Nonnull ProgramStageMetadataService programStageMetadataService,
        @Nonnull EventService eventService, @Nonnull FhirResourceMappingRepository resourceMappingRepository, @Nonnull FhirDhisAssignmentRepository fhirDhisAssignmentRepository, @Nonnull ScriptExecutionContext scriptExecutionContext,
        @Nonnull ValueConverter valueConverter );

}