# All files / blue-button/lib/parser/cda/sections encounters.js

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

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
    501x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    11x
    1x
    1x
     "use strict";

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

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

      var finding = component.define("finding");
      finding.templateRoot("2.16.840.1.113883.10.20.1.28");
      finding.fields([
        ["identifiers", "1..*", "h:id", shared.Identifier],
        ["value", "1..1", "h:value", shared.ConceptDescriptor],
        ["date_time", "1..1", "h:effectiveTime", shared.EffectiveTime]
      ]);

      // Iff needed add this later by refactoring Problem Observation from Problems.  They should share.
      //var diagnosis = component.define("diagnosis");
      //finding.templateRoot(['2.16.840.1.113883.10.20.22.4.80']);
      //finding.fields([
      //  ["code", "1..1", "h:code", shared.ConceptDescriptor]
      //]);
      //finding.cleanupStep(cleanup.extractAllFields(['code']));

      var activity = component.define('activity');
      activity.templateRoot(["2.16.840.1.113883.10.20.1.21"]);
      activity.fields([
        ["encounter", "1..1", "h:code", shared.ConceptDescriptor],
        ["identifiers", "0..*", "h:id", shared.Identifier],
        ["date_time", "1..1", "h:effectiveTime", shared.EffectiveTime],
        ["performers", "0..*", "h:performer/h:assignedEntity", shared.assignedEntity],
        ["locations", "0..*", "h:participant/h:participantRole", shared.serviceDeliveryLocation],
        ["findings", "0..*", finding.xpath(), finding]
        //["diagnoses", "0..*", diagnosis.xpath(), diagnosis]
      ]);

      var encountersSection = component.define('encountersSection');
      encountersSection.templateRoot(["2.16.840.1.113883.10.20.1.3"]);
      encountersSection.fields([
        ["activity", "0..*", activity.xpath(), activity]
      ]);
      encountersSection.cleanupStep(cleanup.replaceWithField(["activity"]));
      return [encountersSection, activity];
    };
    exports.encountersSection = exportEncountersSection;
    exports.encountersEntry = exportEncountersSection;