Skip to content

Commit

Permalink
Merge branch 'master' into dmitry-1.1.0-prerelease
Browse files Browse the repository at this point in the history
  • Loading branch information
kachok committed Jul 14, 2014
2 parents ca04d73 + 0ee1b60 commit 3daa13e
Show file tree
Hide file tree
Showing 6 changed files with 1,090 additions and 26 deletions.
37 changes: 25 additions & 12 deletions lib/parser/ccda/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,31 @@ augmentEffectiveTime.replaceSchema = function(current) {
};

var augmentIndividualName = Cleanup.augmentIndividualName = function() {
if (this.js.middle.length > 0) {
this.js.first = this.js.middle[0];
if (this.js.middle.length > 1) {
this.js.middle.splice(0, 1);
} else {
delete this.js.middle;
}
}
if (!this.js.first && !this.js.last) {
this.js = this.js.freetext_name; // Conditional field does not work well with anything needs to change
} else {
delete this.js.freetext_name;
if (this.js) {
if (this.js.middle && this.js.middle.length > 0) {
this.js.first = this.js.middle[0];
if (this.js.middle.length > 1) {
this.js.middle.splice(0, 1);
} else {
delete this.js.middle;
}
}
if (!this.js.first && !this.js.last && this.js.freetext_name) {
var names = this.js.freetext_name.split(' ').filter(function(piece) {
return piece.length > 0;
});
var n = names.length;
if (n > 0) {
this.js.last = names[n-1];
if (n > 1) {
this.js.first = names[0];
}
if (n > 2) {
this.js.middle = names.slice(1, n-1);
}
}
}
delete this.js.freetext_name;
}
};
augmentIndividualName.updateSchema = function(current) {
Expand Down
Loading

0 comments on commit 3daa13e

Please sign in to comment.