コード例 #1
0
function bindPrescriptionEntityArray($prescriptionEntitys)
{
    $prescriptionDtos = new PrescriptionListDto();
    $prescriptionDtoArray = array();
    foreach ($prescriptionEntitys as $prescriptionEntity => $value) {
        array_push($prescriptionDtoArray, bindPrescriptionEntity($value));
    }
    $prescriptionDtos->setPrescriptions($prescriptionDtoArray);
    return $prescriptionDtos;
}
コード例 #2
0
function bindPrescriptionItemEntity($prescriptionItemEntity)
{
    if ($prescriptionItemEntity != null) {
        $prescriptionItemDto = new PrescriptionItemDto();
        $prescriptionItemDto->setPrescriptionItemId($prescriptionItemEntity->getPrescriptionItemId());
        $prescriptionItemDto->setPrescription(bindPrescriptionEntity($prescriptionItemEntity->getPrescription()));
        $prescriptionItemDto->setName($prescriptionItemEntity->getName());
        return $prescriptionItemDto;
    } else {
        return null;
    }
}
コード例 #3
0
    $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();
});
/*Referances*/
$app->get('/prescriptions/:id/prescriptionitems/prescriptions', function ($id) use($app) {
    global $entityManager;
    $prescriptionItemEntities = $entityManager->getRepository("PrescriptionItemEntity")->findBy(array('prescription' => $id));
    $prescriptionItem = bindPrescriptionItemEntityArray($prescriptionItemEntities);
    $prescriptionItem->printData($app);
});