function bindPrescriptionItemEntityArray($prescriptionItemEntitys)
{
    $prescriptionItemDtos = new PrescriptionItemListDto();
    $prescriptionItemDtoArray = array();
    foreach ($prescriptionItemEntitys as $prescriptionItemEntity => $value) {
        array_push($prescriptionItemDtoArray, bindPrescriptionItemEntity($value));
    }
    $prescriptionItemDtos->setPrescriptionItems($prescriptionItemDtoArray);
    return $prescriptionItemDtos;
}
    $entityManager->flush();
    $prescriptionItemDto = bindPrescriptionItemEntity($prescriptionItemEntity);
    $prescriptionItemDto->printData($app);
});
$app->post('/prescriptionitems/list', function () use($app) {
    global $entityManager;
    $prescriptionItemListDto = new PrescriptionItemListDto();
    $prescriptionItemListDto = $prescriptionItemListDto->bindXml($app);
    $prescriptionItemsArray = array();
    foreach ($prescriptionItemListDto->getPrescriptionItems() as $prescriptionItemDto) {
        $prescriptionItemEntity = bindPrescriptionItemDto($prescriptionItemDto);
        $entityManager->persist($prescriptionItemEntity);
        $entityManager->flush();
        array_push($prescriptionItemsArray, bindPrescriptionItemEntity($prescriptionItemEntity));
    }
    $prescriptionItemListDto = new PrescriptionItemListDto();
    $prescriptionItemListDto->setPrescriptionItems($prescriptionItemsArray);
    $prescriptionItemListDto->printData($app);
});
$app->put('/prescriptionitems/:id', function ($id) use($app) {
    global $entityManager;
    $prescriptionItemEntity = $entityManager->find("PrescriptionItemEntity", $id);
    $entityManager->flush();
    $prescriptionItemDto = bindPrescriptionItemEntity($prescriptionItemEntity);
    $prescriptionItemDto->printData($app);
});
$app->delete('/prescriptionitems/:id', function ($id) use($app) {
    global $entityManager;
    $prescriptionItemEntity = $entityManager->find("PrescriptionItemEntity", $id);
    $entityManager->remove($prescriptionItemEntity);
    $entityManager->flush();