<?xml version="1.0" encoding="UTF-8"?>

<CodeSystem xmlns="http://hl7.org/fhir">
  <id value="identity-resolution-reason"/>
  <text>
    <status value="generated"/><div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: CodeSystem identity-resolution-reason</b></p><a name="identity-resolution-reason"> </a><a name="hcidentity-resolution-reason"> </a><p>This case-sensitive code system <code>https://projo.evoleen.com/fhir/CodeSystem/identity-resolution-reason</code> defines the following codes:</p><table class="codes"><tr><td style="white-space:nowrap"><b>Code</b></td><td><b>Display</b></td><td><b>Definition</b></td></tr><tr><td style="white-space:nowrap">no-match<a name="identity-resolution-reason-no-match"> </a></td><td>No match</td><td>No existing identity matches the sender's phone number or BSUID. Orchestrator creates a new identity (Patient by default) and applies the triggered plan (onboarding).</td></tr><tr><td style="white-space:nowrap">multiple-matches<a name="identity-resolution-reason-multiple-matches"> </a></td><td>Multiple matches</td><td>More than one identity matches the sender's hints. Orchestrator refuses; marks the reverse CR entered-in-error.</td></tr><tr><td style="white-space:nowrap">non-conversational-only<a name="identity-resolution-reason-non-conversational-only"> </a></td><td>Non-conversational only</td><td>Matches exist but none of a conversational type. Orchestrator walks Person.link; if none, creates a new identity.</td></tr><tr><td style="white-space:nowrap">no-active-cr<a name="identity-resolution-reason-no-active-cr"> </a></td><td>No active CR</td><td>Identity matched but no active CommunicationRequest to attach to. Orchestrator reattaches and applies the triggered plan (default/re-engagement); skips if an active CarePlan exists.</td></tr><tr><td style="white-space:nowrap">unresolved-receiver<a name="identity-resolution-reason-unresolved-receiver"> </a></td><td>Unresolved receiver</td><td>Receiver Organization unknown. Orchestrator idempotently upserts a stub Organization, then creates the identity + applies the triggered plan.</td></tr></table></div>
  </text>
  <url value="https://projo.evoleen.com/fhir/CodeSystem/identity-resolution-reason"/>
  <version value="0.1.0"/>
  <name value="IdentityResolutionReasonCS"/>
  <title value="Projo Identity Resolution Reason"/>
  <status value="draft"/>
  <experimental value="true"/>
  <date value="2024-01-01"/>
  <publisher value="Projo"/>
  <contact>
    <name value="Projo"/>
    <telecom>
      <system value="url"/>
      <value value="https://projo.evoleen.com"/>
    </telecom>
  </contact>
  <description value="Reason codes stamped on a reverse CommunicationRequest (category=identity-resolution-required) explaining why the WhatsApp sidecar could not attach an inbound message to an existing identity. The orchestrator reads this code to decide its response (see 09_identity.md)."/>
  <jurisdiction>
    <coding>
      <system value="urn:iso:std:iso:3166"/>
      <code value="CH"/>
      <display value="Switzerland"/>
    </coding>
  </jurisdiction>
  <purpose value="Documentation-only artifact. Projo's runtime extensions, code systems, identifier systems and search parameter are TypeScript constants and bootstrap-time resources, NOT deployed StructureDefinitions. This StructureDefinition exists to document the contract; the source of truth is src/functions/src/lib/fhir/types.ts and docs/FHIR_EXTENSIONS.md."/>
  <copyright value="Copyright (c) Projo. Licensed under CC0-1.0 (public domain dedication). FHIR(R) is the registered trademark of HL7 and is used with permission. This IG references WhatsApp(R), a trademark of Meta Platforms, Inc., for descriptive purposes only."/>
  <caseSensitive value="true"/>
  <content value="complete"/>
  <count value="5"/>
  <concept>
    <code value="no-match"/>
    <display value="No match"/>
    <definition value="No existing identity matches the sender's phone number or BSUID. Orchestrator creates a new identity (Patient by default) and applies the triggered plan (onboarding)."/>
  </concept>
  <concept>
    <code value="multiple-matches"/>
    <display value="Multiple matches"/>
    <definition value="More than one identity matches the sender's hints. Orchestrator refuses; marks the reverse CR entered-in-error."/>
  </concept>
  <concept>
    <code value="non-conversational-only"/>
    <display value="Non-conversational only"/>
    <definition value="Matches exist but none of a conversational type. Orchestrator walks Person.link; if none, creates a new identity."/>
  </concept>
  <concept>
    <code value="no-active-cr"/>
    <display value="No active CR"/>
    <definition value="Identity matched but no active CommunicationRequest to attach to. Orchestrator reattaches and applies the triggered plan (default/re-engagement); skips if an active CarePlan exists."/>
  </concept>
  <concept>
    <code value="unresolved-receiver"/>
    <display value="Unresolved receiver"/>
    <definition value="Receiver Organization unknown. Orchestrator idempotently upserts a stub Organization, then creates the identity + applies the triggered plan."/>
  </concept>
</CodeSystem>