Skip to content

Commit

Permalink
Merge branch 'develop' into componentUpgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
mozzy11 authored Feb 25, 2025
2 parents 37c3dbf + 454d3f7 commit 4a0bdde
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 26 deletions.
56 changes: 50 additions & 6 deletions frontend/src/components/patient/CreatePatientForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ function CreatePatientForm(props) {
const [healthDistricts, setHealthDistricts] = useState([]);
const [educationList, setEducationList] = useState([]);
const [maritalStatuses, setMaritalStatuses] = useState([]);
const [prevfirstName, setPrevfirstName] = useState("");
const [prevlastName, setPrevlastName] = useState("");
const [prevfirstContactName, setPrevfirstContactName] = useState("");
const [prevlastContactName, setPrevlastContactName] = useState("");
const [formAction, setFormAction] = useState("ADD");
const [dateOfBirthFormatter, setDateOfBirthFormatter] = useState({
years: "",
Expand Down Expand Up @@ -206,17 +210,55 @@ function CreatePatientForm(props) {
};

function handleFirstNameChange(event) {
const regex = /^[A-Za-z]*$/;
if (!regex.test(event.target.value)) {
event.target.value = event.target.value.replace(/[^A-Za-z]/g, "");
const regexFlags = "iu";
const regex = new RegExp(
configurationProperties.FIRST_NAME_REGEX,
regexFlags,
);
const value = event.target.value;
if (!regex.test(value)) {
event.target.value = prevfirstName;
}
setPrevfirstName(event.target.value);
}

function handleLastNameChange(event) {
const regex = /^[A-Za-z]*$/;
if (!regex.test(event.target.value)) {
event.target.value = event.target.value.replace(/[^A-Za-z]/g, "");
const regexFlags = "iu";
const regex = new RegExp(
configurationProperties.LAST_NAME_REGEX,
regexFlags,
);
const value = event.target.value;
if (!regex.test(value)) {
event.target.value = prevlastName;
}
setPrevlastName(event.target.value);
}

function handleFirstContactNameChange(event) {
const regexFlags = "iu";
const regex = new RegExp(
configurationProperties.FIRST_NAME_REGEX,
regexFlags,
);
const value = event.target.value;
if (!regex.test(value)) {
event.target.value = prevfirstContactName;
}
setPrevfirstContactName(event.target.value);
}

function handleLastContactNameChange(event) {
const regexFlags = "iu";
const regex = new RegExp(
configurationProperties.LAST_NAME_REGEX,
regexFlags,
);
const value = event.target.value;
if (!regex.test(value)) {
event.target.value = prevlastContactName;
}
setPrevlastContactName(event.target.value);
}

function fetchHealthDistrictsCallback(res) {
Expand Down Expand Up @@ -731,6 +773,7 @@ function CreatePatientForm(props) {
id: "patientcontact.person.lastname",
})}
id={field.name}
onChange={(e) => handleLastContactNameChange(e)}
placeholder={intl.formatMessage({
id: "patient.emergency.lastname",
})}
Expand All @@ -750,6 +793,7 @@ function CreatePatientForm(props) {
id: "patientcontact.person.firstname",
})}
id={field.name}
onChange={(e) => handleFirstContactNameChange(e)}
placeholder={intl.formatMessage({
id: "patient.emergency.firstname",
})}
Expand Down
34 changes: 24 additions & 10 deletions frontend/src/components/patient/SearchPatientForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ function SearchPatientForm(props) {
const [searchFormValues, setSearchFormValues] = useState(
SearchPatientFormValues,
);
const [prevfirstName, setPrevfirstName] = useState("");
const [prevlastName, setPrevlastName] = useState("");

const handlePatientImport = (patientId) => {
console.log("Import button clicked, patientId:", patientId);
Expand Down Expand Up @@ -231,19 +233,31 @@ function SearchPatientForm(props) {
setDob(date);
};

const handleFirstNameChange = (event) => {
const regex = /^[A-Za-z]*$/;
if (!regex.test(event.target.value)) {
event.target.value = event.target.value.replace(/[^A-Za-z]/g, "");
function handleFirstNameChange(event) {
const regexFlags = "iu";
const regex = new RegExp(
configurationProperties.FIRST_NAME_REGEX,
regexFlags,
);
const value = event.target.value;
if (!regex.test(value)) {
event.target.value = prevfirstName;
}
};
setPrevfirstName(event.target.value);
}

const handleLastNameChange = (event) => {
const regex = /^[A-Za-z]*$/;
if (!regex.test(event.target.value)) {
event.target.value = event.target.value.replace(/[^A-Za-z]/g, "");
function handleLastNameChange(event) {
const regexFlags = "iu";
const regex = new RegExp(
configurationProperties.LAST_NAME_REGEX,
regexFlags,
);
const value = event.target.value;
if (!regex.test(value)) {
event.target.value = prevlastName;
}
};
setPrevlastName(event.target.value);
}

const patientSelected = (e) => {
const patientSelected = patientSearchResults.find((patient) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ public class DisplayListController extends BaseRestController {
protected static List<Integer> statusList;
protected static List<String> nfsTestIdList;

private String escapeRegexChars(String regex) {
// TODO Auto-generated method stub
return regex;
}

// Manually create an instance of ExportTrendsByDate
private ExportTrendsByDate exportTrendsByDate = new ExportTrendsByDate();

Expand Down Expand Up @@ -352,6 +357,15 @@ private List<IdValuePair> getSiteNameList() {
@GetMapping(value = "configuration-properties", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
private Map<String, Object> getConfigurationProperties() {
SiteInformation DEFAULT_SITE_INFORATION = new SiteInformation();
String DEFAULT_REGEX = "0-9a-z .'_@-";
DEFAULT_SITE_INFORATION.setValue(DEFAULT_REGEX);
String FIRST_NAME_REGEX = "^[" + escapeRegexChars(
siteInformationService.getMatch("name", "firstNameCharset").orElse(DEFAULT_SITE_INFORATION).getValue())
+ "]*$";
String LAST_NAME_REGEX = "^[" + escapeRegexChars(
siteInformationService.getMatch("name", "lastNameCharset").orElse(DEFAULT_SITE_INFORATION).getValue())
+ "]*$";
Map<String, Object> configs = getOpenConfigurationProperties();

configs.put(Property.allowResultRejection.toString(),
Expand All @@ -369,6 +383,8 @@ private Map<String, Object> getConfigurationProperties() {
ConfigurationProperties.getInstance().getPropertyValue(Property.UseExternalPatientInfo));
configs.put("DEFAULT_PAGE_SIZE",
ConfigurationProperties.getInstance().getPropertyValue("page.defaultPageSize"));
configs.put("FIRST_NAME_REGEX", FIRST_NAME_REGEX);
configs.put("LAST_NAME_REGEX", LAST_NAME_REGEX);
return configs;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ private void createPersonProviderArtifacts(SampleOrderItem sampleOrder, String c
}

private boolean namesDiffer(Person providerPerson, SampleOrderItem sampleOrder) {
if (providerPerson == null) {
if (providerPerson == null || sampleOrder.getProviderPersonId() == null) {
return true;
}
if (providerPerson.getId().trim().equals(sampleOrder.getProviderPersonId().trim())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public boolean duplicateMethodExists(Method method) throws LIMSRuntimeException

// not case sensitive hemolysis and Hemolysis are considered
// duplicates
String sql = "from Method t where trim(lower(t.methodName)) = :param and t.id != :param2";
String sql = "from Method t where trim(lower(t.methodName)) = :param AND t.id != CAST(:param2 AS integer)";
Query<Method> query = entityManager.unwrap(Session.class).createQuery(sql, Method.class);
query.setParameter("param", method.getMethodName().toLowerCase().trim());

Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/pages/result/resultListView.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -949,8 +949,8 @@ function /*void*/ handleEnterEvent( ){
indexed="true" />
<form:hidden path="testResult[${iter.index}].resultType"
id="resultType_${iter.index}" />
<form:hidden path="testResult[${iter.index}].testMethod"
id="testMethod_${iter.index}" />
<!-- <form:hidden path="testResult[${iter.index}].testMethod"
id="testMethod_${iter.index}" /> -->
<form:hidden path="testResult[${iter.index}].valid"
id="valid_${iter.index}" />
<form:hidden path="testResult[${iter.index}].defaultResultValue"
Expand Down
12 changes: 6 additions & 6 deletions src/main/webapp/pages/sample/sampleOrder.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -678,12 +678,12 @@
function parseRequesterPerson(xhr) {
var requester = JSON.parse(xhr.responseText);
$("providerPersonId").value = requester.id;
$("providerFirstNameID").value = requester.firstName;
$("providerLastNameID").value = requester.lastName;
$("providerWorkPhoneID").value = requester.primaryPhone;
$("providerFaxID").value = requester.fax;
$("providerEmailID").value = requester.email;
$("providerPersonId").value = requester.id?requester.id:"";
$("providerFirstNameID").value = requester.firstName?requester.firstName:"";
$("providerLastNameID").value = requester.lastName?requester.lastName:"";
$("providerWorkPhoneID").value = requester.workPhone?requester.workPhone:"";
$("providerFaxID").value = requester.fax?requester.fax:"";
$("providerEmailID").value = requester.email?requester.email:"";
}
function setSelectComboboxToId(selectId, selectVal) {
Expand Down

0 comments on commit 4a0bdde

Please sign in to comment.