I need to make the following query using Symfony 2.1 and Doctrine, but I have no idea how I can make it work, I would appreciate it if you can help me with this problem.
SELECT * FROM (
SELECT
factura.id AS factura,
paciente.identificacion,
paciente.pri_Nombre,
paciente.seg_Nombre,
paciente.pri_Apellido,
paciente.seg_Apellido,
hc.id AS historia,
hc.peso,
hc.estatura
FROM hc
JOIN factura ON factura.id = hc.factura_id
JOIN paciente ON paciente.id = factura.paciente_id
JOIN cargo ON cargo.id = factura.cargo_id
JOIN cliente ON cliente.id = factura.cliente_id
WHERE
factura.fecha > "2018/05/01 00:00:00" AND
factura.fecha <= "2018/10/19 23:59:59" AND
factura.sede_id = 5 AND
factura.estado = 'I' AND
cargo.id = 1 AND
cliente.id = 41
ORDER BY hc.id DESC
) AS h
GROUP BY h.identificacion