mirror of
https://github.com/abhay-raizada/PeerScribe.git
synced 2026-04-26 16:24:03 +00:00
Compare commits
2 Commits
58f145859a
...
fixes
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
85ef6310e2 | ||
|
|
d0dac925e9 |
@@ -13,18 +13,21 @@ interface AddressForm {
|
|||||||
|
|
||||||
interface AddressFormProps {
|
interface AddressFormProps {
|
||||||
nestedFormCallback: (tag: string, form: Object) => void;
|
nestedFormCallback: (tag: string, form: Object) => void;
|
||||||
|
initForm: {[key: string]: any};
|
||||||
}
|
}
|
||||||
|
const ADDRESS_KEY = 'Address';
|
||||||
|
|
||||||
export const AddressForm: React.FC<AddressFormProps> = ({
|
export const AddressForm: React.FC<AddressFormProps> = ({
|
||||||
nestedFormCallback,
|
nestedFormCallback,
|
||||||
|
initForm,
|
||||||
}) => {
|
}) => {
|
||||||
const [form, setForm] = useState<AddressForm>({});
|
const [form, setForm] = useState<AddressForm>(initForm[ADDRESS_KEY] || {});
|
||||||
|
|
||||||
const handleTextChange = (tag: keyof AddressForm, text: string) => {
|
const handleTextChange = (tag: keyof AddressForm, text: string) => {
|
||||||
let newForm = {...form};
|
let newForm = {...form};
|
||||||
newForm[tag] = text;
|
newForm[tag] = text;
|
||||||
setForm(newForm);
|
setForm(newForm);
|
||||||
nestedFormCallback('Address', newForm);
|
nestedFormCallback(ADDRESS_KEY, newForm);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -12,20 +12,24 @@ interface MedicineForm {
|
|||||||
directions?: string;
|
directions?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MEDICINE_KEY = 'MedicationPrescribed';
|
||||||
|
|
||||||
interface MedicineFormProps {
|
interface MedicineFormProps {
|
||||||
nestedFormCallback: (tag: string, form: Object) => void;
|
nestedFormCallback: (tag: string, form: Object) => void;
|
||||||
|
initForm: {[key: string]: any};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MedicineForm: React.FC<MedicineFormProps> = ({
|
export const MedicineForm: React.FC<MedicineFormProps> = ({
|
||||||
nestedFormCallback,
|
nestedFormCallback,
|
||||||
|
initForm,
|
||||||
}) => {
|
}) => {
|
||||||
const [form, setForm] = useState<MedicineForm>({});
|
const [form, setForm] = useState<MedicineForm>(initForm[MEDICINE_KEY] || {});
|
||||||
|
|
||||||
const handleTextChange = (tag: keyof MedicineForm, text: string) => {
|
const handleTextChange = (tag: keyof MedicineForm, text: string) => {
|
||||||
let newForm = {...form};
|
let newForm = {...form};
|
||||||
newForm[tag] = text;
|
newForm[tag] = text;
|
||||||
setForm(newForm);
|
setForm(newForm);
|
||||||
nestedFormCallback('MedicationPrescribed', newForm);
|
nestedFormCallback(MEDICINE_KEY, newForm);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -85,7 +89,7 @@ export const MedicineForm: React.FC<MedicineFormProps> = ({
|
|||||||
<TextInput
|
<TextInput
|
||||||
style={styles.input}
|
style={styles.input}
|
||||||
placeholder="Enter directions"
|
placeholder="Enter directions"
|
||||||
value={form.refills}
|
value={form.directions}
|
||||||
placeholderTextColor="white"
|
placeholderTextColor="white"
|
||||||
onChangeText={(text: string) => handleTextChange('directions', text)}
|
onChangeText={(text: string) => handleTextChange('directions', text)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -11,19 +11,25 @@ interface PatientForm {
|
|||||||
|
|
||||||
interface PatientFormProps {
|
interface PatientFormProps {
|
||||||
nestedFormCallback: (tag: string, form: Object) => void;
|
nestedFormCallback: (tag: string, form: Object) => void;
|
||||||
|
initForm: {[key: string]: any};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const PATIENT_KEY = 'patient';
|
||||||
|
|
||||||
export const PatientForm: React.FC<PatientFormProps> = ({
|
export const PatientForm: React.FC<PatientFormProps> = ({
|
||||||
nestedFormCallback,
|
nestedFormCallback,
|
||||||
|
initForm,
|
||||||
}) => {
|
}) => {
|
||||||
const [form, setForm] = useState<PatientForm>({});
|
const [form, setForm] = useState<PatientForm>(
|
||||||
|
initForm[PATIENT_KEY]?.['human_patient'] || {},
|
||||||
|
);
|
||||||
const [openDate, setOpenDate] = useState<boolean>(false);
|
const [openDate, setOpenDate] = useState<boolean>(false);
|
||||||
|
|
||||||
const handleTextChange = (tag: 'name' | 'date_of_birth', text: string) => {
|
const handleTextChange = (tag: 'name' | 'date_of_birth', text: string) => {
|
||||||
let newForm = {...form};
|
let newForm = {...form};
|
||||||
newForm[tag] = text;
|
newForm[tag] = text;
|
||||||
setForm(newForm);
|
setForm(newForm);
|
||||||
nestedFormCallback('patient', {human_patient: newForm});
|
nestedFormCallback(PATIENT_KEY, {human_patient: newForm});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -62,7 +68,7 @@ export const PatientForm: React.FC<PatientFormProps> = ({
|
|||||||
modal
|
modal
|
||||||
mode={'date'}
|
mode={'date'}
|
||||||
open={openDate}
|
open={openDate}
|
||||||
date={new Date(form.date_of_birth || '01-01-1999')}
|
date={new Date(form.date_of_birth || '1990-01-01')}
|
||||||
onCancel={() => setOpenDate(false)}
|
onCancel={() => setOpenDate(false)}
|
||||||
onConfirm={(date: Date) => {
|
onConfirm={(date: Date) => {
|
||||||
handleTextChange('date_of_birth', date.toDateString());
|
handleTextChange('date_of_birth', date.toDateString());
|
||||||
|
|||||||
@@ -171,13 +171,22 @@ export const PrescriptionCreator = () => {
|
|||||||
<View style={{display: 'flex', flexDirection: 'column', width: '100%'}}>
|
<View style={{display: 'flex', flexDirection: 'column', width: '100%'}}>
|
||||||
<Section title="Patient" collapsible={true}>
|
<Section title="Patient" collapsible={true}>
|
||||||
{' '}
|
{' '}
|
||||||
<PatientForm nestedFormCallback={nestedFormCallback} />
|
<PatientForm
|
||||||
|
initForm={finalJSON}
|
||||||
|
nestedFormCallback={nestedFormCallback}
|
||||||
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
<Section title="Address" collapsible={true}>
|
<Section title="Address" collapsible={true}>
|
||||||
<AddressForm nestedFormCallback={nestedFormCallback} />
|
<AddressForm
|
||||||
|
initForm={finalJSON}
|
||||||
|
nestedFormCallback={nestedFormCallback}
|
||||||
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
<Section title="Medicine" collapsible={true}>
|
<Section title="Medication" collapsible={true}>
|
||||||
<MedicineForm nestedFormCallback={nestedFormCallback} />
|
<MedicineForm
|
||||||
|
initForm={finalJSON}
|
||||||
|
nestedFormCallback={nestedFormCallback}
|
||||||
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
<View style={{margin: 15}}>
|
<View style={{margin: 15}}>
|
||||||
<Button onPress={handleButtonPress} title="Create Rx" />
|
<Button onPress={handleButtonPress} title="Create Rx" />
|
||||||
|
|||||||
Reference in New Issue
Block a user