function(doc) {
    if (doc.type === "SonositeUpload" || doc.type === "VscanUpload") {
        emit([doc.domain, doc.type, doc.case_id], doc._id);
    }
}

function(doc) {
    if (doc.doc_type === "SonositeUpload") {
        emit([doc.doc_type, doc.study_id, doc.related_case_id], doc._id);
    }
    if (doc.doc_type === "VscanUpload") {
        emit([doc.doc_type, doc.scanner_serial, doc.scan_id], doc._id);
    }
}

Add couch view to help debug upload problems
Add couch view to help debug upload problems
