-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop_3x' into fix-705-rewriting-patient-report-screen
- Loading branch information
Showing
9 changed files
with
688 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,277 @@ | ||
import { React, useState, useEffect, useRef, useContext } from "react"; | ||
import { FormattedMessage, useIntl, injectIntl } from "react-intl"; | ||
import { | ||
Grid, | ||
Column, | ||
Form, | ||
Button, | ||
NumberInput, | ||
DataTable, | ||
TableContainer, | ||
Table, | ||
TableHead, | ||
TableRow, | ||
TableHeader, | ||
TableBody, | ||
TableCell, | ||
} from "@carbon/react"; | ||
import CustomLabNumberInput from "../common/CustomLabNumberInput"; | ||
import { NotificationContext } from "../layout/Layout"; | ||
import { AlertDialog, NotificationKinds } from "../common/CustomNotification"; | ||
import { getFromOpenElisServer } from "../utils/Utils"; | ||
|
||
const ExistingOrder = () => { | ||
const intl = useIntl(); | ||
const componentMounted = useRef(false); | ||
const [accessionNumber, setAccessionNumber] = useState(""); | ||
const [orderLabels, setOrderLabels] = useState(1); | ||
const [patientSearchResults, setPatientSearchResults] = useState(null); | ||
const [orderResults, setOrderResults] = useState(null); | ||
const [source, setSource] = useState("about:blank"); | ||
const [renderBarcode, setRenderBarcode] = useState(false); | ||
const { notificationVisible, setNotificationVisible, addNotification } = | ||
useContext(NotificationContext); | ||
useEffect(() => { | ||
componentMounted.current = true; | ||
return () => { | ||
componentMounted.current = false; | ||
}; | ||
}, [accessionNumber]); | ||
const fetchPatientData = (res) => { | ||
if (componentMounted.current) { | ||
let patientsResults = res.patientSearchResults; | ||
if (patientsResults.length > 0) { | ||
setPatientSearchResults(patientsResults[0]); | ||
} else { | ||
setPatientSearchResults(null); | ||
addNotification({ | ||
title: intl.formatMessage({ id: "notification.title" }), | ||
message: intl.formatMessage({ id: "patient.search.nopatient" }), | ||
kind: NotificationKinds.warning, | ||
}); | ||
setNotificationVisible(true); | ||
} | ||
} | ||
}; | ||
|
||
const fetchOrderData = (res) => { | ||
if (componentMounted.current) { | ||
let orderResults = res.existingTests; | ||
setOrderResults(orderResults); | ||
} | ||
}; | ||
|
||
const handleSearch = (e) => { | ||
e.preventDefault(); | ||
getFromOpenElisServer( | ||
`/rest/patient-search-results?labNumber=${accessionNumber}`, | ||
fetchPatientData | ||
); | ||
getFromOpenElisServer( | ||
`/rest/sample-edit?accessionNumber=${accessionNumber}`, | ||
fetchOrderData | ||
); | ||
}; | ||
|
||
const printLabelSets = () => { | ||
setSource( | ||
`/LabelMakerServlet?labNo=${accessionNumber}&type=default&quantity=` | ||
); | ||
setRenderBarcode(true); | ||
}; | ||
|
||
const printOrderLabels = () => { | ||
setSource( | ||
`/LabelMakerServlet?labNo=${accessionNumber}&type=order&quantity=${orderLabels}` | ||
); | ||
setRenderBarcode(true); | ||
}; | ||
|
||
const printSpecimenLabels = (specimenAccessionNumber) => { | ||
setSource( | ||
`/LabelMakerServlet?labNo=${specimenAccessionNumber}&type=specimen&quantity=1` | ||
); | ||
setRenderBarcode(true); | ||
}; | ||
|
||
return ( | ||
<> | ||
{notificationVisible === true ? <AlertDialog /> : ""} | ||
<div className="orderLegendBody"> | ||
<Form onSubmit={handleSearch}> | ||
<Grid> | ||
<Column lg={16}> | ||
<h4> | ||
<FormattedMessage id="sample.entry.search.barcode" /> | ||
</h4> | ||
</Column> | ||
<Column lg={4}> | ||
<CustomLabNumberInput | ||
placeholder={"Enter Lab No"} | ||
id="labNumber" | ||
name="labNumber" | ||
value={accessionNumber} | ||
onChange={(e, rawVal) => { | ||
setOrderResults(null); | ||
setAccessionNumber(rawVal ? rawVal : e?.target?.value); | ||
}} | ||
labelText={<FormattedMessage id="search.label.accession" />} | ||
/> | ||
</Column> | ||
<Column lg={2}> | ||
<Button type="submit"> | ||
<FormattedMessage id="label.button.submit" /> | ||
</Button> | ||
</Column> | ||
</Grid> | ||
</Form> | ||
{patientSearchResults !== null && orderResults !== null && ( | ||
<Grid> | ||
<Column lg={4}> | ||
<h4> | ||
<FormattedMessage id="patient.label.name" /> | ||
</h4> | ||
</Column> | ||
<Column lg={4}> | ||
<h4> | ||
<FormattedMessage id="patient.dob" /> | ||
</h4> | ||
</Column> | ||
<Column lg={4}> | ||
<h4> | ||
<FormattedMessage id="patient.gender" /> | ||
</h4> | ||
</Column> | ||
<Column lg={4}> | ||
<h4> | ||
<FormattedMessage id="patient.natioanalid" /> | ||
</h4> | ||
</Column> | ||
<Column lg={4}> | ||
{patientSearchResults.firstName + | ||
" " + | ||
patientSearchResults.lastName} | ||
</Column> | ||
<Column lg={4}>{patientSearchResults.birthdate}</Column> | ||
<Column lg={4}>{patientSearchResults.gender}</Column> | ||
<Column lg={4}>{patientSearchResults.nationalId}</Column> | ||
</Grid> | ||
)} | ||
</div> | ||
{patientSearchResults !== null && orderResults !== null && ( | ||
<div className="orderLegendBody"> | ||
<Grid> | ||
<Column lg={16}> | ||
<h4> | ||
<FormattedMessage id="barcode.print.section.set" /> | ||
</h4> | ||
</Column> | ||
<Column lg={6}> | ||
<FormattedMessage id="barcode.print.set.instruction" /> | ||
</Column> | ||
<Column> | ||
<Button onClick={printLabelSets}> | ||
<FormattedMessage id="barcode.print.set.button" /> | ||
</Button> | ||
</Column> | ||
</Grid> | ||
</div> | ||
)} | ||
{patientSearchResults !== null && orderResults !== null && ( | ||
<div className="orderLegendBody"> | ||
<DataTable | ||
headers={[ | ||
{ key: "labelType", header: "Label Type" }, | ||
{ key: "accessionNumber", header: "Accession Number" }, | ||
{ key: "additionalInfo", header: "Additional Info" }, | ||
{ key: "numberToPrint", header: "Number to Print" }, | ||
{ key: "button", header: "" }, | ||
]} | ||
rows={[ | ||
{ | ||
id: "row1", | ||
labelType: "Order", | ||
accessionNumber: accessionNumber, | ||
additionalInfo: "", | ||
numberToPrint: ( | ||
<NumberInput | ||
min={1} | ||
max={100} | ||
defaultValue={1} | ||
onChange={(_, state) => setOrderLabels(state.value)} | ||
id="numberToPrint" | ||
className="inputText" | ||
/> | ||
), | ||
button: ( | ||
<Button onClick={printOrderLabels}> | ||
<FormattedMessage id="barcode.print.individual.button" /> | ||
</Button> | ||
), | ||
}, | ||
...orderResults | ||
.filter((result) => result.accessionNumber) | ||
.map((result, index) => ({ | ||
id: `row${index + 2}`, | ||
labelType: "Specimen", | ||
accessionNumber: result.accessionNumber, | ||
additionalInfo: result.sampleType, | ||
numberToPrint: 1, | ||
button: ( | ||
<Button | ||
onClick={() => | ||
printSpecimenLabels(result.accessionNumber) | ||
} | ||
> | ||
<FormattedMessage id="barcode.print.individual.button" /> | ||
</Button> | ||
), | ||
})), | ||
]} | ||
> | ||
{({ rows, headers, getHeaderProps, getTableProps }) => ( | ||
<TableContainer> | ||
<Table {...getTableProps()}> | ||
<TableHead> | ||
<TableRow> | ||
{headers.map((header) => ( | ||
<TableHeader | ||
key={header.key} | ||
{...getHeaderProps({ header })} | ||
> | ||
{header.header} | ||
</TableHeader> | ||
))} | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{rows.map((row) => ( | ||
<TableRow key={row.id}> | ||
{row.cells.map((cell) => ( | ||
<TableCell key={cell.id}>{cell.value}</TableCell> | ||
))} | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</TableContainer> | ||
)} | ||
</DataTable> | ||
</div> | ||
)} | ||
{renderBarcode && ( | ||
<div className="orderLegendBody"> | ||
<Grid> | ||
<Column lg={16}> | ||
<h4> | ||
<FormattedMessage id="barcode.header" /> | ||
</h4> | ||
</Column> | ||
</Grid> | ||
<iframe src={source} width="100%" height="500px" /> | ||
</div> | ||
)} | ||
</> | ||
); | ||
}; | ||
export default injectIntl(ExistingOrder); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from "react"; | ||
import { FormattedMessage } from "react-intl"; | ||
import { Column, Grid, Heading, Section } from "@carbon/react"; | ||
import ExistingOrder from "./ExistingOrder"; | ||
import PrePrint from "./PrePrint"; | ||
|
||
const PrintBarcode = () => { | ||
return ( | ||
<div> | ||
<Grid fullWidth={true}> | ||
<Column lg={12}> | ||
<Section> | ||
<Section> | ||
<Heading> | ||
<FormattedMessage id="barcode.print.title" /> | ||
</Heading> | ||
</Section> | ||
</Section> | ||
</Column> | ||
</Grid> | ||
<PrePrint /> | ||
<ExistingOrder /> | ||
</div> | ||
); | ||
}; | ||
export default PrintBarcode; |
Oops, something went wrong.