class FhirToDhisTransformerContextImpl implements FhirToDhisTransformerContext {

    @Nullable
    @Override
    public String extractDhisId( @Nullable Object idElement )
    {
        if ( idElement == null )
        {
            return null;
        }

        final String id;

        if ( idElement instanceof IIdType )
        {
            final IIdType idType = (IIdType) idElement;

            if ( idType.isLocal() )
            {
                return null;
            }

            id = idType.getIdPart();
        }
        else
        {
            id = idElement.toString();
        }

        if ( id == null )
        {
            return null;
        }

        if ( DhisResourceId.isValidId( id ) )
        {
            return id;
        }

        try
        {
            return DhisFhirResourceId.parse( id ).getId();
        }
        catch ( IllegalArgumentException e )
        {
            throw new TransformerDataException( "Not a valid DHIS2 FHIR ID: " + id, e );
        }
    }

    public  FhirToDhisTransformerContextImpl( @Nonnull FhirRequest fhirRequest, boolean creationDisabled );

}