# All files / blue-button/lib/parser/common shared.js

97.26% Statements 71/73
83.33% Branches 5/6
100% Functions 2/2
97.26% Lines 71/73

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    741x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    169x
    169x
    169x
    169x
    169x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    2x
    2x
    2x
    2x
    2x

    2x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    132x
    132x
    118x
    118x
    132x
    132x
    132x
    1x
    1x
    1x
    1x
    118x
    118x
    118x
    118x
    118x
    118x
    118x
    118x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
     "use strict";

    var bbxml = require("@amida-tech/blue-button-xml");

    var component = bbxml.component;
    var processor = bbxml.processor;

    var cleanup = require('./cleanup');

    var shared = module.exports = {};

    var Identifier = shared.Identifier = component.define("Identifier")
      .fields([
        ["identifier", "1..1", "@root"],
        ["extension", "0..1", "@extension"],
      ]);

    var simpleCode = shared.SimpleCode = function (oid) {
      var r = component.define("SimpleCode." + oid);
      r.fields([]);
      r.cleanupStep(cleanup.augmentSimpleCode(oid));
      return r;
    };

    var email = shared.email = component.define("email");
    email.fields([
      ["address", "1..1", "@value"],
      ["type", "0..1", "@use", simpleCode("2.16.840.1.113883.5.1119")]
    ]);
    email.cleanupStep(function () {
      if (this.js && this.js.address) {
        this.js.address = this.js.address.substring(7);

        //NOTE: type for email should be empty (per PragueExpat)
        if (this.js.type) {
          this.js.type = '';
        }
      }
    });
    email.setXPath("h:telecom[starts-with(@value, 'mailto:')]");

    var phone = shared.phone = component.define("phone");
    phone.fields([
      ["number", "1..1", "@value"],
      ["type", "0..1", "@use", simpleCode("2.16.840.1.113883.5.1119")]
    ]);
    phone.cleanupStep(function () {
      if (this.js && this.js.number) {
        if (this.js.number.substring(0, 4) === "tel:") {
          this.js.number = this.js.number.substring(4);
        }

        this.js.number = this.js.number.trim();
      }
    });
    phone.setXPath("h:telecom[@value and @value!='' and not(starts-with(@value, 'mailto:'))]");

    var simplifiedCodeOID = shared.simplifiedCodeOID = function (oid) {
      var r = component.define("SC " + oid);
      r.fields([
        ["name", "0..1", "@displayName"],
        ["code", "1..1", "@code"],
      ]);
      r.cleanupStep(cleanup.augmentSimplifiedCodeOID(oid));
      return r;
    };

    shared.metaData = component.define("metaData")
      .fields([
        ["identifiers", "0..*", "h:id", Identifier],
        ["confidentiality", '0..1', "h:confidentialityCode", simplifiedCodeOID("2.16.840.1.113883.5.25")],
        ["set_id", "0..1", "h:setId", Identifier]
      ]);