Skip to content

Commit

Permalink
Merge pull request #596 from mozzy11/2.8
Browse files Browse the repository at this point in the history
Updates to validation page
  • Loading branch information
mozzy11 authored Nov 16, 2023
2 parents 52392b2 + aa19bbc commit 36eeb80
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 45 deletions.
68 changes: 45 additions & 23 deletions frontend/src/components/resultPage/SearchResultForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import SearchResultFormValues from "../formModel/innitialValues/SearchResultForm
import { AlertDialog, NotificationKinds } from "../common/CustomNotification";
import { NotificationContext } from "../layout/Layout";
import SearchPatientForm from "../patient/SearchPatientForm";
import { ConfigurationContext } from "../layout/Layout"

function ResultSearchPage() {
const [resultForm, setResultForm] = useState({ testResult: [] });
Expand Down Expand Up @@ -205,7 +206,6 @@ export function SearchResultForm(props) {
<Field name="unitType">
{({ field }) => (
<Select
className="inputSelect2"
labelText={
<FormattedMessage id="search.label.testunit" />
}
Expand Down Expand Up @@ -237,7 +237,6 @@ export function SearchResultForm(props) {
{({ field }) => (
<TextInput
placeholder="Enter Accession No."
className="searchLabNumber inputText2"
name={field.name}
id={field.name}
labelText={
Expand All @@ -258,7 +257,6 @@ export function SearchResultForm(props) {
{({ field }) => (
<TextInput
placeholder={"Enter LabNo"}
className="searchLabNumber inputText"
name={field.name}
id={field.name}
labelText={
Expand All @@ -273,7 +271,6 @@ export function SearchResultForm(props) {
{({ field }) => (
<TextInput
placeholder={"Enter LabNo"}
className="searchLabNumber inputText"
name={field.name}
id={field.name}
labelText={
Expand All @@ -294,7 +291,6 @@ export function SearchResultForm(props) {
{({ field }) => (
<TextInput
placeholder={"Collection Date(dd/mm/yyyy)"}
className="collectionDate inputText"
name={field.name}
id={field.name}
labelText={
Expand All @@ -309,7 +305,6 @@ export function SearchResultForm(props) {
{({ field }) => (
<TextInput
placeholder={"Received Date(dd/mm/yyyy)"}
className="receivedDate inputText"
name={field.name}
id={field.name}
labelText={
Expand All @@ -323,7 +318,6 @@ export function SearchResultForm(props) {
<Field name="testName">
{({ field }) => (
<Select
className="analysisStatus inputText"
labelText={
<FormattedMessage id="search.label.test" />
}
Expand All @@ -348,7 +342,6 @@ export function SearchResultForm(props) {
<Field name="analysisStatus">
{({ field }) => (
<Select
className="analysisStatus inputText"
labelText={
<FormattedMessage id="search.label.analysis" />
}
Expand All @@ -373,7 +366,6 @@ export function SearchResultForm(props) {
<Field name="sampleStatusType">
{({ field }) => (
<Select
className="sampleStatus inputText"
labelText={
<FormattedMessage id="search.label.sample" />
}
Expand All @@ -400,15 +392,9 @@ export function SearchResultForm(props) {

{searchBy.type !== "patient" && (
<Column lg={16}>
<div className="searchActionButtons">
<Button
type="submit"
id="submit"
className="searchResultsBtn"
>
<Button style={{ marginTop: '16px' }} type="submit" id="submit">
<FormattedMessage id="label.button.search" />
</Button>
</div>
</Button>
</Column>
)}
</Grid>
Expand All @@ -435,6 +421,7 @@ export function SearchResults(props) {
const [referalOrganizations, setReferalOrganizations] = useState([]);
const [methods, setMethods] = useState([]);
const [referralReasons, setReferralReasons] = useState([]);
const configurationProperties = useContext(ConfigurationContext);
const saveStatus = "";

const componentMounted = useRef(true);
Expand Down Expand Up @@ -481,7 +468,7 @@ export function SearchResults(props) {
return renderCell(row, index, column, id);
},
sortable: true,
width: "19rem",
width: "15rem",
},
{
name: "Test Date",
Expand All @@ -506,21 +493,21 @@ export function SearchResults(props) {
name: "Normal Range",
selector: (row) => row.normalRange,
sortable: true,
width: "7rem",
width: "8rem",
},
{
name: "Accept",
cell: (row, index, column, id) => {
return renderCell(row, index, column, id);
},
width: "8rem",
width: "5rem",
},
{
name: "Result",
cell: (row, index, column, id) => {
return renderCell(row, index, column, id);
},
width: "8rem",
width: "6rem",
},
{
name: "Current Result",
Expand All @@ -529,12 +516,21 @@ export function SearchResults(props) {
},
width: "8rem",
},
{
name: "Reject",
cell: (row, index, column, id) => {
//if (configurationProperties.allowResultRejection == "true") {
//return renderCell(row, index, column, id);
// }
},
width: "5rem",
},
{
name: "Notes",
cell: (row, index, column, id) => {
return renderCell(row, index, column, id);
},
width: "16rem",
width: "8rem",
},
];

Expand Down Expand Up @@ -581,6 +577,23 @@ export function SearchResults(props) {
</Field>
</>
);

case "Reject":
return (
<>
<Field name="reject">
{() => (
<Checkbox
id={"testResult" + row.id + ".rejected"}
name={"testResult[" + row.id + "].rejected"}
labelText=""
defaultChecked={row.nonconforming}
onChange={(e) => handleCheckBoxChange(e, row.id)}
/>
)}
</Field>
</>
);

case "Notes":
return (
Expand Down Expand Up @@ -862,6 +875,15 @@ export function SearchResults(props) {
jp.value(form, isModified, "true");
};

const handleCheckBoxChange = (e, rowId) => {
const { name, checked } = e.target;
var form = props.results;
var jp = require("jsonpath");
jp.value(form, name, checked);
var isModified = "testResult[" + rowId + "].isModified";
jp.value(form, isModified, "true");
};

const handleDatePickerChange = (date, rowId) => {
console.log("handleDatePickerChange:" + date);
const d = new Date(date).toLocaleDateString("fr-FR");
Expand Down Expand Up @@ -990,7 +1012,7 @@ export function SearchResults(props) {
onChange={handlePageChange}
page={page}
pageSize={pageSize}
pageSizes={[100]}
pageSizes={[100 ,50 ,10]}
totalItems={props.results.testResult?.length}
></Pagination>

Expand Down
9 changes: 4 additions & 5 deletions frontend/src/components/validation/SearchForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const SearchForm = (props) => {
const validationResults = (data) => {
if (data) {
setSearchResults(data);
setIsLoading(false);
if (data.resultList.length > 0) {
const newResultsList = data.resultList.map((data, id) => {
let tempData = { ...data };
Expand All @@ -47,6 +48,7 @@ const SearchForm = (props) => {
resultList: newResultsList,
}));
} else {
setIsLoading(false);
setSearchResults((prevState) => ({
...prevState,
resultList: [],
Expand All @@ -60,7 +62,7 @@ const SearchForm = (props) => {
setNotificationVisible(true);
}
}
setIsLoading(false);

};

useEffect(() => {
Expand Down Expand Up @@ -142,7 +144,6 @@ const SearchForm = (props) => {
{({ field }) => (
<TextInput
placeholder={"Enter Lab No"}
className="searchLabNumber inputText"
name={field.name}
id={field.name}
labelText={
Expand All @@ -166,7 +167,6 @@ const SearchForm = (props) => {
<Field name="unitType">
{({ field }) => (
<Select
className="inputText"
labelText={
<FormattedMessage id="search.label.testunit" />
}
Expand Down Expand Up @@ -200,7 +200,6 @@ const SearchForm = (props) => {
name={field.name}
id={field.id}
dateFormat="d/m/Y"
className="inputText"
datePickerType="single"
value={testDate}
onChange={(e) => {
Expand Down Expand Up @@ -228,7 +227,7 @@ const SearchForm = (props) => {
<Button
type="submit"
id="submit"
className="searchResultsBtn"
style={{ marginTop: '16px' }}
>
<FormattedMessage id="label.button.search" />
</Button>
Expand Down
Loading

0 comments on commit 36eeb80

Please sign in to comment.