Moved the patient lookup to it's own function in interface.c. Still some issues appropriately handling errors. Also having trouble appropriately freeing sql error message as sqlite3_free(error) is causing SIGABORT.