class AssignmentFhirToDhisTransformerUtils extends AbstractFhirToDhisTransformerUtils {

    @Nullable
    public String getMappedDhisId( @Nonnull FhirToDhisTransformerContext context, @Nonnull AbstractRule rule, @Nullable IIdType fhirId )
    {
        if ( fhirId == null || !fhirId.hasIdPart() )
        {
            return null;
        }

        if ( fhirId.getResourceType() == null )
        {
            throw new IllegalArgumentException( "FHIR resource type is not included: " + fhirId.getValue() );
        }

        final FhirResourceType fhirResourceType = FhirResourceType.getByResourceTypeName( fhirId.getResourceType() );

        if ( fhirResourceType == null )
        {
            throw new TransformerMappingException( "FHIR ID contains unsupported resource type: " + fhirId.getResourceType() );
        }

        if ( fhirResourceType.isSyncDhisId() || context.getFhirRequest().isDhisFhirId() )
        {
            return fhirId.getIdPart();
        }

        final FhirClient fhirClient = fhirClientRepository.findOneByIdCached( context.getFhirRequest().getFhirClientId() )
            .orElseThrow( () -> new FatalTransformerException( "FHIR Client with ID " + context.getFhirRequest().getFhirClientId() + " could not be found." ) );

        // rule must not be used to determine different assignment
        return assignmentRepository.findFirstDhisResourceId( fhirClient, fhirId );
    }

    protected  AssignmentFhirToDhisTransformerUtils( @Nonnull ScriptExecutionContext scriptExecutionContext,
        @Nonnull FhirDhisAssignmentRepository assignmentRepository, @Nonnull FhirClientRepository fhirClientRepository );

}