Snapshot 3: Connectathon 32 Base

This is Snapshot #3 for FHIR R5, released to support Connectathon 32. For a full list of available versions, see the Directory of published versions.

Example OperationDefinition/Patient-merge (XML)

Patient Administration Work GroupMaturity Level: N/AStandards Status: Informative

Raw XML (canonical form + also see XML Format Specification)

Operation Definition

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

<OperationDefinition xmlns="http://hl7.org/fhir">
  <id value="Patient-merge"/> 
  <text> 
    <status value="extensions"/> 
    <div xmlns="http://www.w3.org/1999/xhtml">
      <p> URL: [base]/Patient/$merge</p> 
      <p> Parameters</p> 
      <table class="grid">
        <tr> 
          <td> 
            <b> Use</b> 
          </td> 
          <td> 
            <b> Name</b> 
          </td> 
          <td> 
            <b> Cardinality</b> 
          </td> 
          <td> 
            <b> Type</b> 
          </td> 
          <td> 
            <b> Binding</b> 
          </td> 
          <td> 
            <b> Documentation</b> 
          </td> 
        </tr> 
        <tr> 
          <td> IN</td> 
          <td> source-patient</td> 
          <td> 0..1</td> 
          <td> 
            <a href="references.html#Reference">Reference</a> 
          </td> 
          <td/>  
          <td> 
            <div> 
              <p> A direct resource reference to the 
                <strong> source</strong>  patient resource (this may include an identifier)
              </p> 

            </div> 
          </td> 
        </tr> 
        <tr> 
          <td> IN</td> 
          <td> source-patient-identifier</td> 
          <td> 0..*</td> 
          <td> 
            <a href="datatypes.html#Identifier">Identifier</a> 
          </td> 
          <td/>  
          <td> 
            <div> 
              <p> The Identifier(s) of the 
                <strong> source</strong>  patient resource; all of these identifiers MUST be present in the located resource
                 (in addition to the one included in the resource reference above - if included)
              </p> 

              <p> (The purpose of this property is to ensure that the correct source patient resource
                 is selected)</p> 

            </div> 
          </td> 
        </tr> 
        <tr> 
          <td> IN</td> 
          <td> target-patient</td> 
          <td> 0..1</td> 
          <td> 
            <a href="references.html#Reference">Reference</a> 
          </td> 
          <td/>  
          <td> 
            <div> 
              <p> A direct resource reference to the 
                <strong> target</strong>  patient resource
              </p> 

              <p> This is the surviving patient resource, the target for the merge</p> 

            </div> 
          </td> 
        </tr> 
        <tr> 
          <td> IN</td> 
          <td> target-patient-identifier</td> 
          <td> 0..*</td> 
          <td> 
            <a href="datatypes.html#Identifier">Identifier</a> 
          </td> 
          <td/>  
          <td> 
            <div> 
              <p> The Identifier(s) of the 
                <strong> target</strong>  patient resource; all of these identifiers MUST be present in the located resource
(The purpose of this property is to ensure that the correct source patient resource
                 is selected)
              </p> 

            </div> 
          </td> 
        </tr> 
        <tr> 
          <td> IN</td> 
          <td> result-patient</td> 
          <td> 0..1</td> 
          <td> 
            <a href="patient.html">Patient</a> 
          </td> 
          <td/>  
          <td> 
            <div> 
              <p> The details of the Patient resource that is expected to be updated to complete
                 with and must have the same patient.id and provided identifiers included.</p> 

              <p> This resource MUST have the link property included referencing the source patient
                 resource</p> 

              <p> It will be used to perform an update on the target patient resource</p> 

              <p> In the absence of this parameter the servers should copy all identifiers from the
                 source patient into the target patient, and include the link property (as shown
                 in the example below)</p> 

              <p> This is often used when properties from the source patient are desired to be included
                 in the target resource</p> 

              <p> The receiving system may also apply other internal business rules onto the merge
                 which may make the resource different from what is provided here.</p> 

            </div> 
          </td> 
        </tr> 
        <tr> 
          <td> IN</td> 
          <td> preview</td> 
          <td> 0..1</td> 
          <td> 
            <a href="datatypes.html#boolean">boolean</a> 
          </td> 
          <td/>  
          <td> 
            <div> 
              <p> If this is set to true then the merge will not be actually performed; an OperationOutcome
                 will be returned in the Parameters response that will indicate that no merge has
                 occurred and may include other diagnostic info if desired, such as the scale of
                 the merge.</p> 

              <p> e.g. Issue.details.text &quot;Preview only Patient merge - no issues detected&quot;</p> 

              <p> e.g. Issue.diagnostics &quot;Merge would update: 10 years of content or 120 resources&quot;</p> 

              <p> The resulting target patient resource will also be returned in the result</p> 

            </div> 
          </td> 
        </tr> 
        <tr> 
          <td> OUT</td> 
          <td> return</td> 
          <td> 1..1</td> 
          <td> 
            <a href="parameters.html">Parameters</a> 
          </td> 
          <td/>  
          <td> 
            <div> 
              <p> The status of the response will be one of:</p> 

              <ul> 

                <li> 200 OK - If the merge request doesn't expect any issues (although warning may be
                   present) for a preview, or was completed without issues if not a preview</li> 

                <li> 202 Accepted - The merge request has been accepted and does not expect any issues
                   and will continue processing the merge in the background, and you can monitor the
                   Task for completion</li> 

                <li> 400 Bad Request - There are errors in the input parameters that need to corrected</li> 

                <li> 422 Unprocessable Entity - Business rules prevent this merge from completing</li> 

              </ul> 

              <p> The Parameters resource will include:</p> 

              <ul> 

                <li> The Input parameters to the operation</li> 

                <li> An OperationOutcome containing errors, warnings, and information messages</li> 

                <li> The resulting merged Patient resource (or a patient reference if the patient is
                   not committed)</li> 

                <li> Optionally a Task resource to track any additional processing that was required</li> 

              </ul> 

            </div> 
          </td> 
        </tr> 
      </table> 
      <div> 
        <p> There must be at least 1 source patient/patient-identifier parameter and at least
           1 target patient/patient-identifier parameter</p> 

        <p> The result-patient.id must be the same as the target patient reference (if the
           patient reference is provided as an input parameter)</p> 

        <p> If a client needs the server to create a new patient merged from the 2 patient
           resources, the client should create a new patient record and then call the merge
           operation to merge each old patient resource into the newly created patient resource.</p> 

        <p> A server may decide to delete the source record, but this is not defined by the
           standard merge operation, and if this occurs then the target patient's link property
           will remain unchanged.</p> 

        <h1> Merge Processing</h1> 

        <p> The merge operation will have multiple stages, and some of these may take additional
           time for processing and thus be done asynchronously</p> 

        <table class="grid">

          <thead> 

            <tr> 
              <th> Stage</th> 
              <th> Description</th> 
            </tr> 

          </thead> 

          <tbody> 

            <tr> 
              <td> Preview Merge</td> 
              <td> (Optional)&lt;br/&gt;This is a call to the operation (with preview=true) that simply
                 checks for potential errors and warnings, without committing any changes.&lt;br/&gt;This
                 might not be able to capture all possible causes of errors that could be encountered
                 during the processing of the data patching.&lt;br/&gt;The returned Patient resource
                 is a preview only and has not been committed. Hence the version number and last_modified
                 date would be cleared/absent.</td> 
            </tr> 

            <tr> 
              <td> Initiate Merge</td> 
              <td> This stage processes the input parameters checking for errors/warnings and begins
                 the changes to the patient resources.&lt;br/&gt;If the system is able to complete
                 the processing of all reference data to the target patient, then it may be complete
                 and no task is required. Otherwise a Task for tracking would be created and monitor
                 the progress of the merge.</td> 
            </tr> 

            <tr> 
              <td> Data Processing</td> 
              <td> The REST operation may have returned, and processing is ongoing to patch any other
                 resource that references the source patient to reference the target patient.&lt;br/&gt;This
                 may take a considerable period of time in some systems where the volume of records
                 being updated is large.&lt;br/&gt;The source Patient record will be marked as inactive,
                 and add the link property to the target patient (except where systems delete the
                 record)</td> 
            </tr> 

            <tr> 
              <td> Completed (or failed)</td> 
              <td> All data processing is complete, and the Task is marked as completed (maybe with
                 errors)</td> 
            </tr> 

          </tbody> 

        </table> 

        <p> During the Data Processing stage the patient resource and resources referencing
           the source patient may be indeterminate until the merge processing operation completes.</p> 

        <p> 
          <strong> Note:</strong>  Some servers may also update the inactive source patient resource to remove most
           of the data to make it more clear that the resource should not be used, and the
           replaced-by link is the key information. Even to the extent of clearing the name
           and contact details etc.
        </p> 

        <p> 
          <strong> Note:</strong>  During the pre-merge validation stage, a system may perform other internal checks/business
           rules.
        </p> 

        <h2> Merging Identifiers</h2> 

        <p> If the result patient resource is provided in the parameters to the operation,
           then it is assumed that the caller has correctly included all the required identifiers
           desired to be in the target patient (though must include the identifiers specified
           in the input parameters).</p> 

        <p> If the result patient resource is 
          <strong> not</strong>  provided (only the identifier or reference to select it), then the values provided
           in the request parameters (source-patient.identifier and all source-patient-identifiers)
           will be copied into the target resource and marked as old.
        </p> 

        <blockquote> 

          <p> 
            <strong> Review Note:</strong>  If the marking of old still makes sense here for ALL provided identifiers that
             get copied across when the result patient isn't there)
          </p> 

        </blockquote> 

        <p> The server may also migrate other identifiers (and properties) at its discretion,
           and choose to mark these as old or not.</p> 

        <p> 
          <strong> Note:</strong>  If an identifier value is masked, then the server will migrate the identifier
           value correctly, regardless of the masking.
        </p> 

        <h2> Updating Data that References the source Patient</h2> 

        <p> The merge data processing SHALL update all references that refer to the source
           patient to reference the target patient.</p> 

        <p> While updating resources that reference the source patient, ensure that the target
           patient link value isn't also accidentally updated. (don't make it point at itself)</p> 

        <p> A Provenance resource SHOULD be created that references the source and target patient
           resources (or just the target-resource if the source was deleted, or the source
           patient's old identifier) indicating that the merge has occurred. (example below)</p> 

        <p> A Provenance resource MAY be created to link all of the resources that referenced
           the source patient that could then provide information to a potential un-merge
           operation.</p> 

        <p> 
          <strong> Note:</strong>  Some resources that have been updated as a result of the merge, such as AuditEvent,
           Provenance, may have been digitally signed, and this change would invalidate the
           signature. There may be other reasons impacting the updates that should be considered,
           further feedback on this specific use case is required.
        </p> 

        <blockquote> 

          <p> 
            <strong> Review Note:</strong>  Are there other implications of these reference updates that should be identified
             relating to versions - (such as where a version specific reference was included)
          </p> 

        </blockquote> 

        <p> 
          <strong> Note:</strong>  While this processing is occurring, if a client requests clinical data for either
           source or target patient, an OperationOutcome with an informative message MAY be
           included in the resulting bundle indicating this processing is ongoing.
        </p> 

        <blockquote> 

          <p> 
            <strong> Review Note:</strong>  Considering updating http://hl7.org/fhir/valueset-issue-type.html to extended
             with a new child to the transient concept to indicate that merge processing is
             occurring.
          </p> 

        </blockquote> 

        <h2> Post Merge Expectations</h2> 

        <h3> Once the patient resources have been merged:</h3> 

        <p> A GET on the old Patient resource ID (e.g. 
          <code> GET [base]/Patient/pat01</code> ) will return either:
        </p> 

        <ul> 

          <li> 200 OK and returns the old Patient which is now marked as inactive, and has the
             link (replaced-by) populated with the new Patient ID
(Note: some systems may have cleared all the other properties making this a stub
             resource)</li> 

          <li> 404 not found (when the merge system deleted the resource)</li> 

        </ul> 

        <blockquote> 

          <p> 
            <strong> Review Note:</strong>  If the system &quot;knows&quot; that the resource was there it would be preferable
             to return a stub patient 202 as described above.
          </p> 

        </blockquote> 

        <blockquote> 

          <p> 
            <strong> Review Note:</strong>  Security implications such as those from SMART tokens could restrict access here.
          </p> 

        </blockquote> 

        <p> When performing a SEARCH by the old Patient Resource ID return: e.g. GET [base]/Patient?_id=p
          at01 (often used as a substitute for direct GET when doing _include for the managing
           org/general practitioner)</p> 

        <ul> 

          <li> 200 Ok Bundle with the inactive patient which is marked as inactive and has the
             link (replaced-by) populated in it (that you'll need to follow to get any further
             data)</li> 

          <li> 200 Ok Bundle with no patient resource (case where the old patient was deleted)</li> 

          <li> 200 Ok Bundle with the target patient resource (with the link to the one from the
             search) and not include the old patient resource</li> 

          <li> 200 Ok Bundle with both the target and old patient resources</li> 

        </ul> 

        <p> Accessing the Patient $everything operation on the source patient resource (now
           marked as inactive) will return an OperationOutcome and http status of 400 Bad
           Request. The error message should inform that the patient has been merged and should
           follow the Patient link to access the $everything content.</p> 

        <blockquote> 

          <p> 
            <strong> Review Note:</strong>  Considering updating the http://hl7.org/fhir/valueset-issue-type.html to extended
             with a new child to the processing concept to indicate that additional content
             may be associated with a linked patient
          </p> 

        </blockquote> 

        <p> Searching content (e.g. Observations) based on patient ID:</p> 

        <ul> 

          <li> 
            <code> Observation?patient=Patient/pat01</code>  would return a 200 Ok Bundle with no results (as all have been moved to Patient/pat02),
             an OperationOutcome may be included indicating that the patient was merged into
             patient xxx
          </li> 

          <li> 
            <code> Observation?patient=Patient/pat02</code>  would return all the data that is referencing pat02, and all the data that was
             referencing pat01 (which was updated by the merge operation to reference pat02)
          </li> 

        </ul> 

        <p> Use Case - Polling using search on Observations to get updates:</p> 

        <ul> 

          <li> 
            <code> Observation?patient=Patient/pat02</code>  (initial client call at start of year, gets all patient obs)
          </li> 

          <li> 
            <code> Observation?patient=Patient/pat02&amp;_lastupdated=ge2019-03</code>  (client calls at start of march to detect any new patient obs)
          </li> 

          <li> (Patient pat01 is merged into pat02 during April)</li> 

          <li> 
            <code> Observation?patient=Patient/pat02&amp;_lastupdated=ge2019-06</code>  (client calls at start of june to detect any new patient obs, but misses all the
             pat01 observations prior to June)
          </li> 

          <li> Client needs to check for a provenance record of the merge having taken place to
             determine that they need to refresh the local content to see the older data</li> 

        </ul> 

        <p> In this case need to detect the patient merge, &lt;u&gt;and perform a fresh retrieval
           of all content&lt;/u&gt;, there is no way for the server to return any error codes
           in this use case, and may also need to consider notification mechanisms too.</p> 

        <p> Creating/Updating content (e.g. Observations) that reference the old Patient ID:
           (feedback on this required)</p> 

        <ul> 

          <li> 422 Unprocessable Entity with an OperationOutcome indicating that the patient referenced
             was merged into patient xxx
(this is also the existing behavior if the patient resource was deleted)</li> 

          <li> 201 Created if the service is able to automatically process the request and reallocate,
             this could occur during the merge data processing stage, otherwise the above code
             should be returned</li> 

        </ul> 

        <h1> Merge Notification Mechanisms</h1> 

        <p> The indication that a merge has been completed can be notified through several
           ways:</p> 

        <ul> 

          <li> Using FHIR Messaging to invoke the same operation</li> 

          <li> An integration engine sending HL7v2 A40 merge message (A18 may also be applicable
             in backward compatibility modes)</li> 

          <li> Directly calling the $merge operation on the dependent systems (requires the system
             to have both patient resources)</li> 

          <li> Client data refresh notification (to be defined, could be triggered by merge, security
             changes, system migrations, consent changes, etc...)</li> 

          <li> Using Subscriptions to detect the merge operation has occurred (on Provenance and/or
             Patient)</li> 

          <li> Polling the Merge Provenance resource (or the Patient resource for the relevant
             link change)</li> 

          <li> (other non standard notification channels)</li> 

        </ul> 

        <p> These notifications can be sent to other downstream systems, partners, or other
           applications (including EMPIs). An EMPI could expose the merge operation, and therefore
           be a notification sender.</p> 

        <p> Consideration should be taken to ensure that the correct data is acted on.</p> 

        <p> The downstream systems might not have all identifiers that the notifying system
           has, the notifier may be configured to know what &quot;types&quot; of identifiers
           should be propagated to which systems.</p> 

        <p> 
          <strong> Note:</strong>  When using the identifier parameters (rather than id) you should be using the
           same assigner (which in the example above would be the PAS/ADT or clinical system),
           this may be configured in the sending notification system, such as an EMPI based
           on local business rules.
        </p> 

        <h1> Impact on Subscriptions</h1> 

        <p> Subscriptions on merges are most likely to be used by applications connecting directly
           to the system. Many use cases could consider using FHIR Messaging (or other messaging
           e.g. v2 messages) to communicate the merge occurred.</p> 

        <blockquote> 

          <p> 
            <strong> Review Note:</strong>  Interaction with the Subscription v2 resources requires additional review and
             implementer feedback considering:
          </p> 

          <ul> 

            <li> What can be used as triggers for the subscription

              <ul> 

                <li> Patient update with new link values</li> 

                <li> Provenance(s) as an event</li> 

                <li> operation itself as an event (the Task resource, although that might not exist,
                   so just a pre-defined topic)</li> 

              </ul> 

            </li> 

            <li> Will all the data that is patched over to the target patient ID be notified

              <ul> 

                <li> Systems might not notify that the content was changed, and rely on the merge notification
                   to advise if required</li> 

                <li> Also note the Client data refresh notification discussion above</li> 

              </ul> 

            </li> 

          </ul> 

        </blockquote> 

        <h1> Mapping HL7v2 Merge to FHIR</h1> 

        <h2> HL7v2 Merges, Move and Linking</h2> 

        <p> Below is a summary of the Merge, Move and Link operations. They are included here
           as the v2 concepts of Merge, Move and Link may differ (or not) based on the establishment
           of the Patient, Encounter and Account as separate FHIR resources. The Merge, Move
           and Link operations  have 3 levels: Patient Identifier, Patient Account, and Patient
           Visit.</p> 

        <h2> Definitions:  Merge, move, and change identifier events</h2> 

        <p> The term &quot;identifier&quot; is used throughout this section.  An identifier
           is associated with a set (or sets) of data.  For example, an identifier (PID-3
           - Patient Identifier List) may be a medical record number which has associated
           with it account numbers (PID-18 - Patient Account Number).  Account number (PID-18
           - Patient Account Number) is a type of identifier which may have associated with
           it visit numbers (PV1-19 - Visit Number).</p> 

        <p> This section addresses the events that occur usually for the purposes of correcting
           errors in person, patient, account, or visit identifiers.  The types of errors
           that occur typically fall into three categories:</p> 

        <ul> 

          <li> Duplicate identifier created
The registrar fails to identify an existing person, patient, account, or visit
             and creates a new, &quot;duplicate&quot; record instead of using the existing record.
             A &quot;merge&quot; operation is used to fix this type of error.</li> 

          <li> Incorrect identifier selected
The registrar mistakenly selects the wrong person, patient, or account and creates
             or attaches a patient, account, or visit underneath the incorrect person, patient,
             or account. A &quot;move&quot; operation is used to fix this type of error.</li> 

          <li> Incorrect identifier assigned
The registrar accidentally types in the wrong new identifier for a person, patient,
             account, or visit. This type of mistake usually occurs when identifiers are manually
             assigned (not system generated).  A &quot;change identifier&quot; operation is
             used to fix this type of error.</li> 

        </ul> 

        <p> 
          <strong> Note:</strong>  HL7v2 addresses only scenarios 1 and 2 as most identifiers are assigned by the
           related systems, today.
        </p> 

        <h2> Patient record links</h2> 

        <p> Linking two or more patients does not require the actual merging of patient information;
           following a link trigger event, sets of affected patient data records should remain
           distinct.  However, because of differences in database architectures, there may
           be system-dependent limitations or restrictions regarding the linking of one or
           more patients that must be negotiated.</p> 

        <p> There are multiple approaches for implementing MPIs.  It is useful for the purpose
           of MPI mediation to support two types of linkage.  Explicit linkage requires a
           message declaring a link has been made between multiple identifiers.  Implicit
           linkage is performed when a receiving system infers the linkage from the presence
           of multiple identifiers present in 
          <em> PID-3-patient identifier list</em> .
        </p> 

        <p> In an MPI setting, the A24 -link patient information message is preferred for transmitting
           an explicit link of identifiers whether they are in the same or different assigning
           authorities.  The A37 unlink patient information message is preferred for transmitting
           the explicit unlinking of identifiers.</p> 

        <p> Implicit linkage of identifiers, sometimes called passive linking, has been implemented
           using various messages.  An acknowledged method is inclusion of multiple identifiers
           in 
          <em> PID-3-patient identifier list</em> , which the receiving system implicitly links.  An MPI or application that makes
           such an implicit linkage can generate an A24 - link patient information message
           to explicitly notify another system of this action.
        </p> 

        <h2> Merge Events</h2> 

        <h3> ADT/ACK - Merge Patient - Patient Identifier List (Event A40)</h3> 

        <p> 
          <em> 
            <strong> (This is the primary event to be considered associated with FHIR Patient merge)</strong> 
          </em> 
        </p> 

        <p> A merge has been done at the patient identifier list level.  That is, two PID-3
           - Patient Identifier List identifiers have been merged into one.</p> 

        <p> An A40 event is used to signal a merge of records for a patient that was incorrectly
           filed under two different identifiers.  The &quot;incorrect source identifier&quot;
           identified in the MRG segment (MRG-1 - Prior Patient Identifier List) is to be
           merged with the required &quot;correct target identifier&quot; of the same &quot;identifier
           type code&quot; component identified in the PID segment (PID-3 - Patient Identifier
           List). The &quot;incorrect source identifier&quot; would then logically never be
           referenced in future transactions.  It is noted that some systems may still physically
           keep this &quot;incorrect identifier&quot; for audit trail purposes or other reasons
           associated with database index implementation requirements.</p> 

        <h3> ADT/ACK - Merge Account - Patient Account Number (Event A41)</h3> 

        <p> 
          <em> (For information only, not in scope of FHIR for now)</em> 
        </p> 

        <p> A merge has been done at the account identifier level.  That is, two PID-18 - Patient
           Account Number identifiers have been merged into one.</p> 

        <p> An A41 event is used to signal a merge of records for an account that was incorrectly
           filed under two different account numbers.  The &quot;incorrect source patient
           account number&quot; identified in the MRG segment (MRG-3 - Prior Patient Account
           Number) is to be merged with the &quot;correct target patient account number&quot;
           identified in the PID segment (PID-18 - Patient Account Number).  The &quot;incorrect
           source patient account number&quot; would then logically never be referenced in
           future transactions.  It is noted that some systems may still physically keep this
           &quot;incorrect identifier&quot; for audit trail purposes or other reasons associated
           with database index implementation requirements.</p> 

        <blockquote> 

          <p> 
            <strong> Implementer Note:</strong>  This is not merging the Patient, but merging the account, but is the same concept,
             should we also be including this concept as another potential operation?
          </p> 

        </blockquote> 

        <h3> ADT/ACK - Merge Visit - Visit Number (Event A42)</h3> 

        <p> 
          <em> (For information only, not in scope of FHIR for now)</em> 
        </p> 

        <p> A merge has been done at the visit identifier level.  That is, two PV1-19 - Visit
           Number identifiers have been merged into one.</p> 

        <p> An A42 event is used to signal a merge of records for a visit that was incorrectly
           filed under two different visit numbers.  The &quot;incorrect source visit number&quot;
           identified in the MRG segment (MRG-5 - Prior Visit Number) is to be merged with
           the required &quot;correct target visit number&quot; identified in the PV1 segment
           (PV1-19 - Visit Number).  The &quot;incorrect source visit number&quot; would then
           logically never be referenced in future transactions.  It is noted that some systems
           may still physically keep this &quot;incorrect identifier&quot; for audit trail
           purposes or other reasons associated with database index implementation requirements.</p> 

        <blockquote> 

          <p> 
            <strong> Implementer Note:</strong>  Would be interesting to determine if these are used in production (A41 and A42)
          </p> 

        </blockquote> 

        <h2> Move Events</h2> 

        <h3> ADT/ACK - Move Patient Information - Patient Identifier List (Event A43)</h3> 

        <p> A move has been done at the patient identifier list level.  Identifier to be moved
           in the PID-3 - Patient Identifier List and MRG-1 - Prior Patient Identifier List
           will have the same value. The &quot;from&quot; (incorrect source patient ID) and
           &quot;to&quot; (correct target patient ID) identifiers have different values. See
           A43 examples in section 5.  The identifiers involved in identifying the patient
           to be moved (MRG-1 - Prior Patient Identifier List) may or might not have accounts,
           which may or might not have visits.  In any case, all subordinate data sets associated
           with the identifier in MRG-1 - Prior Patient Identifier List are moved along with
           the identifier, from the &quot;incorrect source patient ID&quot; to the &quot;correct
           target patient ID.&quot;</p> 

        <h3> ADT/ACK - Move Account Information - Patient Account Number (Event A44)</h3> 

        <p> 
          <em> (For information only, not in scope of FHIR for now)</em> 
        </p> 

        <p> A move has been done at the account identifier level.  That is, a PID-18 - Patient
           Account Number associated with one PID-3 - Patient Identifier List has been moved
           to another patient identifier list.</p> 

        <p> An A44 event is used to signal a move of records identified by the MRG-3 - Prior
           Patient Account Number from the &quot;incorrect source patient identifier list&quot;
           identified in the MRG segment (MRG-1 - Prior Patient Identifier List) to the &quot;correct
           target patient identifier list&quot; identified in the PID segment (PID-3 - Patient
           Identifier List).</p> 

        <h3> ADT/ACK - Move Visit Information - Visit Number (Event A45)</h3> 

        <p> 
          <em> (For information only, not in scope of FHIR for now)</em> 
        </p> 

        <p> A move has been done at the visit identifier level.  That is, a PV1-19 - Visit
           Number or PV1-50 - Alternate Visit ID associated with one account identifier (PID-18
           - Patient Account Number) has been moved to another account identifier.</p> 

        <p> An A45 event is used to signal a move of records identified by the MRG-5 - Prior
           Visit Number or the MRG-6 - Prior Alternate Visit ID from the &quot;incorrect source
           account identifier&quot; identified in the MRG segment (MRG-3 - Prior Patient Account
           Number) to the &quot;correct target account identifier&quot; identified in the
           PID segment (PID-18 - Patient Account Number).</p> 

        <blockquote> 

          <p> 
            <strong> Review Note:</strong>  Should Event A47 be covered? (this is similar to A43), Some vendor(s?) implement
             this and not A43
          </p> 

        </blockquote> 

        <h2> Link Events</h2> 

        <h3> ADT/ACK - link patient information (event A24)</h3> 

        <p> 
          <em> (For information only, not in scope of FHIR for now)</em> 
        </p> 

        <p> The A24 event is used when the first PID segment needs to be linked to the second
           PID segment and when both patient identifiers identify the same patient.  Linking
           two or more patients does not require the actual merging of patient information;
           following a link event, the affected patient data records should remain distinct.
            For example, this event could be used in a hospital network environment in which
           there are multiple campuses and in which records need to be linked.  For example,
           hospital A, hospital B, and hospital C would each keep their own records on a patient,
           but an A24 link event would be sent to a corporate-wide MPI to enable the coupling
           of ID information with the corporate ID number.  It is used for corporate data
           repositories, etc.  This event is not meant to link mothers and babies since a
           field exists (PID-21-mother’s identifier) for that purpose.  See Section 3.5.3,
           “Patient record links,” for a discussion of issues related to implementing patient
           link messages and MPI issues.</p> 

        <p> This event can also be used to link two patient identifiers when a patient changes
           from inpatient to outpatient, or vice versa.  This event can also be used to link
           two visits of the same patient.</p> 

        <p> The fields included when this message is sent should be the fields pertinent to
           communicate this event.  When other important fields change, it is recommended
           that the A08 (update patient information) event be used in addition.</p> 

        <h3> ADT/ACK - unlink patient information (event A37)</h3> 

        <p> 
          <em> (For information only, not in scope of FHIR for now)</em> 
        </p> 

        <p> The A37 event unlinks two PID segments previously linked with an A24 (link patient
           information) event.</p> 

        <h1> Safety Checklist</h1> 

        <blockquote> 

          <p> 
            <strong> Review Note:</strong>  Seeking implementer feedback on safety checklist items to include
          </p> 

        </blockquote> 

      </div> 
    </div> 
  </text> 
  <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-fmm">
    <valueInteger value="0"/> 
  </extension> 
  <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status">
    <valueCode value="trial-use"/> 
  </extension> 
  <url value="http://hl7.org/fhir/OperationDefinition/Patient-merge"/> 
  <version value="5.0.0-snapshot3"/> 
  <name value="Merge"/> 
  <title value="Patient Merge"/> 
  <status value="draft"/> 
  <kind value="operation"/> 
  <experimental value="false"/> 
  <date value="2022-12-14T07:12:54+11:00"/> 
  <publisher value="HL7 (FHIR Project)"/> 
  <contact> 
    <telecom> 
      <system value="url"/> 
      <value value="http://hl7.org/fhir"/> 
    </telecom> 
    <telecom> 
      <system value="email"/> 
      <value value="fhir@lists.hl7.org"/> 
    </telecom> 
  </contact> 
  <description value="The Merge operation is used to request 2 patient resources be merged.

The target is the remaining patient resource (survivor), the source will be marked
   as inactive (or in some systems deleted)

The source-patient resource will be updated to add a new link reference to the
   target-patient resource (link-type=replaced-by), and also update the status to
   inactive (unless the resource was deleted)

The target-patient resource will be updated to add a new link reference to the
   source-patient resource (link-type=replaces) - and must be included in the result-patient
   parameter if used (if the source patient is deleted, then this link is not required)"/> 
  <jurisdiction> 
    <coding> 
      <system value="http://unstats.un.org/unsd/methods/m49/m49.htm"/> 
      <code value="001"/> 
      <display value="World"/> 
    </coding> 
  </jurisdiction> 
  <affectsState value="true"/> 
  <code value="merge"/> 
  <comment value="There must be at least 1 source patient/patient-identifier parameter and at least
   1 target patient/patient-identifier parameter

The result-patient.id must be the same as the target patient reference (if the
   patient reference is provided as an input parameter)

If a client needs the server to create a new patient merged from the 2 patient
   resources, the client should create a new patient record and then call the merge
   operation to merge each old patient resource into the newly created patient resource.

A server may decide to delete the source record, but this is not defined by the
   standard merge operation, and if this occurs then the target patient's link property
   will remain unchanged.

# Merge Processing
The merge operation will have multiple stages, and some of these may take additional
   time for processing and thus be done asynchronously

|Stage | Description |
|-|-|
| Preview Merge | (Optional)&lt;br/&gt;This is a call to the operation (with preview=true)
   that simply checks for potential errors and warnings, without committing any changes.&lt;br/&
  gt;This might not be able to capture all possible causes of errors that could be
   encountered during the processing of the data patching.&lt;br/&gt;The returned
   Patient resource is a preview only and has not been committed. Hence the version
   number and last_modified date would be cleared/absent. |
| Initiate Merge | This stage processes the input parameters checking for errors/warnings
   and begins the changes to the patient resources.&lt;br/&gt;If the system is able
   to complete the processing of all reference data to the target patient, then it
   may be complete and no task is required. Otherwise a Task for tracking would be
   created and monitor the progress of the merge. |
| Data Processing | The REST operation may have returned, and processing is ongoing
   to patch any other resource that references the source patient to reference the
   target patient.&lt;br/&gt;This may take a considerable period of time in some systems
   where the volume of records being updated is large.&lt;br/&gt;The source Patient
   record will be marked as inactive, and add the link property to the target patient
   (except where systems delete the record)
| Completed (or failed) | All data processing is complete, and the Task is marked
   as completed (maybe with errors) |

During the Data Processing stage the patient resource and resources referencing
   the source patient may be indeterminate until the merge processing operation completes.

**Note:** Some servers may also update the inactive source patient resource to
   remove most of the data to make it more clear that the resource should not be used,
   and the replaced-by link is the key information. Even to the extent of clearing
   the name and contact details etc.

**Note:** During the pre-merge validation stage, a system may perform other internal
   checks/business rules.

## Merging Identifiers
If the result patient resource is provided in the parameters to the operation,
   then it is assumed that the caller has correctly included all the required identifiers
   desired to be in the target patient (though must include the identifiers specified
   in the input parameters).

If the result patient resource is **not** provided (only the identifier or reference
   to select it), then the values provided in the request parameters (source-patient.identifier
   and all source-patient-identifiers) will be copied into the target resource and
   marked as old.

&gt; **Review Note:** If the marking of old still makes sense here for ALL provided
   identifiers that get copied across when the result patient isn't there)

The server may also migrate other identifiers (and properties) at its discretion,
   and choose to mark these as old or not.

**Note:** If an identifier value is masked, then the server will migrate the identifier
   value correctly, regardless of the masking.

## Updating Data that References the source Patient
The merge data processing SHALL update all references that refer to the source
   patient to reference the target patient.

While updating resources that reference the source patient, ensure that the target
   patient link value isn't also accidentally updated. (don't make it point at itself)

A Provenance resource SHOULD be created that references the source and target patient
   resources (or just the target-resource if the source was deleted, or the source
   patient's old identifier) indicating that the merge has occurred. (example below)

A Provenance resource MAY be created to link all of the resources that referenced
   the source patient that could then provide information to a potential un-merge
   operation.

**Note:** Some resources that have been updated as a result of the merge, such
   as AuditEvent, Provenance, may have been digitally signed, and this change would
   invalidate the signature. There may be other reasons impacting the updates that
   should be considered, further feedback on this specific use case is required.

&gt; **Review Note:** Are there other implications of these reference updates that
   should be identified relating to versions - (such as where a version specific reference
   was included)

**Note:** While this processing is occurring, if a client requests clinical data
   for either source or target patient, an OperationOutcome with an informative message
   MAY be included in the resulting bundle indicating this processing is ongoing.

&gt; **Review Note:** Considering updating http://hl7.org/fhir/valueset-issue-type.html
   to extended with a new child to the transient concept to indicate that merge processing
   is occurring.

## Post Merge Expectations
### Once the patient resources have been merged:
A GET on the old Patient resource ID (e.g. `GET [base]/Patient/pat01`) will return
   either:

* 200 OK and returns the old Patient which is now marked as inactive, and has the
   link (replaced-by) populated with the new Patient ID
(Note: some systems may have cleared all the other properties making this a stub
   resource)
* 404 not found (when the merge system deleted the resource)

&gt; **Review Note:** If the system &quot;knows&quot; that the resource was there
   it would be preferable to return a stub patient 202 as described above.

&gt; **Review Note:** Security implications such as those from SMART tokens could
   restrict access here.

When performing a SEARCH by the old Patient Resource ID return: e.g. GET [base]/Patient?_id=p
  at01 (often used as a substitute for direct GET when doing _include for the managing
   org/general practitioner)

* 200 Ok Bundle with the inactive patient which is marked as inactive and has the
   link (replaced-by) populated in it (that you'll need to follow to get any further
   data)
* 200 Ok Bundle with no patient resource (case where the old patient was deleted)
* 200 Ok Bundle with the target patient resource (with the link to the one from
   the search) and not include the old patient resource
* 200 Ok Bundle with both the target and old patient resources

Accessing the Patient $everything operation on the source patient resource (now
   marked as inactive) will return an OperationOutcome and http status of 400 Bad
   Request. The error message should inform that the patient has been merged and should
   follow the Patient link to access the $everything content. 

&gt; **Review Note:** Considering updating the http://hl7.org/fhir/valueset-issue-type.html
   to extended with a new child to the processing concept to indicate that additional
   content may be associated with a linked patient

Searching content (e.g. Observations) based on patient ID:

* `Observation?patient=Patient/pat01` would return a 200 Ok Bundle with no results
   (as all have been moved to Patient/pat02), an OperationOutcome may be included
   indicating that the patient was merged into patient xxx
* `Observation?patient=Patient/pat02` would return all the data that is referencing
   pat02, and all the data that was referencing pat01 (which was updated by the merge
   operation to reference pat02)

Use Case - Polling using search on Observations to get updates:

* `Observation?patient=Patient/pat02` (initial client call at start of year, gets
   all patient obs)
* `Observation?patient=Patient/pat02&amp;_lastupdated=ge2019-03` (client calls
   at start of march to detect any new patient obs)
* (Patient pat01 is merged into pat02 during April)
* `Observation?patient=Patient/pat02&amp;_lastupdated=ge2019-06` (client calls
   at start of june to detect any new patient obs, but misses all the pat01 observations
   prior to June)
* Client needs to check for a provenance record of the merge having taken place
   to determine that they need to refresh the local content to see the older data

In this case need to detect the patient merge, &lt;u&gt;and perform a fresh retrieval
   of all content&lt;/u&gt;, there is no way for the server to return any error codes
   in this use case, and may also need to consider notification mechanisms too.

Creating/Updating content (e.g. Observations) that reference the old Patient ID:
   (feedback on this required)

* 422 Unprocessable Entity with an OperationOutcome indicating that the patient
   referenced was merged into patient xxx
(this is also the existing behavior if the patient resource was deleted)
* 201 Created if the service is able to automatically process the request and reallocate,
   this could occur during the merge data processing stage, otherwise the above code
   should be returned

# Merge Notification Mechanisms
The indication that a merge has been completed can be notified through several
   ways:

* Using FHIR Messaging to invoke the same operation
* An integration engine sending HL7v2 A40 merge message (A18 may also be applicable
   in backward compatibility modes)
* Directly calling the $merge operation on the dependent systems (requires the
   system to have both patient resources)
* Client data refresh notification (to be defined, could be triggered by merge,
   security changes, system migrations, consent changes, etc...)
* Using Subscriptions to detect the merge operation has occurred (on Provenance
   and/or Patient)
* Polling the Merge Provenance resource (or the Patient resource for the relevant
   link change)
* (other non standard notification channels)

These notifications can be sent to other downstream systems, partners, or other
   applications (including EMPIs). An EMPI could expose the merge operation, and therefore
   be a notification sender.

Consideration should be taken to ensure that the correct data is acted on.

The downstream systems might not have all identifiers that the notifying system
   has, the notifier may be configured to know what &quot;types&quot; of identifiers
   should be propagated to which systems.

**Note:** When using the identifier parameters (rather than id) you should be using
   the same assigner (which in the example above would be the PAS/ADT or clinical
   system), this may be configured in the sending notification system, such as an
   EMPI based on local business rules.

# Impact on Subscriptions
Subscriptions on merges are most likely to be used by applications connecting directly
   to the system. Many use cases could consider using FHIR Messaging (or other messaging
   e.g. v2 messages) to communicate the merge occurred.

&gt; **Review Note:** Interaction with the Subscription v2 resources requires additional
   review and implementer feedback considering:
&gt; * What can be used as triggers for the subscription
&gt;    * Patient update with new link values
&gt;    * Provenance(s) as an event
&gt;    * operation itself as an event (the Task resource, although that might
   not exist, so just a pre-defined topic)
&gt; * Will all the data that is patched over to the target patient ID be notified
&gt;    * Systems might not notify that the content was changed, and rely on the
   merge notification to advise if required
&gt;    * Also note the Client data refresh notification discussion above

# Mapping HL7v2 Merge to FHIR
## HL7v2 Merges, Move and Linking
Below is a summary of the Merge, Move and Link operations. They are included here
   as the v2 concepts of Merge, Move and Link may differ (or not) based on the establishment
   of the Patient, Encounter and Account as separate FHIR resources. The Merge, Move
   and Link operations  have 3 levels: Patient Identifier, Patient Account, and Patient
   Visit. 

## Definitions:  Merge, move, and change identifier events
The term &quot;identifier&quot; is used throughout this section.  An identifier
   is associated with a set (or sets) of data.  For example, an identifier (PID-3
   - Patient Identifier List) may be a medical record number which has associated
   with it account numbers (PID-18 - Patient Account Number).  Account number (PID-18
   - Patient Account Number) is a type of identifier which may have associated with
   it visit numbers (PV1-19 - Visit Number).

This section addresses the events that occur usually for the purposes of correcting
   errors in person, patient, account, or visit identifiers.  The types of errors
   that occur typically fall into three categories:
* Duplicate identifier created
The registrar fails to identify an existing person, patient, account, or visit
   and creates a new, &quot;duplicate&quot; record instead of using the existing record.
   A &quot;merge&quot; operation is used to fix this type of error.
* Incorrect identifier selected
The registrar mistakenly selects the wrong person, patient, or account and creates
   or attaches a patient, account, or visit underneath the incorrect person, patient,
   or account. A &quot;move&quot; operation is used to fix this type of error.
* Incorrect identifier assigned
The registrar accidentally types in the wrong new identifier for a person, patient,
   account, or visit. This type of mistake usually occurs when identifiers are manually
   assigned (not system generated).  A &quot;change identifier&quot; operation is
   used to fix this type of error.

**Note:** HL7v2 addresses only scenarios 1 and 2 as most identifiers are assigned
   by the related systems, today.

## Patient record links

Linking two or more patients does not require the actual merging of patient information;
   following a link trigger event, sets of affected patient data records should remain
   distinct.  However, because of differences in database architectures, there may
   be system-dependent limitations or restrictions regarding the linking of one or
   more patients that must be negotiated.

There are multiple approaches for implementing MPIs.  It is useful for the purpose
   of MPI mediation to support two types of linkage.  Explicit linkage requires a
   message declaring a link has been made between multiple identifiers.  Implicit
   linkage is performed when a receiving system infers the linkage from the presence
   of multiple identifiers present in *PID-3-patient identifier list*.

In an MPI setting, the A24 -link patient information message is preferred for transmitting
   an explicit link of identifiers whether they are in the same or different assigning
   authorities.  The A37 unlink patient information message is preferred for transmitting
   the explicit unlinking of identifiers.

Implicit linkage of identifiers, sometimes called passive linking, has been implemented
   using various messages.  An acknowledged method is inclusion of multiple identifiers
   in *PID-3-patient identifier list*, which the receiving system implicitly links.
    An MPI or application that makes such an implicit linkage can generate an A24
   - link patient information message to explicitly notify another system of this
   action.

## Merge Events

### ADT/ACK - Merge Patient - Patient Identifier List (Event A40)
***(This is the primary event to be considered associated with FHIR Patient merge)***

A merge has been done at the patient identifier list level.  That is, two PID-3
   - Patient Identifier List identifiers have been merged into one.

An A40 event is used to signal a merge of records for a patient that was incorrectly
   filed under two different identifiers.  The &quot;incorrect source identifier&quot;
   identified in the MRG segment (MRG-1 - Prior Patient Identifier List) is to be
   merged with the required &quot;correct target identifier&quot; of the same &quot;identifier
   type code&quot; component identified in the PID segment (PID-3 - Patient Identifier
   List). The &quot;incorrect source identifier&quot; would then logically never be
   referenced in future transactions.  It is noted that some systems may still physically
   keep this &quot;incorrect identifier&quot; for audit trail purposes or other reasons
   associated with database index implementation requirements.

### ADT/ACK - Merge Account - Patient Account Number (Event A41)
*(For information only, not in scope of FHIR for now)*

A merge has been done at the account identifier level.  That is, two PID-18 - Patient
   Account Number identifiers have been merged into one.

An A41 event is used to signal a merge of records for an account that was incorrectly
   filed under two different account numbers.  The &quot;incorrect source patient
   account number&quot; identified in the MRG segment (MRG-3 - Prior Patient Account
   Number) is to be merged with the &quot;correct target patient account number&quot;
   identified in the PID segment (PID-18 - Patient Account Number).  The &quot;incorrect
   source patient account number&quot; would then logically never be referenced in
   future transactions.  It is noted that some systems may still physically keep this
   &quot;incorrect identifier&quot; for audit trail purposes or other reasons associated
   with database index implementation requirements.

&gt; **Implementer Note:** This is not merging the Patient, but merging the account,
   but is the same concept, should we also be including this concept as another potential
   operation?

### ADT/ACK - Merge Visit - Visit Number (Event A42)
*(For information only, not in scope of FHIR for now)*

A merge has been done at the visit identifier level.  That is, two PV1-19 - Visit
   Number identifiers have been merged into one.

An A42 event is used to signal a merge of records for a visit that was incorrectly
   filed under two different visit numbers.  The &quot;incorrect source visit number&quot;
   identified in the MRG segment (MRG-5 - Prior Visit Number) is to be merged with
   the required &quot;correct target visit number&quot; identified in the PV1 segment
   (PV1-19 - Visit Number).  The &quot;incorrect source visit number&quot; would then
   logically never be referenced in future transactions.  It is noted that some systems
   may still physically keep this &quot;incorrect identifier&quot; for audit trail
   purposes or other reasons associated with database index implementation requirements.

&gt; **Implementer Note:** Would be interesting to determine if these are used
   in production (A41 and A42)

## Move Events
### ADT/ACK - Move Patient Information - Patient Identifier List (Event A43)

A move has been done at the patient identifier list level.  Identifier to be moved
   in the PID-3 - Patient Identifier List and MRG-1 - Prior Patient Identifier List
   will have the same value. The &quot;from&quot; (incorrect source patient ID) and
   &quot;to&quot; (correct target patient ID) identifiers have different values. See
   A43 examples in section 5.  The identifiers involved in identifying the patient
   to be moved (MRG-1 - Prior Patient Identifier List) may or might not have accounts,
   which may or might not have visits.  In any case, all subordinate data sets associated
   with the identifier in MRG-1 - Prior Patient Identifier List are moved along with
   the identifier, from the &quot;incorrect source patient ID&quot; to the &quot;correct
   target patient ID.&quot;

### ADT/ACK - Move Account Information - Patient Account Number (Event A44)
*(For information only, not in scope of FHIR for now)*

A move has been done at the account identifier level.  That is, a PID-18 - Patient
   Account Number associated with one PID-3 - Patient Identifier List has been moved
   to another patient identifier list.

An A44 event is used to signal a move of records identified by the MRG-3 - Prior
   Patient Account Number from the &quot;incorrect source patient identifier list&quot;
   identified in the MRG segment (MRG-1 - Prior Patient Identifier List) to the &quot;correct
   target patient identifier list&quot; identified in the PID segment (PID-3 - Patient
   Identifier List).

### ADT/ACK - Move Visit Information - Visit Number (Event A45)
*(For information only, not in scope of FHIR for now)*

A move has been done at the visit identifier level.  That is, a PV1-19 - Visit
   Number or PV1-50 - Alternate Visit ID associated with one account identifier (PID-18
   - Patient Account Number) has been moved to another account identifier.

An A45 event is used to signal a move of records identified by the MRG-5 - Prior
   Visit Number or the MRG-6 - Prior Alternate Visit ID from the &quot;incorrect source
   account identifier&quot; identified in the MRG segment (MRG-3 - Prior Patient Account
   Number) to the &quot;correct target account identifier&quot; identified in the
   PID segment (PID-18 - Patient Account Number).

&gt; **Review Note:** Should Event A47 be covered? (this is similar to A43), Some
   vendor(s?) implement this and not A43

## Link Events
### ADT/ACK - link patient information (event A24)
*(For information only, not in scope of FHIR for now)*

The A24 event is used when the first PID segment needs to be linked to the second
   PID segment and when both patient identifiers identify the same patient.  Linking
   two or more patients does not require the actual merging of patient information;
   following a link event, the affected patient data records should remain distinct.
    For example, this event could be used in a hospital network environment in which
   there are multiple campuses and in which records need to be linked.  For example,
   hospital A, hospital B, and hospital C would each keep their own records on a patient,
   but an A24 link event would be sent to a corporate-wide MPI to enable the coupling
   of ID information with the corporate ID number.  It is used for corporate data
   repositories, etc.  This event is not meant to link mothers and babies since a
   field exists (PID-21-mother’s identifier) for that purpose.  See Section 3.5.3,
   “Patient record links,” for a discussion of issues related to implementing patient
   link messages and MPI issues.

This event can also be used to link two patient identifiers when a patient changes
   from inpatient to outpatient, or vice versa.  This event can also be used to link
   two visits of the same patient.

The fields included when this message is sent should be the fields pertinent to
   communicate this event.  When other important fields change, it is recommended
   that the A08 (update patient information) event be used in addition.

### ADT/ACK - unlink patient information (event A37)
*(For information only, not in scope of FHIR for now)*

The A37 event unlinks two PID segments previously linked with an A24 (link patient
   information) event.

# Safety Checklist
&gt; **Review Note:** Seeking implementer feedback on safety checklist items to
   include
"/> 
  <resource value="Patient"/> 
  <system value="false"/> 
  <type value="true"/> 
  <instance value="false"/> 
  <parameter> 
    <name value="source-patient"/> 
    <use value="in"/> 
    <min value="0"/> 
    <max value="1"/> 
    <documentation value="A direct resource reference to the **source** patient resource (this may include
     an identifier)"/> 
    <type value="Reference"/> 
    <targetProfile value="http://hl7.org/fhir/StructureDefinition/Patient"/> 
  </parameter> 
  <parameter> 
    <name value="source-patient-identifier"/> 
    <use value="in"/> 
    <min value="0"/> 
    <max value="*"/> 
    <documentation value="The Identifier(s) of the **source** patient resource; all of these identifiers
     MUST be present in the located resource (in addition to the one included in the
     resource reference above - if included)

(The purpose of this property is to ensure that the correct source patient resource
     is selected)"/> 
    <type value="Identifier"/> 
  </parameter> 
  <parameter> 
    <name value="target-patient"/> 
    <use value="in"/> 
    <min value="0"/> 
    <max value="1"/> 
    <documentation value="A direct resource reference to the **target** patient resource

This is the surviving patient resource, the target for the merge"/> 
    <type value="Reference"/> 
    <targetProfile value="http://hl7.org/fhir/StructureDefinition/Patient"/> 
  </parameter> 
  <parameter> 
    <name value="target-patient-identifier"/> 
    <use value="in"/> 
    <min value="0"/> 
    <max value="*"/> 
    <documentation value="The Identifier(s) of the **target** patient resource; all of these identifiers
     MUST be present in the located resource
(The purpose of this property is to ensure that the correct source patient resource
     is selected)"/> 
    <type value="Identifier"/> 
  </parameter> 
  <parameter> 
    <name value="result-patient"/> 
    <use value="in"/> 
    <min value="0"/> 
    <max value="1"/> 
    <documentation value="The details of the Patient resource that is expected to be updated to complete
     with and must have the same patient.id and provided identifiers included.

This resource MUST have the link property included referencing the source patient
     resource

It will be used to perform an update on the target patient resource

In the absence of this parameter the servers should copy all identifiers from the
     source patient into the target patient, and include the link property (as shown
     in the example below)

This is often used when properties from the source patient are desired to be included
     in the target resource

The receiving system may also apply other internal business rules onto the merge
     which may make the resource different from what is provided here."/> 
    <type value="Patient"/> 
  </parameter> 
  <parameter> 
    <name value="preview"/> 
    <use value="in"/> 
    <min value="0"/> 
    <max value="1"/> 
    <documentation value="If this is set to true then the merge will not be actually performed; an OperationOutcome
     will be returned in the Parameters response that will indicate that no merge has
     occurred and may include other diagnostic info if desired, such as the scale of
     the merge.

e.g. Issue.details.text &quot;Preview only Patient merge - no issues detected&quot;

e.g. Issue.diagnostics &quot;Merge would update: 10 years of content or 120 resources&quot;

The resulting target patient resource will also be returned in the result"/> 
    <type value="boolean"/> 
  </parameter> 
  <parameter> 
    <name value="return"/> 
    <use value="out"/> 
    <min value="1"/> 
    <max value="1"/> 
    <documentation value="The status of the response will be one of:

* 200 OK - If the merge request doesn't expect any issues (although warning may
     be present) for a preview, or was completed without issues if not a preview
* 202 Accepted - The merge request has been accepted and does not expect any issues
     and will continue processing the merge in the background, and you can monitor the
     Task for completion
* 400 Bad Request - There are errors in the input parameters that need to corrected
* 422 Unprocessable Entity - Business rules prevent this merge from completing

The Parameters resource will include:

* The Input parameters to the operation
* An OperationOutcome containing errors, warnings, and information messages
* The resulting merged Patient resource (or a patient reference if the patient
     is not committed)
* Optionally a Task resource to track any additional processing that was required"/> 
    <type value="Parameters"/> 
  </parameter> 
</OperationDefinition> 

Usage note: every effort has been made to ensure that the examples are correct and useful, but they are not a normative part of the specification.