$app->post(’/create/document’, function() use($app) {
$params = $app->request->post(); //$request->getParams();
$sql = "INSERT INTO im_patient_doc
(
impb_id,
imdoc_type,
imdoc_image,
imdoc_start_date,
imdoc_end_date,
imdoc_remarks,
imdoc_status
) VALUES
(
:impbid,
:doctype,
:docimage,
:docstart,
:docend,
:docremarks,
:docstatus
)";
$impbid = $params[‘patientID’];
$doctype = $params[‘docType’];
$docimage = $params[‘docImage’];
$docstart = $params[‘docStart’];
$docend = $params[‘docEnd’];
$docremarks = $params[‘docRemarks’];
$docstatus = $params[‘docStatus’];
try {
$db = getDB($params[‘databaseID’]);
$stmt = $db->prepare($sql);
$query = compact(‘impbid’,‘doctype’,‘docimage’,‘docstart’,‘docend’,‘docremarks’,‘docstatus’);
$stmt->execute($query);
$db = null;
$status = array('success' => '201');
echo json_encode(compact('status'));
} catch (Exception $e) {
$status = array('error' => $e->getMessage());
echo json_encode(compact('status'));
}
});