function bindDoctorEntityArray($doctorEntitys) { $doctorDtos = new DoctorListDto(); $doctorDtoArray = array(); foreach ($doctorEntitys as $doctorEntity => $value) { array_push($doctorDtoArray, bindDoctorEntity($value)); } $doctorDtos->setDoctors($doctorDtoArray); return $doctorDtos; }
function bindDoctorPracticeEntity($doctorPracticeEntity) { if ($doctorPracticeEntity != null) { $doctorPracticeDto = new DoctorPracticeDto(); $doctorPracticeDto->setMedsDoctorPracticeId($doctorPracticeEntity->getMedsDoctorPracticeId()); $doctorPracticeDto->setPractice(bindPracticeEntity($doctorPracticeEntity->getPractice())); $doctorPracticeDto->setDoctor(bindDoctorEntity($doctorPracticeEntity->getDoctor())); return $doctorPracticeDto; } else { return null; } }
function bindPrescriptionEntity($prescriptionEntity) { if ($prescriptionEntity != null) { $prescriptionDto = new PrescriptionDto(); $prescriptionDto->setPrescriptionId($prescriptionEntity->getPrescriptionId()); $prescriptionDto->setAppointment(bindAppointmentEntity($prescriptionEntity->getAppointment())); $prescriptionDto->setDoctor(bindDoctorEntity($prescriptionEntity->getDoctor())); $prescriptionDto->setUser(bindUserEntity($prescriptionEntity->getUser())); $prescriptionDto->setFile(bindFileEntity($prescriptionEntity->getFile())); $prescriptionDto->setEffFrm($prescriptionEntity->getEffFrm()); $prescriptionDto->setEffTo($prescriptionEntity->getEffTo()); return $prescriptionDto; } else { return null; } }
$doctorsArray = array(); foreach ($doctorListDto->getDoctors() as $doctorDto) { $doctorEntity = bindDoctorDto($doctorDto); $entityManager->persist($doctorEntity); $entityManager->flush(); array_push($doctorsArray, bindDoctorEntity($doctorEntity)); } $doctorListDto = new DoctorListDto(); $doctorListDto->setDoctors($doctorsArray); $doctorListDto->printData($app); }); $app->put('/doctors/:id', function ($id) use($app) { global $entityManager; $doctorEntity = $entityManager->find("DoctorEntity", $id); $entityManager->flush(); $doctorDto = bindDoctorEntity($doctorEntity); $doctorDto->printData($app); }); $app->delete('/doctors/:id', function ($id) use($app) { global $entityManager; $doctorEntity = $entityManager->find("DoctorEntity", $id); $entityManager->remove($doctorEntity); $entityManager->flush(); }); /*Referances*/ $app->get('/doctors/:id/doctorpractices/doctors', function ($id) use($app) { global $entityManager; $doctorPracticeEntities = $entityManager->getRepository("DoctorPracticeEntity")->findBy(array('doctor' => $id)); $doctorPractice = bindDoctorPracticeEntityArray($doctorPracticeEntities); $doctorPractice->printData($app); });