Skip to content

Commit

Permalink
Merge pull request #509 from mozzy11/2.8
Browse files Browse the repository at this point in the history
More work on HistoPathology and Immunohistochemistry
  • Loading branch information
mozzy11 authored Aug 16, 2023
2 parents 29829d4 + 7fe2336 commit 335c354
Show file tree
Hide file tree
Showing 29 changed files with 945 additions and 332 deletions.
12 changes: 8 additions & 4 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ export default function App() {
path="/PathologyDashboard"
exact
component={() => <PathologyDashboard />}
role={["Pathologist", "Reception"]}
role=""
labUnitRole={{"Pathology": ["Results"]}}
config={appConfig}
onAuth={onAuth}
logout={logout}
Expand All @@ -167,7 +168,8 @@ export default function App() {
path="/PathologyCaseView/:pathologySampleId"
exact
component={() => <PathologyCaseView />}
role={["Pathologist", "Reception"]}
role=""
labUnitRole={{"Pathology": ["Results"]}}
config={appConfig}
onAuth={onAuth}
logout={logout}
Expand All @@ -177,7 +179,8 @@ export default function App() {
path="/ImmunohistochemistryDashboard"
exact
component={() => <ImmunohistochemistryDashboard />}
role={["Pathologist", "Reception"]}
role=""
labUnitRole={{"Immunohistochemistry": ["Results"]}}
config={appConfig}
onAuth={onAuth}
logout={logout}
Expand All @@ -187,7 +190,8 @@ export default function App() {
path="/ImmunohistochemistryCaseView/:immunohistochemistrySampleId"
exact
component={() => <ImmunohistochemistryCaseView />}
role={["Pathologist", "Reception"]}
role=""
labUnitRole={{"Immunohistochemistry": ["Results"]}}
config={appConfig}
onAuth={onAuth}
logout={logout}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import {useContext, useState, useEffect, useRef } from "react";
import {
Checkbox, Heading, TextInput, Select, SelectItem, Button, Grid, Column,
DataTable, TableContainer, Table, TableHead, TableRow, TableHeader, TableBody, TableCell,
Checkbox, Heading, TextInput, Select, SelectItem, Button, Grid, Column,Tile,
DataTable, TableContainer, Table, TableHead, TableRow, TableHeader, TableBody, TableCell, Section
} from '@carbon/react';
import { Search} from '@carbon/react';
import { getFromOpenElisServer, postToOpenElisServerFullResponse, hasRole } from "../utils/Utils";
import { NotificationContext } from "../layout/Layout";
import {AlertDialog} from "../common/CustomNotification";
import { FormattedMessage, injectIntl } from 'react-intl'
import "./../pathology/PathologyDashboard.css"

function ImmunohistochemistryDashboard() {

Expand All @@ -18,13 +20,46 @@ function ImmunohistochemistryDashboard() {
const [immunohistochemistryEntries, setImmunohistochemistryEntries] = useState([])
const [filters, setFilters] = useState({searchTerm: "", myCases: false, statuses: []});

function formatDateToDDMMYYYY(date) {
var day = date.getDate();
var month = date.getMonth() + 1; // Month is zero-based
var year = date.getFullYear();

// Ensure leading zeros for single-digit day and month
var formattedDay = (day < 10 ? '0' : '') + day;
var formattedMonth = (month < 10 ? '0' : '') + month;

// Construct the formatted string
var formattedDate = formattedDay + '/' + formattedMonth + '/' + year;
return formattedDate;
}

const getPastWeek = () => {
// Get the current date
var currentDate = new Date();

// Calculate the date of the past week
var pastWeekDate = new Date(currentDate);
pastWeekDate.setDate(currentDate.getDate() - 7);

return formatDateToDDMMYYYY(currentDate) + " - " + formatDateToDDMMYYYY(pastWeekDate);
}

const tileList = [
{"title" : "Cases in Progress" , "count" : counts.inProgress} ,
{"title" : "Awaiting Immunohistochemistry Review" , "count" : counts.awaitingReview},
{"title" : "Additional Immunohistochemistry Requests" , "count" : counts.additionalRequests},
{"title" : "Complete (Week " + getPastWeek() + " )" , "count" : counts.complete}
]

const setStatusList = (statusList) => {
if (componentMounted.current) {
setStatuses(statusList);
}
}



const assignCurrentUserAsTechnician = (event, immunohistochemistrySampleId) => {
postToOpenElisServerFullResponse("/rest/immunohistochemistry/assignTechnician?immunohistochemistrySampleId=" + immunohistochemistrySampleId, {}, refreshItems)
}
Expand Down Expand Up @@ -67,14 +102,17 @@ function ImmunohistochemistryDashboard() {
if (event.target.value === 'All') {
setFilters({...filters, statuses: statuses});
} else {
setFilters({...filters, statuses: [{"value": event.target.value}]});
setFilters({...filters, statuses: [{"id": event.target.value}]});
}
}
const loadCounts = (data) => {
setCounts(data);
}

const filtersToParameters = () => {
return "statuses=" + filters.statuses.map((entry) => {
return entry.id;
}).join(",");
}).join(",")+ "&searchTerm="+filters.searchTerm;
}

const refreshItems = () => {
Expand All @@ -88,6 +126,7 @@ function ImmunohistochemistryDashboard() {
useEffect(() => {
componentMounted.current = true;
getFromOpenElisServer("/rest/displayList/IMMUNOHISTOCHEMISTRY_STATUS", setStatusList);
getFromOpenElisServer("/rest/immunohistochemistry/dashboard/count", loadCounts);

return () => {
componentMounted.current = false;
Expand Down Expand Up @@ -116,24 +155,26 @@ function ImmunohistochemistryDashboard() {
return (
<>
{notificationVisible === true ? <AlertDialog/> : ""}
<Grid fullWidth={true} className="gridBoundary">
<Column lg={16} md={8} sm={4}>
<Heading>
Immunohistochemistry
</Heading>
<Grid fullWidth={true}>
<Column lg={16}>
<Section>
<Section >
<Heading >
<FormattedMessage id="immunohistochemistry.label.title" />
</Heading>
</Section>
</Section>
</Column>
<Column lg={4} md={2} sm={1}>
{counts.inProgress} Cases in Progress
</Column>
<Column lg={4} md={2} sm={1}>
{counts.awaitingReview} Awaiting Immunohistochemistry Review
</Column>
<Column lg={4} md={2} sm={1}>
{counts.additionalRequests} Additional Immunohistochemistry Requests
</Column>
<Column lg={4} md={2} sm={1}/>
<Column lg={16} md={8} sm={4} style={{"marginBottom": "1rem" ,"marginTop": "1rem"}}>
{counts.complete} Complete</Column>
</Grid>
<div className="dashboard-container">
{tileList.map((tile, index) => (
<Tile key={index} className="dashboard-tile">
<h3 className="tile-title">{tile.title}</h3>
<p className="tile-value">{tile.count}</p>
</Tile>
))}
</div>
<Grid fullWidth={true} className="gridBoundary">
<Column lg={8} md={4} sm={2}>
<Search
size="sm"
Expand Down
21 changes: 16 additions & 5 deletions frontend/src/components/pathology/PathologyCaseView.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Launch, Subtract } from '@carbon/react/icons';
import { getFromOpenElisServer, postToOpenElisServerFullResponse, hasRole } from "../utils/Utils";
import UserSessionDetailsContext from "../../UserSessionDetailsContext"
import { NotificationContext } from "../layout/Layout";
import { AlertDialog } from "../common/CustomNotification";
import { AlertDialog ,NotificationKinds } from "../common/CustomNotification";
import "./PathologyDashboard.css"


Expand Down Expand Up @@ -88,6 +88,17 @@ function PathologyCaseView() {
async function displayStatus(response) {
var body = await response.json();
console.log(body)
var status = response.status;
setNotificationVisible(true);
if (status == "200") {
const save1 = document.getElementById("pathology_save");
const save2 = document.getElementById("pathology_save2");
save1.disabled = true;
save2.disabled = true;
setNotificationBody({ kind: NotificationKinds.success, title: "Notification Message", message: "Succesfuly saved" });
} else {
setNotificationBody({ kind: NotificationKinds.error, title: "Notification Message", message: "Error while saving" });
}
}

const toBase64 = file => new Promise((resolve, reject) => {
Expand Down Expand Up @@ -163,7 +174,7 @@ function PathologyCaseView() {
<>
<Breadcrumb>
<BreadcrumbItem href="/">Home</BreadcrumbItem>
<BreadcrumbItem href="/PathologyDashboardy">Pathology DashBoard</BreadcrumbItem>
<BreadcrumbItem href="/PathologyDashboard">Pathology DashBoard</BreadcrumbItem>
</Breadcrumb>

<Grid fullWidth={true}>
Expand Down Expand Up @@ -206,7 +217,7 @@ function PathologyCaseView() {
<Grid fullWidth={true} className="gridBoundary">
{notificationVisible === true ? <AlertDialog /> : ""}
<Column lg={16} md={8} sm={4}>
<Button onClick={(e) => { e.preventDefault(); save(e) }}>Save</Button>
<Button id="pathology_save" onClick={(e) => { e.preventDefault(); save(e) }}>Save</Button>
</Column>
<Column lg={4} md={2} sm={2} >
<Select id="status"
Expand Down Expand Up @@ -423,7 +434,7 @@ function PathologyCaseView() {
<Column lg={12} md={6} sm={0}>
</Column>
<Column lg={16} md={8} sm={4}></Column>
{hasRole("Pathologist") &&
{hasRole( userSessionDetails ,"Pathologist") &&
<>
<Column lg={8} md={4} sm={2}>
{initialMount && <FilterableMultiSelect
Expand Down Expand Up @@ -526,7 +537,7 @@ function PathologyCaseView() {
setPathologySampleInfo({ ...pathologySampleInfo, referToImmunoHistoChemistry: !pathologySampleInfo.referToImmunoHistoChemistry });
}} />
</Column>
<Column><Button onClick={(e) => { e.preventDefault(); save(e) }}>Save</Button></Column>
<Column><Button id ="pathology_save2"onClick={(e) => { e.preventDefault(); save(e) }}>Save</Button></Column>

</Grid>

Expand Down
13 changes: 13 additions & 0 deletions frontend/src/components/pathology/PathologyDashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,16 @@
font-size: 14px;
color: #888;
}

.file-container {
background-color: #f5f5f5;
border: 1px solid #ddd;
padding: 20px;
width: 500px;
/* display: flex;
flex-direction: column; */
align-items: flex-start;
justify-content: center;
/* text-align: left; */
margin-top: 20px;
}
27 changes: 26 additions & 1 deletion frontend/src/components/pathology/PathologyDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,36 @@ function PathologyDashboard() {
setCounts(data);
}

function formatDateToDDMMYYYY(date) {
var day = date.getDate();
var month = date.getMonth() + 1; // Month is zero-based
var year = date.getFullYear();

// Ensure leading zeros for single-digit day and month
var formattedDay = (day < 10 ? '0' : '') + day;
var formattedMonth = (month < 10 ? '0' : '') + month;

// Construct the formatted string
var formattedDate = formattedDay + '/' + formattedMonth + '/' + year;
return formattedDate;
}

const getPastWeek = () => {
// Get the current date
var currentDate = new Date();

// Calculate the date of the past week
var pastWeekDate = new Date(currentDate);
pastWeekDate.setDate(currentDate.getDate() - 7);

return formatDateToDDMMYYYY(currentDate) + " - " + formatDateToDDMMYYYY(pastWeekDate);
}

const tileList = [
{"title" : "Cases in Progress" , "count" : counts.inProgress} ,
{"title" : "Awaiting Pathology Review" , "count" : counts.awaitingReview},
{"title" : "Additional Pathology Requests" , "count" : counts.additionalRequests},
{"title" : "Complete" , "count" : counts.complete}
{"title" : "Complete (Week " + getPastWeek() + " )" , "count" : counts.complete}
]

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ const RoutedResultsViewer: React.FC<ResultsViewerProps> = () => {
<Section>
<Section>
{patient ? (<div className="patient-header">
<div className="patient-name"><Tag type="blue">Name :</Tag>{patient.firstName} {patient.lastName}</div>
<div className="patient-dob"> <Tag type="blue">Gender :</Tag>{patient.gender === 'M'?"Male" : "Female" } <Tag>DOB :</Tag> {patient.birthDateForDisplay}</div>
<div className="patient-name"><Tag type="blue">Name :</Tag>{patient.lastName} {patient.firstName}</div>
<div className="patient-dob"> <Tag type="blue">Gender :</Tag>{patient.gender === 'M'?"Male" : "Female" } <Tag type="blue">DOB :</Tag> {patient.birthDateForDisplay}</div>
<div className="patient-id"><Tag type="blue">Unique Health ID number :</Tag>{patient.subjectNumber} </div>
<div className="patient-id"><Tag type="blue">National ID :</Tag>{patient.nationalId}</div>
</div>) : (<div className="patient-header">
Expand Down
19 changes: 18 additions & 1 deletion frontend/src/components/security/SecureRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,24 @@ function SecureRoute(props) {


const hasPermission = (userDetails = userSessionDetails) => {
return !props.role || [].concat(props.role).some(role => userDetails.roles && userDetails.roles.includes(role))
var hasRole = !props.role || [].concat(props.role).some(role => userDetails.roles && userDetails.roles.includes(role))
var containsLabUnitRole = false;
if (props.labUnitRole) {
Object.keys(props.labUnitRole).forEach(labunit => {
if (userDetails.userLabRolesMap) {
const userRoles = userDetails.userLabRolesMap["AllLabUnits"]? userDetails.userLabRolesMap["AllLabUnits"] : userDetails.userLabRolesMap[labunit] || [];
const roles = props.labUnitRole[labunit];
roles.forEach(r => {
if (userRoles.includes(r)) {
containsLabUnitRole = true;
}
})

}
})
}
var hasLabUnitRole = !props.labUnitRole || containsLabUnitRole
return hasRole && hasLabUnitRole
}

const handleOnAction = (event) => {
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 @@ -92,5 +92,6 @@
"testcalculation.label.textValue" : "Text Value" ,
"testcalculation.label.finalresult" : "Final Result",
"advanced.search": "Advanced Search",
"pathology.label.title" : "Pathology"
"pathology.label.title" : "Pathology",
"immunohistochemistry.label.title" : "Immunohistochemistry"
}
3 changes: 2 additions & 1 deletion frontend/src/languages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,6 @@
"testcalculation.label.textValue" : "Valeur de texte" ,
"testcalculation.label.finalresult" : "Résultat final",
"advanced.search" : "Lancer la recherche" ,
"pathology.label.title" : "Pathologie"
"pathology.label.title" : "Pathologie",
"immunohistochemistry.label.title" : "Immunohistochimie"
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.openelisglobal.program.service.ProgramService;
import org.openelisglobal.program.valueholder.Program;
import org.openelisglobal.program.valueholder.immunohistochemistry.ImmunohistochemistrySample;
import org.openelisglobal.program.valueholder.immunohistochemistry.ImmunohistochemistrySampleReport;
import org.openelisglobal.program.valueholder.pathology.PathologySample;
import org.openelisglobal.provider.service.ProviderService;
import org.openelisglobal.provider.valueholder.Provider;
Expand Down Expand Up @@ -90,7 +91,7 @@ public enum ListType {
SEVERITY_CONSEQUENCES_LIST, SEVERITY_RECURRENCE_LIST, ACTION_TYPE_LIST, LABORATORY_COMPONENT, SAMPLE_NATURE,
ELECTRONIC_ORDER_STATUSES, METHODS, METHODS_INACTIVE, METHOD_BY_NAME, PRACTITIONER_PERSONS, ORDER_PRIORITY,
PROGRAM, IMMUNOHISTOCHEMISTRY_STATUS, PATHOLOGY_STATUS, PATHOLOGY_TECHNIQUES, PATHOLOGIST_REQUESTS,
PATHOLOGIST_CONCLUSIONS
PATHOLOGIST_CONCLUSIONS ,IMMUNOHISTOCHEMISTRY_REPORT_TYPES
}

private static Map<ListType, List<IdValuePair>> typeToListMap;
Expand Down Expand Up @@ -208,6 +209,7 @@ public void localeChanged(String locale) {
typeToListMap.put(ListType.ORDER_PRIORITY, createSamplePriorityList());
typeToListMap.put(ListType.PATHOLOGY_STATUS, createPathologyStatusList());
typeToListMap.put(ListType.IMMUNOHISTOCHEMISTRY_STATUS, createImmunohistochemistryStatusList());
typeToListMap.put(ListType.IMMUNOHISTOCHEMISTRY_REPORT_TYPES, createImmunohistochemistryReportTypeList());
typeToListMap.put(ListType.PATHOLOGY_TECHNIQUES, createDictionaryListForCategory("pathology_techniques"));
typeToListMap.put(ListType.PATHOLOGIST_REQUESTS, createDictionaryListForCategory("pathologist_requests"));
typeToListMap.put(ListType.PATHOLOGIST_CONCLUSIONS, createDictionaryListForCategory("pathologist_conclusions"));
Expand All @@ -224,6 +226,11 @@ private List<IdValuePair> createImmunohistochemistryStatusList() {
.map(e -> new IdValuePair(e.name(), e.getDisplay())).collect(Collectors.toList());
}

private List<IdValuePair> createImmunohistochemistryReportTypeList() {
return Arrays.asList(ImmunohistochemistrySampleReport.ImmunoHistologyReportType.values()).stream()
.map(e -> new IdValuePair(e.name(), e.getDisplay())).collect(Collectors.toList());
}

public List<IdValuePair> getList(ListType listType) {
return typeToListMap.get(listType);
}
Expand Down Expand Up @@ -357,6 +364,7 @@ public synchronized void refreshLists() {
typeToListMap = new HashMap<>();
typeToListMap.put(ListType.PATHOLOGY_STATUS, createPathologyStatusList());
typeToListMap.put(ListType.IMMUNOHISTOCHEMISTRY_STATUS, createImmunohistochemistryStatusList());
typeToListMap.put(ListType.IMMUNOHISTOCHEMISTRY_REPORT_TYPES, createImmunohistochemistryReportTypeList());
typeToListMap.put(ListType.HOURS, createHourList());
typeToListMap.put(ListType.MINS, createMinList());
typeToListMap.put(ListType.SAMPLE_TYPE, createTypeOfSampleList());
Expand Down
Loading

0 comments on commit 335c354

Please sign in to comment.