

package gov.va.med.cds.testharness.vhim400.builders;


import org.dom4j.Document;
import org.dom4j.Element;

import java.util.List;


public class TiuBuilderFactory
    implements
        ClinicalDomainBuilderFactoryInterface
{
    private TiuBuilder tiuBuiler = new TiuBuilder();


    @Override
    public void createClinicalDomainData( Document clinicalData, int cnt, Element patientIdentifier )
    {
        buildClinicalDomainEventData( clinicalData, cnt, patientIdentifier );
    }


    private void buildClinicalDomainEventData( Document clinicalData, int count, Element patientIdentifer )
    {
        Element rootElement = clinicalData.getRootElement();

        Element patient = rootElement.element( "patient" );

        List<Element> clinicalDocumentEvents = tiuBuiler.makeClinicalDocumentEvents( count, patientIdentifer );

        for ( Element clinicalDocumentEvent : clinicalDocumentEvents )
        {
            patient.add( clinicalDocumentEvent );
        }
    }


    public void setTiuBuiler( TiuBuilder tiuBuiler )
    {
        this.tiuBuiler = tiuBuiler;
    }
}
