From e4e5dd3324cf0bfda26debc8bdcf5e00173d5d76 Mon Sep 17 00:00:00 2001 From: Mutesasira Moses Date: Tue, 19 Sep 2023 12:45:43 +0300 Subject: [PATCH 1/4] optimise fetching user sample types --- frontend/src/components/addOrder/AddOrder.js | 8 ++- .../systemuser/service/UserServiceImpl.java | 56 +++++++++++-------- .../org/openelisglobal/test/dao/TestDAO.java | 2 + .../test/daoimpl/TestDAOImpl.java | 17 ++++++ .../test/service/TestService.java | 2 + .../test/service/TestServiceImpl.java | 5 ++ .../service/TypeOfSampleService.java | 2 - .../service/TypeOfSampleServiceImpl.java | 11 ---- 8 files changed, 66 insertions(+), 37 deletions(-) diff --git a/frontend/src/components/addOrder/AddOrder.js b/frontend/src/components/addOrder/AddOrder.js index d7da07b43f..0ba2c7516c 100644 --- a/frontend/src/components/addOrder/AddOrder.js +++ b/frontend/src/components/addOrder/AddOrder.js @@ -322,8 +322,12 @@ const AddOrder = (props) => { receivedTime: configurationProperties.currentTimeAsText, }, }); - setAllowSiteNameOptions(configurationProperties.restrictFreeTextRefSiteEntry); - setAllowRequesterOptions(configurationProperties.restrictFreeTextProviderEntry); + setAllowSiteNameOptions( + configurationProperties.restrictFreeTextRefSiteEntry, + ); + setAllowRequesterOptions( + configurationProperties.restrictFreeTextProviderEntry, + ); } if (orderFormValues.sampleOrderItems.requestDate != "") { setInnitialized(true); diff --git a/src/main/java/org/openelisglobal/systemuser/service/UserServiceImpl.java b/src/main/java/org/openelisglobal/systemuser/service/UserServiceImpl.java index b0b1400e58..d55a6f5c2f 100644 --- a/src/main/java/org/openelisglobal/systemuser/service/UserServiceImpl.java +++ b/src/main/java/org/openelisglobal/systemuser/service/UserServiceImpl.java @@ -20,8 +20,10 @@ import org.openelisglobal.systemuser.controller.UnifiedSystemUserController; import org.openelisglobal.systemuser.valueholder.SystemUser; import org.openelisglobal.test.beanItems.TestResultItem; +import org.openelisglobal.test.service.TestService; import org.openelisglobal.test.valueholder.Test; import org.openelisglobal.typeofsample.service.TypeOfSampleService; +import org.openelisglobal.typeofsample.valueholder.TypeOfSample; import org.openelisglobal.userrole.service.UserRoleService; import org.openelisglobal.userrole.valueholder.LabUnitRoleMap; import org.openelisglobal.userrole.valueholder.UserLabUnitRoles; @@ -45,6 +47,8 @@ public class UserServiceImpl implements UserService { private TypeOfSampleService typeOfSampleService; @Autowired ProgramService programService; + @Autowired + TestService testService; @Override @Transactional @@ -173,21 +177,29 @@ public List getUserTestSections(String systemUserId, String roleId) public List getUserSampleTypes(String systemUserId, String roleName) { String resultsRoleId = roleService.getRoleByName(roleName).getId(); List testSections = getUserTestSections(systemUserId, resultsRoleId); - List testUnitIds = new ArrayList<>(); + List testUnitIds = new ArrayList<>(); if (testSections != null) { - testSections.forEach(testSection -> testUnitIds.add(testSection.getId())); + testSections.forEach(testSection -> testUnitIds.add(Integer.valueOf(testSection.getId()))); } - List allTests = typeOfSampleService.getAllActiveTestsByTestUnit(true, testUnitIds); - List allSampleTypes = DisplayListService.getInstance().getList(ListType.SAMPLE_TYPE_ACTIVE); + + List allTests = testService.getTestsByTestSectionIds(testUnitIds); Set sampleIds = new HashSet<>(); // clear cache to create a fresh Map of testId To TypeOfSample - typeOfSampleService.clearCache(); - allTests.forEach(test -> sampleIds.addAll( - typeOfSampleService.getTypeOfSampleForTest(test.getId()).stream().map(e -> e.getId()).collect(Collectors.toList()) - )); + List userSampleTypes = new ArrayList<>(); + if (allTests != null ) { + typeOfSampleService.clearCache(); + allTests.forEach(test -> sampleIds.addAll(typeOfSampleService.getTypeOfSampleForTest(test.getId()).stream() + .map(e -> e.getId()).collect(Collectors.toList()))); + + } - List userSampleTypes = allSampleTypes.stream().filter(type -> sampleIds.contains(type.getId())) - .collect(Collectors.toList()); + sampleIds.forEach( id -> { + TypeOfSample type = typeOfSampleService.get(id); + if(type != null){ + userSampleTypes.add(new IdValuePair(type.getId(), type.getLocalizedName())); + } + }); + return userSampleTypes; } @@ -196,12 +208,12 @@ public List filterResultsByLabUnitRoles(String systemUserId, Lis String roleName) { String resultsRoleId = roleService.getRoleByName(roleName).getId(); List testSections = getUserTestSections(systemUserId, resultsRoleId); - List testUnitIds = new ArrayList<>(); + List testUnitIds = new ArrayList<>(); if (testSections != null) { - testSections.forEach(testSection -> testUnitIds.add(testSection.getId())); + testSections.forEach(testSection -> testUnitIds.add(Integer.valueOf(testSection.getId()))); } - List allTests = typeOfSampleService.getAllActiveTestsByTestUnit(true, testUnitIds); + List allTests = testService.getTestsByTestSectionIds(testUnitIds); List allTestsIds = new ArrayList<>(); allTests.forEach(test -> allTestsIds.add(test.getId())); return results.stream().filter(result -> allTestsIds.contains(result.getTestId())).collect(Collectors.toList()); @@ -211,12 +223,12 @@ public List filterResultsByLabUnitRoles(String systemUserId, Lis public List getAllDisplayUserTestsByLabUnit(String SystemUserId, String roleName) { String resultsRoleId = roleService.getRoleByName(roleName).getId(); List testSections = getUserTestSections(SystemUserId, resultsRoleId); - List testUnitIds = new ArrayList<>(); + List testUnitIds = new ArrayList<>(); if (testSections != null) { - testSections.forEach(testSection -> testUnitIds.add(testSection.getId())); + testSections.forEach(testSection -> testUnitIds.add(Integer.valueOf(testSection.getId()))); } - List allTests = typeOfSampleService.getAllActiveTestsByTestUnit(true, testUnitIds); + List allTests = testService.getTestsByTestSectionIds(testUnitIds); List allTestsIds = new ArrayList<>(); allTests.forEach(test -> allTestsIds.add(test.getId())); @@ -231,12 +243,12 @@ public List filterAnalysisResultsByLabUnitRoles(String SystemUserI String roleName) { String resultsRoleId = roleService.getRoleByName(roleName).getId(); List testSections = getUserTestSections(SystemUserId, resultsRoleId); - List testUnitIds = new ArrayList<>(); + List testUnitIds = new ArrayList<>(); if (testSections != null) { - testSections.forEach(testSection -> testUnitIds.add(testSection.getId())); + testSections.forEach(testSection -> testUnitIds.add(Integer.valueOf(testSection.getId()))); } - List allTests = typeOfSampleService.getAllActiveTestsByTestUnit(true, testUnitIds); + List allTests = testService.getTestsByTestSectionIds(testUnitIds); List allTestsIds = new ArrayList<>(); allTests.forEach(test -> allTestsIds.add(test.getId())); return results.stream().filter(result -> allTestsIds.contains(result.getTestId())).collect(Collectors.toList()); @@ -247,12 +259,12 @@ public List filterAnalysesByLabUnitRoles(String SystemUserId, List testSections = getUserTestSections(SystemUserId, resultsRoleId); - List testUnitIds = new ArrayList<>(); + List testUnitIds = new ArrayList<>(); if (testSections != null) { - testSections.forEach(testSection -> testUnitIds.add(testSection.getId())); + testSections.forEach(testSection -> testUnitIds.add(Integer.valueOf(testSection.getId()))); } - List allTests = typeOfSampleService.getAllActiveTestsByTestUnit(true, testUnitIds); + List allTests = testService.getTestsByTestSectionIds(testUnitIds); List allTestsIds = new ArrayList<>(); allTests.forEach(test -> allTestsIds.add(test.getId())); return results.stream().filter(result -> allTestsIds.contains(result.getTest().getId())).collect(Collectors.toList()); diff --git a/src/main/java/org/openelisglobal/test/dao/TestDAO.java b/src/main/java/org/openelisglobal/test/dao/TestDAO.java index 00fdef31e0..36812866a2 100644 --- a/src/main/java/org/openelisglobal/test/dao/TestDAO.java +++ b/src/main/java/org/openelisglobal/test/dao/TestDAO.java @@ -93,6 +93,8 @@ public interface TestDAO extends BaseDAO { List getTestsByTestSectionId(String id) throws LIMSRuntimeException; + List getTestsByTestSectionIds(List ids) throws LIMSRuntimeException; + Test getTestByGUID(String guid) throws LIMSRuntimeException; List getTestsByLoincCode(String loincCode); diff --git a/src/main/java/org/openelisglobal/test/daoimpl/TestDAOImpl.java b/src/main/java/org/openelisglobal/test/daoimpl/TestDAOImpl.java index cf8605faa7..0829b1908f 100644 --- a/src/main/java/org/openelisglobal/test/daoimpl/TestDAOImpl.java +++ b/src/main/java/org/openelisglobal/test/daoimpl/TestDAOImpl.java @@ -690,4 +690,21 @@ public List getAllTestsByDictionaryResult() { } return null; } + + @Override + public List getTestsByTestSectionIds(List ids) throws LIMSRuntimeException { + try { + String sql = "from Test t where t.testSection.id IN (:ids) and t.isActive='Y'"; + Query query = entityManager.unwrap(Session.class).createQuery(sql, Test.class); + query.setParameterList("ids", ids); + + List list = query.list(); + return list; + + } catch (RuntimeException e) { + handleException(e, "getTestsByTestSectionId"); + } + + return null; + } } \ No newline at end of file diff --git a/src/main/java/org/openelisglobal/test/service/TestService.java b/src/main/java/org/openelisglobal/test/service/TestService.java index e527bfb68d..6e0522f59d 100644 --- a/src/main/java/org/openelisglobal/test/service/TestService.java +++ b/src/main/java/org/openelisglobal/test/service/TestService.java @@ -29,6 +29,8 @@ public interface TestService extends BaseObjectService { List getTestsByTestSectionId(String id); + List getTestsByTestSectionIds(List ids); + List getPageOfTestsBySysUserId(int startingRecNo, int sysUserId); Integer getTotalSearchedTestCount(String searchString); diff --git a/src/main/java/org/openelisglobal/test/service/TestServiceImpl.java b/src/main/java/org/openelisglobal/test/service/TestServiceImpl.java index 4913c1e2a5..c0006b5038 100644 --- a/src/main/java/org/openelisglobal/test/service/TestServiceImpl.java +++ b/src/main/java/org/openelisglobal/test/service/TestServiceImpl.java @@ -721,4 +721,9 @@ public void activateTestsAndDeactivateOthers(List testNames) { activateTests(testNames); } + @Override + public List getTestsByTestSectionIds(List ids) { + return getBaseObjectDAO().getTestsByTestSectionIds(ids); + } + } diff --git a/src/main/java/org/openelisglobal/typeofsample/service/TypeOfSampleService.java b/src/main/java/org/openelisglobal/typeofsample/service/TypeOfSampleService.java index 21e538a600..4ed4efe691 100644 --- a/src/main/java/org/openelisglobal/typeofsample/service/TypeOfSampleService.java +++ b/src/main/java/org/openelisglobal/typeofsample/service/TypeOfSampleService.java @@ -41,8 +41,6 @@ public interface TypeOfSampleService extends BaseObjectService getActiveTestsBySampleTypeIdAndTestUnit(String sampleType, boolean b, List testUnitIds); - List getAllActiveTestsByTestUnit(boolean b, List testUnitIds); - TypeOfSample getTransientTypeOfSampleById(String sampleTypeId); void clearCache(); diff --git a/src/main/java/org/openelisglobal/typeofsample/service/TypeOfSampleServiceImpl.java b/src/main/java/org/openelisglobal/typeofsample/service/TypeOfSampleServiceImpl.java index 9594e7968d..2a99c3a721 100644 --- a/src/main/java/org/openelisglobal/typeofsample/service/TypeOfSampleServiceImpl.java +++ b/src/main/java/org/openelisglobal/typeofsample/service/TypeOfSampleServiceImpl.java @@ -104,17 +104,6 @@ public synchronized List getActiveTestsBySampleTypeIdAndTestUnit(String sa .collect(Collectors.toList()); } - @Override - public List getAllActiveTestsByTestUnit(boolean b, List testUnitIds) { - List allTests = new ArrayList<>(); - List allSampleTypes = getAllTypeOfSamples(); - allSampleTypes.forEach(sample -> { - List testList = getActiveTestsBySampleTypeIdAndTestUnit(sample.getId(), b, testUnitIds); - allTests.addAll(testList); - }); - return allTests; - } - @Override @Transactional(readOnly = true) public List getAllTestsBySampleTypeId(String sampleTypeId) { From 4c34701abcdcd6f35c8c9c0cf992c2099ad0892e Mon Sep 17 00:00:00 2001 From: Mutesasira Moses Date: Tue, 19 Sep 2023 18:26:08 +0300 Subject: [PATCH 2/4] fix result validation --- .../SearchResultValidationFormValues.js | 112 --- frontend/src/components/layout/Header.js | 3 + .../components/resultPage/SearchResultForm.js | 52 +- .../resultValidation/ResultValidation.js | 16 - .../src/components/validation/SearchForm.js | 27 +- .../validation/SearchResultValidationForm.js | 671 ------------------ .../src/components/validation/Validation.js | 4 +- frontend/src/languages/en.json | 15 +- frontend/src/languages/fr.json | 13 +- .../AccessionValidationRestController.java | 57 +- .../service/ResultValidationServiceImpl.java | 4 +- 11 files changed, 129 insertions(+), 845 deletions(-) delete mode 100644 frontend/src/components/formModel/innitialValues/SearchResultValidationFormValues.js delete mode 100644 frontend/src/components/resultValidation/ResultValidation.js delete mode 100644 frontend/src/components/validation/SearchResultValidationForm.js diff --git a/frontend/src/components/formModel/innitialValues/SearchResultValidationFormValues.js b/frontend/src/components/formModel/innitialValues/SearchResultValidationFormValues.js deleted file mode 100644 index 07cfee38fc..0000000000 --- a/frontend/src/components/formModel/innitialValues/SearchResultValidationFormValues.js +++ /dev/null @@ -1,112 +0,0 @@ -export default { - formName: "", - accessionNumber: "", - lastName: "", - firstName: "", - gender: "", - dob: "", - nationalId: "", - subjectNumber: "", - initialSampleCondition: "", - sampleType: "", - testDate: "", - analysisMethod: "", - testName: "", - - testResult: [ - { - accessionNumber: "", - analysisId: "", - analysisMethod: "", - analysisStatusId: "", - childReflex: "", - considerRejectReason: "", - defaultResultValue: "", - dictionaryResults: [], - displayResultAsLog: "", - enumResultType: "", - failedValidation: "", - forceTechApproval: "", - hasQualifiedResult: "", - initialSampleCondition: "", - isGroupSeparator: "", - isModified: "", - lowerAbnormalRange: "", - lowerNormalRange: "", - multiSelectResultValues: "", - nationalId: "", - nextVisitDate: "", - nonconforming: "", - normal: "", - normalRange: "", - notIncludedInWorkplan: "", - note: "", - pastNotes: "", - patientInfo: "", - patientName: "", - qualifiedDictionaryId: "", - qualifiedResultId: "", - qualifiedResultValue: "", - rawResultDisplayType: "", - readOnly: "", - receivedDate: "", - refer: "", - referralCanceled: "", - referralId: "", - referralItem: "", - referralReasonId: "", - referredOut: "", - reflexGroup: "", - reflexJSONResult: "", - reflexParentGroup: "", - rejectReasonId: "", - rejected: "", - remarks: "", - remove: "", - removed: "", - reportable: "", - result: "", - resultDisplayType: "", - resultId: "", - resultLimitId: "", - resultType: "", - resultValue: "", - sampleGroupingNumber: "", - sampleSource: "", - sampleType: "", - sequenceAccessionNumber: "", - sequenceNumber: "", - servingAsTestGroupIdentifier: "", - shadowReferredOut: "", - shadowRejected: "", - shadowResultValue: "", - showSampleDetails: "", - siblingReflexKey: "", - significantDigits: "", - technician: "", - technicianSignatureId: "", - testDate: "", - testId: "", - testKit1InventoryId: "", - testKitId: "", - testKitInactive: "", - testKitInventoryId: "", - testMethod: "", - testName: "", - testSortOrder: "", - thisReflexKey: "", - unitsOfMeasure: "", - upperAbnormalRange: "", - upperNormalRange: "", - userChoiceReflex: "", - valid: "", - }, - ], - - methods: [ - { - id: "", - value: "", - }, - ], -}; diff --git a/frontend/src/components/layout/Header.js b/frontend/src/components/layout/Header.js index 19103d9986..db3b35dab6 100644 --- a/frontend/src/components/layout/Header.js +++ b/frontend/src/components/layout/Header.js @@ -330,6 +330,9 @@ function OEHeader(props) { + + + diff --git a/frontend/src/components/resultPage/SearchResultForm.js b/frontend/src/components/resultPage/SearchResultForm.js index 111371d5a4..32d894e9d6 100644 --- a/frontend/src/components/resultPage/SearchResultForm.js +++ b/frontend/src/components/resultPage/SearchResultForm.js @@ -193,13 +193,16 @@ export function SearchResultForm(props) { > -
+ + {searchBy.type === "unit" && ( {({ field }) => ( + } name={field.name} id={field.name} > @@ -313,7 +333,9 @@ export function SearchResultForm(props) { {({ field }) => ( + } name={field.name} id={field.name} > diff --git a/frontend/src/components/resultValidation/ResultValidation.js b/frontend/src/components/resultValidation/ResultValidation.js deleted file mode 100644 index f0849b959b..0000000000 --- a/frontend/src/components/resultValidation/ResultValidation.js +++ /dev/null @@ -1,16 +0,0 @@ -import React from "react"; -import "../Style.css"; -import { injectIntl } from "react-intl"; -import SearchResultValidationForm from "../common/SearchResultValidationForm"; - -function ResultValidation() { - return ( - <> -
- -
- - ); -} - -export default injectIntl(ResultValidation); diff --git a/frontend/src/components/validation/SearchForm.js b/frontend/src/components/validation/SearchForm.js index 2892025e70..c6743e3c22 100644 --- a/frontend/src/components/validation/SearchForm.js +++ b/frontend/src/components/validation/SearchForm.js @@ -27,6 +27,7 @@ const SearchForm = (props) => { const { setNotificationVisible, setNotificationBody } = useContext(NotificationContext); const [searchResults, setSearchResults] = useState(); const [searchBy, setSearchBy] = useState(); + const [doRange, setDoRagnge] = useState(true); const [testSections, setTestSections] = useState([]); const [testDate, setTestDate] = useState(""); const [isLoading, setIsLoading] = useState(false); @@ -34,9 +35,9 @@ const SearchForm = (props) => { if (data) { setSearchResults(data); if (data.resultList.length > 0) { - const newResultsList = data.resultList.map((data, idx) => { + const newResultsList = data.resultList.map((data, id) => { let tempData = { ...data } - tempData.id = idx + tempData.id = id return tempData }); setSearchResults(prevState => ({ @@ -69,10 +70,12 @@ const SearchForm = (props) => { var accessionNumber = values.accessionNumber ? values.accessionNumber : ""; var unitType = values.unitType ? values.unitType : "" var date = testDate ? testDate : "" - let searchEndPoint = "/rest/accessionValidationByRange?" + + let searchEndPoint = "/rest/accessionValidation?" + "accessionNumber=" + accessionNumber + "&unitType=" + unitType + - "&date=" + date + "&date=" + date + + "&doRange=" + doRange; + getFromOpenElisServer(searchEndPoint, validationResults); } @@ -92,6 +95,9 @@ const SearchForm = (props) => { useEffect(() => { let param = (new URLSearchParams(window.location.search)).get("type") setSearchBy(param); + if(param === "order"){ + setDoRagnge(false) + } getFromOpenElisServer('/rest/user-test-sections', fetchTestSections); }, []); return ( @@ -126,13 +132,13 @@ const SearchForm = (props) => {
- {searchBy === "order" && {({ field }) => + name={field.name} id={field.name} labelText={searchBy == "order"? : } /> } }
@@ -141,7 +147,7 @@ const SearchForm = (props) => { {({ field }) => - return ( - <> -
- -
- - ); - - case "Accept": - return ( - <> - - {({ field }) => - this.handleAcceptAsIsChange(e, row.id)} - /> - } - - - ); - - case "Notes": - - - return ( - <> -
- -
- - ); - - case "Result": - switch (row.resultType) { - case "D": - return - - case "N": - - return this.handleChange(e, row.id)} - /> - - - default: - return row.resultValue - } - - case "Current Result": - switch (row.resultType) { - case "D": - return - - case "N": - - - return this.handleChange(e, row.id)} - /> - - - default: - return row.resultValue - } - default : - break - - } - return row.resultValue; - } - - renderReferral = ({ data }) =>
-        
- - -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- - this.handleDatePickerChange(date, data.id)} - > - - - -
-
- -
; - - validateResults = (e, rowId, row) => { - console.log("validateResults:" + e.target.value) - // e.target.value; - this.handleChange(e, rowId) - } - - // validateResults = (e, rowId) => { - // console.log("validateResults:") - // this.handleChange(e, rowId) - // } - - - handleChange = (e, rowId) => { - const { name, id, value } = e.target; - console.log("handleChange:" + id + ":" + name + ":" + value + ":" + rowId); - // this.setState({value: e.target.value}) - // console.log('State updated to ', e.target.value); - var form = this.state.resultForm; - var jp = require('jsonpath'); - jp.value(form, name, value); - var isModified = "testResult[" + rowId + "].isModified"; - jp.value(form, isModified, "true"); - } - - - handleDatePickerChange = (date, rowId) => { - console.log("handleDatePickerChange:" + date) - const d = new Date(date).toLocaleDateString('fr-FR'); - var form = this.state.resultForm; - var jp = require('jsonpath'); - jp.value(form, "testResult[" + rowId + "].sentDate_", d); - var isModified = "testResult[" + rowId + "].isModified"; - jp.value(form, isModified, "true"); - } - - handleDoRangeChange = () => { - console.log("handleDoRangeChange:") - this.state.doRange = !this.state.doRange; - } - - handleFinishedChange = () => { - console.log("handleFinishedChange:") - this.state.finished = !this.state.finished; - } - - handleAcceptAsIsChange = (e, rowId) => { - console.log("handleAcceptAsIsChange:" + this.state.acceptAsIs[rowId]) - this.handleChange(e, rowId) - if (this.state.acceptAsIs[rowId] == undefined) { - var message = `Checking this box will indicate that you accept the results unconditionally.\n` + - `Expected uses:\n` + - `1. The test has been redone and the result is the same.\n` + - `2. There is no result for the test but you do not want to cancel it.\n` + - `3. The result was changed and the technician wants to give the biologist the option to add a note during the validation step explaining the reason of the change.\n` + - `In either case, leave a note explaining why you are taking this action.\n` - - // message=`Incorrect Username/Password Used \n Please try again…` - - - alert(message); - - this.context.setNotificationBody({ - title: , - message: message, - kind: NotificationKinds.warning - }) - this.context.setNotificationVisible(true); - } - this.state.acceptAsIs[rowId] = !this.state.acceptAsIs[rowId]; - } - - handleSaveChange = () => { - console.log("handleSaveChange:") - - } - - handleSave = (values) => { - //console.log("handleSave:" + values); - values.status = this.state.saveStatus; - var searchEndPoint = "/rest/ReactLogbookResultsUpdate" - postToOpenElisServer(searchEndPoint, JSON.stringify(this.state.resultForm), this.setStatus); - } - - handleSubmit = (values) => { - values.dateOfBirth = this.state.dob - //console.log("handleSubmit:" + this.state.doRange) - this.setState({ resultForm: { testResult: [] }, }); - - var searchEndPoint = "/rest/ReactLogbookResultsByRange?" + - "&labNumber=" + values.labNumber + - "&doRange=" + this.state.doRange + - "&finished=" + this.state.finished - getFromOpenElisServer(searchEndPoint, this.setResults); - }; - - setResults = (resultForm) => { - //console.log("setResults") - var i = 0; - resultForm.testResult.forEach(item => item.id = "" + i++); - this.setState({ resultForm: resultForm }) - } - - setStatus = (status) => { - //console.log("setStatus" + status) - if (status != 200) { - this.context.setNotificationBody({ - title: , - message: "Error: " + status, - kind: NotificationKinds.error - }) - } else { - this.context.setNotificationBody({ - title: , - message: "Success: " + status, - kind: NotificationKinds.success - }) - } - this.context.setNotificationVisible(true); - } - - - - handlePageChange = (pageInfo) => { - if (this.state.page != pageInfo.page) { - this.setState({ page: pageInfo.page }); - } - if (this.state.pageSize != pageInfo.pageSize) { - this.setState({ pageSize: pageInfo.pageSize }); - } - }; - - handlePerPageChange = (newPerPage) => { - this.setState({ perPage: newPerPage }); - }; - - render() { - const { page, pageSize } = this.state; - // const prefix = this.state.prefix; - return ( - <> - {this.context.notificationVisible === true ? : ""} - - - - - {({ values, - errors, - touched, - handleChange, - //handleBlur, - handleSubmit - }) => ( - -
- - - -
-
-
- - - -
-
-
-
- - {({ field }) => - - } - - - - - {({ field }) => - - } - - - - - {({ field }) => - (this.state.doRange = false)} - name={field.name} - labelText="Show Next 99 Orders" - id={field.name} /> - } - - - - -
-
- )} -
- {/*
*/} - {/* */} - {/* */} - - {/* {this.myComponent()} */} - - <> - - {({ values, - errors, - touched, - handleChange, - //handleBlur, - handleSubmit }) => ( - -
- - - - - -
)} -
- -
-
- - - ); - - } -} - -export default injectIntl(SearchResultValidationForm) \ No newline at end of file diff --git a/frontend/src/components/validation/Validation.js b/frontend/src/components/validation/Validation.js index d1d66dfcf7..58f4e5a02e 100644 --- a/frontend/src/components/validation/Validation.js +++ b/frontend/src/components/validation/Validation.js @@ -125,10 +125,10 @@ const Validation = (props) => { handleResponse, ); }; - const handleResponse = (response) => { + const handleResponse = (status) => { let message = "Oops, try gain"; let kind = NotificationKinds.error; - if (response.status === 200) { + if (status == 200) { message = "Results have been validated successfully"; kind = NotificationKinds.success; } diff --git a/frontend/src/languages/en.json b/frontend/src/languages/en.json index bbe700aa32..64fccd3855 100644 --- a/frontend/src/languages/en.json +++ b/frontend/src/languages/en.json @@ -278,6 +278,19 @@ "immunohistochemistry.label.dashboard" : "Immunohistochemistry DashBoard" , "cytology.label.dashboard" : "Cytology DashBoard" , "label.button.start" : "Start" , - "label.button.sample" : "Sample" + "label.button.sample" : "Sample" , + "search.label.accession" : "Enter Accession Number" , + "search.label.testunit" : "Select Test Unit" , + "search.label.testdate" : "Enter Test Date" , + "search.label.collectiondate" : "Enter Collection Date" , + "search.label.recieveddate" : "Enter Recieved Date" , + "search.label.fromaccession" : "From Accesion Number" , + "search.label.toaccession" : "To Accesion Number" , + "search.label.loadnext" : "Load Next 99 Records Starting at Lab Number" , + "search.label.analysis" : "Select Analysis Status" , + "search.label.test" : "Select Test Name" , + "search.label.sample" : "Select Sample Status" + + } diff --git a/frontend/src/languages/fr.json b/frontend/src/languages/fr.json index 01c9f0dfb2..bbd87c96a5 100644 --- a/frontend/src/languages/fr.json +++ b/frontend/src/languages/fr.json @@ -276,5 +276,16 @@ "immunohistochemistry.label.dashboard": "Tableau de bord en immunohistochimie", "cytology.label.dashboard": "Tableau de bord en cytologie", "label.button.start" : "Commencer" , - "label.button.sample" : "Échantillon" + "label.button.sample" : "Échantillon" , + "search.label.accession" : "Saisissez le numéro d'accès", + "search.label.testunit" : "Sélectionnez l'unité de test", + "search.label.testdate" : "Saisissez la date du test", + "search.label.collectiondate" : "Saisissez la date de collecte", + "search.label.recieveddate" : "Saisissez la date de réception", + "search.label.fromaccession" : "Du numéro d'accès", + "search.label.toaccession" : "Au numéro d'accès", + "search.label.loadnext" : "Charger les 99 enregistrements suivants à partir du numéro de laboratoire", + "search.label.analysis" : "Sélectionnez l'état de l'analyse", + "search.label.test" : "Sélectionnez le nom du test", + "search.label.sample" : "Sélectionnez l'état de l'échantillon" } diff --git a/src/main/java/org/openelisglobal/resultvalidation/controller/rest/AccessionValidationRestController.java b/src/main/java/org/openelisglobal/resultvalidation/controller/rest/AccessionValidationRestController.java index b1e8b569dc..8888df3b08 100644 --- a/src/main/java/org/openelisglobal/resultvalidation/controller/rest/AccessionValidationRestController.java +++ b/src/main/java/org/openelisglobal/resultvalidation/controller/rest/AccessionValidationRestController.java @@ -1,5 +1,6 @@ package org.openelisglobal.resultvalidation.controller.rest; +import org.apache.commons.lang3.StringUtils; import org.openelisglobal.analysis.service.AnalysisService; import org.openelisglobal.analysis.valueholder.Analysis; import org.openelisglobal.common.action.IActionConstants; @@ -40,6 +41,7 @@ import org.openelisglobal.resultvalidation.util.ResultValidationSaveService; import org.openelisglobal.resultvalidation.util.ResultsValidationUtility; import org.openelisglobal.role.service.RoleService; +import org.openelisglobal.sample.service.SampleService; import org.openelisglobal.sample.valueholder.Sample; import org.openelisglobal.samplehuman.service.SampleHumanService; import org.openelisglobal.search.service.SearchResultsService; @@ -78,6 +80,9 @@ public class AccessionValidationRestController extends BaseResultValidationContr @Autowired SearchResultsService searchService; + @Autowired + private SampleService sampleService; + private static final String[] ALLOWED_FIELDS = new String[]{"testSectionId", "paging.currentPage", "testSection", @@ -126,25 +131,25 @@ public void initBinder(WebDataBinder binder) { binder.setAllowedFields(ALLOWED_FIELDS); } - // @RequestMapping(value = { "/AccessionValidationRange", "/ResultValidationByTestDate" }, method = RequestMethod.GET) - @GetMapping(value = "accessionValidationByRange", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(value = "accessionValidation", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public ResultValidationForm showAccessionValidationRange(HttpServletRequest request, - @ModelAttribute("form") @Validated(ResultValidationForm.ResultValidation.class) ResultValidationForm oldForm) + @RequestParam(required = false) String accessionNumber, @RequestParam(required = false) String date, + @RequestParam(required = false) String unitType, @RequestParam(defaultValue = "true") Boolean doRange) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { - + ResultValidationForm newForm = new ResultValidationForm(); - if (request.getParameter("accessionNumber") != null && !Objects.equals(request.getParameter("accessionNumber"), "")) { - newForm.setAccessionNumber(request.getParameter("accessionNumber")); - } else if (request.getParameter("date") != null && !Objects.equals(request.getParameter("date"), "")) { - newForm.setTestDate(request.getParameter("date")); - }else if(request.getParameter("unitType") != null && !Objects.equals(request.getParameter("unitType"), "")){ - newForm.setTestSectionId(request.getParameter("unitType")); - } - return getResultValidation(request, newForm); + if (StringUtils.isNotBlank(accessionNumber)) { + newForm.setAccessionNumber(accessionNumber); + } else if (StringUtils.isNotBlank(date)) { + newForm.setTestDate(date); + } else if (StringUtils.isNotBlank(unitType)) { + newForm.setTestSectionId(unitType); + } + return getResultValidation(request, newForm ,doRange); } - private ResultValidationForm getResultValidation(HttpServletRequest request, ResultValidationForm form) + private ResultValidationForm getResultValidation(HttpServletRequest request, ResultValidationForm form ,Boolean doRange) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { @@ -173,7 +178,7 @@ private ResultValidationForm getResultValidation(HttpServletRequest request, Res ts = testSectionService.get(form.getTestSectionId()); } - List resultList; + List resultList = new ArrayList<>(); ResultsValidationUtility resultsValidationUtility = SpringContext.getBean(ResultsValidationUtility.class); if (request.getRequestURI().contains("AccessionValidationRange")) { @@ -184,10 +189,18 @@ private ResultValidationForm getResultValidation(HttpServletRequest request, Res if (!(GenericValidator.isBlankOrNull(form.getTestSectionId()) && GenericValidator.isBlankOrNull(form.getAccessionNumber()) && GenericValidator.isBlankOrNull(form.getTestDate()))) { - - resultList = resultsValidationUtility.getResultValidationList(getValidationStatus(), + + if (doRange) { + resultList = resultsValidationUtility.getResultValidationList(getValidationStatus(), form.getTestSectionId(), form.getAccessionNumber(), form.getTestDate()); - + } else { + if (StringUtils.isNotBlank(form.getAccessionNumber())) { + Sample sample = getSample(form.getAccessionNumber()); + resultList = resultsValidationUtility.getValidationAnalysisBySample(sample); + } + + } + filteredresultList = userService.filterAnalysisResultsByLabUnitRoles(getSysUserId(request), resultList, Constants.ROLE_VALIDATION); request.setAttribute("pageSize", filteredresultList.size()); @@ -236,7 +249,7 @@ public ResultValidationForm showAccessionValidationRangeSave(HttpServletRequest System.out.println("Post:LogbookResultsRestController:" + form); if ("true".equals(request.getParameter("pageResults"))) { - return getResultValidation(request, form); + return getResultValidation(request, form ,false); } form.setSearchFinished(false); @@ -590,6 +603,14 @@ private SystemUser createSystemUser() { return systemUserService.get(getSysUserId(request)); } + private Sample getSample(String accessionNumber) { + return sampleService.getSampleByAccessionNumber(accessionNumber); + } + + private Patient getPatient(Sample sample) { + return sampleHumanService.getPatientForSample(sample); + } + @Override protected String findLocalForward(String forward) { if (FWD_SUCCESS.equals(forward)) { diff --git a/src/main/java/org/openelisglobal/resultvalidation/service/ResultValidationServiceImpl.java b/src/main/java/org/openelisglobal/resultvalidation/service/ResultValidationServiceImpl.java index db0912ba47..e8000287f6 100644 --- a/src/main/java/org/openelisglobal/resultvalidation/service/ResultValidationServiceImpl.java +++ b/src/main/java/org/openelisglobal/resultvalidation/service/ResultValidationServiceImpl.java @@ -83,7 +83,9 @@ public void persistdata(List deletableList, List analysisUpdat for (Note note : noteUpdateList) { if (note != null) { if (note.getId() == null) { - noteService.insert(note); + if (!noteService.duplicateNoteExists(note)) { + noteService.insert(note); + } } else { noteService.update(note); } From 9d652efaf9e55014d99075468535472446c0cabe Mon Sep 17 00:00:00 2001 From: abertnamanya Date: Tue, 19 Sep 2023 20:06:59 +0300 Subject: [PATCH 3/4] added patient age dates --- .../components/patient/CreatePatientForm.js | 135 ++++++++++++++++-- 1 file changed, 122 insertions(+), 13 deletions(-) diff --git a/frontend/src/components/patient/CreatePatientForm.js b/frontend/src/components/patient/CreatePatientForm.js index ef8098745f..6e350dddc5 100644 --- a/frontend/src/components/patient/CreatePatientForm.js +++ b/frontend/src/components/patient/CreatePatientForm.js @@ -3,6 +3,7 @@ import { FormattedMessage, injectIntl } from "react-intl"; import "../Style.css"; import { getFromOpenElisServer, postToOpenElisServer } from "../utils/Utils"; import { nationalityList } from "../data/countries"; +import format from 'date-fns/format' import { Heading, @@ -39,13 +40,86 @@ function CreatePatientForm(props) { const [maritalStatuses, setMaritalStatuses] = useState([]); const [formAction, setFormAction] = useState("ADD"); const componentMounted = useRef(false); + const [dateOfBirthFormatter,setDateOfBirthFormatter] = useState({ + "years": "", "months": "", "days": "" + }) const handleDatePickerChange = (values, ...e) => { var patient = values; patient.birthDateForDisplay = e[1]; setPatientDetails(patient); + if (patient.birthDateForDisplay !== "") { + getYearsMonthsDaysFromDOB(patient.birthDateForDisplay) + } }; + function getYearsMonthsDaysFromDOB(date) { + const selectedDate = date.split('/'); + let today = new Date(); + + let year = today.getFullYear(); + let month = today.getMonth() + 1; + let day = today.getDate(); + + let yy = parseInt(selectedDate[2]); + let mm = parseInt(selectedDate[1]); + let dd = parseInt(selectedDate[0]); + + let years, months, days; + months = month - mm; + if (day < dd) { + months = months - 1; + } + years = year - yy; + if (month * 100 + day < mm * 100 + dd) { + years = years - 1; + months = months + 12; + } + days = Math.floor((today.getTime() - (new Date(yy + years, mm + months - 1, dd)).getTime()) / (24 * 60 * 60 * 1000)); + + setDateOfBirthFormatter({ + ...dateOfBirthFormatter, + years: years, months: months, days: days + }); + } + + const getDOBByYearMonthsDays = () => { + const currentDate = new Date(); + const pastDate = new Date(); + + pastDate.setFullYear(currentDate.getFullYear() - dateOfBirthFormatter.years); + pastDate.setMonth(currentDate.getMonth() - dateOfBirthFormatter.months); + pastDate.setDate(currentDate.getDate() - dateOfBirthFormatter.days); + const dob = format(new Date(pastDate),'dd/MM/yyyy'); + setPatientDetails((prevState) => ({ + ...prevState, + birthDateForDisplay: dob, + })); + } + + function handleYearsChange(e){ + let years = e.target.value; + setDateOfBirthFormatter({ + ...dateOfBirthFormatter, + years: years + }); + } + + function handleMonthsChange(e){ + let months = e.target.value; + setDateOfBirthFormatter({ + ...dateOfBirthFormatter, + months: months + }); + } + + function handleDaysChange(e){ + let days = e.target.value; + setDateOfBirthFormatter({ + ...dateOfBirthFormatter, + days: days + }); + } const handleRegionSelection = (e, values) => { var patient = values; patient.healthDistrict = ""; @@ -61,6 +135,10 @@ function CreatePatientForm(props) { setHealthDistricts(res); } + useEffect(()=>{ + getDOBByYearMonthsDays(); + },[dateOfBirthFormatter]) + useEffect(() => { if (props.selectedPatient.patientPK) { if (props.selectedPatient.healthRegion != null) { @@ -76,6 +154,7 @@ function CreatePatientForm(props) { const patient = props.selectedPatient; patient.patientUpdateStatus = "UPDATE"; setPatientDetails(patient); + getYearsMonthsDaysFromDOB(patient.birthDateForDisplay); setFormAction("UPDATE"); } }, [props.selectedPatient]); @@ -87,6 +166,7 @@ function CreatePatientForm(props) { props.orderFormValues.patientProperties.guid !== "" ) { setPatientDetails(props.orderFormValues.patientProperties); + getYearsMonthsDaysFromDOB(props.orderFormValues.patientProperties.birthDateForDisplay); } } }; @@ -393,20 +473,33 @@ function CreatePatientForm(props) { )}
- - {({ field }) => ( - - - - - )} - + /> + + + +
@@ -414,6 +507,22 @@ function CreatePatientForm(props) {
+
+ + {({ field }) => ( + + + + + )} + +
From 04e5ce73148432bb2a252f1834e5475475139b32 Mon Sep 17 00:00:00 2001 From: Mutesasira Moses Date: Tue, 19 Sep 2023 20:47:56 +0300 Subject: [PATCH 4/4] fix modify order --- .../src/components/modifyOrder/ModifyOrder.js | 2 ++ .../systemuser/service/UserServiceImpl.java | 22 +++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/modifyOrder/ModifyOrder.js b/frontend/src/components/modifyOrder/ModifyOrder.js index 38b88c0770..30797abb49 100644 --- a/frontend/src/components/modifyOrder/ModifyOrder.js +++ b/frontend/src/components/modifyOrder/ModifyOrder.js @@ -11,9 +11,11 @@ function ModifyOrder() { return ( <> +
+
); } diff --git a/src/main/java/org/openelisglobal/systemuser/service/UserServiceImpl.java b/src/main/java/org/openelisglobal/systemuser/service/UserServiceImpl.java index d55a6f5c2f..72b8388fb5 100644 --- a/src/main/java/org/openelisglobal/systemuser/service/UserServiceImpl.java +++ b/src/main/java/org/openelisglobal/systemuser/service/UserServiceImpl.java @@ -172,7 +172,7 @@ public List getUserTestSections(String systemUserId, String roleId) return userTestSections; } } - + @Override public List getUserSampleTypes(String systemUserId, String roleName) { String resultsRoleId = roleService.getRoleByName(roleName).getId(); @@ -181,22 +181,26 @@ public List getUserSampleTypes(String systemUserId, String roleName if (testSections != null) { testSections.forEach(testSection -> testUnitIds.add(Integer.valueOf(testSection.getId()))); } - + List allTests = testService.getTestsByTestSectionIds(testUnitIds); Set sampleIds = new HashSet<>(); // clear cache to create a fresh Map of testId To TypeOfSample List userSampleTypes = new ArrayList<>(); - if (allTests != null ) { + if (allTests != null) { typeOfSampleService.clearCache(); - allTests.forEach(test -> sampleIds.addAll(typeOfSampleService.getTypeOfSampleForTest(test.getId()).stream() - .map(e -> e.getId()).collect(Collectors.toList()))); + allTests.forEach(test -> { + List sampleTypes = typeOfSampleService.getTypeOfSampleForTest(test.getId()); + if (sampleTypes != null) { + sampleIds.addAll(sampleTypes.stream().map(e -> e.getId()).collect(Collectors.toList())); + } + }); } - - sampleIds.forEach( id -> { + + sampleIds.forEach(id -> { TypeOfSample type = typeOfSampleService.get(id); - if(type != null){ - userSampleTypes.add(new IdValuePair(type.getId(), type.getLocalizedName())); + if (type != null) { + userSampleTypes.add(new IdValuePair(type.getId(), type.getLocalizedName())); } });