Skip to content

Commit

Permalink
Merge branch 'I-TECH-UW:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Nirvanjha2004 authored Jan 11, 2025
2 parents d5c5d38 + e0a6881 commit d21ca0c
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 103 deletions.
6 changes: 3 additions & 3 deletions frontend/cypress/pages/ModifyOrderPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class ModifyOrderPage {

clickRespectivePatient() {
return cy
.get('tbody tr')
.first()
.find('.cds--radio-button__appearance')
.get("tbody tr")
.first()
.find(".cds--radio-button__appearance")
.click();
}
}
Expand Down
39 changes: 33 additions & 6 deletions frontend/src/components/patient/CreatePatientForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,16 @@ function CreatePatientForm(props) {
};

function handleYearsChange(e, values) {
setPatientDetails(values);
let years = e.target.value;
// Ensure years is not negative
const years = Math.max(0, Number(e.target.value));

// Update form values with the validated years
setPatientDetails({
...values,
// Update the specific field that contains years to ensure the form shows the corrected value
[e.target.name]: years,
});

let dobFormatter = {
...dateOfBirthFormatter,
years: years,
Expand All @@ -153,8 +161,16 @@ function CreatePatientForm(props) {
}

function handleMonthsChange(e, values) {
setPatientDetails(values);
let months = e.target.value;
// Ensure months is not negative
const months = Math.max(0, Number(e.target.value));

// Update form values with the validated months
setPatientDetails({
...values,
// Update the specific field that contains months to ensure the form shows the corrected value
[e.target.name]: months,
});

let dobFormatter = {
...dateOfBirthFormatter,
months: months,
Expand All @@ -163,8 +179,16 @@ function CreatePatientForm(props) {
}

function handleDaysChange(e, values) {
setPatientDetails(values);
let days = e.target.value;
// Ensure days is not negative
const days = Math.max(0, Number(e.target.value));

// Update form values with the validated days
setPatientDetails({
...values,
// Update the specific field that contains days to ensure the form shows the corrected value
[e.target.name]: days,
});

let dobFormatter = {
...dateOfBirthFormatter,
days: days,
Expand Down Expand Up @@ -625,6 +649,7 @@ function CreatePatientForm(props) {
})}
id="years"
type="number"
min="0"
onChange={(e) => handleYearsChange(e, values)}
placeholder={intl.formatMessage({
id: "patient.information.age",
Expand All @@ -637,6 +662,7 @@ function CreatePatientForm(props) {
name="months"
labelText={intl.formatMessage({ id: "patient.age.months" })}
type="number"
min="0"
onChange={(e) => handleMonthsChange(e, values)}
id="months"
placeholder={intl.formatMessage({
Expand All @@ -649,6 +675,7 @@ function CreatePatientForm(props) {
value={dateOfBirthFormatter.days}
name="days"
type="number"
min="0"
onChange={(e) => handleDaysChange(e, values)}
labelText={intl.formatMessage({ id: "patient.age.days" })}
id="days"
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<minor.version>1</minor.version>
<state.version>0</state.version>
<!-- 0 = alpha, 1 = beta, 2 = rc, 3 = deployable -->
<fix.version>0</fix.version>
<fix.version>1</fix.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<liquibase.propertyFile>${project.basedir}/liquibase/liquibase.properties</liquibase.propertyFile>
<castor.version>1.4.1</castor.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import org.openelisglobal.common.form.BaseForm;
import org.openelisglobal.common.log.LogEvent;
import org.openelisglobal.common.util.ConfigurationProperties;
import org.openelisglobal.common.util.ControllerUtills;
import org.openelisglobal.common.util.StringUtil;
import org.openelisglobal.internationalization.MessageUtil;
import org.openelisglobal.login.dao.UserModuleService;
import org.openelisglobal.login.valueholder.UserSessionData;
import org.openelisglobal.view.PageBuilderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
Expand All @@ -28,7 +28,7 @@
import org.springframework.web.servlet.support.RequestContextUtils;

@Component
public abstract class BaseController implements IActionConstants {
public abstract class BaseController extends ControllerUtills implements IActionConstants {

// Request being autowired appears to be threadsafe because of how Spring
// handles autowiring, despite all controllers being singletons
Expand Down Expand Up @@ -183,17 +183,6 @@ protected void setPageTitles(HttpServletRequest request, BaseForm form) {
}
}

protected String getSysUserId(HttpServletRequest request) {
UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA);
if (usd == null) {
usd = (UserSessionData) request.getAttribute(USER_SESSION_DATA);
if (usd == null) {
return null;
}
}
return String.valueOf(usd.getSystemUserId());
}

protected void setSuccessFlag(HttpServletRequest request, boolean success) {
request.setAttribute(FWD_SUCCESS, success);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
package org.openelisglobal.common.rest;

import javax.servlet.http.HttpServletRequest;
import org.openelisglobal.common.action.IActionConstants;
import org.openelisglobal.login.valueholder.UserSessionData;
import org.openelisglobal.common.util.ControllerUtills;
import org.springframework.stereotype.Component;

@Component
public class BaseRestController implements IActionConstants {
public class BaseRestController extends ControllerUtills implements IActionConstants {

protected String getSysUserId(HttpServletRequest request) {
UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA);
if (usd == null) {
usd = (UserSessionData) request.getAttribute(USER_SESSION_DATA);
if (usd == null) {
return null;
}
}
return String.valueOf(usd.getSystemUserId());
}
}
}
19 changes: 19 additions & 0 deletions src/main/java/org/openelisglobal/common/util/ControllerUtills.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.openelisglobal.common.util;

import javax.servlet.http.HttpServletRequest;
import org.openelisglobal.common.action.IActionConstants;
import org.openelisglobal.login.valueholder.UserSessionData;

public class ControllerUtills {

protected String getSysUserId(HttpServletRequest request) {
UserSessionData usd = (UserSessionData) request.getSession().getAttribute(IActionConstants.USER_SESSION_DATA);
if (usd == null) {
usd = (UserSessionData) request.getAttribute(IActionConstants.USER_SESSION_DATA);
if (usd == null) {
return null;
}
}
return String.valueOf(usd.getSystemUserId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import nl.martijndwars.webpush.PushService;
import org.apache.http.HttpResponse;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.openelisglobal.login.valueholder.UserSessionData;
import org.openelisglobal.common.rest.BaseRestController;
import org.openelisglobal.notifications.dao.NotificationDAO;
import org.openelisglobal.notifications.dao.NotificationSubscriptionDAO;
import org.openelisglobal.notifications.entity.Notification;
Expand All @@ -31,12 +31,11 @@

@RequestMapping("/rest")
@RestController
public class NotificationRestController {
public class NotificationRestController extends BaseRestController {

private final NotificationDAO notificationDAO;
private final SystemUserService systemUserService;
private final NotificationSubscriptionDAO notificationSubscriptionDAO;
private static final String USER_SESSION_DATA = "userSessionData";

@Autowired
private ConfigurableEnvironment env;
Expand Down Expand Up @@ -210,15 +209,4 @@ public ResponseEntity<?> unsubscribe(HttpServletRequest request) {

return ResponseEntity.ok().body("Unsubscribed successfully");
}

protected String getSysUserId(HttpServletRequest request) {
UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA);
if (usd == null) {
usd = (UserSessionData) request.getAttribute(USER_SESSION_DATA);
if (usd == null) {
return null;
}
}
return String.valueOf(usd.getSystemUserId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.validator.GenericValidator;
import org.openelisglobal.common.rest.BaseRestController;
import org.openelisglobal.common.services.DisplayListService;
import org.openelisglobal.login.valueholder.UserSessionData;
import org.openelisglobal.patient.action.bean.PatientSearch;
import org.openelisglobal.qaevent.form.NonConformingEventForm;
import org.openelisglobal.qaevent.service.NCEventService;
Expand All @@ -26,12 +26,10 @@

@RestController
@RequestMapping(value = "/rest")
public class NonConformingEventsCorrectionActionRestController {
public class NonConformingEventsCorrectionActionRestController extends BaseRestController {

private NCEventService ncEventService = SpringContext.getBean(NCEventService.class);

private static final String USER_SESSION_DATA = "userSessionData";

@Autowired
private NonConformingEventWorker nonConformingEventWorker;

Expand Down Expand Up @@ -90,15 +88,4 @@ public ResponseEntity<?> updateNCECorretiveActionForm(@RequestBody NonConforming
return ResponseEntity.ok().body(Map.of("success", false));
}
}

protected String getSysUserId(HttpServletRequest request) {
UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA);
if (usd == null) {
usd = (UserSessionData) request.getAttribute(USER_SESSION_DATA);
if (usd == null) {
return null;
}
}
return String.valueOf(usd.getSystemUserId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import javax.servlet.http.HttpServletRequest;
import org.openelisglobal.common.exception.LIMSInvalidConfigurationException;
import org.openelisglobal.common.provider.query.PatientSearchResults;
import org.openelisglobal.common.rest.BaseRestController;
import org.openelisglobal.common.rest.bean.NceSampleInfo;
import org.openelisglobal.common.rest.bean.NceSampleItemInfo;
import org.openelisglobal.common.services.DisplayListService;
import org.openelisglobal.common.services.RequesterService;
import org.openelisglobal.common.util.DateUtil;
import org.openelisglobal.login.valueholder.UserSessionData;
import org.openelisglobal.qaevent.form.NonConformingEventForm;
import org.openelisglobal.qaevent.service.NceCategoryService;
import org.openelisglobal.qaevent.valueholder.NcEvent;
Expand All @@ -33,7 +33,7 @@
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ReportNonConformEventsRestController {
public class ReportNonConformEventsRestController extends BaseRestController {

private final SampleService sampleService;
private final SampleItemService sampleItemService;
Expand All @@ -42,8 +42,6 @@ public class ReportNonConformEventsRestController {
private final NceCategoryService nceCategoryService;
private final RequesterService requesterService;

private static final String USER_SESSION_DATA = "userSessionData";

@Autowired
private SystemUserService systemUserService;

Expand Down Expand Up @@ -175,17 +173,6 @@ private NceSampleInfo addSample(Sample sample) {
return sampleInfo;
}

protected String getSysUserId(HttpServletRequest request) {
UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA);
if (usd == null) {
usd = (UserSessionData) request.getAttribute(USER_SESSION_DATA);
if (usd == null) {
return null;
}
}
return String.valueOf(usd.getSystemUserId());
}

private Sample getSampleForLabNumber(String labNumber) throws LIMSInvalidConfigurationException {
return sampleService.getSampleByAccessionNumber(labNumber);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.openelisglobal.common.rest.BaseRestController;
import org.openelisglobal.common.services.DisplayListService;
import org.openelisglobal.common.util.DateUtil;
import org.openelisglobal.login.valueholder.UserSessionData;
import org.openelisglobal.qaevent.form.NonConformingEventForm;
import org.openelisglobal.qaevent.service.NCEventService;
import org.openelisglobal.qaevent.service.NceCategoryService;
Expand All @@ -29,7 +29,7 @@
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ViewNonConformEventsRestController {
public class ViewNonConformEventsRestController extends BaseRestController {

@Autowired
private NCEventService ncEventService;
Expand All @@ -46,8 +46,6 @@ public class ViewNonConformEventsRestController {
@Autowired
private SampleItemService sampleItemService;

private static final String USER_SESSION_DATA = "userSessionData";

private final NonConformingEventWorker nonConformingEventWorker;

public ViewNonConformEventsRestController(NonConformingEventWorker nonConformingEventWorker) {
Expand Down Expand Up @@ -120,15 +118,4 @@ public ResponseEntity<?> postReportNonConformingEvent(@RequestBody NonConforming
.body("An error occurred while processing the request." + e);
}
}

protected String getSysUserId(HttpServletRequest request) {
UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA);
if (usd == null) {
usd = (UserSessionData) request.getAttribute(USER_SESSION_DATA);
if (usd == null) {
return null;
}
}
return String.valueOf(usd.getSystemUserId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ protected void appendOtherDiseaseCrosstab(Date lowDate, Date highDate, SQLConsta

protected void defineBasicColumns() {
add("accession_number", "LABNO", NONE);
add("lab_unit", "LAB_UNIT", NONE);
add("national_id", "IDENTIFIER", NONE);
add("gender", "SEX", NONE);
add("birth_date", "BIRTHDATE", DATE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ protected void appendResultCrosstab(java.sql.Date lowDate, java.sql.Date highDat
+ " join clinlims.sample AS s on s.id = si.samp_id \n"
+ " join clinlims.test_result AS tr on r.test_result_id = tr.id \n"
+ " join clinlims.test AS t on tr.test_id = t.id \n"
+ " join clinlims.test_section ts on t.test_section_id = ts.id \n"
+ " left join sample_projects sp on si.samp_id = sp.samp_id \n" + "\n"
+ " WHERE sp.id IS NULL AND s.entered_date >= date(''" + formatDateForDatabaseSql(lowDate)
+ "'') AND s.entered_date <= date(''" + formatDateForDatabaseSql(highDate) + " '') " + "\n "
Expand Down Expand Up @@ -631,7 +632,11 @@ protected void appendObservationHistoryCrosstab(java.sql.Date lowDate, java.sql.
}

protected void appendCrosstabPreamble(SQLConstant listName) {
query.append(", \n\n ( SELECT s.id AS samp_id, " + listName + ".* " + " FROM sample AS s LEFT JOIN \n ");
query.append(", \n\n ( SELECT s.id AS samp_id, " + " (SELECT ts.name FROM clinlims.test_section ts "
+ " JOIN clinlims.test t ON t.test_section_id = ts.id "
+ " JOIN clinlims.analysis a ON a.test_id = t.id "
+ " WHERE a.sampitem_id = si.id LIMIT 1) as lab_unit, " + listName + ".* " + " FROM sample AS s "
+ " LEFT JOIN sample_item si ON s.id = si.samp_id " + " LEFT JOIN \n ");
}

protected void appendCrosstabPostfix(java.sql.Date lowDate, java.sql.Date highDate, SQLConstant listName) {
Expand Down
Loading

0 comments on commit d21ca0c

Please sign in to comment.