package gov.va.med.cds.persistence.hibernate.tiu.vista;

import gov.va.med.cds.common.person.correlation.PersonIdentifier;
import gov.va.med.cds.common.person.correlation.PersonIdentifierInterface;
import gov.va.med.cds.junit.runners.Suite;
import gov.va.med.cds.junit.runners.SuiteAwareSpringRunner;

import java.util.ArrayList;
import java.util.List;

import org.dom4j.Element;
import org.hibernate.EntityMode;
import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;

@RunWith(SuiteAwareSpringRunner.class)
@ContextConfiguration(locations ={"classpath:gov/va/med/cds/config/testConcurrentReadVistaTiuContext.xml" })
public class DocumentUpdateEventTest
{
    @Autowired
    private SessionFactory tiuXmlSessionFactory;
 
    @Test
    @Suite(groups="broken")
    public void testReadDocumentUpdateEvent1( )throws Exception
    {
        String identity = "2159";
        String assigningFacility = "0";
        String assigningAuthority = "";
        
        PersonIdentifierInterface personIdentifier = new PersonIdentifier() ;
        personIdentifier.setIdentity(identity);
        personIdentifier.setAssigningFacility(assigningFacility);
        personIdentifier.setAssigningAuthority(assigningAuthority);
        
        List<String> concatenatedPersonIds = new ArrayList<String>();
        String concatenatedPersonId = personIdentifier.getAssigningFacility() + "/" + personIdentifier.getIdentity();
        concatenatedPersonIds.add( concatenatedPersonId );
        
        Assert.assertNotNull( tiuXmlSessionFactory );
 //org.hibernate.Session session = tiuXmlSessionFactory.openSession().getSession(EntityMode.DOM4J );
        String s = "select documentUpdateEvents from ClinicalDocumentEvent cde where 0 || '/' || cde.patient.identifier.identity in ( :pids )))";

  //Query q = session.createQuery( s );
  //      q.setParameterList( "pids", concatenatedPersonIds );
  //      List results = (List)q.list();
        
 //       Element element  = (Element) results.get( 0 );
  //      session.close();
    }

}




