import { Fragment } from 'inferno';
import { useBackend } from '../backend';
import { Box, Button, Collapsible, Icon, Input, LabeledList, Section, Tabs } from '../components';
import { ComplexModal, modalOpen, modalRegisterBodyOverride } from '../interfaces/common/ComplexModal';
import { Window } from '../layouts';
import { LoginInfo } from './common/LoginInfo';
import { LoginScreen } from './common/LoginScreen';
import { TemporaryNotice } from './common/TemporaryNotice';
const severities = {
'Minor': 'good',
'Medium': 'average',
'Dangerous!': 'bad',
'Harmful': 'bad',
'BIOHAZARD THREAT!': 'bad',
};
const doEdit = (context, field) => {
modalOpen(context, 'edit', {
field: field.edit,
value: field.value,
});
};
const virusModalBodyOverride = (modal, context) => {
const { act } = useBackend(context);
const virus = modal.args;
return (
act('modal_close')} />}>
{virus.spread_text} Transmission
{virus.antigen}
{virus.rate}
{virus.resistance}%
{virus.species}
{virus.symptoms.map((s) => (
Strength:
{' '}
{s.strength}
Aggressiveness:
{' '}
{s.aggressiveness}
))}
);
};
export const MedicalRecords = (_properties, context) => {
const { data } = useBackend(context);
const { authenticated, screen } = data;
if (!authenticated) {
return (
);
}
let body;
if (screen === 2) {
// List Records
body = ;
} else if (screen === 3) {
// Record Maintenance
body = ;
} else if (screen === 4) {
// View Records
body = ;
} else if (screen === 5) {
// Virus Database
body = ;
} else if (screen === 6) {
// Medbot Tracking
body = ;
}
return (
);
};
const MedicalRecordsList = (_properties, context) => {
const { act, data } = useBackend(context);
const { records } = data;
return (
act('search', { t1: value })}
/>
{records.map((record, i) => (
);
};
const MedicalRecordsMaintenance = (_properties, context) => {
const { act } = useBackend(context);
return (
act('del_all')} />
);
};
const MedicalRecordsView = (_properties, context) => {
const { act, data } = useBackend(context);
const { medical, printing } = data;
return (
act('del_r')}
/>
);
};
const MedicalRecordsViewGeneral = (_properties, context) => {
const { data } = useBackend(context);
const { general } = data;
if (!general || !general.fields) {
return General records lost!;
}
return (
{general.fields.map((field, i) => (
{field.value}
{!!field.edit && doEdit(context, field)} />}
))}
{!!general.has_photos &&
general.photos.map((p, i) => (
Photo #{i + 1}
))}
);
};
const MedicalRecordsViewMedical = (_properties, context) => {
const { act, data } = useBackend(context);
const { medical } = data;
if (!medical || !medical.fields) {
return (
Medical records lost!
act('new')} />
);
}
return (
{medical.fields.map((field, i) => (
{field.value}
doEdit(context, field)}
/>
))}
{medical.comments.length === 0 ? (
No comments found.
) : (
medical.comments.map((comment, i) => (
{comment.header}
{comment.text}
act('del_c', { del_c: i + 1 })} />
))
)}
modalOpen(context, 'add_c')}
/>
);
};
const MedicalRecordsViruses = (_properties, context) => {
const { act, data } = useBackend(context);
const { virus } = data;
virus.sort((a, b) => (a.name > b.name ? 1 : -1));
return virus.map((vir, i) => (
act('vir', { vir: vir.D })} />
));
};
const MedicalRecordsMedbots = (_properties, context) => {
const { data } = useBackend(context);
const { medbots } = data;
if (medbots.length === 0) {
return There are no Medbots.;
}
return medbots.map((medbot, i) => (
{medbot.area || 'Unknown'} ({medbot.x}, {medbot.y})
{medbot.on ? (
Online
{medbot.use_beaker
? 'Reservoir: ' + medbot.total_volume + '/' + medbot.maximum_volume
: 'Using internal synthesizer.'}
) : (
Offline
)}
));
};
const MedicalRecordsNavigation = (_properties, context) => {
const { act, data } = useBackend(context);
const { screen } = data;
return (
act('screen', { screen: 2 })}>
List Records
act('screen', { screen: 5 })}>
Virus Database
act('screen', { screen: 6 })}>
Medbot Tracking
act('screen', { screen: 3 })}>
Record Maintenance
);
};
modalRegisterBodyOverride('virus', virusModalBodyOverride);