Unfortunately no.  Not all patients will have every identifier.  Almost all will have the BHSMRN identifier , but not all will have a FHMRN or CKS.    The goal is to check every outbound A40 to see if the CKS is different in the two segments.  If they are we write them to a file.  If not, we move to the next.