From f4819fc6c120e309e0596824dc3cf4fc0db72df7 Mon Sep 17 00:00:00 2001 From: CalebSLane Date: Mon, 31 Jul 2023 23:12:33 -0700 Subject: [PATCH] fix file location moved --- .../src/components/common/SearchResultForm.js | 4 +- .../ImmunohistochemistryCaseView.js | 477 ++++++++++++++++++ .../ImmunohistochemistryDashboard.js | 236 +++++++++ 3 files changed, 715 insertions(+), 2 deletions(-) create mode 100644 frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js create mode 100644 frontend/src/components/immunohistochemistry/ImmunohistochemistryDashboard.js diff --git a/frontend/src/components/common/SearchResultForm.js b/frontend/src/components/common/SearchResultForm.js index 998e3482c..b5468828f 100644 --- a/frontend/src/components/common/SearchResultForm.js +++ b/frontend/src/components/common/SearchResultForm.js @@ -52,7 +52,7 @@ class ResultSearchPage extends React.Component { } -class SearchResultForm extends React.Component { +export class SearchResultForm extends React.Component { static contextType = NotificationContext; constructor(props) { @@ -186,7 +186,7 @@ class SearchResultForm extends React.Component { } } -class SearchResults extends React.Component { +export class SearchResults extends React.Component { static contextType = NotificationContext; constructor(props) { diff --git a/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js b/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js new file mode 100644 index 000000000..e42f00a5b --- /dev/null +++ b/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js @@ -0,0 +1,477 @@ +import {useContext, useState, useEffect, useRef } from "react"; +import {useParams} from "react-router-dom"; +import config from "../../config.json"; +import { + IconButton, Heading, TextInput, Select, FilterableMultiSelect, SelectItem, Button, Grid, Column, + Checkbox, FileUploader, Tag, TextArea} from '@carbon/react'; + import { Launch, Subtract} from '@carbon/react/icons'; +import { getFromOpenElisServer, postToOpenElisServerFullResponse, hasRole } from "../utils/Utils"; +import UserSessionDetailsContext from "../../UserSessionDetailsContext" +import { NotificationContext } from "../layout/Layout"; +import {AlertDialog} from "../common/CustomNotification"; +import {SearchResults} from "../common/SearchResultForm" + + +export const QuestionnaireResponse = ({questionnaireResponse})=> { + + + const renderQuestionResponse = (item) => { + console.log(JSON.stringify(item)) + return <> +
+ {item.text}: + {item.answer && item.answer.map( (answer, index) => { + return {renderAnswer(answer)} + })} +
+ + } + + const renderAnswer = (answer) => { + console.log(JSON.stringify(answer)) + + var display = ''; + if ('valueString' in answer) { + display = answer.valueString + } else if ('valueBoolean' in answer) { + display = answer.valueBoolean + } else if ('valueCoding' in answer) { + display = answer.valueCoding.display + } else if ('valueDate' in answer) { + display = answer.valueDate + } else if ('valueDecimal' in answer) { + display = answer.valueDecimal + } else if ('valueInteger' in answer) { + display = answer.valueInteger + } else if ('valueQuantity' in answer) { + display = answer.valueQuantity.value + answer.valueQuantity.unit + } else if ('valueTime' in answer) { + display = answer.valueTime + } + return <> + + {display} + + } + + return <> + {questionnaireResponse && questionnaireResponse.item.map( (item, index) => { + return {renderQuestionResponse(item)} + })} + + + +} + + +function ImmunohistochemistryCaseView() { + + const componentMounted = useRef(false); + + const { immunohistochemistrySampleId } = useParams() + + const { notificationVisible } = useContext(NotificationContext); + const [immunohistochemistrySampleInfo, setImmunohistochemistrySampleInfo ] = useState({}); + + const [initialMount, setInitialMount ] = useState(false); + + const [statuses, setStatuses ] = useState([]); + const [techniques, setTechniques ] = useState([]); + const [requests, setRequests ] = useState([]); + const [conclusions, setConclusions ] = useState([]); + const [technicianUsers, setTechnicianUsers] = useState([]); + const [pathologistUsers, setPathologistUsers] = useState([]); + + async function displayStatus (response) { + var body = await response.json(); + console.log(body) + } + + const toBase64 = file => new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = () => resolve(reader.result); + reader.onerror = reject; +}); + + const save = (e) => { + let submitValues = { + "assignedTechnicianId": immunohistochemistrySampleInfo.assignedTechnicianId, + "assignedPathologistId": immunohistochemistrySampleInfo.assignedPathologistId, + "status": immunohistochemistrySampleInfo.status, + "release": immunohistochemistrySampleInfo.release + } + + postToOpenElisServerFullResponse("/rest/immunohistochemistry/caseView/" + immunohistochemistrySampleId, JSON.stringify(submitValues), displayStatus); + } + + + const setInitialImmunohistochemistrySampleInfo = (e) => { + setImmunohistochemistrySampleInfo(e); + setInitialMount(true); + } + + useEffect(() => { + componentMounted.current = true; + getFromOpenElisServer("/rest/displayList/IMMUNOHISTOCHEMISTRY_STATUS", setStatuses); + //TODO make conclusions list instead of reusing pathrequest + getFromOpenElisServer("/rest/users/", setTechnicianUsers); + getFromOpenElisServer("/rest/users/Pathologist", setPathologistUsers); + getFromOpenElisServer("/rest/immunohistochemistry/caseView/" + immunohistochemistrySampleId, setInitialImmunohistochemistrySampleInfo ); + + return () => { + componentMounted.current = false + } + }, []); + + return ( + <> + + {notificationVisible === true ? : ""} + + + + Immunohistochemistry - {immunohistochemistrySampleInfo.labNumber} + + + + + Order Date {immunohistochemistrySampleInfo.requestDate} + Name: {immunohistochemistrySampleInfo.lastName}, {immunohistochemistrySampleInfo.firstName} + Age: {immunohistochemistrySampleInfo.age} Sex: {immunohistochemistrySampleInfo.sex} + + + Referring Facility: Ward/Dept/Unit: Requester: + + + + + + + + + + + + + + + + + + + + + {immunohistochemistrySampleInfo.blocks && immunohistochemistrySampleInfo.blocks.map((block, index) => { + return ( + <> + + + { + var newBlocks = [...immunohistochemistrySampleInfo.blocks]; + newBlocks = newBlocks.splice(index, 1); + setImmunohistochemistrySampleInfo({...immunohistochemistrySampleInfo, blocks: newBlocks}); + }} kind='tertiary' size='sm'> + + + Block + + + { + var newBlocks = [...immunohistochemistrySampleInfo.blocks]; + newBlocks[index].blockNumber = e.target.value; + setImmunohistochemistrySampleInfo({...immunohistochemistrySampleInfo, blocks: newBlocks}); + }}/> + + + { + var newBlocks = [...immunohistochemistrySampleInfo.blocks]; + newBlocks[index].location = e.target.value; + setImmunohistochemistrySampleInfo({...immunohistochemistrySampleInfo, blocks: newBlocks}); + }} + /> + + + + + + + ) + })} + + + + + + {immunohistochemistrySampleInfo.slides && immunohistochemistrySampleInfo.slides.map((slide, index) => { + return ( + <> + + { + var newSlides = [...immunohistochemistrySampleInfo.slides]; + setImmunohistochemistrySampleInfo({...immunohistochemistrySampleInfo, slides: newSlides.splice(index, 1)});}} kind='tertiary' size='sm'> + + + Slide + + + { + var newSlides = [...immunohistochemistrySampleInfo.slides]; + newSlides[index].slideNumber = e.target.value; + setImmunohistochemistrySampleInfo({...immunohistochemistrySampleInfo, slides: newSlides}); + }} + /> + + + { + var newSlides = [...immunohistochemistrySampleInfo.slides]; + newSlides[index].location = e.target.value; + setImmunohistochemistrySampleInfo({...immunohistochemistrySampleInfo, slides: newSlides}); + }} + /> + + + { + e.preventDefault(); + let file = e.target.files[0]; + var newSlides = [...immunohistochemistrySampleInfo.slides]; + let encodedFile = await toBase64(file); + newSlides[index].base64Image = encodedFile; + setImmunohistochemistrySampleInfo({...immunohistochemistrySampleInfo, slides: newSlides}); + }} + onClick={function noRefCheck(){}} + onDelete={(e) => { + e.preventDefault(); + var newSlides = [...immunohistochemistrySampleInfo.slides]; + newSlides[index].base64Image = ''; + setImmunohistochemistrySampleInfo({...immunohistochemistrySampleInfo, slides: newSlides}); + }} + /> + {immunohistochemistrySampleInfo.slides[index].image && + <> + + + } + + + + + ) + })} + + + + + + + + + + + {hasRole("Pathologist") && + <> + + {initialMount && (item ? item.value : '')} + initialSelectedItems={immunohistochemistrySampleInfo.techniques} + onChange={(changes) => { + setImmunohistochemistrySampleInfo({...immunohistochemistrySampleInfo, techniques : changes.selectedItems}); + }} + selectionFeedback="top-after-reopen" + /> + } + + + {immunohistochemistrySampleInfo.techniques && immunohistochemistrySampleInfo.techniques.map((technique, index) => ( + {}} + > + {technique.value} + + ))} + + + + {initialMount && (item ? item.value : '')} + initialSelectedItems={immunohistochemistrySampleInfo.requests} + onChange={(changes) => { + setImmunohistochemistrySampleInfo({...immunohistochemistrySampleInfo, "requests" : changes.selectedItems}); + }} + selectionFeedback="top-after-reopen" + /> + } + + + {immunohistochemistrySampleInfo.requests && immunohistochemistrySampleInfo.requests.map((technique, index) => ( + {}} + > + {technique.value} + + ))} + + +