-- screening table

create table `profile_checkcare` (
	id 				varchar(60) 	not null primary key, -- ktp
	name 			varchar(36) 	not null,
	dob 			date 			not null, -- date of birth
	sex 			varchar(6) 		default null
) engine=InnoDB default charset=utf8mb4;

create table `checkcare_bmi` ( -- indeks massa tubuh
	id				int(11) 		not null auto_increment primary key,
	`profile`		varchar(60)		not null,
	`weight`		double 			not null,
	`height`		double 			not null,
	`when`			date 			not null,
	key				`idx_profile` 	(`profile`),
	constraint 		`checkcare_bmi_fk_profile`
		foreign key (`profile`) references `profile_checkcare` (`id`)
		on update cascade
		on delete cascade
) engine=InnoDB default charset=utf8mb4;

create table `checkcare_temp` (
	id 				int(11)			not null auto_increment primary key,
	`profile`		varchar(60)		not null,
	`temperature` 	double			not null,
	`scale`			varchar(3)		not null, -- C, F, or K
	`when`			datetime		not null,
	key				`idx_profile` 	(`profile`),
	constraint 		`checkcare_bmi_fk_profile`
		foreign key (`profile`) references `profile_checkcare` (`id`)
		on update cascade
		on delete cascade
)

/*
profile output:
- id
- name
- dob
- age
- sex
- weight
- height
- fasting record
- clinical history

bmi output:
- weight
- height
- age
- sex
- result
- when

temp output:
- when
- temperature
*/
