diff --git a/src/scheduling/appointments/service/Appointments.tsx b/src/scheduling/appointments/service/Appointments.tsx
deleted file mode 100644
index c57dda8725..0000000000
--- a/src/scheduling/appointments/service/Appointments.tsx
+++ /dev/null
@@ -1,234 +0,0 @@
-import axios from 'axios'
-import dotenv from 'dotenv'
-import Appointment from '../../../shared/model/Appointment'
-dotenv.config()
-
-const endpoint = `${process.env.REACT_APP_ENDPOINT}`
-
-const config = {
- headers: {
- Authorization: `${process.env.REACT_APP_AUTHORIZATION}`,
- 'x-source-id': `${process.env.REACT_APP_XSOURCEID}`,
- },
-}
-
-export const getAppointment = () => {
- return axios
- .get(`${endpoint}/Appointment?practitioner=140857915539458`, config)
- .then(async (response) => {
- console.log(response)
- const data = await response.data
- console.log(data)
- console.log(data.data.entry)
- return data.data.entry
- })
- .catch((error) => {
- console.log(error)
- })
-}
-
-export const getAppointmentId = (id: number) => {
- return axios
- .get(`${endpoint}/Appointment/${id}`, config)
- .then(async (response) => {
- console.log(response)
- const data = await response.data
- console.log(data)
- console.log(data.data)
- return data.data
- })
- .catch((error) => {
- console.log(error)
- })
-}
-
-export const createAppointment = (appointment: Appointment) => {
- console.log(appointment)
-
- const data = {
- data: {
- resourceType: 'Appointment',
- start: new Date(appointment.start),
- minutesDuration: appointment.minutesDuration,
- description: '',
- meta: {},
- created: new Date(Date.now()),
- status: appointment.status ? appointment.status : 'Scheduled',
- participant: [
- {
- actor: {
- reference: `Patient/${appointment.patientId}`,
- },
- },
- {
- actor: {
- reference: 'Practitioner/140857915539458',
- },
- },
- {
- actor: {
- reference: 'HealthcareService/140857911017476',
- },
- },
- ],
- extension: [
- {
- url: 'http://xcaliber-fhir/structureDefinition/slot-type',
- valueString: 'appointment',
- },
- {
- url: 'http://xcaliber-fhir/structureDefinition/appointment-mode',
- valueString: 'IN_PERSON',
- },
- {
- url: 'http://xcaliber-fhir/structureDefinition/status',
- extension: [
- {
- url: 'http://xcaliber-fhir/structureDefinition/status',
- valueString: `${appointment.status ? appointment.status : 'Scheduled'}`,
- },
- {
- url: 'http://xcaliber-fhir/structureDefinition/room',
- valueString: null,
- },
- ],
- },
- ],
- appointmentType: {
- coding: [
- {
- system: 'https://hl7.org/fhir/v2/ValueSet/appointment-type',
- code: `${
- appointment.appointmentType ? appointment.appointmentType.text : 'Routine Visit'
- }`,
- display: `${
- appointment.appointmentType ? appointment.appointmentType.text : 'Routine Visit'
- }`,
- },
- ],
- text: `${appointment.appointmentType ? appointment.appointmentType.text : 'Routine Visit'}`,
- },
- patientInstruction: null,
- contained: [],
- },
- }
-
- console.log(data)
-
- return axios
- .post(`${endpoint}/Appointment`, data, config)
- .then(async (response) => {
- console.log(response)
- const data = response.data
- console.log(data.data)
- return data.data
- })
- .catch((error) => {
- console.log(error)
- return { id: 404, status: 'error' }
- })
-}
-
-export const updateAppointment = (appointment: Appointment) => {
- console.log(appointment)
- const data = {
- data: {
- resourceType: 'Appointment',
- start: new Date(appointment.start),
- minutesDuration: appointment.minutesDuration,
- description: '',
- meta: {},
- created: new Date(Date.now()),
- status: appointment.status,
- participant: [
- {
- actor: {
- reference: `Patient/${
- appointment.patientId
- ? appointment.patientId
- : appointment?.participant[0].actor.reference.substring(8)
- }`,
- },
- },
- {
- actor: {
- reference: 'Practitioner/140857915539458',
- },
- },
- {
- actor: {
- reference: 'HealthcareService/140857911017476',
- },
- },
- ],
- extension: [
- {
- url: 'http://xcaliber-fhir/structureDefinition/slot-type',
- valueString: 'appointment',
- },
- {
- url: 'http://xcaliber-fhir/structureDefinition/appointment-mode',
- valueString: 'IN_PERSON',
- },
- {
- url: 'http://xcaliber-fhir/structureDefinition/status',
- extension: [
- {
- url: 'http://xcaliber-fhir/structureDefinition/status',
- valueString: `${appointment.status ? appointment.status : 'Scheduled'}`,
- },
- {
- url: 'http://xcaliber-fhir/structureDefinition/room',
- valueString: null,
- },
- ],
- },
- ],
- appointmentType: {
- coding: [
- {
- system: 'https://hl7.org/fhir/v2/ValueSet/appointment-type',
- code: `${
- appointment.appointmentType.text ? appointment.appointmentType.text : 'Routine visit'
- }`,
- display: `${
- appointment.appointmentType.text ? appointment.appointmentType.text : 'Routine visit'
- }`,
- },
- ],
- text: `${
- appointment.appointmentType.text ? appointment.appointmentType.text : 'Routine visit'
- }`,
- },
- patientInstruction: null,
- contained: [],
- },
- }
-
- console.log(data)
- return axios
- .put(`${endpoint}/Appointment/${appointment.id}`, data, config)
- .then(async (response) => {
- console.log(response)
- const data = response.data
- console.log(data.data)
- return data.data
- })
- .catch((error) => {
- console.log(error)
- return { id: 404, status: 'error' }
- })
-}
-
-export const deleteAppointment = (id: number) => {
- return axios
- .delete(`${endpoint}/Appointment/${id}`, config)
- .then((response) => {
- console.log(response)
- return 'success'
- })
- .catch((error) => {
- console.log(error)
- return 'error'
- })
-}
diff --git a/src/scheduling/appointments/service/Patients.tsx b/src/scheduling/appointments/service/Patients.tsx
deleted file mode 100644
index 00cec176d2..0000000000
--- a/src/scheduling/appointments/service/Patients.tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-import axios from 'axios'
-import dotenv from 'dotenv'
-dotenv.config()
-
-const endpoint = `${process.env.REACT_APP_ENDPOINT}`
-
-const config = {
- headers: {
- Authorization: `${process.env.REACT_APP_AUTHORIZATION}`,
- 'x-source-id': `${process.env.REACT_APP_XSOURCEID}`,
- },
-}
-
-export const getAllPatients = () => {
- return axios
- .get(`${endpoint}/Patient`, config)
- .then(async (response) => {
- console.log(response)
- const data = await response.data
- console.log(data)
- return data.data.entry
- })
- .catch((error) => {
- console.log(error)
- })
-}
-
-export const getPatientNameById = (id: number) => {
- return axios
- .get(`${endpoint}/Patient/${id}`, config)
- .then(async (response) => {
- console.log(response)
- const data = await response.data
- console.log(data)
- console.log(data.data.name[0].given.join(' '))
- const name = data.data.name[0].given.join(' ')
- return name
- })
- .catch((error) => {
- console.log(error)
- })
-}
diff --git a/src/scheduling/appointments/util/scheduling-appointment.util.ts b/src/scheduling/appointments/util/scheduling-appointment.util.ts
index 2f6145f8a6..ac049e500f 100644
--- a/src/scheduling/appointments/util/scheduling-appointment.util.ts
+++ b/src/scheduling/appointments/util/scheduling-appointment.util.ts
@@ -17,11 +17,9 @@ export function getAppointmentLabel(appointment: Appointment | undefined) {
return ''
}
- const { id, start,minutesDuration} = appointment
+ const { id, startDateTime, endDateTime } = appointment
- return start
- ? `${toLocaleString(new Date(start))} - ${toLocaleString(new Date(
- new Date(start).setMinutes(new Date(start).getMinutes() + minutesDuration),
- ))}`
+ return startDateTime && endDateTime
+ ? `${toLocaleString(new Date(startDateTime))} - ${toLocaleString(new Date(endDateTime))}`
: id
}
diff --git a/src/scheduling/appointments/util/validate-appointment.ts b/src/scheduling/appointments/util/validate-appointment.ts
index f47a8af231..b490b5ca43 100644
--- a/src/scheduling/appointments/util/validate-appointment.ts
+++ b/src/scheduling/appointments/util/validate-appointment.ts
@@ -18,12 +18,10 @@ export class AppointmentError extends Error {
export default function validateAppointment(appointment: Appointment): AppointmentError {
const newError: any = {}
- if (!appointment.patientId) {
+ if (!appointment.patient) {
newError.patient = 'scheduling.appointment.errors.patientRequired'
}
- if (isBefore(new Date(
- new Date(appointment.start).setMinutes(new Date(appointment.start).getMinutes() + appointment.minutesDuration),
- ), new Date(appointment.start))) {
+ if (isBefore(new Date(appointment.endDateTime), new Date(appointment.startDateTime))) {
newError.startDateTime = 'scheduling.appointment.errors.startDateMustBeBeforeEndDate'
}
diff --git a/src/scheduling/appointments/view/ViewAppointment.tsx b/src/scheduling/appointments/view/ViewAppointment.tsx
index 947ded3065..23b5518ecb 100644
--- a/src/scheduling/appointments/view/ViewAppointment.tsx
+++ b/src/scheduling/appointments/view/ViewAppointment.tsx
@@ -2,24 +2,18 @@ import { Spinner, Button, Modal, Toast } from '@hospitalrun/components'
import React, { useCallback, useEffect, useState } from 'react'
import { useSelector } from 'react-redux'
import { useHistory, useParams } from 'react-router-dom'
+
import useAddBreadcrumbs from '../../../page-header/breadcrumbs/useAddBreadcrumbs'
import { useButtonToolbarSetter } from '../../../page-header/button-toolbar/ButtonBarProvider'
import { useUpdateTitle } from '../../../page-header/title/TitleContext'
-import Loading from '../../../shared/components/Loading'
-// import usePatient from '../../../patients/hooks/usePatient'
+import usePatient from '../../../patients/hooks/usePatient'
import useTranslator from '../../../shared/hooks/useTranslator'
-import Appointment from '../../../shared/model/Appointment'
-import Patient from '../../../shared/model/Patient'
import Permissions from '../../../shared/model/Permissions'
import { RootState } from '../../../shared/store'
-// import useAppointment from '../../hooks/useAppointment'
-// import useDeleteAppointment from '../../hooks/useDeleteAppointment'
+import useAppointment from '../../hooks/useAppointment'
+import useDeleteAppointment from '../../hooks/useDeleteAppointment'
import AppointmentDetailForm from '../AppointmentDetailForm'
-import { deleteAppointment, getAppointmentId } from '../service/Appointments'
-import { getPatientNameById } from '../service/Patients'
import { getAppointmentLabel } from '../util/scheduling-appointment.util'
-// import { getAppointmentLabel } from '../util/scheduling-appointment.util'
-// import { Appointment } from '../ViewAppointments'
const ViewAppointment = () => {
const { t } = useTranslator()
@@ -33,43 +27,13 @@ const ViewAppointment = () => {
const { id } = useParams
()
const history = useHistory()
- // const [deleteMutate] = useDeleteAppointment()
+ const [deleteMutate] = useDeleteAppointment()
const [showDeleteConfirmation, setShowDeleteConfirmation] = useState(false)
const setButtonToolBar = useButtonToolbarSetter()
const { permissions } = useSelector((state: RootState) => state.user)
- // const { data: appointment } = useAppointment(id)
-
- const [appointment, setAppointment] = useState()
- const [patientName, setPatientName] = useState()
- const [isLoading, setIsLoading] = useState(true)
-
- const appointmentFunc = async () => {
- setAppointment(await getAppointmentId(id))
- setIsLoading(false)
- }
-
- const patientFunc = async () => {
- setPatientName(
- await getPatientNameById(
- parseInt(String(appointment?.participant[0].actor.reference.substr(8))),
- ),
- )
- }
-
- useEffect(() => {
- console.log(id)
- appointmentFunc()
- }, [])
-
- useEffect(() => {
- if (appointment) {
- console.log('view appointment', appointment)
- patientFunc()
- }
- }, [appointment])
-
- // const { data: patient } = usePatient(appointment ? appointment.patient : id)
+ const { data: appointment } = useAppointment(id)
+ const { data: patient } = usePatient(appointment ? appointment.patient : id)
const breadcrumbs = [
{ i18nKey: 'scheduling.appointments.label', location: '/appointments' },
{ text: appointment ? getAppointmentLabel(appointment) : '', location: `/patients/${id}` },
@@ -81,27 +45,15 @@ const ViewAppointment = () => {
setShowDeleteConfirmation(true)
}
- const onDeleteConfirmationButtonClick = async () => {
+ const onDeleteConfirmationButtonClick = () => {
if (!appointment) {
return
}
- console.log(appointment)
-
- // deleteMutate({ appointmentId: appointment.id }).then(() => {
- // history.push('/appointments')
- // Toast('success', t('states.success'), t('scheduling.appointment.successfullyDeleted'))
- // })
-
- let status = await deleteAppointment(parseInt(appointment.id))
-
- if (status === 'success') {
+ deleteMutate({ appointmentId: appointment.id }).then(() => {
history.push('/appointments')
Toast('success', t('states.success'), t('scheduling.appointment.successfullyDeleted'))
- } else {
- Toast('error', t('states.error'), 'Could not delete appointment')
- }
-
+ })
setShowDeleteConfirmation(false)
}
@@ -147,19 +99,11 @@ const ViewAppointment = () => {
}
}, [getButtons, setButtonToolBar])
- if (isLoading || appointment === undefined) {
- return
- }
-
return (
<>
- {patientName && appointment ? (
+ {patient && appointment ? (
-
+
{
+ var date = new Date(item)
+ console.log('date: ', date)
+ // var formattedDate = format(date, 'yyyy-mm-dd')
+ var formattedDate = moment(date).format('YYYY-MM-DD')
+ console.log('formattedDate', formattedDate)
+ // let year = formattedDate.substring(0, 5)
+ // let month = formattedDate.substring(5, 7)
+ // if (parseInt(month) < 10) {
+ // month = '0' + (parseInt(month) + 1)
+ // } else {
+ // month = '' + (parseInt(month) + 1)
+ // }
+ // let day = formattedDate.substring(7, 10)
+ // let finalDate = year + month + day
+ // console.log("finaldate",finalDate)
+ return formattedDate
+}
+
+export const deParsefunc = (item: TableData) => {
+ let finalDate = dateParser(item.dateOfBirth)
+
+ let tempObj = {
+ context: {
+ requestId: '5b316a07ceb2ee6422f53b837b65c4d0',
+ source: 'ELATION',
+ quorum: true,
+ notify: true,
+ },
+ data: {
+ resourceType: 'Patient',
+
+ name: [
+ {
+ use: 'official',
+ family: item.familyName,
+ given: [item.givenName, item.suffix],
+ text: item.givenName + ' ' + item.suffix + ' ' + item.familyName,
+ },
+ ],
+ identifier: [
+ {
+ type: {
+ text: 'ssn',
+ coding: [
+ {
+ system: 'http://terminology.hl7.org/CodeSystem/v2-0203',
+ code: 'SS',
+ },
+ ],
+ },
+ system: 'http://hl7.org/fhir/sid/us-ssn',
+ value: null,
+ },
+ ],
+ address: tableObjDeparser(item.addresses, 'address'),
+ birthDate: finalDate,
+ gender: item.sex,
+ generalPractitioner: [
+ {
+ reference: 'Practitioner/140857915539458',
+ },
+ ],
+ contact: [
+ {
+ name: {
+ use: 'official',
+ family: 'EmergencyLName',
+ given: ['EmergencyFName', ''],
+ text: 'EmergencyFName EmergencyLName',
+ },
+ relationship: [
+ {
+ text: 'Child',
+ coding: [
+ {
+ code: 'C',
+ display: 'Emergency Contact',
+ },
+ ],
+ },
+ ],
+ telecom: [
+ {
+ system: 'phone',
+ value: '9876567898',
+ },
+ ],
+ address: {
+ line: ['test emergency address', '#456'],
+ city: 'test emergency city',
+ state: 'AL',
+ postalCode: '98765',
+ },
+ },
+ ],
+ extension: [
+ {
+ url: 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex',
+ valueCode: 'Male',
+ },
+ {
+ url: 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity',
+ valueString: 'Hispanic or Latino',
+ },
+ {
+ url: 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-race',
+ valueString: 'Black or African American',
+ },
+ {
+ url: 'http://xcaliber-fhir/structureDefinition/gender-marker',
+ valueString: 'F',
+ },
+ {
+ url: 'http://xcaliber-fhir/structureDefinition/pronouns',
+ valueString: 'she_her_hers',
+ },
+ {
+ url: 'http://xcaliber-fhir/structureDefinition/sexual-orientation',
+ valueString: 'prefer_not_to_say',
+ },
+ {
+ url: 'http://xcaliber-fhir/structureDefinition/notes',
+ valueString: 'Test notes',
+ },
+ {
+ url: 'http://xcaliber-fhir/structureDefinition/provider.html',
+ valueString: 140983539597314,
+ },
+ {
+ url: 'http://xcaliber-fhir/structureDefinition/provider-npi.html',
+ valueString: '1730691296',
+ },
+ {
+ url: 'http://xcaliber-fhir/structureDefinition/master-patient',
+ valueString: 141002016555288,
+ },
+ {
+ url: 'http://xcaliber-fhir/structureDefinition/created-date',
+ valueString: '2022-09-28T08:07:14Z',
+ },
+ {
+ url: 'http://xcaliber-fhir/structureDefinition/practice',
+ valueInteger: 140857911017476,
+ },
+ {
+ url: 'http://xcaliber-fhir/structureDefinition/modified-date',
+ valueDateTime: '2022-09-28T08:07:14Z',
+ },
+ ],
+ telecom: phnEmlParser(item.phoneNumbers, item.emails),
+ meta: null,
+ contained: [
+ {
+ resourceType: 'RelatedPerson',
+ id: 141002015965544,
+ name: [
+ {
+ use: 'official',
+ family: 'Test',
+ given: ['Other', ''],
+ },
+ ],
+ relationship: [
+ {
+ coding: [
+ {
+ code: 'O',
+ },
+ ],
+ text: 'Other',
+ },
+ ],
+ address: [
+ {
+ line: ['101 Lane Street'],
+ city: 'Madison',
+ state: 'WI',
+ postalCode: '53711',
+ },
+ ],
+ telecom: [
+ {
+ value: '1231231233',
+ },
+ ],
+ },
+ ],
+ communication: [],
+ },
+ }
+ return tempObj
+}
+
+export const tableObjParser = (dataM: any, type: string) => {
+ let count = 1
+ let ads: any = []
+ if (type === 'address') {
+ dataM?.map((data: any) => {
+ let adsObj: any = { id: '' + count, value: '', type: 'home' }
+ let ad = ''
+ let line = data.line?.map((i: any) => {
+ ad += i + ' '
+ })
+ console.log(line)
+ console.log(ad)
+ adsObj.value = ad
+ ads.push(adsObj)
+ count++
+ })
+ } else if (type === 'phone') {
+ dataM?.map((data: any) => {
+ if (data.system === 'phone') {
+ let phnObj: any = { id: '' + count, value: data.value, type: data.use }
+ ads.push(phnObj)
+ }
+ })
+ } else {
+ dataM?.map((data: any) => {
+ let emlObj: any = { id: '' + count, value: data.value, type: 'mobile' }
+ if (data.system === 'email') {
+ ads.push(emlObj)
+ }
+ })
+ }
+
+ return ads
+}
+
+export const tableObjDeparser = (data: any, type: any) => {
+ let ads: any = []
+
+ if (type === 'address') {
+ data?.map((item: any) => {
+ let obj: any = { line: [], city: 'Madison', state: 'WI', postalCode: '53711' }
+ obj.line[0] = item.value
+ obj.line[1] = ' '
+ ads.push(obj)
+ })
+ }
+ return ads
+}
+
+export const phnEmlParser = (phnData: any, emlData: any) => {
+ let ads: any = []
+
+ phnData?.map((item: any) => {
+ let obj: any = { system: 'phone', value: item.value, use: item.type }
+ ads.push(obj)
+ })
+
+ emlData?.map((item: any) => {
+ let obj: any = { system: 'email', value: item.value }
+ ads.push(obj)
+ })
+
+ return ads
+}
+
+export const parserFunc = (data: any) => {
+ let dataHolder: TableData[] = []
+ data?.map((item: any) => {
+ let tempObj: TableData = {}
+ tempObj.bloodType = 'bloodType'
+ tempObj.addresses = tableObjParser(item.resource.address, 'address')
+ tempObj.code = item.resource.id
+ tempObj.dateOfBirth = item.resource.birthDate
+ tempObj.familyName = item.resource.name[0].family
+ tempObj.fullName = item.resource.name[0].text
+ tempObj.givenName = item.resource.name[0].given[0]
+ tempObj.suffix = item.resource.name[0].given[1]
+ tempObj.id = item.resource.id
+ tempObj.sex = item.resource.gender
+ tempObj.type = 'mockType'
+ dataHolder.push(tempObj)
+ })
+ return dataHolder
+}
+
+const parserFuncSingle = (item: any) => {
+ let tempObj: TableData = {}
+ tempObj.bloodType = 'bloodType'
+ tempObj.addresses = tableObjParser(item.address, 'address')
+ tempObj.code = item.id
+ tempObj.dateOfBirth = item.birthDate
+ tempObj.familyName = item.name[0].family
+ tempObj.fullName = item.name[0].text
+ tempObj.givenName = item.name[0].given[0]
+ tempObj.suffix = item.name[0].given[1]
+ tempObj.id = item.id
+ tempObj.sex = item.gender
+ tempObj.type = 'mockType'
+ tempObj.phoneNumbers = tableObjParser(item.telecom, 'phone')
+ tempObj.emails = tableObjParser(item.telecom, 'email')
+ console.log('tempObj:', tempObj)
+ return tempObj
+}
+
+export const getAllPatients = () => {
+ return axios
+ .get(`${endpointUrl}/Patient`, config)
+ .then(async (response) => {
+ console.log(response)
+ const data = await response.data
+ const parsedData = parserFunc(data.data.entry)
+ return parsedData
+ })
+ .catch((error) => {
+ console.log(error)
+ })
+}
+
+export const getPatient = (id: string) => {
+ return axios
+ .get(`${endpointUrl}/Patient/${id}`, config)
+ .then(async (response) => {
+ const data = await response.data
+ const parsedData = parserFuncSingle(data.data)
+ return parsedData
+ })
+ .catch((error) => {
+ console.log(error)
+ })
+}
+
+export const addPatient = (patient: any) => {
+ let d = deParsefunc(patient)
+ return axios
+ .post(`${endpointUrl}/Patient`, d, config)
+ .then(async (response) => {
+ console.log(response)
+ const data = await response
+ console.log(data.data.data)
+ return data.data.data
+ })
+ .catch((error) => {
+ console.log(error)
+ })
+}
+
+export const editPatient = (patient: any, id: any) => {
+ console.log('>>>>>>>>>Patient', patient)
+ let d = deParsefunc(patient)
+ console.log('>>>>>>>>d', d)
+ return axios
+ .put(`${endpointUrl}/Patient/${id}`, d, config)
+ .then(async (response) => {
+ console.log(response)
+ const data = await response
+ console.log(data.data.data)
+ return data.data.data
+ })
+ .catch((error) => {
+ console.log(error)
+ })
+}
diff --git a/src/shared/components/Sidebar.tsx b/src/shared/components/Sidebar.tsx
index 03b0c91fff..31ae8ce6d9 100644
--- a/src/shared/components/Sidebar.tsx
+++ b/src/shared/components/Sidebar.tsx
@@ -61,7 +61,7 @@ const Sidebar = () => {
}
const listSubItemStyle: CSSProperties = {
- width: '16vw',
+ width:'16vw',
cursor: 'pointer',
fontSize: 'small',
borderBottomWidth: 0,
diff --git a/src/shared/components/input/DateTimePickerWithLabelFormGroup.tsx b/src/shared/components/input/DateTimePickerWithLabelFormGroup.tsx
index d21efbe930..d139fdc030 100644
--- a/src/shared/components/input/DateTimePickerWithLabelFormGroup.tsx
+++ b/src/shared/components/input/DateTimePickerWithLabelFormGroup.tsx
@@ -1,11 +1,10 @@
import { Label, DateTimePicker } from '@hospitalrun/components'
import React from 'react'
-import moment from 'moment'
interface Props {
name: string
label: string
- value: Date
+ value: Date | undefined
isEditable?: boolean
isRequired?: boolean
onChange?: (date: Date) => void
@@ -28,9 +27,8 @@ const DateTimePickerWithLabelFormGroup = (props: Props) => {
isInvalid={isInvalid}
feedback={feedback}
onChange={(inputDate) => {
- console.log('date time picker', inputDate)
if (onChange) {
- onChange(new Date(inputDate))
+ onChange(inputDate)
}
}}
showTimeSelect
@@ -38,10 +36,6 @@ const DateTimePickerWithLabelFormGroup = (props: Props) => {
timeFormat="h:mm aa"
timeIntervals={15}
withPortal={false}
- minDate={moment().toDate()}
- maxDate={moment().add(3, 'months').toDate()}
- minTime={moment().toDate()}
- maxTime={new Date(new Date().setHours(19, 0, 0, 0))}
/>
)
diff --git a/src/shared/db/AppointmentRepository.ts b/src/shared/db/AppointmentRepository.ts
index bfd161a80d..36adcea156 100644
--- a/src/shared/db/AppointmentRepository.ts
+++ b/src/shared/db/AppointmentRepository.ts
@@ -1,10 +1,10 @@
import escapeStringRegexp from 'escape-string-regexp'
import { relationalDb } from '../config/pouchdb'
-import AppointmentDB from '../model/Appointment'
+import Appointment from '../model/Appointment'
import Repository from './Repository'
-class AppointmentRepository extends Repository {
+class AppointmentRepository extends Repository {
constructor() {
super('appointment', relationalDb)
this.db.createIndex({
@@ -15,7 +15,7 @@ class AppointmentRepository extends Repository {
}
// Fuzzy search for patient appointments. Used for patient appointment search bar
- async searchPatientAppointments(patientId: string, text: string): Promise {
+ async searchPatientAppointments(patientId: string, text: string): Promise {
const escapedString = escapeStringRegexp(text)
return super.search({
selector: {
diff --git a/src/shared/model/Appointment.ts b/src/shared/model/Appointment.ts
index d5e3552541..bdd6791c77 100644
--- a/src/shared/model/Appointment.ts
+++ b/src/shared/model/Appointment.ts
@@ -1,6 +1,6 @@
import AbstractDBModel from './AbstractDBModel'
-export default interface AppointmentDB extends AbstractDBModel {
+export default interface Appointment extends AbstractDBModel {
startDateTime: string
endDateTime: string
patient: string
@@ -8,21 +8,3 @@ export default interface AppointmentDB extends AbstractDBModel {
reason: string
type: string
}
-
-export default interface Appointment {
- appointmentType: {
- text: string
- }
- participant: {
- actor: {
- reference: string
- }
- }[]
- id: string
- start: string
- end:string
- minutesDuration: number
- status: string
- patientId:string
-}
-
diff --git a/src/shared/model/Patient.ts b/src/shared/model/Patient.ts
index 3f4f48ca81..8bbc19825b 100644
--- a/src/shared/model/Patient.ts
+++ b/src/shared/model/Patient.ts
@@ -26,6 +26,4 @@ export default interface Patient extends AbstractDBModel, Name, ContactInformati
careGoals: CareGoal[]
bloodType: string
visits: Visit[]
- emergencyContactName:string
- emergencyContactNumber:string
}