Skip to content
Mariano Andres Botta edited this page Mar 26, 2019 · 4 revisions

CDA

Borrar todos los CDA de un paciente

Se puede cambiar la condicón del primer find por la necesidad del usuario.

db.getCollection('CDAFiles.files').find({'metadata.paciente': ObjectId(ID)}).forEach(function(xml){ 
    db.getCollection('CDAFiles.files').find({'metadata.cdaId': xml._id.valueOf()}).forEach(function (PDF) {
        db.getCollection('CDAFiles.files').remove({_id:  PDF._id });
        db.getCollection('CDAFiles.chunks').remove({files_id:  PDF._id });
    });
    db.getCollection('CDAFiles.files').remove({_id:  xml._id });
    db.getCollection('CDAFiles.chunks').remove({files_id:  xml._id });
});

Clone this wiki locally