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

100% Statements 39/39
100% Branches 3/3
100% Functions 1/1
100% Lines 39/39

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
    401x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    10x
    9x
    9x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    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 exportFunctionalStatusSection = function (version) {
      var sectionIDs = bbm.CCDA["sections" + version];
      var clinicalStatementsIDs = bbm.CCDA["statements" + version];

      var status = component.define('functionalStatusEntry');
      status.templateRoot([clinicalStatementsIDs.FunctionalStatusProblemObservation, clinicalStatementsIDs.CognitiveStatusProblemObservation]);
      status.fields([
          ["identifiers", "0..*", "h:id", shared.Identifier],
          ["type", "1..1", "h:code", shared.ConceptDescriptor],
          ["date_time", "0..1", "h:effectiveTime", shared.EffectiveTime],
          ["code", "0..1", "h:value", shared.ConceptDescriptor],
          ["status", "0..1", "./@negationInd"]
        ])
        // cleanup to map present @negationInd to {"status": "negative"},
        // and absent @negationInd to {"status": "completed"}
        .cleanupStep(cleanup.replaceWithObject("status", "negative"))
        .cleanupStep(function () {
          if (this.js && !this.js["status"]) {
            this.js["status"] = "completed";
          }
        });

      var functionalStatusSection = component.define('functionalStatusSection');
      functionalStatusSection.templateRoot([sectionIDs.FunctionalStatusSection]);
      functionalStatusSection.fields([
        ["statuses", "0..*", status.xpath(), status]
      ]);
      functionalStatusSection.cleanupStep(cleanup.replaceWithField(["statuses"]));
      return [functionalStatusSection, status];
    };
    exports.functionalStatusSection = exportFunctionalStatusSection;
    exports.functionStatusEntry = exportFunctionalStatusSection;