# All files / blue-button/lib/parser/ccda/sections payers.js

100% Statements 89/89
100% Branches 1/1
100% Functions 1/1
100% Lines 89/89

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
    901x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    1x
    1x
    1x
     "use strict";

    var shared = require("../shared");
    var component = require("@amida-tech/blue-button-xml").component.withNullFlavor();
    var cleanup = require("../cleanup");
    var bbm = require("@amida-tech/blue-button-meta");

    var exportPayersSection = function (version) {
      var sectionIDs = bbm.CCDA["sections" + version];
      var clinicalStatementsIDs = bbm.CCDA["statements" + version];

      var procedure = component.define('procedure');
      procedure.fields([
        ["code", "1..1", "h:code", shared.ConceptDescriptor]
      ]);

      var authorization = component.define('authorization');
      authorization.fields([
        ["identifiers", "0..*", "h:id", shared.Identifier],
        ["procedure", "1..1", "h:entryRelationship/h:procedure", procedure]
      ]);

      var policy_holder = component.define('policy_holder');
      policy_holder.fields([
        ["performer", "1..1", "h:participantRole", shared.assignedEntity]
      ]);

      var participant = component.define('participant');
      participant.fields([
        ["date_time", "0..1", "h:time", shared.EffectiveTime],
        ["code", "1..1", "h:participantRole/h:code", shared.ConceptDescriptor],
        ["performer", "1..1", "h:participantRole", shared.assignedEntity],
        ["name", "0..*", "h:participantRole/h:playingEntity/h:name", shared.IndividualName]
      ]);

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

      var organization = component.define('organization');
      organization.fields([
        ["address", "0..1", "h:addr", shared.Address],
        ["identifiers", "0..*", "h:id", shared.Identifier],
        ["phone", "0..*", shared.phone.xpath(), shared.phone],
        ["email", "0..*", shared.email.xpath(), shared.email]
      ]);

      var insurance = component.define('insurance');
      insurance.fields([
        ["code", "1..1", "h:assignedEntity/h:code", shared.ConceptDescriptor],
        ["performer", "0..1", "h:assignedEntity", shared.assignedEntity]
      ]);

      var policy = component.define('policy');
      policy.fields([
        ["identifiers", "0..*", "h:id", shared.Identifier],
        ["code", "1..1", "h:code", shared.ConceptDescriptor],
        ["insurance", "1..1", "h:performer", insurance]
      ]);

      var entry = component.define('entry');
      entry.templateRoot([clinicalStatementsIDs.CoverageActivity]);
      entry.fields([
        ["identifiers", "0..*", "h:id", shared.Identifier],
        ["policy", "1..1", "h:entryRelationship/h:act", policy],
        ["guarantor", "1..1", "h:entryRelationship/h:act/h:performer/h:templateId[not (@root='2.16.840.1.113883.10.20.22.4.87')]", guarantor],
        ["participant", "1..1", "h:entryRelationship/h:act/h:participant", participant],
        ["policy_holder", "1..1", "h:entryRelationship/h:act/h:participant[not (@typeCode='COV')]", policy_holder],
        ["authorization", "1..1", "h:entryRelationship/h:act/h:entryRelationship/h:act", authorization]
      ]);

      var payers_section = component.define('payers_section');
      payers_section.templateRoot([sectionIDs.PayersSection, sectionIDs.PayersSectionEntriesOptional]);
      payers_section.fields([
        ["entry", "0..*", entry.xpath(), entry]
      ]);
      payers_section.cleanupStep(cleanup.replaceWithField('entry'));

      return [payers_section, entry];
    };

    exports.payers_section = exportPayersSection;
    exports.payers_entry = exportPayersSection;