Skip to content

Commit

Permalink
Merge pull request #793 from FluxNotes/summary-section-reorg
Browse files Browse the repository at this point in the history
Summary section reorg
  • Loading branch information
danlee1025 authored Oct 21, 2019
2 parents 406af20 + b434701 commit 216735f
Show file tree
Hide file tree
Showing 15 changed files with 473 additions and 61 deletions.
3 changes: 2 additions & 1 deletion src/containers/FullApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ export class FullApp extends Component {
});
} else {
const labelForItem = itemLabel; // (_.isArray(itemLabel) ? itemLabel[0] : itemLabel );
const title = "Source for " + (labelForItem === item.value ? labelForItem : labelForItem + " of " + item.value);
const valueForItem = _.isObject(item.value) ? item.value.value : item.value;
const title = "Source for " + (labelForItem === valueForItem ? labelForItem : labelForItem + " of " + valueForItem);
this.setState({
isModalOpen: true,
modalTitle: title,
Expand Down
14 changes: 10 additions & 4 deletions src/model/fluxWrappers/core/FluxCondition.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import FluxAdverseDrugReaction from './FluxAdverseDrugReaction';
import FluxObservation from './FluxObservation';
import FluxProcedureRequest from './FluxProcedureRequest';
import hpiConfig from '../../hpi-configuration.json';
import Lang from 'lodash';
import _ from 'lodash';
import moment from 'moment';
import FluxEntry from '../base/FluxEntry';
import FluxMedicationStatement from './FluxMedicationStatement';
Expand Down Expand Up @@ -240,7 +240,7 @@ class FluxCondition extends FluxEntry {

getTests() {
return this.getObservationsOfType(FluxObservation).filter((item) => {
return !Lang.isNull(item.quantity);
return !_.isNull(item.quantity);
});
}

Expand All @@ -249,7 +249,7 @@ class FluxCondition extends FluxEntry {
let results = this.getTests();
results.sort(this._observationsTimeSorter);
let mostRecentLabResults = results;
if (sinceDate && !Lang.isNull(sinceDate)) {
if (sinceDate && !_.isNull(sinceDate)) {
mostRecentLabResults = this.getMostRecentLabResults(results, sinceDate);
}

Expand Down Expand Up @@ -299,6 +299,12 @@ class FluxCondition extends FluxEntry {
return mostRecentLabResultsArray;
}

getMostRecentLabResultByCode(code) {
const mostRecentLabResults = this.getMostRecentLabResultOfEachType();
const filteredLabResults = mostRecentLabResults.filter(lab => lab.codeableConceptCode === code);
return filteredLabResults.length > 0 ? filteredLabResults[0] : null;
}

getMostRecentLabResultsAsText() {
// Set the max number of months prior to today that a lab result can be
const numberOfMonths = 6;
Expand Down Expand Up @@ -401,7 +407,7 @@ class FluxCondition extends FluxEntry {
const procedure = patient.getProceduresForCondition(this).find((p) => {
return (p.code === procedureCode);
});
return !Lang.isEmpty(procedure);
return !_.isEmpty(procedure);
}

buildEventNarrative(hpiText, patient, conditionCode = null) {
Expand Down
2 changes: 1 addition & 1 deletion src/summary/NarrativeNameValuePairsVisualizer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class NarrativeNameValuePairsVisualizer extends Visualizer {
value: [
snippet.value,
snippet.unsigned,
snippet.source,
snippet.source || snippet.value.source,
snippet.shortcutData
],
};
Expand Down
1 change: 1 addition & 0 deletions src/summary/TabularListVisualizer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ export default class TabularListVisualizer extends Visualizer {
let colText = _.isObject(col.value) ? col.value.value : col.value;
const longElementText = colText;

// NOTE: Truncates any text blocks over 100 characters. It is unclear where the motivation for this number originally came from
if (!_.isEmpty(colText) && colText.length > 100) colText = colText.substring(0, 100) + "...";

let itemClass = isUnsigned ? 'list-unsigned' : 'list-captured';
Expand Down
3 changes: 2 additions & 1 deletion src/summary/metadata/ActiveConditionsSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export default class ActiveConditionsSection extends MetadataSection {
const conditions = patient.getActiveConditions();
return conditions.map((c, i) => {
return [
{ value: c.type,
{
value: c.type,
isUnsigned: patient.isUnsigned(c),
source: this.determineSource(patient, c),
shortcutData: {
Expand Down
41 changes: 41 additions & 0 deletions src/summary/metadata/ActiveConditionsSubsection.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import MetadataSection from "./MetadataSection";
import _ from 'lodash';

export default class ActiveConditionsSubsection extends MetadataSection {
getMetadata(preferencesManager, patient, condition, roleType, role, specialty) {
return {
name: "Active Conditions",
itemsFunction: this.getItemListForConditions
};
}

// Returns conditions in the correct format to be displayed in the summary section
getItemListForConditions = (patient, currentConditionEntry) => {
if (_.isNull(patient) || _.isNull(currentConditionEntry)) return [];

const conditions = patient.getActiveConditions();

return conditions.map(c => {
const value = this.getValue(c,patient);
const name = c.type;
return {
name,
value
};
});
}

// Returns the supplementary info for the condition (i.e. location and diagnosis date)
getValue = (condition, patient) => {
const val = condition.bodySite;
const unsigned = patient.isUnsigned(condition);
const source = this.determineSource(patient, condition);
const when = condition.diagnosisDate;
return {
source,
when,
value: val,
isUnsigned: unsigned,
};
}
}
56 changes: 56 additions & 0 deletions src/summary/metadata/ActiveTreatmentsSubsection.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import MetadataSection from './MetadataSection';
import ActiveTreatmentSummaryObjectFactory from '../activeTreatmentSummary/ActiveTreatmentSummaryObjectFactory';
import _ from 'lodash';

export default class ActiveTreatmentsSubsection extends MetadataSection {
getMetadata(preferencesManager, patient, condition, roleType, role, specialty) {
return {
name: "Treatment",
itemsFunction: this.getItemListForTreatments
};
}

// Returns toxicites in the correct format to be displayed in the summary section
getItemListForTreatments = (patient, currentConditionEntry) => {
if (_.isNull(patient) || _.isNull(currentConditionEntry)) return [];

const activeTreatmentSummaryObject = ActiveTreatmentSummaryObjectFactory.createInstance(patient, currentConditionEntry);
const activeTreatmentSummaryJson = activeTreatmentSummaryObject.getActiveTreatmentSummary(patient, currentConditionEntry);

if (_.isNull(activeTreatmentSummaryJson) || _.isUndefined(activeTreatmentSummaryJson.displayText)) return [];

// Always use the displayText provided back from the summaryObject
const treatmentSummaryValue = activeTreatmentSummaryJson.displayText;
const treatments = [];

// If there are medications, push mediations to treatments array
if (activeTreatmentSummaryJson.medications) {
activeTreatmentSummaryJson.medications.forEach((med) => {
const name = `${treatmentSummaryValue} ${med.medication}`;
const value = this.getMedValue(med, patient);
treatments.push({
name,
value,
shortcut: null
});
});
}

// TO DO: Support adding relevant procedures into treatments table

return treatments;
}

// Returns the value for the toxicity which includes grade, unsigned, source, and date
getMedValue = (med, patient) => {
const val = `${med.startDate} - ${med.endDate}`;
const unsigned = patient.isUnsigned(med);
const source = this.determineSource(patient, med);

return {
source,
value: val,
isUnsigned: unsigned,
};
}
}
10 changes: 5 additions & 5 deletions src/summary/metadata/BreastCancerMetadata.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ export default class BreastCancerMetadata extends MetadataSection {
defaultTemplate: "Patient has ${.Name} laterality ${.Laterality} stage ${.Stage} diagnosed on ${Key Dates.Diagnosis}."
},
{
defaultTemplate: "You last saw this patient on ${Most Recent Visit.Date of Last Visit with You}.",
defaultTemplate: "You last saw this patient on ${Recent appointments.You last saw this patient}.",
dataMissingTemplate: "There are no recorded encounters for you with this patient.",
useDataMissingTemplateCriteria: [
"Most Recent Visit.Date of Last Visit with You"
"Recent appointments.You last saw this patient"
]
},
{
defaultTemplate: "This patient was last seen in your facility by ${Most Recent Visit.Who Last Visited Here} on ${Most Recent Visit.Date of Last Visit Here}.",
defaultTemplate: "This patient was last seen in your facility by ${Recent appointments.Clinician who saw patient} on ${Recent appointments.Last visit to this practice}.",
dataMissingTemplate: "No recent visits to this facility are on record.",
useDataMissingTemplateCriteria: [
"Most Recent Visit.Who Last Visited Here",
"Most Recent Visit.Date of Last Visit Here"
"Recent appointments.Clinician who saw patient",
"Recent appointments.Last visit to this practice"
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions src/summary/metadata/MostRecentVisitsSubsection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import moment from 'moment';
export default class MostRecentVisitsSubsection extends MetadataSection {
getMetadata(preferencesManager, patient, condition, roleType, role, specialty) {
return {
name: "Most Recent Visit",
name: "Recent appointments",
items: [
{
name: "Date of Last Visit with You",
name: "You last saw this patient",
value: (patient, currentConditionEntry, user) => {
const encounters = patient.getPreviousEncountersChronologicalOrder();
const filteredEncounters = encounters.filter(e => e.practitioner === user.getUserName());
Expand All @@ -22,7 +22,7 @@ export default class MostRecentVisitsSubsection extends MetadataSection {
}
},
{
name: "Date of Last Visit Here",
name: "Last visit to this practice",
value: (patient, currentConditionEntry, user) => {
const encounters = patient.getPreviousEncountersChronologicalOrder();
const filteredEncounters = encounters.filter(e => e.provider === user.provider);
Expand All @@ -37,7 +37,7 @@ export default class MostRecentVisitsSubsection extends MetadataSection {
}
},
{
name: "Who Last Visited Here",
name: "Clinician who saw patient",
value: (patient, currentConditionEntry, user) => {
const encounters = patient.getPreviousEncountersChronologicalOrder();
const filteredEncounters = encounters.filter(e => e.provider === user.provider);
Expand Down
9 changes: 2 additions & 7 deletions src/summary/metadata/RecentLabResultsSubsection.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import MetadataSection from "./MetadataSection";
import Lang from 'lodash';
import _ from 'lodash';
// import moment from 'moment';

export default class RecentLabResultsSubsection extends MetadataSection {
Expand All @@ -11,13 +11,8 @@ export default class RecentLabResultsSubsection extends MetadataSection {
}

getItemListForLabResults = (patient, currentConditionEntry) => {
if (Lang.isNull(patient) || Lang.isNull(currentConditionEntry)) return [];
if (_.isNull(patient) || _.isNull(currentConditionEntry)) return [];

// Set the max number of months prior to today that a lab result can be
//const numberOfMonths = 6;

// labResultsInOrder contains all lab results within a specified number of months from today
//const labResultsInOrder = currentConditionEntry.getLabResultsChronologicalOrder(moment().subtract(numberOfMonths, 'months'));
const labResultsInOrder = currentConditionEntry.getMostRecentLabResultOfEachType();

return labResultsInOrder.map((l, i) => {
Expand Down
4 changes: 2 additions & 2 deletions src/summary/metadata/RecentToxicitiesSubsection.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import MetadataSection from "./MetadataSection";
import Lang from 'lodash';
import _ from 'lodash';

export default class RecentToxicitiesSubsection extends MetadataSection {
getMetadata(preferencesManager, patient, condition, roleType, role, specialty) {
Expand All @@ -11,7 +11,7 @@ export default class RecentToxicitiesSubsection extends MetadataSection {

// Returns toxicites in the correct format to be displayed in the summary section
getItemListForToxicities = (patient, currentConditionEntry) => {
if (Lang.isNull(patient) || Lang.isNull(currentConditionEntry)) return [];
if (_.isNull(patient) || _.isNull(currentConditionEntry)) return [];

const toxicities = currentConditionEntry.getMostRecentToxicities();

Expand Down
Loading

0 comments on commit 216735f

Please sign in to comment.