import React from "react"; import { Device } from "fhir/r4"; import { SheetHeader, SheetDescription } from "../ui/sheet"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "../ui/tabs"; import { ChevronRight } from "lucide-react"; import { formatDateForDisplay } from "../../lib/utils"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "../ui/accordion"; import { FhirCodeableConceptDisplay } from "../../utils/fhirCodeableConcept"; import { FhirReferenceDisplay } from "../../utils/fhirReference"; import { FhirIdentifierDisplay } from "../../utils/fhirIdentifier"; import { FhirAnnotationDisplay } from "../../utils/fhirAnnotation"; import { FhirQuantityDisplay } from "../../utils/fhirQuantity"; import { FHIRContactPointDisplay } from "../../utils/fhirContactPoint"; import { FieldHistoryProvider, FieldHistoryScope, } from "../FieldHistory/FieldHistoryProvider"; import { ShowFieldHistoryToggle } from "../FieldHistory/ShowFieldHistoryToggle"; import { RecordEditedMarker } from "../FieldHistory/RecordEditedMarker"; import { Field } from "../FieldHistory/Field"; import { FieldGroup } from "../FieldHistory/FieldLayout"; import { StatusBadge } from "../ui/status"; interface FhirDeviceDisplayProps { device: Device; isOpen: boolean; onClose: () => void; title?: string; } export const FhirDeviceDisplay: React.FC = ({ device, isOpen, title, }) => { if (!isOpen) return null; // / D5 - was a hand-rolled pill: a local STATUS_STYLES record of hardcoded hex pairs // applied as an INLINE STYLE, with the raw FHIR code as the text. Colour-only, non-token, and one // of twelve near-identical copies. carries the shared word plus D5's colour AND shape. const renderStatusPill = (status: string | undefined): React.ReactNode => ( ); return (
{title || "Device Details"}

{device.deviceName && device.deviceName.length > 0 ? device.deviceName.map((name, index) => ( {name?.name} {index < device.deviceName!.length - 1 ? ", " : ""} )) : "Device name not available"}

Overview Device Information } /> } path="type.coding[0].display" /> } /> } /> } /> } />

Device Names

{device.deviceName && device.deviceName.length > 0 ? ( device.deviceName.map((name, index) => (

Device Name {index + 1}

{name.type.replace(/-/g, " ")} ) : undefined } />
)) ) : (

No device names recorded

)}

Manufacturing & Identification

Manufacturing & Expiration Dates

Unique Device Identifier (UDI) Regulatory Data

{device.udiCarrier && device.udiCarrier.length > 0 ? ( device.udiCarrier.map((udiCarrier, index) => (

UDI Carrier {index + 1}

{udiCarrier.entryType.replace(/-/g, " ")} ) : undefined } />
)) ) : (

No UDI carriers recorded

)}

Additional Device Details

} /> } /> } /> } />
{device.property && device.property.length > 0 && (

Device Properties

{device.property.map((property, index) => (

Property {index + 1}

} /> 0 ? (
{property.valueQuantity.map( (quantity, qIndex) => ( ), )}
) : undefined } /> } />
))}
)}

Notes

} />
); }; export default FhirDeviceDisplay;