diff --git a/packages/openchs-android/package.json b/packages/openchs-android/package.json index 0fd65a461..7d2bfc802 100644 --- a/packages/openchs-android/package.json +++ b/packages/openchs-android/package.json @@ -37,7 +37,7 @@ "lodash": "4.17.11", "moment": "2.19.3", "native-base": "2.12.1", - "openchs-models": "0.2.60", + "openchs-models": "0.2.61", "prop-types": "15.7.2", "react": "16.8.3", "react-native": "0.59.5", diff --git a/packages/openchs-android/src/action/common/ObservationsHolderActions.js b/packages/openchs-android/src/action/common/ObservationsHolderActions.js index 1cdb78603..2262b801a 100644 --- a/packages/openchs-android/src/action/common/ObservationsHolderActions.js +++ b/packages/openchs-android/src/action/common/ObservationsHolderActions.js @@ -24,7 +24,7 @@ class ObservationsHolderActions { const formElementStatuses = ObservationsHolderActions._getFormElementStatuses(newState, context); const ruleValidationErrors = ObservationsHolderActions.getRuleValidationErrors(formElementStatuses); const hiddenFormElementStatus = _.filter(formElementStatuses, (form) => form.visibility === false); - newState.observationsHolder.updatePrimitiveObs(newState.filteredFormElements, formElementStatuses); + newState.observationsHolder.updatePrimitiveCodedObs(newState.filteredFormElements, formElementStatuses); newState.removeHiddenFormValidationResults(hiddenFormElementStatus); const validationResult = action.formElement.validate(action.value); newState.handleValidationResults(ObservationsHolderActions.addPreviousValidationErrors(ruleValidationErrors, validationResult, newState.validationResults), context); @@ -57,7 +57,7 @@ class ObservationsHolderActions { const formElementStatuses = ObservationsHolderActions._getFormElementStatuses(newState, context); const ruleValidationErrors = ObservationsHolderActions.getRuleValidationErrors(formElementStatuses); const hiddenFormElementStatus = _.filter(formElementStatuses, (form) => form.visibility === false); - newState.observationsHolder.updatePrimitiveObs(newState.filteredFormElements, formElementStatuses); + newState.observationsHolder.updatePrimitiveCodedObs(newState.filteredFormElements, formElementStatuses); const validationResult = action.formElement.validate(_.isNil(observation) ? null : observation.getValueWrapper()); newState.handleValidationResults(ObservationsHolderActions.addPreviousValidationErrors(ruleValidationErrors, validationResult, newState.validationResults), context); newState.removeHiddenFormValidationResults(hiddenFormElementStatus); @@ -80,7 +80,7 @@ class ObservationsHolderActions { const ruleValidationErrors = ObservationsHolderActions.getRuleValidationErrors(formElementStatuses); const hiddenFormElementStatus = _.filter(formElementStatuses, (form) => form.visibility === false); const validationResult = action.formElement.validate(_.isNil(observation) ? null : observation.getValueWrapper()); - newState.observationsHolder.updatePrimitiveObs(newState.filteredFormElements, formElementStatuses); + newState.observationsHolder.updatePrimitiveCodedObs(newState.filteredFormElements, formElementStatuses); newState.handleValidationResults(ObservationsHolderActions.addPreviousValidationErrors(ruleValidationErrors, validationResult, newState.validationResults), context); newState.removeHiddenFormValidationResults(hiddenFormElementStatus); return newState; @@ -100,7 +100,7 @@ class ObservationsHolderActions { const formElementStatuses = ObservationsHolderActions._getFormElementStatuses(newState, context); const ruleValidationErrors = ObservationsHolderActions.getRuleValidationErrors(formElementStatuses); const hiddenFormElementStatus = _.filter(formElementStatuses, (form) => form.visibility === false); - newState.observationsHolder.updatePrimitiveObs(newState.filteredFormElements, formElementStatuses); + newState.observationsHolder.updatePrimitiveCodedObs(newState.filteredFormElements, formElementStatuses); const validationResult = action.formElement.validate(dateValue); newState.handleValidationResults(ObservationsHolderActions.addPreviousValidationErrors(ruleValidationErrors, validationResult, newState.validationResults), context); newState.removeHiddenFormValidationResults(hiddenFormElementStatus); @@ -115,7 +115,7 @@ class ObservationsHolderActions { const formElementStatuses = ObservationsHolderActions._getFormElementStatuses(newState, context); const ruleValidationErrors = ObservationsHolderActions.getRuleValidationErrors(formElementStatuses); const hiddenFormElementStatus = _.filter(formElementStatuses, (form) => form.visibility === false); - newState.observationsHolder.updatePrimitiveObs(newState.filteredFormElements, formElementStatuses); + newState.observationsHolder.updatePrimitiveCodedObs(newState.filteredFormElements, formElementStatuses); const validationResult = action.formElement.validate(_.isNil(observation) ? null : observation.getValueWrapper()); newState.handleValidationResults(ObservationsHolderActions.addPreviousValidationErrors(ruleValidationErrors, validationResult, newState.validationResults), context); newState.removeHiddenFormValidationResults(hiddenFormElementStatus); diff --git a/packages/openchs-android/src/action/program/ChecklistItemActions.js b/packages/openchs-android/src/action/program/ChecklistItemActions.js index e56821e93..d2e17cd8d 100644 --- a/packages/openchs-android/src/action/program/ChecklistItemActions.js +++ b/packages/openchs-android/src/action/program/ChecklistItemActions.js @@ -59,7 +59,7 @@ class ChecklistItemActions { newState.checklistItem.completionDate = action.value; const formElementStatuses = ObservationsHolderActions.updateFormElements(newState.formElementGroup, newState, context); newState.observationsHolder.removeNonApplicableObs(newState.formElementGroup.getFormElements(), newState.filteredFormElements); - newState.observationsHolder.updatePrimitiveObs(newState.filteredFormElements, formElementStatuses); + newState.observationsHolder.updatePrimitiveCodedObs(newState.filteredFormElements, formElementStatuses); return newState; } } diff --git a/packages/openchs-android/src/action/program/ProgramEncounterActions.js b/packages/openchs-android/src/action/program/ProgramEncounterActions.js index e423056ea..7ccacb241 100644 --- a/packages/openchs-android/src/action/program/ProgramEncounterActions.js +++ b/packages/openchs-android/src/action/program/ProgramEncounterActions.js @@ -115,7 +115,7 @@ class ProgramEncounterActions { newState.handleValidationResults(newState.programEncounter.validate(), context); const formElementStatuses = ObservationsHolderActions.updateFormElements(newState.formElementGroup, newState, context); newState.observationsHolder.removeNonApplicableObs(newState.formElementGroup.getFormElements(), newState.filteredFormElements); - newState.observationsHolder.updatePrimitiveObs(newState.filteredFormElements, formElementStatuses); + newState.observationsHolder.updatePrimitiveCodedObs(newState.filteredFormElements, formElementStatuses); return newState; } diff --git a/packages/openchs-android/src/action/program/ProgramEnrolmentActions.js b/packages/openchs-android/src/action/program/ProgramEnrolmentActions.js index 9b8e1591c..e9418123e 100644 --- a/packages/openchs-android/src/action/program/ProgramEnrolmentActions.js +++ b/packages/openchs-android/src/action/program/ProgramEnrolmentActions.js @@ -45,7 +45,7 @@ export class ProgramEnrolmentActions { action.workLists ); programEnrolmentState = programEnrolmentState.clone(); - programEnrolmentState.observationsHolder.updatePrimitiveObs(filteredElements, formElementStatuses); + programEnrolmentState.observationsHolder.updatePrimitiveCodedObs(filteredElements, formElementStatuses); return programEnrolmentState; } else { return state.clone(); diff --git a/packages/openchs-android/src/state/AbstractDataEntryState.js b/packages/openchs-android/src/state/AbstractDataEntryState.js index 266e5d2c5..cd318c521 100644 --- a/packages/openchs-android/src/state/AbstractDataEntryState.js +++ b/packages/openchs-android/src/state/AbstractDataEntryState.js @@ -133,7 +133,7 @@ class AbstractDataEntryState { this.moveNext(); const formElementStatuses = ObservationHolderActions.updateFormElements(this.formElementGroup, this, context); this.observationsHolder.removeNonApplicableObs(this.formElementGroup.getFormElements(), this.filteredFormElements); - this.observationsHolder.updatePrimitiveObs(this.filteredFormElements, formElementStatuses); + this.observationsHolder.updatePrimitiveCodedObs(this.filteredFormElements, formElementStatuses); if (this.hasNoFormElements()) { General.logDebug("No form elements here. Moving to next screen"); return this.handleNext(action, context); diff --git a/packages/openchs-android/src/state/EncounterActionState.js b/packages/openchs-android/src/state/EncounterActionState.js index dfdd6d23c..96cf65758 100644 --- a/packages/openchs-android/src/state/EncounterActionState.js +++ b/packages/openchs-android/src/state/EncounterActionState.js @@ -50,7 +50,7 @@ class EncounterActionState extends AbstractDataEntryState { static createOnLoadState(encounter, form, isNewEntity, formElementGroup, filteredFormElements, formElementStatuses, workLists, messageDisplayed) { let indexOfGroup = _.findIndex(form.getFormElementGroups(), (feg) => feg.uuid === formElementGroup.uuid) + 1; let state = new EncounterActionState([], formElementGroup, new Wizard(form.numberOfPages, indexOfGroup, indexOfGroup), isNewEntity, encounter, filteredFormElements, workLists, messageDisplayed); - state.observationsHolder.updatePrimitiveObs(filteredFormElements, formElementStatuses); + state.observationsHolder.updatePrimitiveCodedObs(filteredFormElements, formElementStatuses); return state; } diff --git a/packages/openchs-android/src/state/ProgramEncounterState.js b/packages/openchs-android/src/state/ProgramEncounterState.js index 1b561b954..75441cff7 100644 --- a/packages/openchs-android/src/state/ProgramEncounterState.js +++ b/packages/openchs-android/src/state/ProgramEncounterState.js @@ -23,7 +23,7 @@ class ProgramEncounterState extends AbstractDataEntryState { static createOnLoad(programEncounter, form, isNewEntity, formElementGroup, filteredFormElements, formElementStatuses, workLists, messageDisplayed) { let indexOfGroup = _.findIndex(form.getFormElementGroups(), (feg) => feg.uuid === formElementGroup.uuid) + 1; let state = new ProgramEncounterState(formElementGroup, new Wizard(form.numberOfPages, indexOfGroup, indexOfGroup), isNewEntity, programEncounter, filteredFormElements, workLists, messageDisplayed); - state.observationsHolder.updatePrimitiveObs(filteredFormElements, formElementStatuses); + state.observationsHolder.updatePrimitiveCodedObs(filteredFormElements, formElementStatuses); return state; } diff --git a/packages/openchs-android/src/state/SubjectRegistrationState.js b/packages/openchs-android/src/state/SubjectRegistrationState.js index 702368ad1..529830eee 100644 --- a/packages/openchs-android/src/state/SubjectRegistrationState.js +++ b/packages/openchs-android/src/state/SubjectRegistrationState.js @@ -36,7 +36,7 @@ class SubjectRegistrationState extends AbstractDataEntryState { ); state.form = form; state.minLevelTypeUUIDs = minLevelTypeUUIDs; - state.observationsHolder.updatePrimitiveObs(filteredFormElements, formElementStatuses); + state.observationsHolder.updatePrimitiveCodedObs(filteredFormElements, formElementStatuses); return state; } diff --git a/packages/openchs-android/src/views/form/formElement/SelectFormElement.js b/packages/openchs-android/src/views/form/formElement/SelectFormElement.js index 4d48bdead..db23b73ff 100644 --- a/packages/openchs-android/src/views/form/formElement/SelectFormElement.js +++ b/packages/openchs-android/src/views/form/formElement/SelectFormElement.js @@ -26,6 +26,7 @@ class SelectFormElement extends AbstractFormElement { } render() { + const disabled = this.props.element.editable === false; const valueLabelPairs = this.props.element.getAnswers() .map((answer) => new RadioLabelValue(answer.concept.name, answer.concept.uuid, answer.abnormal)); return ( @@ -38,10 +39,12 @@ class SelectFormElement extends AbstractFormElement { labelKey={this.props.element.name} mandatory={this.props.element.mandatory} validationError={this.props.validationResult} - labelValuePairs={valueLabelPairs}/> + labelValuePairs={valueLabelPairs} + disabled={disabled} + /> ); } } -export default SelectFormElement; \ No newline at end of file +export default SelectFormElement; diff --git a/packages/openchs-android/src/views/primitives/PresetOptionItem.js b/packages/openchs-android/src/views/primitives/PresetOptionItem.js index ac6391944..fec7be734 100644 --- a/packages/openchs-android/src/views/primitives/PresetOptionItem.js +++ b/packages/openchs-android/src/views/primitives/PresetOptionItem.js @@ -12,7 +12,8 @@ import General from "../../utility/General"; class PresetOptionItem extends AbstractComponent { static defaultProps = { - chunked: false + chunked: false, + disabled: false, }; static propTypes = { @@ -39,10 +40,10 @@ class PresetOptionItem extends AbstractComponent { getSelectComponent() { if (this.props.multiSelect) - return ( this.props.onPress()}/>); else - return ( this.props.onPress()} color={Colors.AccentColor}/>); } @@ -73,7 +74,7 @@ class PresetOptionItem extends AbstractComponent { }; const ToRender = this.props.chunked ? chunked : single; return ( - this.props.onPress()} style={ToRender.container}> + this.props.onPress()} style={ToRender.container} disabled={this.props.disabled}> {this.getSelectComponent()} diff --git a/packages/openchs-android/src/views/primitives/RadioGroup.js b/packages/openchs-android/src/views/primitives/RadioGroup.js index 6ac69328c..c34bc4a29 100644 --- a/packages/openchs-android/src/views/primitives/RadioGroup.js +++ b/packages/openchs-android/src/views/primitives/RadioGroup.js @@ -26,6 +26,7 @@ class RadioGroup extends AbstractComponent { borderStyle: {}, inPairs: false, multiSelect: false, + disabled: false, }; static propTypes = { @@ -60,7 +61,8 @@ class RadioGroup extends AbstractComponent { style={{ paddingVertical: Distances.VerticalSpacingBetweenOptionItems, paddingRight: Distances.HorizontalSpacingBetweenOptionItems - }}/> + }} + disabled={this.props.disabled}/> )} ); } @@ -76,7 +78,9 @@ class RadioGroup extends AbstractComponent { style={{ paddingVertical: Distances.VerticalSpacingBetweenOptionItems, paddingRight: Distances.HorizontalSpacingBetweenOptionItems - }}/>) + }} + disabled={this.props.disabled} + />) } renderSingleValue() {