Skip to content

Commit

Permalink
Merge pull request #897 from UCSF-IGHS/dev
Browse files Browse the repository at this point in the history
[v0.6.26] Bug fixes and feature enhancements
  • Loading branch information
samuelmale authored Mar 25, 2022
2 parents 0dc6551 + 132730f commit c2d9b96
Show file tree
Hide file tree
Showing 23 changed files with 5,816 additions and 2,355 deletions.
59 changes: 2 additions & 57 deletions src/components/encounter-list/encounter-list.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { OHRIFormLauncherWithIntent } from '../ohri-form-launcher/ohri-form-laun
import styles from './encounter-list.scss';
import OTable from '../data-table/o-table.component';
import { Button, Link, OverflowMenu, OverflowMenuItem, Pagination } from 'carbon-components-react';
import { encounterRepresentation, stopReasonUUID, substituteReasonUUID, switchReasonUUID } from '../../constants';
import { encounterRepresentation } from '../../constants';
import moment from 'moment';
import { Add16 } from '@carbon/icons-react';
import {
Expand All @@ -24,13 +24,6 @@ export interface EncounterListColumn {
getValue: (encounter: any) => string;
link?: any;
}
//
export interface ARTDateConcepts {
artTherapyDateTime_UUID: string;
switchDateUUID: string;
substitutionDateUUID: string;
artStopDateUUID: string;
}

export interface EncounterListProps {
patientUuid: string;
Expand Down Expand Up @@ -80,6 +73,7 @@ export function getObsFromEncounters(encounters, obsConcept) {

export function getObsFromEncounter(encounter, obsConcept, isDate?: Boolean, isTrueFalseConcept?: Boolean) {
const obs = findObs(encounter, obsConcept);

if (isTrueFalseConcept) {
return obs ? 'Yes' : 'No';
}
Expand All @@ -95,55 +89,6 @@ export function getObsFromEncounter(encounter, obsConcept, isDate?: Boolean, isT
return obs.value;
}

export function getLatestARTDateConcept(encounter, dateConcepts: ARTDateConcepts): string {
let artStartDate = findObs(encounter, dateConcepts.artTherapyDateTime_UUID);
let artSubstitutionDate = findObs(encounter, dateConcepts.substitutionDateUUID);
let artSwitchDate = findObs(encounter, dateConcepts.switchDateUUID);
let artStopDate = findObs(encounter, dateConcepts.artStopDateUUID);

artStartDate = artStartDate ? artStartDate.value : null;
artSubstitutionDate = artSubstitutionDate ? artSubstitutionDate.value : null;
artSwitchDate = artSwitchDate ? artSwitchDate.value : null;
artStopDate = artStopDate ? artStopDate.value : null;

let latestDateConcept: string = dateConcepts.artTherapyDateTime_UUID;
let latestDate = artStartDate;
if (artSubstitutionDate > latestDate) {
latestDateConcept = dateConcepts.substitutionDateUUID;
latestDate = artSubstitutionDate;
}
if (artSwitchDate > latestDate) {
latestDate = artSwitchDate;
latestDateConcept = dateConcepts.switchDateUUID;
}
if (artStopDate > latestDate) {
latestDate = artStopDate;
latestDateConcept = dateConcepts.artStopDateUUID;
}

return latestDateConcept;
}

export function getARTReasonConcept(encounter, dateConcepts: ARTDateConcepts): string {
const latestDateConcept: string = getLatestARTDateConcept(encounter, dateConcepts);
let artReaseonConcept = '';
switch (latestDateConcept) {
case dateConcepts.artStopDateUUID:
artReaseonConcept = stopReasonUUID;
break;
case dateConcepts.substitutionDateUUID:
artReaseonConcept = substituteReasonUUID;
break;
case dateConcepts.switchDateUUID:
artReaseonConcept = switchReasonUUID;
break;
default:
artReaseonConcept = '';
}

return artReaseonConcept;
}

const EncounterList: React.FC<EncounterListProps> = ({
patientUuid,
encounterUuid,
Expand Down
22 changes: 22 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const studyPopulationTypeConcept = 'd3d4ae96-8c8a-43db-a9dc-dac951f5dcb3'
export const dateOfHIVDiagnosisConcept = '160554AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
export const entryPointConcept = '160540AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
export const re_enrolmentDateConcept = '20efadf9-86d3-4498-b3ab-7da4dad9c429';
export const otherEntryPoint = '161011AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';

// Clinical visit
export const clinicalVisitEncounterType = 'cb0a65a7-0587-477e-89b9-cf2fd144f1d4';
Expand Down Expand Up @@ -145,9 +146,11 @@ export const therapyPlanConcept = '7557d77c-172b-4673-9335-67a38657dd01';
export const artStopDateUUID = '162572AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
export const switchDateUUID = '164516AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
export const substitutionDateUUID = '164431AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
export const dateRestartedUUID = '160738AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
export const switchReasonUUID = '160568AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
export const substituteReasonUUID = '160562AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
export const stopReasonUUID = '163513AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
export const restartReasonUUID = '161011AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';

// HIV Lab Results
export const hivLabResultsEncounterType_UUID = ' 15272be5-ae9c-4278-a303-4b8907eae73b';
Expand All @@ -172,3 +175,22 @@ export const visitDate_UUID = '163137AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
export const receivingFacility_UUID = '162724AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
export const TransferOutDate_UUID = '160649AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
export const verified_UUID = '797e0073-1f3f-46b1-8b1a-8cdad134d2b3';

//Patient Tracing
export const ContactDate_UUID = '160753AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
export const ContactMethod_UUID = '59c023dd-eed2-4b11-8c34-b88e9439db3c';
export const ContactOutcome_UUID = 'bc45edbd-11e7-4888-ad7d-4ec3dd8cdcf6';
export const PatientTracingEncounterType_UUID = '0cd5d4cb-204e-419a-9dd7-1e18e939ce4c';

//Intimate Partner
export const IntimatePartnerEncounterType_UUID = '881fff34-b4a9-4d11-b2f5-a8a23a9f402b';
export const ThreatenedToHurt_UUID = 'bd86f7ee-1d5f-4f5d-aa0f-4680aa6e65cb';
export const SexuallyMolested_UUID = '1246AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
export const howOftenThreatened_UUID = '953f6271-57ef-414e-bdba-fe9e0246db58';
export const howOftenSexuallyMolested_UUID = '1dd53a22-2e8f-425b-8ba4-59172ed3fafe';

//Contact Tracing
export const ContactTracingEncounterType_UUID = '570e9e42-4306-41dc-9bf8-634bbc70a524';
export const ContactTracingDate_UUID = '160753AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
export const ContactTracingMethod_UUID = '59c023dd-eed2-4b11-8c34-b88e9439db3c';
export const ContactTracingOutcome_UUID = '36a3e671-9d60-4109-b41f-046f44f4b389';
18 changes: 18 additions & 0 deletions src/forms/components/encounter/ohri-encounter-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,13 @@ export const OHRIEncounterForm: React.FC<OHRIEncounterFormProps> = ({
} else {
page.isHidden = false;
}
page.sections.forEach(section => {
if (section.hide) {
evalHide({ value: section, type: 'section' }, allFormFields, tempInitVals);
} else {
section.isHidden = false;
}
});
});
setForm(form);
setFormInitialValues(tempInitVals);
Expand Down Expand Up @@ -418,6 +425,17 @@ export const OHRIEncounterForm: React.FC<OHRIEncounterFormProps> = ({
setFields(fields_temp);
});
}
if (field.sectionDependants) {
field.sectionDependants.forEach(dependant => {
for (let i = 0; i < form.pages.length; i++) {
const section = form.pages[i].sections.find((section, _sectionIndex) => section.label == dependant);
if (section) {
evalHide({ value: section, type: 'section' }, fields, { ...values, [fieldName]: value });
break;
}
}
});
}
if (field.pageDependants) {
field.pageDependants?.forEach(dep => {
const dependant = form.pages.find(f => f.label == dep);
Expand Down
33 changes: 18 additions & 15 deletions src/forms/components/page/ohri-form-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import styles from './_page.scss';
import OHRIFormSection from '../section/ohri-form-section.component';
import { Waypoint } from 'react-waypoint';
import { Accordion, AccordionItem } from 'carbon-components-react';
import { isTrue } from '../../utils/boolean-utils';

function OHRIFormPage({ page, onFieldChange, setSelectedPage, isCollapsed }) {
let newLabel = page.label.replace(/\s/g, '');
Expand All @@ -19,21 +20,23 @@ function OHRIFormPage({ page, onFieldChange, setSelectedPage, isCollapsed }) {
</div>
<Accordion>
{/* <p className={styles.required}>All fields are required unless marked optional</p> */}
{page.sections.map((sec, index) => {
return (
<AccordionItem title={sec.label} open={isCollapsed} className={styles.sectionContent}>
<div className={styles.formSection} key={index}>
<OHRIFormSection
fields={sec.questions}
showTitle={page.sections.length > 1}
onFieldChange={onFieldChange}
sectionTitle={sec.label}
key={index}
/>
</div>
</AccordionItem>
);
})}
{page.sections
.filter(sec => !isTrue(sec.isHidden))
.map((sec, index) => {
return (
<AccordionItem title={sec.label} open={isCollapsed} className={styles.sectionContent}>
<div className={styles.formSection} key={index}>
<OHRIFormSection
fields={sec.questions}
showTitle={page.sections.length > 1}
onFieldChange={onFieldChange}
sectionTitle={sec.label}
key={index}
/>
</div>
</AccordionItem>
);
})}
</Accordion>
</div>
</Waypoint>
Expand Down
1 change: 1 addition & 0 deletions src/forms/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export interface OHRIFormFieldProps {
handler: SubmissionHandler;
}
export interface OHRIFormSection {
hide?: HideProps;
label: string;
isExpanded: string;
isHidden?: boolean;
Expand Down
1 change: 1 addition & 0 deletions src/forms/utils/expression-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ function registerDependency(node: FormNode, determinant: OHRIFormField) {
determinant.sectionDependants = new Set();
}
determinant.sectionDependants.add(node.value.label);
break;
default:
if (!determinant.fieldDependants) {
determinant.fieldDependants = new Set();
Expand Down
6 changes: 3 additions & 3 deletions src/ohri-patient-dashboards-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"programs-summary-dashboard",
"allergies-summary-dashboard",
"attachments-results-summary-dashboard",
"drug-orders-summary-dashboard",
"encounters-summary-dashboard"
"drug-orders-summary-dashboard"
]
}
}
},
"notesConceptUuids": ["161011AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"]
},
"@openmrs/esm-patient-banner-app": {
"extensionSlots": {
Expand Down
12 changes: 12 additions & 0 deletions src/packages/forms-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import covid_outcome_form_v_1_0 from './covid/forms/outcome-form/1.0.json';
import covid_case_form_v_1_0 from './covid/forms/case-form/1.0.json';
import death_form_v_1_0 from './hiv/forms/care-and-treatment/death-form/1.0.json';
import transfer_out_v_1_0 from './hiv/forms/care-and-treatment/transfer-out/1.0.json';
import patient_tracing_v_1_0 from './hiv/forms/care-and-treatment/patient-tracing/1.0.json';
import intimate_partner_v_1_0 from './hiv/forms/care-and-treatment/intimate-partner/1.0.json';
import contact_tracing_v_1_0 from './hiv/forms/care-and-treatment/contact-tracing/1.0.json';

export default {
hiv: {
Expand Down Expand Up @@ -46,6 +49,15 @@ export default {
transfer_out: {
'1.0': transfer_out_v_1_0,
},
patient_tracing: {
'1.0': patient_tracing_v_1_0,
},
intimate_partner: {
'1.0': intimate_partner_v_1_0,
},
contact_tracing: {
'1.0': contact_tracing_v_1_0,
},
},
covid: {
covid_assessment: {
Expand Down
Loading

0 comments on commit c2d9b96

Please sign in to comment.