@openmrs/ngx-formentry 3.1.2-pre.189 → 3.1.2-pre.203

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.
@@ -2114,6 +2114,16 @@
2114
2114
  var obsValue = (_a = findObs(rawEncounter === null || rawEncounter === void 0 ? void 0 : rawEncounter.obs, uuid)) === null || _a === void 0 ? void 0 : _a.value;
2115
2115
  return !!targetControl ? targetControl : typeof obsValue === 'object' ? obsValue.uuid : !!obsValue ? obsValue : null;
2116
2116
  };
2117
+ JsExpressionHelper.prototype.doesNotMatchExpression = function (regexString, val) {
2118
+ if (!val || ['undefined', 'null', ''].includes(val.toString())) {
2119
+ return true;
2120
+ }
2121
+ var pattern = new RegExp(regexString);
2122
+ if (!pattern.test(val)) {
2123
+ return true;
2124
+ }
2125
+ return false;
2126
+ };
2117
2127
  Object.defineProperty(JsExpressionHelper.prototype, "helperFunctions", {
2118
2128
  get: function () {
2119
2129
  var helper = this;
@@ -2127,7 +2137,8 @@
2127
2137
  isEmpty: helper.isEmpty,
2128
2138
  arrayContains: helper.arrayContains,
2129
2139
  extractRepeatingGroupValues: helper.extractRepeatingGroupValues,
2130
- getObsFromControlOrEncounter: helper.getObsFromControlOrEncounter
2140
+ getObsFromControlOrEncounter: helper.getObsFromControlOrEncounter,
2141
+ doesNotMatchExpression: helper.doesNotMatchExpression
2131
2142
  };
2132
2143
  },
2133
2144
  enumerable: false,
@@ -16218,6 +16229,83 @@
16218
16229
  }]
16219
16230
  }] });
16220
16231
 
16232
+ var PatientIdentifierAdapter = /** @class */ (function () {
16233
+ function PatientIdentifierAdapter() {
16234
+ }
16235
+ PatientIdentifierAdapter.prototype.generateFormPayload = function (form, locationUuid) {
16236
+ return this.generateNodePayload(form.rootNode, locationUuid);
16237
+ };
16238
+ PatientIdentifierAdapter.prototype.generateNodePayload = function (rootNode, locationUuid) {
16239
+ var nodes = this.getPatientIdentifierNodes(rootNode);
16240
+ var payload = [];
16241
+ nodes.forEach(function (node) {
16242
+ if (node.control.value !== null &&
16243
+ node.control.value !== undefined &&
16244
+ node.control.value !== '') {
16245
+ payload.push({
16246
+ identifierType: node.question.extras.questionOptions.identifierType,
16247
+ identifier: node.control.value,
16248
+ location: locationUuid,
16249
+ preferred: false
16250
+ });
16251
+ }
16252
+ });
16253
+ return payload;
16254
+ };
16255
+ PatientIdentifierAdapter.prototype.populateForm = function (form, payload) {
16256
+ this.populateNode(form.rootNode, payload);
16257
+ };
16258
+ PatientIdentifierAdapter.prototype.populateNode = function (rootNode, payload) {
16259
+ if (!Array.isArray(payload)) {
16260
+ throw new Error('Expected an array of patient identfiers');
16261
+ }
16262
+ var nodes = this.getPatientIdentifierNodes(rootNode);
16263
+ nodes.forEach(function (node) {
16264
+ payload.forEach(function (element) {
16265
+ if (element.identifierType.uuid ===
16266
+ node.question.extras.questionOptions.identifierType) {
16267
+ if (element.identifier) {
16268
+ node.control.setValue(element.identifier);
16269
+ node.initialValue = element.identifier;
16270
+ }
16271
+ }
16272
+ });
16273
+ });
16274
+ };
16275
+ PatientIdentifierAdapter.prototype.getPatientIdentifierNodes = function (rootNode) {
16276
+ var results = [];
16277
+ this.getPatientIdentifierTypeNodes(rootNode, results);
16278
+ return results;
16279
+ };
16280
+ PatientIdentifierAdapter.prototype.getPatientIdentifierTypeNodes = function (rootNode, array) {
16281
+ var _this = this;
16282
+ if (rootNode.question.extras &&
16283
+ rootNode.question.extras.type === 'patientIdentifier') {
16284
+ array.push(rootNode);
16285
+ }
16286
+ if (rootNode instanceof GroupNode) {
16287
+ var node = rootNode;
16288
+ for (var o in node.children) {
16289
+ if (node.children[o] instanceof NodeBase) {
16290
+ this.getPatientIdentifierTypeNodes(node.children[o], array);
16291
+ }
16292
+ }
16293
+ }
16294
+ if (rootNode instanceof ArrayNode) {
16295
+ var node = rootNode;
16296
+ node.children.forEach(function (child) {
16297
+ _this.getPatientIdentifierTypeNodes(child, array);
16298
+ });
16299
+ }
16300
+ };
16301
+ return PatientIdentifierAdapter;
16302
+ }());
16303
+ PatientIdentifierAdapter.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: PatientIdentifierAdapter, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
16304
+ PatientIdentifierAdapter.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: PatientIdentifierAdapter });
16305
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: PatientIdentifierAdapter, decorators: [{
16306
+ type: i0.Injectable
16307
+ }] });
16308
+
16221
16309
  var FormEntryModule = /** @class */ (function () {
16222
16310
  function FormEntryModule() {
16223
16311
  }
@@ -16272,7 +16360,8 @@
16272
16360
  PersonAttribuAdapter,
16273
16361
  OrderValueAdapter,
16274
16362
  DiagnosisValueAdapter,
16275
- DebugModeService
16363
+ DebugModeService,
16364
+ PatientIdentifierAdapter
16276
16365
  ], imports: [[
16277
16366
  i1.CommonModule,
16278
16367
  i21.ReactiveFormsModule,
@@ -16349,7 +16438,8 @@
16349
16438
  PersonAttribuAdapter,
16350
16439
  OrderValueAdapter,
16351
16440
  DiagnosisValueAdapter,
16352
- DebugModeService
16441
+ DebugModeService,
16442
+ PatientIdentifierAdapter
16353
16443
  ],
16354
16444
  exports: [
16355
16445
  FormRendererComponent,
@@ -16430,6 +16520,7 @@
16430
16520
  exports.Option = Option;
16431
16521
  exports.OrderValueAdapter = OrderValueAdapter;
16432
16522
  exports.Pair = Pair;
16523
+ exports.PatientIdentifierAdapter = PatientIdentifierAdapter;
16433
16524
  exports.PersonAttribuAdapter = PersonAttribuAdapter;
16434
16525
  exports.QuestionBase = QuestionBase;
16435
16526
  exports.QuestionFactory = QuestionFactory;