Skip to content

Commit 4a976f0

Browse files
committed
#1428 | webapp changes to introduce new concept datatype ImageV2
1 parent 3b0a65d commit 4a976f0

File tree

7 files changed

+60
-61
lines changed

7 files changed

+60
-61
lines changed

src/adminApp/components/CreateEditFilters.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,18 @@ import { AvniFormLabel } from "../../common/components/AvniFormLabel";
1616
import { AvniTextField } from "../../common/components/AvniTextField";
1717
import ErrorMessageUtil from "../../common/utils/ErrorMessageUtil";
1818

19-
const nonSupportedTypes = ["Duration", "Image", "Video", "Subject", "Location", "PhoneNumber", "GroupAffiliation", "Audio", "File"];
19+
const nonSupportedTypes = [
20+
"Duration",
21+
"Image",
22+
"ImageV2",
23+
"Video",
24+
"Subject",
25+
"Location",
26+
"PhoneNumber",
27+
"GroupAffiliation",
28+
"Audio",
29+
"File"
30+
];
2031
export const CreateEditFilters = ({
2132
omitTableData,
2233
selectedFilter,

src/dataEntryApp/components/FormElement.js

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const elements = {
3232
Notes: NotesFormElement,
3333
NA: div,
3434
Image: MediaFormElement,
35+
ImageV2: MediaFormElement,
3536
Video: MediaFormElement,
3637
Audio: MediaFormElement,
3738
File: MediaFormElement,

src/formDesigner/common/constants.js

+8-32
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,14 @@ class FormTypeInfo {
1717

1818
export const FormTypeEntities = {
1919
IndividualProfile: new FormTypeInfo("IndividualProfile", "Subject registration", "individual"),
20-
SubjectEnrolmentEligibility: new FormTypeInfo(
21-
"SubjectEnrolmentEligibility",
22-
"Subject enrolment eligibility",
23-
"individual"
24-
),
25-
ManualProgramEnrolmentEligibility: new FormTypeInfo(
26-
"ManualProgramEnrolmentEligibility",
27-
"Manual enrolment eligibility",
28-
"individual"
29-
),
20+
SubjectEnrolmentEligibility: new FormTypeInfo("SubjectEnrolmentEligibility", "Subject enrolment eligibility", "individual"),
21+
ManualProgramEnrolmentEligibility: new FormTypeInfo("ManualProgramEnrolmentEligibility", "Manual enrolment eligibility", "individual"),
3022
ProgramEnrolment: new FormTypeInfo("ProgramEnrolment", "Program enrolment", "programEnrolment"),
3123
ProgramExit: new FormTypeInfo("ProgramExit", "Program exit", "programEnrolment"),
3224
ProgramEncounter: new FormTypeInfo("ProgramEncounter", "Program encounter", "programEncounter"),
33-
ProgramEncounterCancellation: new FormTypeInfo(
34-
"ProgramEncounterCancellation",
35-
"Program encounter cancellation",
36-
"programEncounter"
37-
),
25+
ProgramEncounterCancellation: new FormTypeInfo("ProgramEncounterCancellation", "Program encounter cancellation", "programEncounter"),
3826
Encounter: new FormTypeInfo("Encounter", "Encounter", "encounter"),
39-
IndividualEncounterCancellation: new FormTypeInfo(
40-
"IndividualEncounterCancellation",
41-
"Individual Encounter Cancellation",
42-
"encounter"
43-
),
27+
IndividualEncounterCancellation: new FormTypeInfo("IndividualEncounterCancellation", "Individual Encounter Cancellation", "encounter"),
4428
ChecklistItem: new FormTypeInfo("ChecklistItem", "Check list item", "checklistItem"),
4529
Location: new FormTypeInfo("Location", "Location"),
4630
Task: new FormTypeInfo("Task", "Task", "task"),
@@ -54,24 +38,15 @@ export const FormTypeEntities = {
5438
},
5539

5640
isForProgramEncounter(formTypeInfo) {
57-
return (
58-
formTypeInfo === FormTypeEntities.ProgramEncounterCancellation ||
59-
formTypeInfo === FormTypeEntities.ProgramEncounter
60-
);
41+
return formTypeInfo === FormTypeEntities.ProgramEncounterCancellation || formTypeInfo === FormTypeEntities.ProgramEncounter;
6142
},
6243

6344
isForProgramEnrolment(formTypeInfo) {
64-
return (
65-
formTypeInfo === FormTypeEntities.ProgramEnrolment ||
66-
formTypeInfo === FormTypeEntities.ProgramExit
67-
);
45+
return formTypeInfo === FormTypeEntities.ProgramEnrolment || formTypeInfo === FormTypeEntities.ProgramExit;
6846
},
6947

7048
isForSubjectEncounter(formTypeInfo) {
71-
return (
72-
formTypeInfo === FormTypeEntities.Encounter ||
73-
formTypeInfo === FormTypeEntities.IndividualEncounterCancellation
74-
);
49+
return formTypeInfo === FormTypeEntities.Encounter || formTypeInfo === FormTypeEntities.IndividualEncounterCancellation;
7550
}
7651
};
7752

@@ -100,6 +75,7 @@ export const inlineConceptDataType = _.sortBy([
10075
"Time",
10176
"Duration",
10277
"Image",
78+
"ImageV2",
10379
"Id",
10480
"Video",
10581
"Subject",

src/formDesigner/components/FormElement.js

+7-26
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export const dataTypeIcons = {
130130
Text: <TextFieldsIcon />,
131131
Notes: <NoteIcon />,
132132
Image: <ImageIcon />,
133+
ImageV2: <ImageIcon />,
133134
DateTime: <DateRangeIcon />,
134135
Time: <QueryBuilderIcon />,
135136
Duration: <TimerIcon />,
@@ -172,22 +173,11 @@ function FormElement(props) {
172173
TransitionProps={{ mountOnEnter: true, unmountOnExit: true }}
173174
expanded={props.formElementData.expanded}
174175
className={props.formElementData.error ? classes.rootError : classes.root}
175-
onChange={event =>
176-
props.handleGroupElementChange(
177-
props.groupIndex,
178-
"expanded",
179-
!props.formElementData.expanded,
180-
props.index
181-
)
182-
}
176+
onChange={event => props.handleGroupElementChange(props.groupIndex, "expanded", !props.formElementData.expanded, props.index)}
183177
onMouseEnter={() => setDragElement(true)}
184178
onMouseLeave={() => setDragElement(false)}
185179
>
186-
<ExpansionPanelSummary
187-
aria-controls={panel + "bh-content"}
188-
id={panel + "bh-header"}
189-
{...props.dragHandleProps}
190-
>
180+
<ExpansionPanelSummary aria-controls={panel + "bh-content"} id={panel + "bh-header"} {...props.dragHandleProps}>
191181
<Grid container direction={"row"}>
192182
<Grid container item alignItems={"center"} justify={"center"}>
193183
<DragHandler />
@@ -201,6 +191,7 @@ function FormElement(props) {
201191
"Text",
202192
"Notes",
203193
"Image",
194+
"ImageV2",
204195
"DateTime",
205196
"Time",
206197
"Duration",
@@ -223,11 +214,7 @@ function FormElement(props) {
223214
)}
224215
{props.formElementData.concept.dataType === "Coded" && (
225216
<div className={classes.iconDataType}>
226-
<Tooltip
227-
title={
228-
props.formElementData.concept.dataType + " : " + props.formElementData.type
229-
}
230-
>
217+
<Tooltip title={props.formElementData.concept.dataType + " : " + props.formElementData.type}>
231218
{dataTypeIcons["concept"][props.formElementData.type]}
232219
</Tooltip>
233220
</div>
@@ -236,9 +223,7 @@ function FormElement(props) {
236223
</Grid>
237224
<Grid item sm={10} style={{ paddingTop: "10px" }}>
238225
<Typography component={"span"} className={classes.heading}>
239-
<span className={classes.expandIcon}>
240-
{props.formElementData.expanded ? <ExpandLessIcon /> : <ExpandMoreIcon />}
241-
</span>
226+
<span className={classes.expandIcon}>{props.formElementData.expanded ? <ExpandLessIcon /> : <ExpandMoreIcon />}</span>
242227
<InputLabel
243228
name={"name" + panel}
244229
style={{ display: "inline-block" }}
@@ -254,11 +239,7 @@ function FormElement(props) {
254239
<IconButton aria-label="delete" onClick={handleDelete} disabled={disableFormElement}>
255240
<DeleteIcon />
256241
</IconButton>
257-
<ToolTip
258-
toolTipKey={"APP_DESIGNER_FORM_ELEMENT_NAME"}
259-
onHover
260-
displayPosition={"bottom"}
261-
/>
242+
<ToolTip toolTipKey={"APP_DESIGNER_FORM_ELEMENT_NAME"} onHover displayPosition={"bottom"} />
262243
</Grid>
263244
</Grid>
264245
</Grid>

src/formDesigner/components/FormElementDetails.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const BackButton = props => {
7474
);
7575
};
7676

77-
export const multiSelectFormElementConceptDataTypes = ["Coded", "Subject", "Image", "Video", "File", "Encounter"];
77+
export const multiSelectFormElementConceptDataTypes = ["Coded", "Subject", "Image", "ImageV2", "Video", "File", "Encounter"];
7878

7979
function FormElementDetails({ userInfo, ...props }) {
8080
const classes = useStyles();
@@ -488,7 +488,7 @@ function FormElementDetails({ userInfo, ...props }) {
488488
index={props.index}
489489
/>
490490
)}
491-
{props.formElementData.concept.dataType === "Image" && (
491+
{(props.formElementData.concept.dataType === "Image" || props.formElementData.concept.dataType === "ImageV2") && (
492492
<Grid container item sm={12}>
493493
<Grid item sm={3}>
494494
<TextField
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from "react";
2+
import { AvniSwitch } from "../../common/components/AvniSwitch";
3+
4+
export const ImageV2Concept = ({ onKeyValueChange, checked }) => {
5+
const onChange = event => onKeyValueChange({ key: "captureLocationInformation", value: event.target.checked }, 0);
6+
return (
7+
<div style={{ marginTop: 10, marginBottom: 10 }}>
8+
<AvniSwitch
9+
checked={checked}
10+
onChange={onChange}
11+
name="Capture Location Information"
12+
toolTipKey={"APP_DESIGNER_CAPTURE_LOCATION_INFORMATION"}
13+
/>
14+
</div>
15+
);
16+
};

src/formDesigner/views/CreateEditConcept.js

+14
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { SubjectConcept } from "../components/SubjectConcept";
2929
import { PhoneNumberConcept } from "../components/PhoneNumberConcept";
3030
import { EncounterConcept } from "../components/EncounterConcept";
3131
import { connect } from "react-redux";
32+
import { ImageV2Concept } from "../components/ImageV2Concept";
3233

3334
export const moveUp = (conceptAnswers, index) => {
3435
if (index === 0) return conceptAnswers;
@@ -125,6 +126,7 @@ class CreateEditConcept extends Component {
125126
"highestAddressLevelTypeUUID",
126127
"subjectTypeUUID",
127128
"verifyPhoneNumber",
129+
"captureLocationInformation",
128130
"encounterTypeUUID",
129131
"encounterScope",
130132
"encounterIdentifier"
@@ -687,6 +689,18 @@ class CreateEditConcept extends Component {
687689
}
688690
}
689691

692+
if (this.state.dataType === "ImageV2") {
693+
const locationInformationKey = find(this.state.keyValues, ({ key, value }) => key === "captureLocationInformation");
694+
if (locationInformationKey) {
695+
dataType = <ImageV2Concept onKeyValueChange={this.onKeyValueChange} checked={locationInformationKey.value} />;
696+
} else {
697+
this.setState(prevState => ({
698+
...prevState,
699+
keyValues: [{ key: "captureLocationInformation", value: false }]
700+
}));
701+
}
702+
}
703+
690704
return (
691705
<Box boxShadow={2} p={2} bgcolor="background.paper">
692706
<DocumentationContainer filename={"Concept.md"}>

0 commit comments

Comments
 (0)