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

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

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

      var referenceRange = component.define('referenceRange')
        .fields([
          ["low", "0..1", "h:value/h:low/@value"],
          ["high", "0..1", "h:value/h:high/@value"],
          ["unit", "0..1", "h:value/h:low/@unit"],
          ["range", "0..1", "h:text/text()"]
        ]);

      var ResultObservation = component.define("ResultObservation")
        .templateRoot("2.16.840.1.113883.3.88.11.83.15.1")
        .fields([
          ["identifiers", "0..*", "h:id", shared.Identifier],
          ["result", "1..1", "h:code", shared.ConceptDescriptor],
          ["date_time", "1..1", "h:effectiveTime", shared.EffectiveTime],
          //["physicalQuantity.text", "1..1", "h:value[@xsi:type='ST']", shared.PhysicalQuantity],
          ["status", "1..1", "h:statusCode/@code"],
          ["text", "0..1", "h:value[@xsi:type='ST']/text()"],
          ["reference_range", "0..1", "h:referenceRange/h:observationRange", referenceRange],
          //["codedValue", "0..1", "h:value[@xsi:type='CD']", shared.ConceptDescriptor],
          //["freeTextValue", "0..1", "h:text", shared.TextWithReference],
          ["interpretations", "0..*", "h:interpretationCode[@codeSystem='2.16.840.1.113883.5.83']", shared.SimplifiedCode]
        ]);
      //ResultObservation.cleanupStep(cleanup.extractAllFields(['resultName']));

      // TODO: Accomodating both PQ and CD values needed
      //ResultObservation.cleanupStep(cleanup.extractAllFields(['physicalQuantity']));
      //ResultObservation.cleanupStep(cleanup.extractAllFields(['codedValue']));

      var ResultsOrganizer = component.define("ResultsOrganizer")
        .templateRoot("2.16.840.1.113883.10.20.1.32")
        .fields([
          ["identifiers", "0..*", "h:id", shared.Identifier],
          ["result_set", "0..1", "h:code", shared.ConceptDescriptor],
          ["results", "1..*", ResultObservation.xpath(), ResultObservation]
        ]);

      var resultsSection = component.define("resultsSection");
      resultsSection.templateRoot(['2.16.840.1.113883.3.88.11.83.122']); // .1 for "entries required"
      resultsSection.fields([
        ["panels", "0..*", ResultsOrganizer.xpath(), ResultsOrganizer]
      ]);
      resultsSection.cleanupStep(cleanup.replaceWithField('panels'));

      return [resultsSection, ResultsOrganizer];
    };

    exports.resultsSection = exportResultsSection;
    exports.resultsEntry = exportResultsSection;