@Test
  public void mapOrdersWithObs_shouldMapAllObservationsToLabOrderResults() {
    EncounterTransaction.Order order1 =
        createOrder("uuid1", "concept1", Order.Action.NEW.toString(), null);
    EncounterTransaction.Order order2 =
        createOrder("uuid2", "concept2", Order.Action.REVISE.toString(), null);
    List<EncounterTransaction.Order> testOrders = Arrays.asList(order1, order2);
    EncounterTransaction.Observation order1_Obs1 = createObservation("obsuuid1", order1.getUuid());
    EncounterTransaction.Observation order1_Obs2 = createObservation("obsuuid2", order1.getUuid());
    EncounterTransaction.Observation order2_Obs1 = createObservation("obsuuid3", order2.getUuid());
    List<EncounterTransaction.Observation> observations =
        Arrays.asList(order1_Obs1, order1_Obs2, order2_Obs1);
    Map<String, Encounter> orderToEncounterMapping = new HashMap<>();
    orderToEncounterMapping.put(order1.getUuid(), encounter);
    orderToEncounterMapping.put(order2.getUuid(), encounter);
    Map<String, Encounter> observationToEncounterMapping = new HashMap<>();
    observationToEncounterMapping.put(order1_Obs1.getUuid(), encounter);
    observationToEncounterMapping.put(order1_Obs2.getUuid(), encounter);
    observationToEncounterMapping.put(order2_Obs1.getUuid(), encounter);

    List<LabOrderResult> results =
        labOrderResultsServiceImpl.mapOrdersWithObs(
            testOrders,
            observations,
            orderToEncounterMapping,
            observationToEncounterMapping,
            new HashMap());

    assertEquals(3, results.size());
  }
  @Test
  public void filterTestOrders_shouldNotFilterByConcept() throws Exception {
    Map<String, Encounter> encounterTestOrderUuidMap = new HashMap<>();
    EncounterTransaction.Order order1 =
        createOrder("uuid1", "concept1", Order.Action.NEW.toString(), null);
    when(encounterTransaction.getOrders()).thenReturn(Arrays.asList(order1));

    List<EncounterTransaction.Order> orders =
        labOrderResultsServiceImpl.filterTestOrders(
            encounterTransaction, encounter, encounterTestOrderUuidMap, null);

    assertEquals(1, orders.size());
  }
  @Test
  public void mapOrdersWithObs_shouldMapLabTestWithoutResultToLabOrderResult() {
    EncounterTransaction.Order order1 =
        createOrder("uuid1", "concept1", Order.Action.NEW.toString(), null);
    List<EncounterTransaction.Order> testOrders = Arrays.asList(order1);
    Map<String, Encounter> orderToEncounterMapping = new HashMap<>();
    orderToEncounterMapping.put(order1.getUuid(), encounter);

    List<LabOrderResult> results =
        labOrderResultsServiceImpl.mapOrdersWithObs(
            testOrders,
            new ArrayList<EncounterTransaction.Observation>(),
            orderToEncounterMapping,
            new HashMap(),
            new HashMap());

    assertEquals(1, results.size());
  }
  @Test
  public void filterTestOrders_EvenWhenTheyAreDiscontinued() throws Exception {
    List<String> concepts = Arrays.asList("concept1", "concept2", "concept3");
    Map<String, Encounter> encounterTestOrderUuidMap = new HashMap<>();
    EncounterTransaction.Order order1 =
        createOrder("uuid1", "concept1", Order.Action.NEW.toString(), null);
    EncounterTransaction.Order order2 =
        createOrder("uuid2", "concept2", Order.Action.REVISE.toString(), null);
    EncounterTransaction.Order order3 =
        createOrder("uuid3", "concept3", Order.Action.NEW.toString(), new Date());
    when(encounterTransaction.getOrders()).thenReturn(Arrays.asList(order1, order2, order3));

    List<EncounterTransaction.Order> orders =
        labOrderResultsServiceImpl.filterTestOrders(
            encounterTransaction, encounter, encounterTestOrderUuidMap, concepts);

    assertEquals(3, orders.size());
  }