From 477a924fe034b4f778e313708e1c91e992eb836a Mon Sep 17 00:00:00 2001 From: abhay-raizada Date: Mon, 17 Jun 2024 17:51:09 +0530 Subject: [PATCH] Medicine Form --- components/PrescriptionCreator/ImportNsec.tsx | 94 +++++++++++----- .../PrescriptionCreator/MedicineForm.tsx | 101 ++++++++++++++++++ components/PrescriptionCreator/index.tsx | 30 +----- yarn.lock | 2 +- 4 files changed, 172 insertions(+), 55 deletions(-) create mode 100644 components/PrescriptionCreator/MedicineForm.tsx diff --git a/components/PrescriptionCreator/ImportNsec.tsx b/components/PrescriptionCreator/ImportNsec.tsx index 1b37eb0..07f6e1f 100644 --- a/components/PrescriptionCreator/ImportNsec.tsx +++ b/components/PrescriptionCreator/ImportNsec.tsx @@ -1,30 +1,68 @@ -import { useState } from "react"; -import { Button, Modal, NativeSyntheticEvent, Text, TextInput, TextInputChangeEventData, View } from "react-native" +import {useState} from 'react'; +import { + Button, + Modal, + NativeSyntheticEvent, + Text, + TextInput, + TextInputChangeEventData, + View, +} from 'react-native'; -export const ImportNsec = ({ isVisible, onClose, onPress }: { isVisible: boolean, onClose: () => void, onPress: (nsec: `nsec1${string}`) => void }) => { +export const ImportNsec = ({ + isVisible, + onClose, + onPress, +}: { + isVisible: boolean; + onClose: () => void; + onPress: (nsec: `nsec1${string}`) => void; +}) => { + const [nsec, setNsec] = useState(''); - const [nsec, setNsec] = useState(""); - - const handleNsec = (value: string) => { - setNsec(value) - } - return ( - { console.log("closing....") ; onClose(); return true }} - onDismiss={() => {onClose()}} - presentationStyle="pageSheet"> - - - - Import Your Nsec - - - - - - - - - ) -} \ No newline at end of file + const handleNsec = (value: string) => { + setNsec(value); + }; + return ( + { + console.log('closing....'); + onClose(); + return true; + }} + onDismiss={() => { + onClose(); + }} + presentationStyle="pageSheet"> + + + Import Your Nsec + + + + + + + + ); +}; diff --git a/components/PrescriptionCreator/MedicineForm.tsx b/components/PrescriptionCreator/MedicineForm.tsx new file mode 100644 index 0000000..f086eab --- /dev/null +++ b/components/PrescriptionCreator/MedicineForm.tsx @@ -0,0 +1,101 @@ +import {Text, TextInput, View} from 'react-native'; +import {Section} from './Section'; +import {styles, TextTheme} from './styles'; +import {useState} from 'react'; + +interface MedicineForm { + name?: string; + dosage_form?: string; + strength?: string; + quantity?: string; + refills?: string; + directions?: string; +} + +interface MedicineFormProps { + nestedFormCallback: (tag: string, form: Object) => void; +} + +export const MedicineForm: React.FC = ({ + nestedFormCallback, +}) => { + const [form, setForm] = useState({}); + + const handleTextChange = (tag: keyof MedicineForm, text: string) => { + let newForm = {...form}; + newForm[tag] = text; + setForm(newForm); + nestedFormCallback('MedicationPrescribed', newForm); + }; + + return ( +
+ + + Name of Medicine + handleTextChange('name', text)} + /> + + + Form of Dosage + + handleTextChange('dosage_form', text) + } + /> + + + Strength + handleTextChange('strength', text)} + /> + + + Quantity + handleTextChange('quantity', text)} + /> + + + Refills + handleTextChange('refills', text)} + /> + + + Directions + + handleTextChange('directions', text) + } + /> + + +
+ ); +}; diff --git a/components/PrescriptionCreator/index.tsx b/components/PrescriptionCreator/index.tsx index 853da74..8455824 100644 --- a/components/PrescriptionCreator/index.tsx +++ b/components/PrescriptionCreator/index.tsx @@ -1,46 +1,23 @@ import {Alert, Appearance, Dimensions, Image, Text, View} from 'react-native'; import {Colors} from 'react-native/Libraries/NewAppScreen'; -import {PropsWithChildren, useEffect, useState} from 'react'; -import {Button, Card, Modal} from '@ant-design/react-native'; +import {useEffect, useState} from 'react'; +import {Button} from '@ant-design/react-native'; // import { SendPrescription } from './sendPrescription'; import {Dropdown} from 'react-native-element-dropdown'; import { SimplePool, UnsignedEvent, finalizeEvent, - generateSecretKey, getPublicKey, nip04, nip19, } from 'nostr-tools'; import EncryptedStorage from 'react-native-encrypted-storage'; import {ImportNsec} from './ImportNsec'; -import {json2xml} from 'xml-js'; import {Section} from './Section'; import {PatientForm} from './PatientForm'; import {AddressForm} from './AddressForm'; - -/* - Patient - - Name - - Date Of Birth - - Address - - Address Line 1 - - City - - StateProvince - - Postal Code - - Country Code - - Medicine - - Name - - Dosage Form - - Strength - - Quantity - - Re-fills - - Directions - ` - */ +import {MedicineForm} from './MedicineForm'; function OBJtoXML(obj: any) { var xml = ''; @@ -254,6 +231,7 @@ export const PrescriptionCreator = () => { +