# All files / blue-button/lib/parser router.js

98.86% Statements 87/88
75% Branches 6/8
100% Functions 2/2
98.86% Lines 87/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
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    1x
    1x
    10x
    10x

    10x
    10x
    10x
    2x
    10x
    2x
    8x
    6x
    6x
    10x
    10x
    1x
    1x
     //CCDA to JSON parser.

    "use strict";

    var generateComponents = function (version) {

      version = version.indexOf("-") > -1 ? "_" + version.split("-")[1] : "";

      return {

        //Base CCD Object.
        cda_ccd: require("./cda/ccd").CCD(version),

        //Base C32 Object.
        c32_ccd: require("./c32/ccd").C32(version),
        c32_demographics: require("./c32/demographics").patient,
        c32_vitals: require("./c32/sections/vitals").vitalSignsSection,
        c32_medications: require("./c32/sections/medications").medicationsSection,
        c32_problems: require("./c32/sections/problems").problemsSection,
        c32_immunizations: require("./c32/sections/immunizations").immunizationsSection,
        c32_results: require("./c32/sections/results").resultsSection,
        c32_allergies: require("./c32/sections/allergies").allergiesSection,
        c32_encounters: require("./c32/sections/encounters").encountersSection,
        c32_procedures: require("./c32/sections/procedures").proceduresSection,

        //exposing individual entries just in case
        c32_vitals_entry: require("./c32/sections/vitals").vitalSignsEntry,
        c32_medications_entry: require("./c32/sections/medications").medicationsEntry,
        c32_problems_entry: require("./c32/sections/problems").problemsEntry,
        c32_immunizations_entry: require("./c32/sections/immunizations").immunizationsEntry,
        c32_results_entry: require("./c32/sections/results").resultsEntry,
        c32_allergies_entry: require("./c32/sections/allergies").allergiesEntry,
        c32_encounters_entry: require("./c32/sections/encounters").encountersEntry,
        c32_procedures_entry: require("./c32/sections/procedures").proceduresEntry,

        //CCDA domains.
        ccda_ccd: require("./ccda/ccd").CCD(version),
        ccda_demographics: require("./ccda/demographics").patient,
        ccda_header: require("./ccda/header").header,
        ccda_vitals: require("./ccda/sections/vitals").vitalSignsSection(version)[0],
        ccda_medications: require("./ccda/sections/medications").medicationsSection(version)[0],
        ccda_problems: require("./ccda/sections/problems").problemsSection(version)[0],
        ccda_immunizations: require("./ccda/sections/immunizations").immunizationsSection(version)[0],
        ccda_results: require("./ccda/sections/results").resultsSection(version)[0],
        ccda_allergies: require("./ccda/sections/allergies").allergiesSection(version)[0],
        ccda_encounters: require("./ccda/sections/encounters").encountersSection(version)[0],
        ccda_procedures: require("./ccda/sections/procedures").proceduresSection(version)[0],
        ccda_social_history: require("./ccda/sections/social_history").socialHistorySection(version)[0],
        ccda_plan_of_care: require("./ccda/sections/plan_of_care").plan_of_care_section(version)[0],
        ccda_payers: require("./ccda/sections/payers").payers_section(version)[0],
        ccda_functional_statuses: require('./ccda/sections/functional_status').functionalStatusSection(version)[0],
        ccda_hospital_discharge_instructions: require('./ccda/sections/hospital_discharge_instructions').hospital_discharge_instructions_section(version)[0],
        ccda_hospital_discharge_medications: require('./ccda/sections/hospital_discharge_medications').hospital_discharge_medications_section(version)[0],
        ccda_reason_for_referral: require('./ccda/sections/reason_for_referral').reason_for_referral_section(version)[0],

        //exposing individual entries just in case
        ccda_vitals_entry: require("./ccda/sections/vitals").vitalSignsEntry(version)[1],
        ccda_medications_entry: require("./ccda/sections/medications").medicationsEntry(version)[1],
        ccda_problems_entry: require("./ccda/sections/problems").problemsEntry(version)[1],
        ccda_immunizations_entry: require("./ccda/sections/immunizations").immunizationsEntry(version)[1],
        ccda_results_entry: require("./ccda/sections/results").resultsEntry(version)[1],
        ccda_allergies_entry: require("./ccda/sections/allergies").allergiesEntry(version)[1],
        ccda_encounters_entry: require("./ccda/sections/encounters").encountersEntry(version)[1],
        ccda_procedures_entry: require("./ccda/sections/procedures").proceduresEntry(version)[1],
        ccda_plan_of_care_entry: require("./ccda/sections/plan_of_care").plan_of_care_entry(version)[1],
        ccda_payers_entry: require("./ccda/sections/payers").payers_entry(version)[1],
        ccda_functional_statuses_entry: require('./ccda/sections/functional_status').functionalStatusSection(version)[1],
        ccda_hospital_discharge_medications_entry: require('./ccda/sections/hospital_discharge_medications').hospital_discharge_medications_section(version)[1],
      };
    };

    var componentRouter = function (componentName, type) {

      if (componentName) {
        return generateComponents(type["type"])[componentName];
      } else {

        if (type["type"] === 'c32') {
          return generateComponents(type["type"]).c32_ccd;
        } else if (type["type"] === 'cda') {
          return generateComponents(type["type"]).cda_ccd;
        } else {
          return generateComponents(type["type"]).ccda_ccd;
        }
      }
    };

    module.exports.componentRouter = componentRouter;