function bindPrescriptionEntityArray($prescriptionEntitys)
{
    $prescriptionDtos = new PrescriptionListDto();
    $prescriptionDtoArray = array();
    foreach ($prescriptionEntitys as $prescriptionEntity => $value) {
        array_push($prescriptionDtoArray, bindPrescriptionEntity($value));
    }
    $prescriptionDtos->setPrescriptions($prescriptionDtoArray);
    return $prescriptionDtos;
}
    $entityManager->flush();
    $prescriptionDto = bindPrescriptionEntity($prescriptionEntity);
    $prescriptionDto->printData($app);
});
$app->post('/prescriptions/list', function () use($app) {
    global $entityManager;
    $prescriptionListDto = new PrescriptionListDto();
    $prescriptionListDto = $prescriptionListDto->bindXml($app);
    $prescriptionsArray = array();
    foreach ($prescriptionListDto->getPrescriptions() as $prescriptionDto) {
        $prescriptionEntity = bindPrescriptionDto($prescriptionDto);
        $entityManager->persist($prescriptionEntity);
        $entityManager->flush();
        array_push($prescriptionsArray, bindPrescriptionEntity($prescriptionEntity));
    }
    $prescriptionListDto = new PrescriptionListDto();
    $prescriptionListDto->setPrescriptions($prescriptionsArray);
    $prescriptionListDto->printData($app);
});
$app->put('/prescriptions/:id', function ($id) use($app) {
    global $entityManager;
    $prescriptionEntity = $entityManager->find("PrescriptionEntity", $id);
    $entityManager->flush();
    $prescriptionDto = bindPrescriptionEntity($prescriptionEntity);
    $prescriptionDto->printData($app);
});
$app->delete('/prescriptions/:id', function ($id) use($app) {
    global $entityManager;
    $prescriptionEntity = $entityManager->find("PrescriptionEntity", $id);
    $entityManager->remove($prescriptionEntity);
    $entityManager->flush();