Skip to content

Commit

Permalink
formatting:
Browse files Browse the repository at this point in the history
  • Loading branch information
chaldon committed Oct 6, 2015
1 parent 260b8e2 commit d502355
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 82 deletions.
64 changes: 32 additions & 32 deletions app.js
Expand Up @@ -72,43 +72,43 @@ istream
}, function (res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
//console.log('BODY2: ' + chunk);
result2 = result2 + chunk;
})
.on('end', function() {
var resource = JSON.parse(result2);
var comparator = function (l, r, propn) {
if (_.isNumber(l)) {
return;
}
if (_.isString(l)) {
return;
}
if (_.isBoolean(l)) {
return;
}
if (_.isArray(l) && _.isArray(r)) {
if (l.length !== r.length) {
console.log('!-------- Array length differ %s', propn);
//console.log('BODY2: ' + chunk);
result2 = result2 + chunk;
})
.on('end', function () {
var resource = JSON.parse(result2);
var comparator = function (l, r, propn) {
if (_.isNumber(l)) {
return;
}
for (var i = 0; i < l.lenght && i < r.length; i++) {
comparator(l[i], r[i], propn);
if (_.isString(l)) {
return;
}
if (_.isBoolean(l)) {
return;
}
if (_.isArray(l) && _.isArray(r)) {
if (l.length !== r.length) {
console.log('!-------- Array length differ %s', propn);
}
for (var i = 0; i < l.lenght && i < r.length; i++) {
comparator(l[i], r[i], propn);
}
}
}

for (var prop in l) {
if (l.hasOwnProperty(prop)) {
if (!r.hasOwnProperty(prop)) {
console.log('!-------- Missed prop ' + prop);
} else {
comparator(l[prop], r[prop], prop);
for (var prop in l) {
if (l.hasOwnProperty(prop)) {
if (!r.hasOwnProperty(prop)) {
console.log('!-------- Missed prop ' + prop);
} else {
comparator(l[prop], r[prop], prop);
}
}
}
}
};
console.log('compare:\n %j \n %j', element[0].resource, resource);
comparator(element[0].resource, resource);
});
};
console.log('compare:\n %j \n %j', element[0].resource, resource);
comparator(element[0].resource, resource);
});
});
req.end();
});
Expand Down
105 changes: 55 additions & 50 deletions lib/parser.js
Expand Up @@ -231,10 +231,10 @@ var makeCode = function (node, dropDisplayeElement) {
};

var makeQuantity = function (node) {
var retval = makeCode(node, true);
if(retval.unit === 'a') {
var retval = makeCode(node, true);
if (retval.unit === 'a') {
retval.unit = 'years';
}
}
return retval;
};

Expand Down Expand Up @@ -917,19 +917,19 @@ var PlayingEntity = function (allergyIntolerance) {
return;
}
ensureProperty.call(allergyIntolerance, 'substance');
if(!allergyIntolerance.substance.coding) {
if (!allergyIntolerance.substance.coding) {
allergyIntolerance.substance.coding = [];
}
}
allergyIntolerance.substance.coding.push(makeCode(node));
};
this.translation = function (node) {
if (node.attributes.nullFlavor) {
return;
}
ensureProperty.call(allergyIntolerance, 'substance');
if(!allergyIntolerance.substance.coding) {
if (!allergyIntolerance.substance.coding) {
allergyIntolerance.substance.coding = [];
}
}
allergyIntolerance.substance.coding.push(makeCode(node));
};
this.name$ = function (text) {
Expand Down Expand Up @@ -1114,36 +1114,40 @@ ReferenceRange.prototype = proto;

var genericConditionHandler = function (condition, templateId) {
var retval = {};
switch(templateId) {
case '2.16.840.1.113883.10.20.22.4.4':
retval = {
code: function(node) {
condition.category = {'coding':makeCode(node)};
},
effectiveTime: function(node) {
if (node.attributes.value) {
condition.onsetDateTime = dateFix(node.attributes.value);
} else {
condition.onsetPeriod = {};
proto.control.push(new Triplet(node, new EffectiveTime(null, condition.onsetPeriod), templateId));
}
},
value: function(node) {
condition.code = {'coding':makeCode(node)};
switch (templateId) {
case '2.16.840.1.113883.10.20.22.4.4':
retval = {
code: function (node) {
condition.category = {
'coding': makeCode(node)
};
},
effectiveTime: function (node) {
if (node.attributes.value) {
condition.onsetDateTime = dateFix(node.attributes.value);
} else {
condition.onsetPeriod = {};
proto.control.push(new Triplet(node, new EffectiveTime(null, condition.onsetPeriod), templateId));
}
};
break;
case '2.16.840.1.113883.10.20.22.4.6':
},
value: function (node) {
condition.code = {
'coding': makeCode(node)
};
}
};
break;
case '2.16.840.1.113883.10.20.22.4.6':
retval = {
value: function(node) {
condition.clinicalStatus = (node.attributes.displayName)?node.attributes.displayName: node.attributes.code;
}
value: function (node) {
condition.clinicalStatus = (node.attributes.displayName) ? node.attributes.displayName : node.attributes.code;
}
};
break;
}
retval.entryRelationship = function (node) {
proto.control.push(new Triplet(node, new EntryRelationship(null, condition), templateId));
};
retval.entryRelationship = function(node) {
proto.control.push(new Triplet(node, new EntryRelationship(null, condition), templateId));
};
return retval;
};

Expand Down Expand Up @@ -1567,7 +1571,7 @@ var Observation = function (classCode, resource, param1, bundle, composition) {
if (isInContextOf('2.16.840.1.113883.10.20.22.4.4')) { //Problem observation
condition = resource;
if (condition) {
this._self = genericConditionHandler(condition,'2.16.840.1.113883.10.20.22.4.6');
this._self = genericConditionHandler(condition, '2.16.840.1.113883.10.20.22.4.6');
this._self.prototype = proto;
}
}
Expand Down Expand Up @@ -1966,17 +1970,18 @@ var SubstanceAdministration = function () {
var substanceAdministration;

function getDosage() {
var dosage;
if( _.isArray(this.dosage)){
dosage = _.last(this.dosage);
if (!dosage) {
dosage = {
/*'schedule': {
'repeat': {}
}*/
};
this.dosage.push(dosage);
}} else {
var dosage;
if (_.isArray(this.dosage)) {
dosage = _.last(this.dosage);
if (!dosage) {
dosage = {
/*'schedule': {
'repeat': {}
}*/
};
this.dosage.push(dosage);
}
} else {
dosage = this.dosage;
}
return dosage;
Expand Down Expand Up @@ -2332,9 +2337,9 @@ Act.prototype = proto;
var RelatedSubject = function (familyMemberHistory) {

this.code = function (node) {
familyMemberHistory.relationship = [
{'coding': [makeCode(node)]}
];
familyMemberHistory.relationship = [{
'coding': [makeCode(node)]
}];
};

this.subject = function (node) {
Expand Down Expand Up @@ -2416,7 +2421,7 @@ var Encounter = function (resource) {
encounter.type = [{
'coding': [makeCode(node)]
}];
proto.control.push(new Triplet(node, new DeepCodeExtractor(encounter.type[encounter.type.length-1]), templateId));
proto.control.push(new Triplet(node, new DeepCodeExtractor(encounter.type[encounter.type.length - 1]), templateId));
},
effectiveTime: function (node) {
if (node.attributes.value) {
Expand Down Expand Up @@ -2754,7 +2759,7 @@ var SomeWithName = function (some) {

proto.control.push(new Triplet(node, new Name(name)));
};

/*this.name = function (node) {
if (!_some.name) {
_some.name = {};
Expand All @@ -2770,7 +2775,7 @@ SomeWithName.prototype = proto;

var SomeWithSingleName = function (some) {
var _some = some;

this.name = function (node) {
if (!_some.name) {
_some.name = {};
Expand Down

0 comments on commit d502355

Please sign in to comment.