department-of-veterans-affairs/vets-website

View on GitHub
src/applications/mhv-medical-records/util/pdfHelpers/allergies.js

Summary

Maintainability
A
2 hrs
Test Coverage
import { processList } from '../helpers';

export const generateAllergiesIntro = (records, lastUpdatedIndicator) => {
  return {
    title: 'Allergies',
    subject: `VA Medical Record\n\n${lastUpdatedIndicator}`,
    preface: `This list includes all allergies, reactions, and side-effects in your VA medical records. If you have allergies or reactions that are missing from this list, tell your care team at your next appointment.\n\nShowing ${
      records.length
    } records from newest to oldest.`,
  };
};

export const generateAllergyItem = record => {
  if (record.isOracleHealthData) {
    return {
      items: [
        {
          title: 'Date entered',
          value: record.date,
          inline: true,
        },
        {
          title: 'Signs and symptoms',
          value: processList(record.reaction),
          inline: true,
        },
        {
          title: 'Type of allergy',
          value: record.type,
          inline: true,
        },
        {
          title: 'Provider',
          value: record.provider,
          inline: true,
        },
        {
          title: 'Provider notes',
          value: record.notes,
          inline: true,
        },
      ],
    };
  }

  return {
    items: [
      {
        title: 'Date entered',
        value: record.date,
        inline: true,
      },
      {
        title: 'Signs and symptoms',
        value: processList(record.reaction),
        inline: true,
      },
      {
        title: 'Type of allergy',
        value: record.type,
        inline: true,
      },
      {
        title: 'Location',
        value: record.location,
        inline: true,
      },
      {
        title: 'Observed or historical',
        value: record.observedOrReported,
        inline: true,
      },
      {
        title: 'Provider notes',
        value: record.notes,
        inline: true,
      },
    ],
  };
};

export const generateAllergiesContent = (records, isOracleHealthData) => ({
  results: {
    items: records.map(record => ({
      header: record.name,
      ...generateAllergyItem({ ...record, isOracleHealthData }),
    })),
  },
});