helpers.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: tatu
  5. * Date: 6/23/20
  6. * Time: 12:10 AM
  7. */
  8. use App\Models\AppSession;
  9. use App\Models\Client;
  10. use App\Models\Pro;
  11. use App\Models\Bill;
  12. //require_once './class.Diff.php';
  13. use Soundasleep\Html2Text as Html2Text;
  14. if(!function_exists('toFeetAndInches')) {
  15. function toFeetAndInches($value, $ftLabel = ' ft.', $inLabel = ' in.') {
  16. if(!$value) return '-';
  17. $value = round($value);
  18. $ft = round(floor($value / 12));
  19. $in = $value % 12;
  20. return "$ft$ftLabel $in$inLabel";
  21. }
  22. }
  23. if(!function_exists('feetFromInches')) {
  24. function feetFromInches($value) {
  25. if(!$value) return 0;
  26. $value = round($value);
  27. return round(floor($value / 12));
  28. }
  29. }
  30. if(!function_exists('inchesAfterFeetFromInches')) {
  31. function inchesAfterFeetFromInches($value) {
  32. if(!$value) return 0;
  33. $value = round($value);
  34. return round($value % 12);
  35. }
  36. }
  37. if(!function_exists('genericBills')) {
  38. function genericBills(Pro $performerPro, $patient, $entityType, $entityUid) {
  39. $genericBills = Bill::where('bill_service_type', 'GENERIC');
  40. if($performerPro->pro_type !== 'ADMIN') {
  41. $genericBills = $genericBills->where('generic_pro_id', $performerPro->id);
  42. }
  43. if($patient) {
  44. $genericBills = $genericBills->where('client_id', $patient->id);
  45. }
  46. if($entityType && $entityUid) {
  47. $genericBills = $genericBills
  48. ->where('generic_target_entity_type', $entityType)
  49. ->where('generic_target_entity_uid', $entityUid);
  50. }
  51. return $genericBills->orderBy('created_at', 'DESC')->get();
  52. }
  53. }
  54. if(!function_exists('hasActiveGenericBill')) {
  55. function hasActiveGenericBill(Pro $performerPro, $patient, $entityType, $entityUid) {
  56. $genericBills = Bill::where('bill_service_type', 'GENERIC')->where('is_cancelled', false);
  57. if($performerPro->pro_type !== 'ADMIN') {
  58. $genericBills = $genericBills->where('generic_pro_id', $performerPro->id);
  59. }
  60. if($patient) {
  61. $genericBills = $genericBills->where('client_id', $patient->id);
  62. }
  63. if($entityType && $entityUid) {
  64. $genericBills = $genericBills
  65. ->where('generic_target_entity_type', $entityType)
  66. ->where('generic_target_entity_uid', $entityUid);
  67. }
  68. return $genericBills->count() > 0;
  69. }
  70. }
  71. if(!function_exists('queryLineExcept')) {
  72. function queryLineExcept($except = []) {
  73. $params = request()->all();
  74. $final = [];
  75. foreach ($params as $k => $v) {
  76. if(in_array($k, $except) === FALSE) {
  77. if(is_array($v)) $v = implode(',', $v);
  78. $final[] = "$k=" . urlencode($v);
  79. }
  80. }
  81. return implode('&', $final);
  82. }
  83. }
  84. if(!function_exists('sortColumnHead')) {
  85. function sortColumnHead($url, $label, $sortKey, $defaultDirection = 'ASC') {
  86. $currentSortKey = request()->input('sort');
  87. $currentDir = request()->input('dir');
  88. $targetDir = $currentDir ? ($currentDir === 'ASC' ? 'DESC' : 'ASC') : $defaultDirection;
  89. echo '<a href="' . $url . '?sort=' . $sortKey . '&dir=' . $targetDir . '&' . queryLineExcept(['sort', 'dir']) . '">' . $label . '</a>';
  90. if($currentSortKey === $sortKey) {
  91. if($currentDir === 'ASC') {
  92. echo "&nbsp;&nbsp;↑";
  93. }
  94. elseif($currentDir === 'DESC') {
  95. echo "&nbsp;&nbsp;↓";
  96. }
  97. }
  98. }
  99. }
  100. if(!function_exists('html2Text')) {
  101. function html2Text($old, $new){
  102. }
  103. }
  104. if(!function_exists('diff')) {
  105. function diff($old, $new){
  106. // return Diff::toHTML(Diff::compare($old, $new));
  107. }
  108. }
  109. if(!function_exists('get_current_session')) {
  110. function get_current_session(){
  111. return AppSession::where('session_key', request()->cookie('sessionKey'))->first();
  112. }
  113. }
  114. if(!function_exists('friendly_date_time')) {
  115. function friendly_date_time($value, $includeTime = true, $default = '-', $long_year=false) {
  116. if(!$value || empty($value)) return $default;
  117. try {
  118. if($includeTime) {
  119. $realTimezone = 'US/Eastern';
  120. $date = new DateTime($value);
  121. $date->setTimezone(new DateTimeZone($realTimezone));
  122. return $date->format("m/d/y" . ($includeTime ? ", h:ia" : "")) . ($includeTime ? ' EST' : '');
  123. }
  124. else {
  125. $result = strtotime($value);
  126. if($long_year){
  127. $result = date("m/d/Y" . ($includeTime ? ", h:ia" : ""), $result);
  128. }else{
  129. $result = date("m/d/y" . ($includeTime ? ", h:ia" : ""), $result);
  130. }
  131. return $result;
  132. }
  133. }
  134. catch (Exception $e) {
  135. return $value;
  136. }
  137. }
  138. }
  139. if(!function_exists('friendlier_date_time')) {
  140. function friendlier_date_time($value, $includeTime = true, $default = '-') {
  141. return friendly_date_time($value, $includeTime, $default);
  142. }
  143. }
  144. if(!function_exists('friendly_date_time_short')) {
  145. function friendly_date_time_short($value, $includeTime = true, $default = '-') {
  146. if(!$value || empty($value)) return $default;
  147. try {
  148. $result = strtotime($value);
  149. $result = date("m/d/y" . ($includeTime ? ", h:ia" : ""), $result);
  150. return $result;
  151. }
  152. catch (Exception $e) {
  153. return $value;
  154. }
  155. }
  156. }
  157. if(!function_exists('friendly_date_time_short_with_tz')) {
  158. function friendly_date_time_short_with_tz($value, $includeTime = true, $tz='UTC', $default = '-') {
  159. if(!$value || empty($value)) return $default;
  160. try {
  161. $realTimezone = resolve_timezone($tz);
  162. $date = new DateTime($value);
  163. $date->setTimezone(new DateTimeZone($realTimezone));
  164. return $date->format("m/d/y" . ($includeTime ? ", h:iA" : ""));
  165. }
  166. catch (Exception $e) {
  167. return $e->getMessage();
  168. }
  169. }
  170. }
  171. if(!function_exists('friendly_date_time_short_with_tz_from_timestamp')) {
  172. function friendly_date_time_short_with_tz_from_timestamp($value, $tz='UTC', $default = '-') {
  173. if(!$value || empty($value)) return $default;
  174. try {
  175. $realTimezone = resolve_timezone($tz);
  176. $date = new DateTime("@$value");
  177. $date->setTimezone(new DateTimeZone($realTimezone));
  178. return $date->format("m/d/y, h:iA");
  179. }
  180. catch (Exception $e) {
  181. return $e->getMessage();
  182. }
  183. }
  184. }
  185. if(!function_exists('postgres_date_time_short_with_tz')) {
  186. function postgres_date_time_short_with_tz($value, $includeTime = true, $tz='UTC', $default = '-') {
  187. if(!$value || empty($value)) return $default;
  188. try {
  189. $realTimezone = resolve_timezone($tz);
  190. $date = new DateTime($value);
  191. $date->setTimezone(new DateTimeZone($realTimezone));
  192. return $date->format("Y-m-d" . ($includeTime ? " h:i:s" : ""));
  193. }
  194. catch (Exception $e) {
  195. return $e->getMessage();
  196. }
  197. }
  198. }
  199. if(!function_exists('postgres_date_time_short_with_tz_from_timestamp')) {
  200. function postgres_date_time_short_with_tz_from_timestamp($value, $tz='UTC', $default = '-') {
  201. if(!$value || empty($value)) return $default;
  202. try {
  203. $realTimezone = resolve_timezone($tz);
  204. $date = new DateTime("@$value");
  205. $date->setTimezone(new DateTimeZone($realTimezone));
  206. return $date->format("Y-m-d h:i:s");
  207. }
  208. catch (Exception $e) {
  209. return $e->getMessage();
  210. }
  211. }
  212. }
  213. if(!function_exists('friendly_date_time_short_with_tz_from_timestamp_divide1000')) {
  214. function friendly_date_time_short_with_tz_from_timestamp_divide1000($value, $tz='UTC', $default = '-') {
  215. if(!$value || empty($value)) return $default;
  216. try {
  217. $value = (floor($value / 1000));
  218. $realTimezone = resolve_timezone($tz);
  219. $date = new DateTime("@$value");
  220. $date->setTimezone(new DateTimeZone($realTimezone));
  221. return $date->format("m/d/y, h:iA");
  222. }
  223. catch (Exception $e) {
  224. return $e->getMessage();
  225. }
  226. }
  227. }
  228. if(!function_exists('friendly_date_short_with_tz_from_timestamp_divide1000')) {
  229. function friendly_date_short_with_tz_from_timestamp_divide1000($value, $tz='EASTERN', $default = '-') {
  230. if(!$value || empty($value)) return $default;
  231. try {
  232. $value = (floor($value / 1000));
  233. $realTimezone = resolve_timezone($tz);
  234. $date = new DateTime("@$value");
  235. $date->setTimezone(new DateTimeZone($realTimezone));
  236. return $date->format("m/d/y");
  237. }
  238. catch (Exception $e) {
  239. return $e->getMessage();
  240. }
  241. }
  242. }
  243. if(!function_exists('friendly_date')) {
  244. function friendly_date($value) {
  245. if(!$value || empty($value)) return '';
  246. try {
  247. $result = strtotime($value);
  248. $result = date("m/d/Y", $result);
  249. return $result;
  250. }
  251. catch (Exception $e) {
  252. return $value;
  253. }
  254. }
  255. }
  256. if(!function_exists('friendly_date_month_year')) {
  257. function friendly_date_month_year($value) {
  258. if(!$value || empty($value)) return '';
  259. try {
  260. $result = strtotime($value);
  261. $result = date("M Y", $result);
  262. return $result;
  263. }
  264. catch (Exception $e) {
  265. return $value;
  266. }
  267. }
  268. }
  269. if(!function_exists('friendlier_date')) {
  270. function friendlier_date($value) {
  271. if(!$value || empty($value)) return '';
  272. try {
  273. $result = strtotime($value);
  274. $result = date("m/d/Y", $result);
  275. return $result;
  276. }
  277. catch (Exception $e) {
  278. return $value;
  279. }
  280. }
  281. }
  282. if(!function_exists('relative_friendly_date')) {
  283. function relative_friendly_date($value) {
  284. if(!$value || empty($value)) return '';
  285. try {
  286. $result = date_diff(date_create($value), date_create('now'))->days;
  287. if ($result > 30) $result = date('F Y', strtotime($value));
  288. else if ($result > 1) $result .= ' days ago';
  289. else if ($result === 1) $result = 'Yesterday';
  290. else if ($result === 0) $result = 'Today';
  291. return $result;
  292. }
  293. catch (Exception $e) {
  294. return $value;
  295. }
  296. }
  297. }
  298. if(!function_exists('unfriendly_date')) {
  299. function unfriendly_date($value) {
  300. if(!$value || empty($value)) return '';
  301. try {
  302. $result = strtotime($value);
  303. $result = date("Y-m-d", $result);
  304. return $result;
  305. }
  306. catch (Exception $e) {
  307. return $value;
  308. }
  309. }
  310. }
  311. if(!function_exists('friendly_time')) {
  312. function friendly_time($value, $default = '-') {
  313. if(!$value || empty($value)) return $default;
  314. try {
  315. $result = strtotime($value);
  316. $result = date("h:i a", $result);
  317. return $result;
  318. }
  319. catch (Exception $e) {
  320. return $value;
  321. }
  322. }
  323. }
  324. if(!function_exists('military_time')) {
  325. function military_time($value, $tz='UTC', $default = '-') {
  326. if(!$value || empty($value)) return $default;
  327. try {
  328. $realTimezone = resolve_timezone($tz);
  329. $date = new DateTime($value);
  330. $date->setTimezone(new DateTimeZone($realTimezone));
  331. return $date->format("H:i");
  332. }
  333. catch (Exception $e) {
  334. return $value;
  335. }
  336. }
  337. }
  338. if(!function_exists('resolve_timezone')) {
  339. function resolve_timezone($value) {
  340. try {
  341. switch ($value) {
  342. case 'ALASKA': {
  343. return 'US/Alaska';
  344. }
  345. case 'CENTRAL': {
  346. return 'US/Central';
  347. }
  348. case 'EASTERN': {
  349. return 'US/Eastern';
  350. }
  351. case 'HAWAII': {
  352. return 'US/Hawaii';
  353. }
  354. case 'MOUNTAIN': {
  355. return 'US/Mountain';
  356. }
  357. case 'PACIFIC': {
  358. return 'US/Pacific';
  359. }
  360. case 'PUERTO_RICO': {
  361. return 'America/Puerto_Rico';
  362. }
  363. case 'UTC': {
  364. return 'UTC';
  365. }
  366. }
  367. }
  368. catch (Exception $e) {
  369. return $value;
  370. }
  371. }
  372. }
  373. // $date = new DateTime('2000-01-01', new DateTimeZone('Pacific/Nauru'));
  374. // echo $date->format('Y-m-d H:i:sP') . "\n";
  375. if(!function_exists('friendly_month')) {
  376. function friendly_month($value) {
  377. if(!$value || empty($value)) return "-";
  378. try {
  379. $result = strtotime($value);
  380. $result = date("F o", $result);
  381. return $result;
  382. }
  383. catch (Exception $e) {
  384. return $value;
  385. }
  386. }
  387. }
  388. if(!function_exists('day_part_from_date')) {
  389. function day_part_from_date($value) {
  390. if(!$value || empty($value)) return "-";
  391. try {
  392. $result = strtotime($value);
  393. $result = date("d", $result);
  394. return $result;
  395. }
  396. catch (Exception $e) {
  397. return $value;
  398. }
  399. }
  400. }
  401. if(!function_exists('month_part_from_date')) {
  402. function month_part_from_date($value) {
  403. if(!$value || empty($value)) return "-";
  404. try {
  405. $result = strtotime($value);
  406. $result = date("m", $result);
  407. return $result;
  408. }
  409. catch (Exception $e) {
  410. return $value;
  411. }
  412. }
  413. }
  414. if(!function_exists('year_part_from_date')) {
  415. function year_part_from_date($value) {
  416. if(!$value || empty($value)) return "-";
  417. try {
  418. $result = strtotime($value);
  419. $result = date("Y", $result);
  420. return $result;
  421. }
  422. catch (Exception $e) {
  423. return $value;
  424. }
  425. }
  426. }
  427. if(!function_exists('friendly_money')){
  428. function friendly_money($value){
  429. return number_format((float)$value, 2, '.', '');
  430. }
  431. }
  432. if(!function_exists('time_in_hrminsec')) {
  433. function time_in_hrminsec($value, $default = '-') {
  434. if(!$value || empty($value)) return $default;
  435. $value = intval($value);
  436. $minutes = intval($value / 60);
  437. $seconds = $value % 60;
  438. $hours = 0;
  439. if($minutes >= 60) {
  440. $hours = intval($minutes / 60);
  441. $minutes = $minutes % 60;
  442. }
  443. $output = [];
  444. if($hours > 0) {
  445. $output[] = "{$hours}h";
  446. }
  447. if($minutes > 0) {
  448. $output[] = "{$minutes}m";
  449. }
  450. if($seconds > 0) {
  451. $output[] = "{$seconds}s";
  452. }
  453. return implode(" ", $output);
  454. }
  455. }
  456. if(!function_exists('sanitize_field_name')) {
  457. function sanitize_field_name($name) {
  458. $result = strtolower($name);
  459. return preg_replace("/[^0-9a-z]/i", "_", $result);
  460. }
  461. }
  462. if(!function_exists('sanitize_state_name')) {
  463. function sanitize_state_name($name) {
  464. $result = strtolower($name);
  465. return ucwords(preg_replace("/_/i", " ", $result));
  466. }
  467. }
  468. if(!function_exists('renderNoteTemplate')) {
  469. function renderNoteTemplate($template, $topLevel)
  470. {
  471. echo
  472. '<div class="note-template-item" ' .
  473. 'template="' . (isset($template->template) ? $template->template : $template->text) . '" ' .
  474. 'type="' . (isset($template->type) ? $template->type : "value") . '" ' .
  475. '>' .
  476. '<div class="note-template-text d-flex align-items-center">' .
  477. '<span class="label">' .
  478. '<input type="checkbox" />' .
  479. '<span>' . $template->text . '</span>' .
  480. '</span>';
  481. if (isset($template->type) && $template->type === 'plus-minus') {
  482. echo '<div class="ml-auto mr-2 text-nowrap">';
  483. echo '<a href="#" class="plus-trigger"><i class="fa fa-plus-circle"></i></a>';
  484. echo '<a href="#" class="minus-trigger ml-1"><i class="fa fa-minus-circle"></i></a>';
  485. echo '</div>';
  486. }
  487. echo '</div>';
  488. if (isset($template->children) && count($template->children)) {
  489. echo '<i class="fa fa-chevron-right has-children"></i>';
  490. echo '<div class="note-template-children">';
  491. foreach ($template->children as $t) {
  492. renderNoteTemplate($t, false);
  493. }
  494. echo '</div>';
  495. } else if (isset($template->type) && $template->type !== 'plus-minus') {
  496. echo '<i class="fa fa-chevron-right has-children"></i>';
  497. echo '<div class="note-template-children">';
  498. if ($template->type === 'alpha') {
  499. echo '<textarea class="form-control form-control-sm"></textarea>';
  500. } else {
  501. echo '<input type="' . $template->type . '" class="form-control form-control-sm">';
  502. }
  503. echo '</div>';
  504. }
  505. echo '</div>';
  506. }
  507. }
  508. if(!function_exists('renderNoteTemplates')) {
  509. function renderNoteTemplates($path)
  510. {
  511. $templates = json_decode(file_get_contents($path));
  512. foreach ($templates->templates as $template) {
  513. renderNoteTemplate($template, true);
  514. }
  515. }
  516. }
  517. if(!function_exists('renderNoteExamTemplates')) {
  518. function renderNoteExamTemplates($parentPath, $childPath)
  519. {
  520. $templates = json_decode(file_get_contents($parentPath));
  521. $templates = $templates->templates;
  522. // override as needed with what is in template set
  523. if(file_exists($childPath)) {
  524. $orTemplates = json_decode(file_get_contents($parentPath));
  525. $orTemplates = $orTemplates->templates;
  526. for ($i = 0; $i < count($templates); $i++) {
  527. for ($j = 0; $j < count($orTemplates); $j++) {
  528. if($templates[$i]->text === $orTemplates[$j]->text) {
  529. $templates[$i] = $orTemplates[$j];
  530. }
  531. }
  532. }
  533. }
  534. foreach ($templates as $template) {
  535. renderNoteTemplate($template, true);
  536. }
  537. }
  538. }
  539. if(!function_exists('getVal')) {
  540. function getVal($object, $prop)
  541. {
  542. if (isset($object->$prop)) {
  543. return $object->$prop;
  544. } else {
  545. return '';
  546. }
  547. }
  548. }
  549. if(!function_exists('appTZtoPHPTZ')) {
  550. function appTZtoPHPTZ($_timezone)
  551. {
  552. switch ($_timezone) {
  553. case 'ALASKA':
  554. $timezone = "US/Alaska";
  555. break;
  556. case 'CENTRAL':
  557. $timezone = "US/Central";
  558. break;
  559. case 'HAWAII':
  560. $timezone = "US/Hawaii";
  561. break;
  562. case 'MOUNTAIN':
  563. $timezone = "US/Mountain";
  564. break;
  565. case 'PACIFIC':
  566. $timezone = "US/Pacific";
  567. break;
  568. case 'PUERTO_RICO':
  569. $timezone = "America/Puerto_Rico";
  570. break;
  571. default:
  572. $timezone = "US/Eastern";
  573. break;
  574. }
  575. return $timezone;
  576. }
  577. }
  578. if(!function_exists('convertToTimezone')) {
  579. function convertToTimezone($_dateTime, $_targetTimezone, $_sourceTimezone = 'UTC', $_returnRaw = false)
  580. {
  581. if (!$_dateTime) return $_dateTime;
  582. $date = new \DateTime($_dateTime, new \DateTimeZone($_sourceTimezone));
  583. $date->setTimezone(new \DateTimeZone(appTZtoPHPTZ($_targetTimezone)));
  584. return $_returnRaw ? $date : $date->format('Y-m-d H:i:s');
  585. }
  586. }
  587. if(!function_exists('minutes_to_hhmm')) {
  588. function minutes_to_hhmm($_minutes)
  589. {
  590. $h = intval(floor($_minutes / 60));
  591. $m = $_minutes;
  592. if($h > 0) {
  593. $m = $_minutes - $h * 60;
  594. }
  595. $h = ($h < 10 ? '0' : '') . $h;
  596. $m = ($m < 10 ? '0' : '') . $m;
  597. return $h . ':' . $m;
  598. }
  599. }
  600. if(!function_exists('vsValue')) {
  601. function vsValue($_v, $patient = null, $_direct = false)
  602. {
  603. if ($_direct) {
  604. return $_v ? $_v : '<span class="font-weight-normal text-info font-italic">empty</span>';
  605. }
  606. return @($patient->{$_v}) ? $patient->{$_v} : '<span class="font-weight-normal text-info font-italic">empty</span>';
  607. }
  608. }
  609. if(!function_exists('vsElement')) {
  610. function vsElement($_v, $type, $name, $patient, $class = '')
  611. {
  612. return '<input type="' . $type . '" class="form-control form-control-sm min-width-unset rounded-0 ' . $class . '" ' .
  613. 'name="' . $name . '" ' .
  614. 'value="' . (@($patient->{$_v}) ? $patient->{$_v} : '') . '">';
  615. }
  616. }
  617. if(!function_exists('vsRoElement')) {
  618. function vsRoElement($_v, $type, $name, $patient, $class = '')
  619. {
  620. return '<input type="' . $type . '" readonly class="form-control form-control-sm min-width-unset rounded-0 ' . $class . '" ' .
  621. 'name="' . $name . '" ' .
  622. 'value="' . (@($patient->{$_v}) ? $patient->{$_v} : '') . '">';
  623. }
  624. }
  625. if(!function_exists('str_compact')) {
  626. function str_compact($_str)
  627. {
  628. return preg_replace("/[^a-zA-Z0-9]/", "", strip_tags($_str));
  629. }
  630. }
  631. if(!function_exists('noteMethodDisplay')) {
  632. function noteMethodDisplay($method)
  633. {
  634. if($method === 'IN_CLINIC') return 'In-Clinic';
  635. $method = str_replace('_', ' ', $method);
  636. return ucwords(strtolower($method));
  637. }
  638. }
  639. if(!function_exists('friendly_timezone')) {
  640. function friendly_timezone($tz) {
  641. $map = [
  642. 'EASTERN' => 'EST',
  643. 'CENTRAL' => 'CST',
  644. 'MOUNTAIN' => 'MST',
  645. 'PACIFIC' => 'PST',
  646. 'ALASKA' => 'AST',
  647. 'HAWAII' => 'HST',
  648. 'PUERTO_RICO' => 'PR'
  649. ];
  650. return $map[$tz] ?? str_replace("_", " ", $tz);
  651. }
  652. }