So how is this done?
The key is to find someway of 'tagging' these data items so that we can tell if a given item is local to a Trust, or is National.
For many of the data items we have the luxury of having access to a descriptive flexfield attribute. Where this is available, we have reserved an attribute to hold this tag (known in NHS project terms as the VPD code or TRUST ID). Were possible, we have used the same attribute number across the entities (although there are some exceptions to this).
For some entities however, there is no descriptive flexfield segment to use. In this case, we have resorted to having a central custom table. This table will hold the entity reference (ie table name), the entitiy key and the VPD code. Given the size and complexity of this implementation, this custom table is partitioned to provide performant non-locking access across the system.
For items that are national, we do not populate a value into this field. This enforces the assumption that an item is nationally available unless it is tagged with a value.
This also enforces the rule that an item can only be owned by 1 Trust.
Each trust is allocated its own unique Trust ID. This is a 3-character code, that is allocated from a centrally controlled list (ie the Trusts cannot pick and chose their own Trust ID).
I can hear you getting restless at this point.
But surely some of the entities have enforced uniqueness in their names, such as Organization?
Good question!.
This would be true, however by enforcing certain business rules upon the creation of such data we can get around this problem.

The example i will use is Organization.
The chances are, that with 600+ Trusts all using the same system, there is the likelyhood that one or more of them will have a department called Human Resources (say).
In a bog-standard clean HRMS install, you could not create 2 organizations with the same name of "Human Resources", as the name has to be unique within the business group. This is enforced via a database index constraint.
So for the NHS, Trust A create an organization called 'Human Resources' but they are forced into calling it 'nnn Human Resources', where nnn is their unique Trust ID.
Trust 'B' can create their Human Resources organization, and this gets called 'zzz Human Resources', where zzz is their unique Trust ID.
There are certain 'quirks' of the system that behave differently under VPD as well.
In a clean HRMS install, the system only allows you to have one primary organization hierarchy per business group. For the NHS each Trust requires to have its own primary hierarchy. However since the "1 primary per BG" rule is enforced by code, rather than by a database constraint, we can get around this quite happily
without having to hack the core code.
For example....
Trust A create their primary hierarchy. It is local to them, and owned by them.
Trust B go ahead and create their primary hierarchy. As far as the system is concerned, at the time this hierarchy is being created it cannot see Trust A's hierarchy and so allows Trust B's hierarchy to be created.
I digress slightly, so moving back on track...
We have allocated somewhere to 'hold' the tagging attribute, either directly on the entitiy, or in a central repository. How do we actually maintain these tags and ensure they are populated?
For that, we have to jump onto another post...