1 |
|
2 | (function() {
|
3 | var Field, HeadSegment, Segment, _,
|
4 | __hasProp = {}.hasOwnProperty,
|
5 | __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
6 |
|
7 | Field = require('./Field');
|
8 |
|
9 | Segment = require('./Segment');
|
10 |
|
11 | _ = require('underscore');
|
12 |
|
13 | HeadSegment = (function(_super) {
|
14 | __extends(HeadSegment, _super);
|
15 |
|
16 | function HeadSegment(segment, control) {
|
17 | this.control = control;
|
18 | HeadSegment.__super__.constructor.call(this, segment, this.control);
|
19 | this.fields.splice(1, 0, new Field([[this.control.fields]], this.control));
|
20 | }
|
21 |
|
22 | HeadSegment.prototype.toString = function() {
|
23 | return _.reduce(this.fields, function(memo, field, index) {
|
24 | if (index === 0) {
|
25 | memo.push('MSH');
|
26 | memo.push("" + this.control.components + this.control.repeat + this.control.escape + this.control.subcomponents);
|
27 | } else if (index > 2) {
|
28 | memo.push(field.toString());
|
29 | }
|
30 | return memo;
|
31 | }, [], this).join(this.control.fields);
|
32 | };
|
33 |
|
34 | return HeadSegment;
|
35 |
|
36 | })(Segment);
|
37 |
|
38 | module.exports = HeadSegment;
|
39 |
|
40 | }).call(this);
|