|
|
@ -1,10 +1,10 @@ |
|
|
const fields = ["nome", "r_g", "c_p_f", "data_de_nascimento", "endereco", "telefone"] |
|
|
const fields = ["nome", "r_g", "c_p_f", "data_de_nascimento", "endereco", "telefone"] |
|
|
|
|
|
|
|
|
const data = _val.map(); |
|
|
const data = _val.map(); |
|
|
var errors = _val.list(); |
|
|
|
|
|
|
|
|
const errors = _val.list(); |
|
|
|
|
|
|
|
|
for (field of fields) { |
|
|
for (field of fields) { |
|
|
let value = _req.getString(field); |
|
|
|
|
|
|
|
|
const value = _req.getString(field); |
|
|
if (!value) { |
|
|
if (!value) { |
|
|
errors.add(field); |
|
|
errors.add(field); |
|
|
} else { |
|
|
} else { |
|
|
@ -13,11 +13,12 @@ for (field of fields) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (errors.isEmpty()) { |
|
|
if (errors.isEmpty()) { |
|
|
var insertedData = _db.insertIfNotExists( |
|
|
|
|
|
|
|
|
const insertedData = _db.insertIfNotExists( |
|
|
'paciente', |
|
|
'paciente', |
|
|
data |
|
|
data |
|
|
); |
|
|
); |
|
|
_out.json({insertedData: insertedData}) |
|
|
|
|
|
|
|
|
_out.json({insertedData}) |
|
|
} else { |
|
|
} else { |
|
|
_out.json({"erros": {"campos_faltando": errors}}) |
|
|
|
|
|
|
|
|
_header.status(400); |
|
|
|
|
|
_out.json({"erros": {"campos faltando": errors}}) |
|
|
} |
|
|
} |