Creating a new record in a table with match fields storing key fields from records in two other tables?
I want to create a new record in an Encounter table that includes two match fields storing key fields from records in two other tables: Patient and Provider. I can create a button on a Patient table layout, use a script to store the Patient record key field in a variable, go to an Encounter table layout, create a new record in the Encounter table, and set the match field in the new Encounter record to the Patient record key field stored in the variable. But then I have to repeat the process to get the key field from the Provider table into it's match field in the Encounter table record.
What I'd like to do is create a single layout from which the user can look up a Patient record from the Patient table, look up a Provider record from the Provider table, store the key fields from both, then tap a button to create a new Encounter record in the Encounter table with the key fields stored in their respective match fields in that new Encounter record.
Thanks in advance for you help!