Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // @flow
- import data, {
- type Patient as BasePatient,
- type Reading as BaseReading,
- } from "./data.json";
- export type Reading = $Diff<BaseReading, { timestamp: string }> & {
- timestamp: number,
- };
- export type Patient = ($Diff<BasePatient, { readings: BaseReading[] }> & {
- title: string,
- readings: Reading[],
- });
- const patients : Patient = data.patients.map(p => ({
- ...p,
- title: `${p.mrn} / ${p.sex}`,
- readings: p.readings.map(r => ({
- ...r,
- timestamp: Date.parse(r.timestamp),
- })),
- }));
- const readings = patients.reduce(
- (acc, { readings, ...p }) => [...acc, ...readings.map(r => ({ ...r, ...p }))],
- [],
- );
- export { patients, readings };
Add Comment
Please, Sign In to add comment