PKB already offers an HL7-based, automated add to teams workflow.
This page outlines upcoming work to discharge patients from a team in a similar fashion.
The ZTM custom segment already supports a list of aliases in ZTM-1, which indicate which team(s) the patient should be added to.
This will be expanded so that a list of aliases can also be provided in ZTM-2, to indicate which team(s) the patient should be discharged from.
Each discharge alias will need to map to a team in the sender's organisation. If the patient is currently admitted to that team, then they will be discharged (which includes revoking any granted privacy labels).
MSH|^~\&|SendingApp|SendingFacility|HL7API|PKB|20160102101112||ADT^A28|ABC0000000001|P|2.4
PID|||9999999999^^^NHS^NH|
ZTM|add-to-team-alias|remove-from-team-alias