@openmrs/ngx-formentry 3.0.1-pre.103 → 3.0.1-pre.105

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2086,17 +2086,23 @@
2086
2086
  return array.indexOf(members) !== -1;
2087
2087
  }
2088
2088
  };
2089
- /*
2090
- TODO make it possible to bootstrap expressions without control relations to make alternateControl optional as at the moment it required
2091
- if no other expression on the control as a relationship to another control*/
2092
- JsExpressionHelper.prototype.extractObsValue = function (rawEncounter, uuid, alternateControl) {
2089
+ /**
2090
+ * Takes a target control, an encounter and concept uuid. If the target control has a value it returns it
2091
+ * otherwise it tries to find it in the encounter. Finally it returns null of it can't find either of them.
2092
+ * @param targetControl
2093
+ * @param rawEncounter
2094
+ * @param uuid
2095
+ * @returns
2096
+ */
2097
+ JsExpressionHelper.prototype.getObsFromControlOrEncounter = function (targetControl, rawEncounter, uuid) {
2093
2098
  var _a;
2094
2099
  var findObs = function (obs, uuid) {
2095
2100
  var result;
2096
- obs === null || obs === void 0 ? void 0 : obs.some(function (o) { var _a; return result = ((_a = o === null || o === void 0 ? void 0 : o.concept) === null || _a === void 0 ? void 0 : _a.uuid) === uuid ? o : findObs(o.children || [], uuid); });
2101
+ obs === null || obs === void 0 ? void 0 : obs.some(function (o) { var _a; return result = ((_a = o === null || o === void 0 ? void 0 : o.concept) === null || _a === void 0 ? void 0 : _a.uuid) === uuid ? o : findObs(o.groupMembers || [], uuid); });
2097
2102
  return result;
2098
2103
  };
2099
- return ((_a = findObs(rawEncounter === null || rawEncounter === void 0 ? void 0 : rawEncounter.obs, uuid)) === null || _a === void 0 ? void 0 : _a.value) || alternateControl;
2104
+ var obsValue = (_a = findObs(rawEncounter === null || rawEncounter === void 0 ? void 0 : rawEncounter.obs, uuid)) === null || _a === void 0 ? void 0 : _a.value;
2105
+ return !!targetControl ? targetControl : typeof obsValue === 'object' ? obsValue.uuid : !!obsValue ? obsValue : null;
2100
2106
  };
2101
2107
  Object.defineProperty(JsExpressionHelper.prototype, "helperFunctions", {
2102
2108
  get: function () {
@@ -2111,7 +2117,7 @@
2111
2117
  isEmpty: helper.isEmpty,
2112
2118
  arrayContains: helper.arrayContains,
2113
2119
  extractRepeatingGroupValues: helper.extractRepeatingGroupValues,
2114
- extractObsValue: helper.extractObsValue
2120
+ getObsFromControlOrEncounter: helper.getObsFromControlOrEncounter
2115
2121
  };
2116
2122
  },
2117
2123
  enumerable: false,