<?php

use App\Models\Page;

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

/** @var \App\Models\Pro $hcpPro */
/** @var \App\Models\Pro $pro */
/** @var \App\Models\Note $note */

if(!@$hcpPro) {
    if(@$note) {
        $hcpPro = $note->hcpPro;
    }
    else {
        $hcpPro = $pro; // should never get here
    }
}

$contentData = [];

if($page) {
    $contentData = json_decode($page->data, true);
}else{
    if ($patient->canvas_data) {
        $canvasData = json_decode($patient->canvas_data, true);
        if(!isset($canvasData["lifestyle_rx_update"])) $canvasData['lifestyle_rx_update'] = [];
        $contentData = $canvasData["lifestyle_rx_update"];
    }
}
if(!isset($contentData[$hcpPro->id])) $contentData[$hcpPro->id] = [];
$contentData = $contentData[$hcpPro->id];


