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

95.65% Statements 132/138
50% Branches 1/2
100% Functions 0/0
95.65% Lines 132/138

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
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    1391x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    20x
    20x

    20x
    20x
    20x
    20x
    20x
    20x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
     "use strict";

    var component = require("@amida-tech/blue-button-xml").component;
    var processor = require("@amida-tech/blue-button-xml").processor;
    var cleanup = require("./cleanup");
    var common = require("@amida-tech/blue-button-xml").common;

    var commonShared = require('../common/shared');

    var shared = module.exports = Object.create(commonShared);

    var TextWithReference = shared.TextWithReference = component.define("TextWithReference");
    TextWithReference.fields([
        ["text", "0..*", "text()"],
        ["reference", "0..1", "./h:reference/@value"],
      ])
      .cleanupStep(cleanup.resolveReference);

    var NegationIndicator = shared.NegationIndicator = component.define("NegationIndicator");
    NegationIndicator.fields([
        ["negation_indicator", "0..1", "@negationInd", processor.asBoolean]
      ]).cleanupStep(function () {
        //Flag missing negations as false.
        if (this.js) {
          if (!common.exists(this.js)) {
            this.js.negation_indicator = false;
          }
          if (this.js.negation_indicator === 'true') {
            this.js.negation_indicator = true;
          }
        } else {
          this.js = {
            negation_indicator: false
          };
        }
      })
      .cleanupStep(cleanup.replaceWithField('negation_indicator'));

    var conceptWoutTranslation = component.define("conceptWoutTranslation");
    conceptWoutTranslation.fields([
      ["name", "0..1", "@displayName"],
      ["code", "1..1", "@code"],
      ["system", "1..1", "@codeSystem"],
      ["code_system_name", "0..1", "@codeSystemName"],
      ["nullFlavor", "0..1", "@nullFlavor"],
      ["original_text", "0..1", "h:originalText", TextWithReference]
    ]);
    conceptWoutTranslation.cleanupStep(cleanup.augmentConcept);
    conceptWoutTranslation.cleanupStep(cleanup.removeField('system'));

    var ConceptDescriptor = shared.ConceptDescriptor = conceptWoutTranslation.define("ConceptDescriptor");
    ConceptDescriptor.fields([
      ["translations", "0..*", "h:translation", conceptWoutTranslation],
    ]);

    var AgeDescriptor = shared.AgeDescriptor = component.define("AgeDescriptor");
    AgeDescriptor.fields([
        ["units", "0..1", "@unit"],
      ])
      .cleanupStep(cleanup.augmentAge);

    var SimplifiedCode = shared.SimplifiedCode = ConceptDescriptor.define("SimpifiedCode")
      .cleanupStep(cleanup.augmentSimplifiedCode);

    var PhysicalQuantity = shared.PhysicalQuantity = component.define("PhysicalQuantity")
      .fields([
        ["value", "1..1", "@value", processor.asFloat],
        ["unit", "0..1", "@unit"]
      ]);

    var EventOffset = shared.EventOffset = component.define("EventOffset")
      .fields([
        ["low", "0..1", "h:/low", PhysicalQuantity],
        ["high", "0..1", "h:/high", PhysicalQuantity],
        ["center", "0..1", "h:/center", PhysicalQuantity],
        ["width", "0..1", "h:/width", PhysicalQuantity],
      ]);

    var EffectiveTime = shared.EffectiveTime = component.define("EffectiveTime")
      .fields([
        ["point", "0..1", "@value", processor.asTimestamp],
        ["point_resolution", "0..1", "@value", processor.asTimestampResolution],
        ["low", "0..1", "h:low/@value", processor.asTimestamp],
        ["low_resolution", "0..1", "h:low/@value", processor.asTimestampResolution],
        ["high", "0..1", "h:high/@value", processor.asTimestamp],
        ["high_resolution", "0..1", "h:high/@value", processor.asTimestampResolution],
        ["center", "0..1", "h:center/@value", processor.asTimestamp],
        ["center_resolution", "0..1", "h:center/@value", processor.asTimestampResolution]
      ])
      .cleanupStep(cleanup.augmentEffectiveTime);

    var IndividualName = shared.IndividualName = component.define('IndividualName')
      .fields([
        ["prefix", "0..1", "h:prefix/text()"],
        ["middle", "0..*", "h:given/text()"],
        ["last", "0..1", "h:family/text()"],
        ["suffix", "0..1", "h:suffix/text()"],
        ["freetext_name", "0..1", "../h:name/text()", processor.asString]
      ]).cleanupStep(cleanup.augmentIndividualName).cleanupStep(cleanup.clearNulls);

    var Address = shared.Address = component.define("Address")
      .fields([
        ["street_lines", "1..4", "h:streetAddressLine/text()"],
        ["city", "1..1", "h:city/text()", processor.asString],
        ["state", "0..1", "h:state/text()"],
        ["zip", "0..1", "h:postalCode/text()"],
        ["country", "0..1", "h:country/text()"],
        ["use", "0..1", "@use", shared.SimpleCode("2.16.840.1.113883.5.1119")]
      ]);

    var Organization = shared.Organization = component.define("Organization")
      .fields([
        ["identifiers", "0..*", "h:id", shared.Identifier],
        ["name", "0..*", "h:name/text()"],
        ["address", "0..*", "h:addr", Address],
        ["email", "0..*", shared.email.xpath(), shared.email],
        ["phone", "0..*", shared.phone.xpath(), shared.phone]
      ]);

    var assignedEntity = shared.assignedEntity = component.define("assignedEntity")
      .fields([
        ["identifiers", "0..*", "h:id", shared.Identifier],
        ["name", "0..*", "h:assignedPerson/h:name", IndividualName],
        ["address", "0..*", "h:addr", Address],
        ["email", "0..*", shared.email.xpath(), shared.email],
        ["phone", "0..*", shared.phone.xpath(), shared.phone],
        ["organization", "0..*", "h:representedOrganization", Organization],
        ["code", "0..*", "h:code", ConceptDescriptor],
      ]);

    shared.serviceDeliveryLocation = component.define('serviceDeliveryLocation')
      .fields([
        ["name", "0:1", "h:playingEntity/h:name/text()"],
        ["location_type", "1..1", "h:code", ConceptDescriptor],
        ["address", "0..*", "h:addr", Address],
        ["email", "0..*", shared.email.xpath(), shared.email],
        ["phone", "0..*", shared.phone.xpath(), shared.phone]
      ]);