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

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.
@@ -2007,6 +2007,10 @@
2007
2007
  return height && weight && refSectionObject ? formattedSDValue : null;
2008
2008
  };
2009
2009
  JsExpressionHelper.prototype.calcSouthEastAsiaNonLabCVDRisk = function (sex, smoker, age, sbp, bmi) {
2010
+ var hasValidValues = (typeof sex === "string" && typeof smoker === "boolean" && typeof age === "number" && typeof sbp === "number" && typeof bmi === "number");
2011
+ if (!hasValidValues) {
2012
+ return null;
2013
+ }
2010
2014
  // Bin functions
2011
2015
  var getAgeBin = function (age) { return Math.floor((Math.min(Math.max(40, age), 74) - 40) / 5); };
2012
2016
  var getSbpBin = function (sbp) { return Math.max(0, Math.floor((Math.min(sbp, 180) - 120) / 20) + 1); };
@@ -2086,17 +2090,23 @@
2086
2090
  return array.indexOf(members) !== -1;
2087
2091
  }
2088
2092
  };
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) {
2093
+ /**
2094
+ * Takes a target control, an encounter and concept uuid. If the target control has a value it returns it
2095
+ * otherwise it tries to find it in the encounter. Finally it returns null of it can't find either of them.
2096
+ * @param targetControl
2097
+ * @param rawEncounter
2098
+ * @param uuid
2099
+ * @returns
2100
+ */
2101
+ JsExpressionHelper.prototype.getObsFromControlOrEncounter = function (targetControl, rawEncounter, uuid) {
2093
2102
  var _a;
2094
2103
  var findObs = function (obs, uuid) {
2095
2104
  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); });
2105
+ 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
2106
  return result;
2098
2107
  };
2099
- return ((_a = findObs(rawEncounter === null || rawEncounter === void 0 ? void 0 : rawEncounter.obs, uuid)) === null || _a === void 0 ? void 0 : _a.value) || alternateControl;
2108
+ var obsValue = (_a = findObs(rawEncounter === null || rawEncounter === void 0 ? void 0 : rawEncounter.obs, uuid)) === null || _a === void 0 ? void 0 : _a.value;
2109
+ return !!targetControl ? targetControl : typeof obsValue === 'object' ? obsValue.uuid : !!obsValue ? obsValue : null;
2100
2110
  };
2101
2111
  Object.defineProperty(JsExpressionHelper.prototype, "helperFunctions", {
2102
2112
  get: function () {
@@ -2111,7 +2121,7 @@
2111
2121
  isEmpty: helper.isEmpty,
2112
2122
  arrayContains: helper.arrayContains,
2113
2123
  extractRepeatingGroupValues: helper.extractRepeatingGroupValues,
2114
- extractObsValue: helper.extractObsValue
2124
+ getObsFromControlOrEncounter: helper.getObsFromControlOrEncounter
2115
2125
  };
2116
2126
  },
2117
2127
  enumerable: false,