openchs-models 1.31.30 → 1.31.31

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.
package/dist/Concept.js CHANGED
@@ -128,8 +128,9 @@ class Concept extends _BaseEntity.default {
128
128
  concept.unit = conceptResource.unit;
129
129
  concept.voided = conceptResource.voided || false; //This change should be independently deployable irrespective of server
130
130
  //remove orphan keyValues (because KeyValue doesn't have primary key
131
+ // entityService &&
132
+ // entityService.deleteObjects(conceptResource["uuid"], Concept.schema.name, "keyValues");
131
133
 
132
- entityService && entityService.deleteObjects(conceptResource["uuid"], Concept.schema.name, "keyValues");
133
134
  concept.keyValues = _lodash.default.map(conceptResource.keyValues, _KeyValue.default.fromResource);
134
135
  return concept;
135
136
  }
@@ -155,20 +156,18 @@ class Concept extends _BaseEntity.default {
155
156
  concept.name = name;
156
157
  concept.datatype = dataType;
157
158
  concept.uuid = uuid;
158
- concept.keyValues = keyValues;
159
+ concept.keyValues = _lodash.default.map(keyValues, _KeyValue.default.fromResource);
159
160
  return concept;
160
161
  }
162
+ /**
163
+ * This should never be cloned and used for reference as this is metadata which is not to be modified during transactional data operations
164
+ *
165
+ * @returns {Concept}
166
+ */
167
+
161
168
 
162
169
  cloneForReference() {
163
- const concept = Concept.create(this.name, this.datatype, this.keyValues);
164
- concept.uuid = this.uuid;
165
- concept.unit = this.unit;
166
- concept.lowAbsolute = this.lowAbsolute;
167
- concept.lowNormal = this.lowNormal;
168
- concept.hiNormal = this.hiNormal;
169
- concept.hiAbsolute = this.hiAbsolute;
170
- concept.answers = this.answers || [];
171
- return concept;
170
+ return this;
172
171
  }
173
172
 
174
173
  _valuePresent(value) {
@@ -164,7 +164,7 @@ class Observation extends _PersistedObject.default {
164
164
  }
165
165
 
166
166
  cloneForEdit() {
167
- return clone(this.concept.cloneForReference(), this.getValueWrapper().cloneForEdit());
167
+ return clone(this.concept, this.getValueWrapper().cloneForEdit());
168
168
  }
169
169
 
170
170
  shallowClone() {
@@ -144,8 +144,8 @@ class FormElement extends _BaseEntity.default {
144
144
  formElement.groupUuid = _ResourceUtil.default.getUUIDFor(resource, "groupQuestionUUID");
145
145
  formElement.documentation = entityService.findByKey("uuid", _ResourceUtil.default.getUUIDFor(resource, "documentationUUID"), _Documentation.default.schema.name);
146
146
  formElement.concept = concept; //remove orphan keyValues (because KeyValue doesn't have primary key
147
+ // entityService.deleteObjects(resource["uuid"], FormElement.schema.name, "keyValues");
147
148
 
148
- entityService.deleteObjects(resource["uuid"], FormElement.schema.name, "keyValues");
149
149
  formElement.keyValues = _lodash.default.map(resource.keyValues, _KeyValue.default.fromResource);
150
150
  formElement.validFormat = _Format.default.fromResource(resource["validFormat"]);
151
151
  return formElement;
@@ -394,7 +394,7 @@ class FormElement extends _BaseEntity.default {
394
394
  formElement.name = this.name;
395
395
  formElement.displayOrder = this.displayOrder;
396
396
  formElement.mandatory = this.mandatory;
397
- formElement.keyValues = this.keyValues;
397
+ formElement.keyValues = _lodash.default.map(this.keyValues, _KeyValue.default.fromResource);
398
398
  formElement.concept = this.concept;
399
399
  formElement.type = this.type;
400
400
  formElement.formElementGroup = this.formElementGroup;
@@ -17,7 +17,7 @@ class KeyValue extends _PersistedObject.default {
17
17
  static fromResource(resource) {
18
18
  const keyValue = new KeyValue();
19
19
  keyValue.key = resource.key;
20
- keyValue.value = JSON.stringify(resource.value);
20
+ keyValue.value = typeof resource.value !== "string" ? JSON.stringify(resource.value) : resource.value;
21
21
  return keyValue;
22
22
  }
23
23
 
@@ -55,6 +55,14 @@ class RealmProxy {
55
55
  close() {
56
56
  return this.realmDb.close();
57
57
  }
58
+ /**
59
+ *
60
+ * @param schemaName
61
+ * @param properties
62
+ * @param updateMode , all === true, modified , never === false
63
+ * @returns {*}
64
+ */
65
+
58
66
 
59
67
  create(schemaName, properties, updateMode = "never") {
60
68
  const underlyingObject = _lodash.default.isNil(properties.that) ? properties : properties.that;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "openchs-models",
3
3
  "description": "OpenCHS data model to be used by front end clients",
4
- "version": "1.31.30",
4
+ "version": "1.31.31",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",