E-mail d’ordonnances de programmes de santé plan-prescription

Sur cette page : Suivez un cas d’utilisation de personnalisation qui effectue une itération sur des tableaux de profils imbriqués avec des règles conditionnelles pour créer un plan d’intégrité en répertoriant les ordonnances qui sont prêtes à être récupérées ou rappelées.

Un profil contient des programmes de santé, et chaque programme inclut des ordonnances. Les ordonnances comportent différents états, tels que « prêt », « rappel » ou « récupéré ».

Dans ce cas d’utilisation, nous souhaitons envoyer un seul e-mail à chaque profil, contenant toutes les ordonnances qui sont prêtes à être récupérées ou rappelées. Cliquez sur chaque onglet ci-dessous pour plus d’informations sur la syntaxe à utiliser pour mettre en œuvre ce cas d’utilisation.

Message affiché

Bonjour Jean Dupont,

Voici les ordonnances qui sont prêtes à être récupérées ou qui ont été rappelées :

Programme de santé A

  • Prescription ID: pres1
    Nom : Médicament A
    State: ready
  • Prescription ID: pres2
    Nom : Médicament B
    State: rappel

Programme de santé B

  • Prescription ID: pres4
    Nom : D de médicament
    State: ready
Modèle HTML
code language-html
<p>Hi {{profile.person.firstName}} {{profile.person.lastName}},</p>
<p>Here are the prescriptions that are either ready for pick up or have been recalled:</p>
{{#each profile.plans as |plan|}}
<h3>{{plan.name}}</h3>
<ul>
   {{#each plan.prescriptions as |prescription|}}
   {%#if prescription.state = "ready" or prescription.state = "recall"%}
   <li>
      <strong>Prescription ID:</strong> {{prescription.prescription_id}}<br>
      <strong>Name:</strong> {{prescription.name}}<br>
      <strong>State:</strong> {{prescription.state}}
   </li>
   {%/if%}
   {{/each}}
</ul>
{{/each}}
Données de profil
code language-javascript
{
  "profile": {
    "person": {
      "firstName": "John",
      "lastName": "Doe"
    },
    "plans": [
      {
        "planId": "plan1",
        "name": "Health Plan A",
        "prescriptions": [
          {
            "prescription_id": "pres1",
            "name": "Medication A",
            "state": "ready"
          },
          {
            "prescription_id": "pres2",
            "name": "Medication B",
            "state": "recall"
          }
        ]
      },
      {
        "planId": "plan2",
        "name": "Health Plan B",
        "prescriptions": [
          {
            "prescription_id": "pres3",
            "name": "Medication C",
            "state": "picked up"
          },
          {
            "prescription_id": "pres4",
            "name": "Medication D",
            "state": "ready"
          }
        ]
      }
    ]
  }
}
AI Knowledge Reference

This section contains structured knowledge intended to support interpretation, retrieval, and question answering related to this topic.

For complete understanding, this information should be combined with the documentation on this page. Neither source is intended to stand alone; the page describes the feature, while this section provides additional context that helps disambiguate terminology, intent, applicability, and constraints.

  • TL;DR: This page demonstrates a complete personalization use case: iterating over nested profile arrays (health plans containing prescriptions) with conditional filtering to display only prescriptions in “ready” or “recall” states in an email.

Intents:

  • See a rendered output example of a personalized health plan email
  • Understand the HTML template using nested {{#each}} and {%#if%} blocks for conditional array iteration
  • Understand the required profile data structure: a plans array where each plan contains a prescriptions array with state fields

Glossary:

  • Nested iteration: Using {{#each}} loops inside other {{#each}} loops to traverse multi-level array structures in profile data (e.g., plans → prescriptions).
  • Prescription state: A field on each prescription object indicating its lifecycle status in this use case — values used are “ready”, “recall”, and “picked up”. (use-case specific)
  • {%#if%} / {%/if%}: Conditional block syntax used within message templates to filter array items during iteration (distinct from the double-curly {{#if}} Handlebars syntax).

Terminology:

  • Canonical name: nested array iteration — variants: nested loops, nested each, multi-level iteration
  • Do not confuse: {{#each}} / {{/each}} (Handlebars iteration syntax, double curly braces) ≠ {%#if%} / {%/if%} (conditional syntax, percent-curly braces) — both are used together in this template
  • Do not confuse: “ready” (prescription available for pickup) ≠ “recall” (prescription has been recalled) ≠ “picked up” (prescription already collected — excluded from the output by the conditional filter)

FAQ:

  • Q: Which prescription states are included in the email output? — Only prescriptions with state “ready” or “recall” are displayed. Prescriptions with state “picked up” are excluded by the {%#if prescription.state = "ready" or prescription.state = "recall"%} conditional filter.
  • Q: What profile data structure is required for this use case? — A profile with a plans array, where each plan object contains a prescriptions array. Each prescription object must have prescription_id, name, and state fields.
  • Q: How are plans and prescriptions iterated in the template? — The outer {{#each profile.plans as |plan|}} loop iterates over each health plan. Inside it, {{#each plan.prescriptions as |prescription|}} iterates over each plan’s prescriptions, and a conditional block filters to only “ready” or “recall” states.
recommendation-more-help
journey-optimizer-help