<script>
	import { onDestroy } from 'svelte';
	import { navlinks } from '$lib/stores.js';

	export let data;
	const links = navlinks.push({
		name: data.facesheet_data.name ? data.facesheet_data.name.split(',')[0].toLowerCase().replace(/(?:^|\s|["'([{])+\S/g, m => m.toUpperCase()) + ' ' + data.facesheet_data.ssn.split('-')[2] : 'Chart',
		href: '/chart/' + data.mrn,
		children: [
			{ name: 'Orders',		href: '/chart/' + data.mrn + '/orders' },
			{ name: 'Labs',			href: '/chart/' + data.mrn + '/labs' },
			{ name: 'Notes',		href: '/chart/' + data.mrn + '/notes' },
			{ name: 'Flowsheet',	href: '/chart/' + data.mrn + '/flowsheet' },
		]
	});
	onDestroy(() => navlinks.pop(links));
</script>

<slot />
