Skip to content

Commit

Permalink
Merge pull request I-TECH-UW#979 from mozzy11/develop_3x
Browse files Browse the repository at this point in the history
Result and Validation pages should Refresh after Submission
  • Loading branch information
mozzy11 authored Apr 12, 2024
2 parents 6a1748e + 0bf2b94 commit 1136351
Show file tree
Hide file tree
Showing 13 changed files with 161 additions and 38 deletions.
2 changes: 0 additions & 2 deletions frontend/src/components/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ function Login(props) {
</Heading>
</FormLabel>
<TextInput
className="inputText"
id="loginName"
invalidText={props.intl.formatMessage({
id: "login.msg.username.missing",
Expand All @@ -184,7 +183,6 @@ function Login(props) {
ref={firstInput}
/>
<TextInput.PasswordInput
className="inputText"
id="password"
invalidText={props.intl.formatMessage({
id: "login.msg.password.missing",
Expand Down
14 changes: 10 additions & 4 deletions frontend/src/components/addOrder/AddOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ const AddOrder = (props) => {
...orderFormValues.sampleOrderItems,
referringSiteName: e.target.value,
referringSiteId: "",
referringSiteDepartmentId : ""
referringSiteDepartmentId: "",
},
});
}
Expand All @@ -274,7 +274,7 @@ const AddOrder = (props) => {
...orderFormValues.sampleOrderItems,
referringSiteId: siteId,
referringSiteName: "",
referringSiteDepartmentId : "",
referringSiteDepartmentId: "",
},
});
}
Expand Down Expand Up @@ -382,7 +382,7 @@ const AddOrder = (props) => {
(orderFormValues.sampleOrderItems.referringSiteId || ""),
loadDepartments,
);
}, [orderFormValues.sampleOrderItems.referringSiteId]);
}, [orderFormValues.sampleOrderItems.referringSiteId]);

function handlePriority(e) {
setOrderFormValues({
Expand Down Expand Up @@ -621,7 +621,9 @@ const AddOrder = (props) => {
labelText={intl.formatMessage({ id: "order.department.label" })}
onChange={handleRequesterDept}
required
value={orderFormValues.sampleOrderItems.referringSiteDepartmentId}
value={
orderFormValues.sampleOrderItems.referringSiteDepartmentId
}
>
<SelectItem value="" text="" />
{departments.map((department, index) => (
Expand Down Expand Up @@ -783,6 +785,10 @@ const AddOrder = (props) => {
onChange={handleRequesterEmail}
value={orderFormValues.sampleOrderItems.providerEmail}
id="providerEmailId"
invalid={error("sampleOrderItems.providerEmail") ? true : false}
invalidText={intl.formatMessage({
id: "error.invalid.email",
})}
/>
</Column>

Expand Down
16 changes: 8 additions & 8 deletions frontend/src/components/addOrder/Index.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,14 +566,14 @@ const Index = () => {
delete orderFormValues.sampleOrderItems.questionnaire;
}
//remove display Lists rom the form
orderFormValues.sampleOrderItems.priorityList = []
orderFormValues.sampleOrderItems.programList =[]
orderFormValues.sampleOrderItems.referringSiteList=[]
orderFormValues.initialSampleConditionList=[]
orderFormValues.testSectionList =[]
orderFormValues.sampleOrderItems.providersList=[]
orderFormValues.sampleOrderItems.paymentOptions=[]
orderFormValues.sampleOrderItems.testLocationCodeList=[]
orderFormValues.sampleOrderItems.priorityList = [];
orderFormValues.sampleOrderItems.programList = [];
orderFormValues.sampleOrderItems.referringSiteList = [];
orderFormValues.initialSampleConditionList = [];
orderFormValues.testSectionList = [];
orderFormValues.sampleOrderItems.providersList = [];
orderFormValues.sampleOrderItems.paymentOptions = [];
orderFormValues.sampleOrderItems.testLocationCodeList = [];
console.log(JSON.stringify(orderFormValues));
postToOpenElisServer(
"/rest/SamplePatientEntry",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as Yup from "yup";

const ModifyOrderEntryValidationSchema = Yup.object().shape({
sampleOrderItems: Yup.object()
.shape({
labNo: Yup.string().required("Sample Lab Number is required"),
referringSiteName: Yup.string(),
referringSiteId: Yup.string(),
providerLastName: Yup.string().required(
"Requester Last Name is required",
),
providerFirstName: Yup.string().required(
"Requester First Name is required",
),
providerEmail: Yup.string().email("Invalid Email"),
})
.test("referringSiteName", "Referring Site is required", function (value) {
const { referringSiteName, referringSiteId } = value || {};
return !!referringSiteName || !!referringSiteId;
}),
});

export default ModifyOrderEntryValidationSchema;
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const OrderEntryValidationSchema = Yup.object().shape({
providerFirstName: Yup.string().required(
"Requester First Name is required",
),
providerEmail: Yup.string().email("Invalid Email"),
})
.test("referringSiteName", "Referring Site is required", function (value) {
const { referringSiteName, referringSiteId } = value || {};
Expand Down
36 changes: 26 additions & 10 deletions frontend/src/components/modifyOrder/ModifyOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import OrderSuccessMessage from "../addOrder/OrderSuccessMessage";
import { FormattedMessage, useIntl } from "react-intl";
import PatientHeader from "../common/PatientHeader";
import PageBreadCrumb from "../common/PageBreadCrumb";
import ModifyOrderEntryValidationSchema from "../formModel/validationSchema/ModifyOrderEntryValidationSchema";
let breadcrumbs = [
{ label: "home.label", link: "/" },
{ label: "sample.label.search.Order", link: "/SampleEdit" },
Expand Down Expand Up @@ -75,9 +76,23 @@ const ModifyOrder = () => {
};
}, []);

useEffect(() => {
ModifyOrderEntryValidationSchema.validate(orderFormValues, {
abortEarly: false,
})
.then((validData) => {
setErrors([]);
console.debug("Valid Data:", validData);
})
.catch((errors) => {
setErrors(errors);
console.error("Validation Errors:", errors.errors);
});
}, [orderFormValues]);

const loadOrderValues = (data) => {
if (componentMounted.current) {
data.sampleOrderItems.referringSiteName=""
data.sampleOrderItems.referringSiteName = "";
setOrderFormValues(data);
}
};
Expand Down Expand Up @@ -111,15 +126,15 @@ const ModifyOrder = () => {
e.preventDefault();
setPage(page + 1);
orderFormValues.sampleOrderItems.modified = true;
//remove display Lists rom the form
orderFormValues.sampleOrderItems.priorityList = []
orderFormValues.sampleOrderItems.programList =[]
orderFormValues.sampleOrderItems.referringSiteList=[]
orderFormValues.initialSampleConditionList=[]
orderFormValues.testSectionList =[]
orderFormValues.sampleOrderItems.providersList=[]
orderFormValues.sampleOrderItems.paymentOptions=[]
orderFormValues.sampleOrderItems.testLocationCodeList=[]
//remove display Lists rom the form
orderFormValues.sampleOrderItems.priorityList = [];
orderFormValues.sampleOrderItems.programList = [];
orderFormValues.sampleOrderItems.referringSiteList = [];
orderFormValues.initialSampleConditionList = [];
orderFormValues.testSectionList = [];
orderFormValues.sampleOrderItems.providersList = [];
orderFormValues.sampleOrderItems.paymentOptions = [];
orderFormValues.sampleOrderItems.testLocationCodeList = [];
console.log(JSON.stringify(orderFormValues));
postToOpenElisServer(
"/rest/sample-edit",
Expand Down Expand Up @@ -319,6 +334,7 @@ const ModifyOrder = () => {
kind="primary"
className="forwardButton"
onClick={handleSubmitOrderForm}
disabled={errors?.errors?.length > 0 ? true : false}
>
<FormattedMessage id="label.button.submit" />
</Button>
Expand Down
8 changes: 2 additions & 6 deletions frontend/src/components/patient/SearchPatientForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,8 @@ function SearchPatientForm(props) {
"patientId",
);
if (patientId) {
let searchValues = {
...searchFormValues,
patientId: patientId,
};
setSearchFormValues(searchValues);
handleSubmit(searchValues);
const searchEndPoint = "/rest/patient-details?patientID=" + patientId;
getFromOpenElisServer(searchEndPoint, fetchPatientDetails);
}
}, []);
return (
Expand Down
69 changes: 65 additions & 4 deletions frontend/src/components/resultPage/SearchResultForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ function ResultSearchPage() {
testResult: [],
});
const [resultForm, setResultForm] = useState(originalResultForm);
const [searchBy, setSearchBy] = useState({ type: "", doRange: false });
const [param, setParam] = useState("&accessionNumber=");

const setResults = (resultForm) => {
setOriginalResultForm(resultForm);
Expand All @@ -46,8 +48,17 @@ function ResultSearchPage() {

return (
<>
<SearchResultForm setResults={setResults} />
<SearchResults results={resultForm} setResultForm={setResultForm} />
<SearchResultForm
setParam={setParam}
setSearchBy={setSearchBy}
setResults={setResults}
/>
<SearchResults
extraParams={param}
searchBy={searchBy}
results={resultForm}
setResultForm={setResultForm}
/>
</>
);
}
Expand Down Expand Up @@ -177,6 +188,37 @@ export function SearchResultForm(props) {
"&finished=" +
true;
setUrl(searchEndPoint);
props.setSearchBy?.(searchBy);
switch (searchBy.type) {
case "unit":
props.setParam("&testSectionId=" + values.unitType);
break;
case "patient":
props.setParam("&patientId=" + patient.patientPK);
break;
case "order":
props.setParam("&accessionNumber=" + labNo);
break;
case "date":
props.setParam(
"&selectedTest=" +
values.testName +
"&selectedSampleStatus=" +
values.sampleStatusType +
"&selectedAnalysisStatus=" +
values.analysisStatus +
"&collectionDate=" +
values.collectionDate +
"&recievedDate=" +
values.recievedDate,
);
break;
case "range":
props.setParam(
"&accessionNumber=" + labNo + "&upperAccessionNumber=" + endLabNo,
);
break;
}

getFromOpenElisServer(searchEndPoint, setResultsWithId);
};
Expand Down Expand Up @@ -315,6 +357,9 @@ export function SearchResultForm(props) {
let accessionNumber = new URLSearchParams(window.location.search).get(
"accessionNumber",
);
let upperAccessionNumber = new URLSearchParams(window.location.search).get(
"upperAccessionNumber",
);
if (accessionNumber) {
let searchValues = {
...searchFormValues,
Expand All @@ -323,6 +368,15 @@ export function SearchResultForm(props) {
setSearchFormValues(searchValues);
querySearch(searchValues);
}
if (accessionNumber || upperAccessionNumber) {
let searchValues = {
...searchFormValues,
accessionNumber: accessionNumber,
endLabNo: upperAccessionNumber,
};
setSearchFormValues(searchValues);
querySearch(searchValues);
}
let collectionDate = new URLSearchParams(window.location.search).get(
"collectionDate",
);
Expand Down Expand Up @@ -442,6 +496,7 @@ export function SearchResultForm(props) {
placeholder={"Enter LabNo"}
name={field.name}
id={field.name}
defaultValue={values["endLabNo"]}
labelText={
<FormattedMessage id="search.label.toaccession" />
}
Expand Down Expand Up @@ -1413,6 +1468,12 @@ export function SearchResults(props) {
message: createMesssage(resp),
kind: NotificationKinds.success,
});
window.location.href =
"/result?type=" +
props.searchBy.type +
"&doRange=" +
props.searchBy.doRange +
props.extraParams;
} else {
addNotification({
title: intl.formatMessage({ id: "notification.title" }),
Expand All @@ -1425,13 +1486,13 @@ export function SearchResults(props) {

const createMesssage = (resp) => {
var message = "";
if (resp.reflex.length > 0) {
if (resp.reflex?.length > 0) {
message +=
intl.formatMessage({ id: "reflexTests" }) +
": " +
resp.reflex.join(", ");
}
if (resp.calculated.length > 0) {
if (resp.calculated?.length > 0) {
message +=
intl.formatMessage({ id: "calculatedTests" }) +
": " +
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/components/validation/Index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ let breadcrumbs = [{ label: "home.label", link: "/" }];
const Index = () => {
const { notificationVisible } = useContext(NotificationContext);
const [results, setResults] = useState({ resultList: [] });
const [params, setParams] = useState("");
return (
<>
<PageBreadCrumb breadcrumbs={breadcrumbs} />
Expand All @@ -28,8 +29,8 @@ const Index = () => {
</Grid>
<div className="orderLegendBody">
{notificationVisible === true ? <AlertDialog /> : ""}
<SearchForm setResults={setResults} />
<Validation results={results} />
<SearchForm setParams={setParams} setResults={setResults} />
<Validation params={params} results={results} />
</div>
</>
);
Expand Down
18 changes: 18 additions & 0 deletions frontend/src/components/validation/SearchForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,24 @@ const SearchForm = (props) => {
"&doRange=" +
doRange;
setUrl(searchEndPoint);
switch (searchBy) {
case "routine":
props.setParams("?type=" + searchBy + "&testSectionId=" + unitType);
break;
case "order":
props.setParams(
"?type=" + searchBy + "&accessionNumber=" + accessionNumber,
);
break;
case "testDate":
props.setParams("?type=" + searchBy + "&date=" + date);
break;
case "range":
props.setParams(
"?type=" + searchBy + "&accessionNumber=" + accessionNumber,
);
break;
}
getFromOpenElisServer(searchEndPoint, validationResults);
};

Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/validation/Validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ const Validation = (props) => {
if (status == 200) {
message = intl.formatMessage({ id: "validation.save.success" });
kind = NotificationKinds.success;
window.location.href = "/validation" + props.params;
}
addNotification({
kind: kind,
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -833,5 +833,6 @@
"error.report.csv.study": "Please select study type.",
"error.report.csv.date": "Please select date type.",
"header.label.study.vlloadtrends": "Viral Load Data Export Report",
"reports.label.trends": "Trends"
"reports.label.trends": "Trends",
"error.invalid.email": "Invalid Email"
}
3 changes: 2 additions & 1 deletion frontend/src/languages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -776,5 +776,6 @@
"error.report.csv.study": "Veuillez sélectionner le type d'étude.",
"error.report.csv.date": "Veuillez sélectionner le type de date.",
"header.label.study.vlloadtrends": "Rapport d'exportation des données de charge virale",
"reports.label.trends": "Tendances"
"reports.label.trends": "Tendances",
"error.invalid.email": "Email invalide"
}

0 comments on commit 1136351

Please sign in to comment.