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

100% Statements 88/88
100% Branches 4/4
100% Functions 1/1
100% Lines 88/88

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
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    891x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    34x
    18x
    1x
    1x
    1x
    1x
    18x
    18x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    33x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    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 _ = require("lodash");

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

      var VitalSignObservation = component.define("VitalSignObservation")
        .templateRoot(clinicalStatementsIDs.VitalSignObservation)
        .fields([
          ["identifiers", "0..*", "h:id", shared.Identifier], //this one is stripped out by "paredown" cleanup step in component.js
          ["vital", "1..1", "h:code", shared.ConceptDescriptor],
          //["identifiers","0..*", "h:id", shared.Identifier], //dup with first line
          ["status", "1..1", "h:statusCode/@code"],
          ["date_time", "1..1", "h:effectiveTime", shared.EffectiveTime],
          ["physicalQuantity", "1..1", "h:value[@xsi:type='PQ']", shared.PhysicalQuantity],
          // ["freeTextValue", "0..1", "h:text", shared.TextWithReference],
          ["interpretations", "0..*", "h:interpretationCode[@codeSystem='2.16.840.1.113883.5.83']", shared.SimplifiedCode],
          ["text", "0..1", "h:value[@xsi:type='ED']", shared.TextWithReference],
          ["nullVitalReplacementText", "0..1", "h:text", shared.TextWithReference]
        ]);
      //VitalSignObservation.cleanupStep(cleanup.extractAllFields(['code']));
      VitalSignObservation.cleanupStep(cleanup.extractAllFields(['physicalQuantity']));
      // custom cleanup to replace a nullFlavored h:code with the contents of h:text
      VitalSignObservation.cleanupStep(function () {
        if (_.has(this, "js.nullVitalReplacementText")) {
          if (_.get(this, "js.vital.code_system_name") === "Null Flavor") {
            this.js.vital = {
              "name": this.js.nullVitalReplacementText
            };
          }
          delete this.js.nullVitalReplacementText;
        }
      });
      VitalSignObservation.cleanupStep(cleanup.replaceStringFieldWithNullFlavorName("text"));

      var vitalSignsSection = component.define("vitalSignsSection");
      vitalSignsSection.templateRoot([sectionIDs.VitalSignsSection, sectionIDs.VitalSignsSectionEntriesOptional]);
      vitalSignsSection.fields([
        ["entry", "0..*", VitalSignObservation.xpath(), VitalSignObservation]
      ]);
      vitalSignsSection.cleanupStep(cleanup.replaceWithField('entry'));
      return [vitalSignsSection, VitalSignObservation];
    };

    // var VitalSignObservation = component.define("VitalSignObservation")
    //     .templateRoot(clinicalStatementsIDs.VitalSignObservation)
    //     .fields([
    //         ["identifiers", "0..*", "h:id", shared.Identifier], //this one is stripped out by "paredown" cleanup step in component.js
    //         ["vital", "1..1", "h:code", shared.ConceptDescriptor],
    //         //["identifiers","1..*", "h:id", shared.Identifier], //dup with first line
    //         ["status", "1..1", "h:statusCode/@code"],
    //         ["date_time", "1..1", "h:effectiveTime", shared.EffectiveTime],
    //         ["physicalQuantity", "1..1", "h:value[@xsi:type='PQ']", shared.PhysicalQuantity],
    //         //["freeTextValue", "0..1", "h:text", shared.TextWithReference],
    //         ["interpretations", "0..*", "h:interpretationCode[@codeSystem='2.16.840.1.113883.5.83']", shared.SimplifiedCode]
    //     ]);
    //   //VitalSignObservation.cleanupStep(cleanup.extractAllFields(['code']));
    //   VitalSignObservation.cleanupStep(cleanup.extractAllFields(['physicalQuantity']));

    /*
      //Vitals organizer is not used (flattened out in JSON model)
      var VitalSignsOrganizer = component.define("VitalSignsOrganizer")
      .templateRoot("2.16.840.1.113883.10.20.22.4.26")
      .fields([
        ["panelName","0..1", "h:code", shared.ConceptDescriptor],
        ["sourceIds","1..*", "h:id", shared.Identifier],
        ["vitals", "1..*", VitalSignObservation.xpath(), VitalSignObservation]
      ]);

      exports.VitalSignsSection = Component.define("VitalSignsSection")
      .templateRoot("2.16.840.1.113883.10.20.22.2.4.1")
      .fields([
        //["name","0..1", "h:code", shared.ConceptDescriptor],
        //["panels","0..*", VitalSignsOrganizer.xpath(), VitalSignsOrganizer],
        ["vitals","0..*", VitalSignObservation.xpath(), VitalSignObservation],
      ]);
      */

    exports.vitalSignsSection = exportVitalSignsSection;

    exports.vitalSignsEntry = exportVitalSignsSection;