import React, { useState, useEffect } from 'react'; import { TextareaControl } from "../ui/textarea-control"; import { Card, CardHeader, CardBody, CardDivider } from '../ui/wp-card'; import { Elevation } from '../ui/elevation'; import { Divider } from '../ui/divider'; import { Heading } from '../ui/heading'; import { Spacer } from '../ui/spacer'; import { useFormContext, Controller, useFieldArray } from 'react-hook-form'; import { IValueSet, useAuthServiceContext, usePractitionerServiceContext, useValueSetServiceContext } from '../../services'; import { FhirCodeableConcept, FhirPeriod, PractitionerRoleSelector } from '../../components'; import { Practitioner } from 'fhir/r4'; // - WordPress's ToggleControl, swapped for the ui/* adapter. Same props, same JSX; // only `__nextHasNoMarginBottom` is dropped, which means nothing outside WordPress. import { ToggleControl } from '../ui/toggle-control'; interface FhirScheduleProps { elevated?: boolean; disabled?: boolean; isNew: boolean; } export const FhirSchedule: React.FC = ({ isNew, elevated = true, disabled = false }) => { const { control, watch } = useFormContext(); const { currentUser, userRole, USER_ROLES, practitionerRoles } = useAuthServiceContext(); const { practitionersList } = usePractitionerServiceContext(); const { fetchValueSet, valueSetUrls } = useValueSetServiceContext(); const [loading, setLoading] = useState(false); // value sets const [practiceCodes, setPracticeCodes] = useState([]); const [serviceCategory, setServiceCategory] = useState([]); const [serviceType, setServiceType] = useState([]); const spacerMargin = '24px'; const actorType = watch('actorType'); const identifierFieldArray = useFieldArray({ control: control, name: 'identifier' }); useEffect(() => { const loadValueSets = async () => { setLoading(true); try { const [ practiceCodesValueSet, serviceCategoryValueSet, serviceTypeValueSet ] = await Promise.all([ fetchValueSet(valueSetUrls.practiceCodes), fetchValueSet(valueSetUrls.serviceCategory), fetchValueSet(valueSetUrls.serviceType) ]); setPracticeCodes(practiceCodesValueSet); setServiceCategory(serviceCategoryValueSet); setServiceType(serviceTypeValueSet); } catch (err) { console.error('Error loading value sets:', err); } finally { setLoading(false); } }; loadValueSets(); }, [fetchValueSet, valueSetUrls]); return ( {elevated && } Schedule Information {/* practitionerRole */} {/* active */} ( )}/> {/* comment */} ( )}/> Planning Horizon {/* planningHorizon */} Services {/* serviceCategory */} {/* serviceType */} {/* specialty */} {/**/} {/**/} {/* */} {/* {(tab) => {*/} {/* // services*/} {/* if (tab.name === 'services') {*/} {/* return (*/} {/*
*/} {/* */} {/* /!* serviceCategory *!/*/} {/* */} {/* */} {/* /!* serviceType *!/*/} {/* */} {/* */} {/* /!* specialty *!/*/} {/* */} {/* */} {/*
*/} {/* );*/} {/* }*/} {/* // identifiers*/} {/* if (tab.name === 'identifiers') {*/} {/* return (*/} {/*
*/} {/* */} {/* /!* identifier *!/*/} {/* */} {/* */} {/*
*/} {/* );*/} {/* }*/} {/* }}*/} {/*
*/} {/*
*/}
); }; export default FhirSchedule;