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

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

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

      //These three elements aren't used right now, but can be refactored to use in standardized way.
      var AgeObservation = component.define("AgeObservation")
        .templateRoot("2.16.840.1.113883.10.20.1.38");

      var ProblemStatus = component.define("ProblemStatus")
        .templateRoot("2.16.840.1.113883.10.20.1.50")
        .fields([
          ["name", "0..1", "h:value/@displayName"],
          ["date_time", "0..1", "h:effectiveTime", shared.EffectiveTime],
        ]);

      var ProblemObservation = component.define("ProblemObservation")
        .fields([
          ["code", "0..1", "../h:value", shared.ConceptDescriptor],
          ["problem_text", "0..1", "../h:text", shared.TextWithReference],
          ["date_time", "0..1", "../h:effectiveTime", shared.EffectiveTime],
        ]).cleanupStep(cleanup.augmentObservation).cleanupStep(cleanup.removeField("problem_text"));

      //TODO:  Cleanup/investigate negation status.
      var ProblemConcernAct = component.define("ProblemConcernAct")
        .fields([
          ["date_time", "0..1", "h:effectiveTime", shared.EffectiveTime],
          ["identifiers", "0..*", "h:entryRelationship/h:observation/h:id", shared.Identifier],
          ["negation_indicator", "0..1", "h:entryRelationship/h:observation", shared.NegationIndicator],
          ["problem", "1:1", "h:entryRelationship/h:observation/h:value", ProblemObservation],
          ["onset_age", "0..1", "h:entryRelationship/h:observation/h:entryRelationship/h:observation/h:templateId[@root='2.16.840.1.1 13883.10.20.1.38']/../h:value/@value"],
          ["onset_age_unit", "0..1", "h:entryRelationship/h:observation/h:entryRelationship/h:observation/h:templateId[@root='2.16.840.1.1 13883.10.20.1.38']/../h:value", shared.AgeDescriptor],
          ["status", "0..1", ProblemStatus.xpath(), ProblemStatus],
          //Patient Status not supported.
          //["patient_status", "0..1", "h:entryRelationship/h:observation/h:entryRelationship/h:observation/h:templateId[@root='2.16.840.1.113883.10.20.22.4.5']/../h:value/@displayName"],
          ["source_list_identifiers", "0..*", "h:id", shared.Identifier],
        ]);

      var NonProblemObservation = ProblemConcernAct
        .define("ProblemObservation");

      var ProblemOrganizer = component.define("ProblemOrganizer")
        .templateRoot(["2.16.840.1.113883.3.88.11.83.7"]);

      var problemsSection = component.define("problemsSection");
      problemsSection.templateRoot(["2.16.840.1.113883.3.88.11.83.103"]); // coded entries required
      problemsSection.fields([
        ["problems", "0..*", ProblemOrganizer.xpath(), ProblemConcernAct],
      ]);

      problemsSection.cleanupStep(cleanup.replaceWithField("problems"));
      return [problemsSection, ProblemConcernAct];
    };

    exports.problemsSection = exportProblemsSection;
    exports.problemsEntry = exportProblemsSection;