2020-09-03 22:27:44 +00:00
|
|
|
import {BarCodeScanner} from 'expo-barcode-scanner';
|
2020-09-01 19:55:23 +00:00
|
|
|
import React, {ReactElement, useState} from 'react';
|
2020-09-03 22:27:44 +00:00
|
|
|
import {Text, View} from 'react-native';
|
2020-09-02 16:13:16 +00:00
|
|
|
import {Button, DefaultTheme, HelperText, Subheading, TextInput, Title} from 'react-native-paper';
|
2020-08-29 03:40:55 +00:00
|
|
|
import {ButtonProps, ScannerProps} from '../models/ElementProps';
|
2020-09-01 02:12:32 +00:00
|
|
|
import {colors, styles} from './Styles';
|
2020-08-29 03:40:55 +00:00
|
|
|
|
2020-09-01 19:55:23 +00:00
|
|
|
|
2020-08-29 03:40:55 +00:00
|
|
|
export const Scanner = (props: ScannerProps): ReactElement => {
|
2020-09-04 21:50:50 +00:00
|
|
|
return <View style={styles.container}>
|
|
|
|
<View style={styles.container}>
|
|
|
|
<BarCodeScanner
|
|
|
|
type={props.cameraType}
|
|
|
|
onBarCodeScanned={props.onScanned}
|
|
|
|
style={styles.fullScreen}
|
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
<View style={styles.centerMiddle}>
|
|
|
|
<View style={styles.captureBox}/>
|
|
|
|
</View>
|
2020-09-10 22:23:55 +00:00
|
|
|
<Subheading style={styles.shadow}>
|
|
|
|
Instruct the patient to hold their card up with the barcode facing the camera. Keep the barcode in the orange box.
|
|
|
|
</Subheading>
|
2020-09-04 21:50:50 +00:00
|
|
|
<View style={styles.centerMiddle}>
|
|
|
|
<Button
|
|
|
|
mode="text"
|
|
|
|
color={colors.primary}
|
|
|
|
icon="cancel"
|
|
|
|
onPress={props.onCancel}
|
|
|
|
style={styles.btnWhite}
|
|
|
|
>Cancel</Button>
|
|
|
|
</View>
|
|
|
|
</View>;
|
2020-08-29 03:40:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const ScanButton = (props: ButtonProps): ReactElement => {
|
|
|
|
return <Button
|
2020-09-01 02:12:32 +00:00
|
|
|
icon="camera"
|
|
|
|
mode="contained"
|
|
|
|
color={colors.accent}
|
2020-08-29 03:40:55 +00:00
|
|
|
onPress={props.onClicked}
|
2020-09-01 02:12:32 +00:00
|
|
|
style={styles.btnLg}
|
|
|
|
labelStyle={styles.btnLg}
|
|
|
|
>Scan Barcode</Button>;
|
2020-08-29 03:40:55 +00:00
|
|
|
};
|
2020-09-02 16:13:16 +00:00
|
|
|
|
|
|
|
export const InputIdButton = (props: ButtonProps): ReactElement => {
|
|
|
|
return <Button
|
|
|
|
icon="keyboard"
|
|
|
|
mode="text"
|
|
|
|
color={colors.onBackground}
|
|
|
|
onPress={props.onClicked}
|
2020-09-04 21:50:50 +00:00
|
|
|
style={{marginTop: 30}}
|
2020-09-02 16:13:16 +00:00
|
|
|
>Enter ID Number Manually</Button>;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const IdNumberInput = (props: ScannerProps): ReactElement => {
|
|
|
|
const [inputStr, setInputStr] = useState<string>('');
|
|
|
|
const pattern = /^[\d]{9}$/;
|
|
|
|
const hasErrors = () => {
|
|
|
|
return !pattern.test(inputStr);
|
|
|
|
};
|
|
|
|
|
|
|
|
const onSubmit = () => {
|
|
|
|
props.onScanned({type: '', data: inputStr});
|
|
|
|
}
|
|
|
|
|
|
|
|
return <View style={styles.settings}>
|
2020-09-04 21:50:50 +00:00
|
|
|
<Title style={styles.headingInverse}>Manual ID # Entry</Title>
|
2020-09-02 16:13:16 +00:00
|
|
|
<View style={{marginBottom: 10}}>
|
|
|
|
<Subheading style={{color: DefaultTheme.colors.text, marginBottom: 60}}>
|
2020-09-03 22:27:44 +00:00
|
|
|
Please double check that you have entered the number correctly. Entering an incorrect ID number will prevent
|
|
|
|
patients from receiving their test results.
|
2020-09-02 16:13:16 +00:00
|
|
|
</Subheading>
|
|
|
|
<TextInput
|
|
|
|
label="ID #"
|
|
|
|
value={inputStr}
|
|
|
|
onChangeText={inputStr => setInputStr(inputStr)}
|
|
|
|
mode="outlined"
|
|
|
|
theme={DefaultTheme}
|
2020-09-10 22:23:55 +00:00
|
|
|
keyboardType="numeric"
|
2020-09-02 16:13:16 +00:00
|
|
|
/>
|
|
|
|
<HelperText type="error" visible={hasErrors()}>
|
|
|
|
ID number must be exactly 9 digits. No other characters are allowed.
|
|
|
|
</HelperText>
|
|
|
|
<Button
|
|
|
|
icon="check"
|
|
|
|
mode="contained"
|
|
|
|
color={colors.primary}
|
|
|
|
style={{marginBottom: 10}}
|
|
|
|
disabled={hasErrors()}
|
|
|
|
onPress={onSubmit}
|
|
|
|
>Submit</Button>
|
|
|
|
<Button
|
|
|
|
icon="cancel"
|
|
|
|
mode="outlined"
|
|
|
|
color={colors.primary}
|
|
|
|
onPress={props.onCancel}
|
|
|
|
>Cancel</Button>
|
|
|
|
</View>
|
|
|
|
</View>;
|
|
|
|
};
|