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

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

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
    511x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    30x
    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 exportEncountersSection = function (version) {
      var sectionIDs = bbm.CCDA["sections" + version];
      var clinicalStatementsIDs = bbm.CCDA["statements" + version];

      var finding = component.define("finding");
      finding.templateRoot([clinicalStatementsIDs.Indication]);
      finding.fields([
        ["identifiers", "1..*", "h:id", shared.Identifier],
        ["value", "1..1", "h:value", shared.ConceptDescriptor],
        ["date_time", "1..1", "h:effectiveTime", shared.EffectiveTime]
      ]);
      //finding.cleanupStep(cleanup.extractAllFields(['value']));

      // 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([clinicalStatementsIDs.EncounterActivities, clinicalStatementsIDs.EncounterActivity]);
      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([sectionIDs.EncountersSection, sectionIDs.EncountersSectionEntriesOptional]);
      encountersSection.fields([
        ["activity", "0..*", activity.xpath(), activity]
      ]);
      encountersSection.cleanupStep(cleanup.replaceWithField(["activity"]));
      return [encountersSection, activity];
    };
    exports.encountersSection = exportEncountersSection;
    exports.encountersEntry = exportEncountersSection;