<?php 

use App\Models\Page;

$page = Page::where('client_id', $patient->id)->where('category', 'CANVAS')->where('key', 'ros')->first();

$contentData = [
    'value'=>''
];
$isempty = false;

if($page){
    $contentData = json_decode($page->data, true);
}else {
    if ($patient->canvas_data) {
        $canvasData = json_decode($patient->canvas_data, true);
        if (isset($canvasData["ros"])) {
            $contentData = $canvasData["ros"];
        }
        else {
            $isempty = true;
        }
    }
    else {
        $isempty = true;
    }
}

if(!isset($contentData['value'])){
    $contentData['value'] = '';
}

if($isempty) {
    echo '<span class="text-secondary">No ROS data</span>';
}else {
    echo $contentData['value'];
}