/**
 * 
 */
package gov.va.med.cds.testharness.vhim400;

import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.ElementModifier;

/**
 * @author vhaislegberb
 *
 */
public class RequestIdAppendingElementModifier
    implements
        ElementModifier
{

    /* (non-Javadoc)
     * @see org.dom4j.io.ElementModifier#modifyElement(org.dom4j.Element)
     */
    @Override
    public Element modifyElement( Element element )
        throws Exception
    {
        if ( "ClinicalData".equals( element.getName() ) )
        {
            Element patient = element.element( "patient" );
            patient.detach();

            Element requestId = DocumentHelper.createElement( "requestId" );
            requestId.setText( "the_request_id" );
            element.add( requestId );

            element.add( patient );
        }
        
        return element;
    }

}
