Skip to content

Commit

Permalink
Merge branch '2.8' of github.com:I-TECH-UW/OpenELIS-Global-2 into 2.8
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebSLane committed Sep 19, 2023
2 parents f45d800 + b2956c8 commit 2ad8ceb
Show file tree
Hide file tree
Showing 21 changed files with 325 additions and 897 deletions.
8 changes: 6 additions & 2 deletions frontend/src/components/addOrder/AddOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

This file was deleted.

3 changes: 3 additions & 0 deletions frontend/src/components/layout/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ function OEHeader(props) {
<SideNavMenuItem href="/validation?type=testDate">
<FormattedMessage id="sidenav.label.validation.testdate" />
</SideNavMenuItem>
<SideNavMenuItem href="/validation?type=range">
<FormattedMessage id="sidenav.label.results.byrange" />
</SideNavMenuItem>
</SideNavMenu>

<SideNavMenu aria-label="Reports" title="Reports">
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/modifyOrder/ModifyOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ function ModifyOrder() {

return (
<>
<div className="orderLegendBody">
<SearchPatientForm
getSelectedPatient={getSelectedPatient}
></SearchPatientForm>
</div>
</>
);
}
Expand Down
135 changes: 122 additions & 13 deletions frontend/src/components/patient/CreatePatientForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = "";
Expand All @@ -61,6 +135,10 @@ function CreatePatientForm(props) {
setHealthDistricts(res);
}

useEffect(()=>{
getDOBByYearMonthsDays();
},[dateOfBirthFormatter])

useEffect(() => {
if (props.selectedPatient.patientPK) {
if (props.selectedPatient.healthRegion != null) {
Expand All @@ -76,6 +154,7 @@ function CreatePatientForm(props) {
const patient = props.selectedPatient;
patient.patientUpdateStatus = "UPDATE";
setPatientDetails(patient);
getYearsMonthsDaysFromDOB(patient.birthDateForDisplay);
setFormAction("UPDATE");
}
}, [props.selectedPatient]);
Expand All @@ -87,6 +166,7 @@ function CreatePatientForm(props) {
props.orderFormValues.patientProperties.guid !== ""
) {
setPatientDetails(props.orderFormValues.patientProperties);
getYearsMonthsDaysFromDOB(props.orderFormValues.patientProperties.birthDateForDisplay);
}
}
};
Expand Down Expand Up @@ -393,27 +473,56 @@ function CreatePatientForm(props) {
</DatePicker>
)}
</Field>
<Field name="gender">
{({ field }) => (
<RadioButtonGroup
valueSelected={values.gender}
legendText="Gender"
name={field.name}

<TextInput
value={dateOfBirthFormatter.years}
name="years"
labelText="Age/Years"
id="years"
onChange={ handleYearsChange }
className="inputText"
id="create_patient_gender"
>
<RadioButton id="radio-1" labelText="Male" value="M" />
<RadioButton id="radio-2" labelText="Female" value="F" />
</RadioButtonGroup>
)}
</Field>
/>

<TextInput
value={dateOfBirthFormatter.months}
name="months"
labelText="Months"
onChange={ handleMonthsChange }
id="months"
className="inputText"
/>

<TextInput
value={dateOfBirthFormatter.days}
name="days"
onChange={ handleDaysChange}
labelText="Days"
id="days"
className="inputText"
/>
<div className="error">
<ErrorMessage name="birthDateForDisplay"></ErrorMessage>
</div>
<div className="error">
<ErrorMessage name="gender"></ErrorMessage>
</div>
</div>
<div className="inlineDiv">
<Field name="gender">
{({ field }) => (
<RadioButtonGroup
valueSelected={values.gender}
legendText="Gender"
name={field.name}
className="inputText"
id="create_patient_gender"
>
<RadioButton id="radio-1" labelText="Male" value="M" />
<RadioButton id="radio-2" labelText="Female" value="F" />
</RadioButtonGroup>
)}
</Field>
</div>
<Accordion>
<AccordionItem title="Additional Information">
<div className="inlineDiv">
Expand Down
Loading

0 comments on commit 2ad8ceb

Please sign in to comment.