package org.openmrs.reference;

import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.openmrs.reference.page.HeaderPage;
import org.openmrs.reference.page.HomePage;
import org.openmrs.reference.page.PatientCaptureVitalsPage;
import org.openmrs.reference.page.PatientDashboardPage;
import org.openmrs.uitestframework.test.TestBase;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.openmrs.uitestframework.test.TestData.PatientInfo;


/**
 * Created by tomasz on 25.05.15.
 */
public class CaptureVitalsTest  extends TestBase {


    private HeaderPage headerPage;
    private HomePage homePage;
    private PatientDashboardPage patientDashboardPage;
    private PatientCaptureVitalsPage patientCaptureVitalsPage;
    private PatientInfo patient;

    @Before
    public void setUp() throws InterruptedException {
        loginPage.loginAsAdmin();
        homePage = new HomePage(driver);
        patientDashboardPage = new PatientDashboardPage(driver);
        patientCaptureVitalsPage = new PatientCaptureVitalsPage(driver);
        assertPage(homePage);
    }

    private void registerAPatient() throws InterruptedException{
        patient = createTestPatient();
        currentPage().goToPage(PatientDashboardPage.URL_PATH + "?patientId=" + patient.uuid);
    }

    @After
    public void tearDown() throws Exception {
        deletePatient(patient.uuid);
        //waitForPatientDeletion(patient.uuid);
        headerPage.logOut();
    }

    @Test
    @Category(org.openmrs.reference.groups.BuildTests.class)
    public void captureVital() throws InterruptedException {
        registerAPatient();
        patientDashboardPage.startVisit();        
        patientDashboardPage.goToCaptureVitals();
        patientCaptureVitalsPage.waitForJsVariable("Navigator.isReady");
        patientCaptureVitalsPage.setHeightField("185");
        patientCaptureVitalsPage.setWeightField("78");
        patientCaptureVitalsPage.setTemperatureField("36.6");
        patientCaptureVitalsPage.setPulseField("120");
        patientCaptureVitalsPage.setRespiratoryField("110");
        patientCaptureVitalsPage.setBloodPressureFields("120", "70");
        patientCaptureVitalsPage.setBloodOxygenSaturationField("50");
        patientCaptureVitalsPage.confirm();
        patientCaptureVitalsPage.save();
    }


}

@@ -78,33 +78,8 @@
 re;%0A
-import org.junit.Ignore;%0A
 impo
@@ -407,98 +407,8 @@
 ase;
-%0A%0Aimport static org.junit.Assert.assertNotNull;%0Aimport static org.junit.Assert.assertTrue;
 %0Aimp
@@ -567,43 +567,8 @@
 %7B%0A%0A%0A
-    private HeaderPage headerPage;%0A
     
@@ -1373,57 +1373,13 @@
     
-//waitForPatientDeletion(patient.uuid);%0A        h
+new H
 eade
@@ -1379,24 +1379,32 @@
 w HeaderPage
+(driver)
 .logOut();%0A 

Fix tearDown of CaptureVitalsTeest