<?php

$vitalMap = [
    'heightInInches' => 'Ht. (in.)',
    'weightPounds' => 'Wt. (lbs.)',
    'temperatureF' => 'Temp. (F)',
    'pulseRatePerMinute' => 'Pulse',
    'respirationRatePerMinute' => 'Resp.',
    'pulseOx' => 'Pulse Ox.',
    'systolicBP' => 'SBP',
    'diastolicBP' => 'DBP',
    'smokingStatus' => 'Smoking Status',
    'bmi' => 'BMI'
];
$vitalLabels = ['Ht. (in.)','Wt. (lbs.)','Temp. (F)','Pulse','Resp.','Pulse Ox.','SBP','DBP','Smoking Status', 'BMI'];
$vitalValues = [];
foreach($patient->measurements as $measurement) {
    if(!empty($measurement->label) && in_array($measurement->label, $vitalLabels)){
        $vitalValues[$measurement->label] = [
            'value'=>$measurement->value,
            'effectiveDate' => $measurement->effective_date
        ];
    }
}

$value = [];
global $defaultData;
foreach ($vitalValues as $lbl => $line):
    $value[] = '<p>' . $lbl . ': <b>' . $line['value'] . '</b>' .
        '<span class="text-sm"> (as on ' . friendly_date_time($line['effectiveDate'], false) . ')</span>' .
        '</p>';
endforeach;
$value = implode("", $value);
$defaultData = [
    "summary" => $value,
    "value" => $value,
];
