Bruce,
Basically, I have two apps in play here. One is a NT7 app for patients to enter and maintain their own history information. The other is our main desktop database, that physicians use to view all data and produce reports. The desktop app will have access to the history data patients create in the NT7 app. The physician needs to know if there is new history data or if existing data has been changed/updated, so it can be verified before use in reports.
So, my idea was to add a new file (PHRRecords.tps) that will be contain a few fields to indicate the status of the patient given history data. In the PostInsert and PostUpdate embeds of the NT app I have the following code:
Access:Main_PHRRecords.Open()
Access:Main_PHRRecords.UseFile()
PHR:SRC_ID = p_web.GSV('CLI:CLINHX_ID')
PHR:SRC_FILE = 'Clinical History'
If Access:Main_PHRRecords.Fetch(PHR:SRCID_KEY) = Level:Benign
PHR:SRC_ID = p_web.GSV('CLI:CLINHX_ID')
PHR:SRC_FILE = 'Clinical History'
PHR:SRC_DATA = 'PHR'
PHR:SRC_DATE = Today()
PHR:SRC_TIME = Clock()
PHR:SRC_ACTION = 'Update'
PHR:SRC_USER = p_web.GSV('PatientName')
PHR:SRC_STATUS = 'Not Verified'
Access:Main_PHRRecords.Update()
ElsIf Access:Main_PHRRecords.Fetch(PHR:SRCID_KEY) = Level:Notify
PHR:SRC_ID = p_web.GSV('CLI:CLINHX_ID')
PHR:SRC_FILE = 'Clinical History'
PHR:SRC_DATA = 'PHR'
PHR:SRC_DATE = Today()
PHR:SRC_TIME = Clock()
PHR:SRC_ACTION = 'Insert'
PHR:SRC_USER = p_web.GSV('PatientName')
PHR:SRC_STATUS = 'Not Verified'
Access:Main_PHRRecords.Insert()
END
Access:Main_PHRRecords.Close()
As you can see, I'm only storing basic data about the source (src) of the data, such as Clinical History, time and date and whether this was an new record (Insert) or edited data (Change) and the status (eg. Not Verified). I have added a new browse to the desktop app to display this data so a physician can get an idea of what the patient has entered and have an opportunity to verify if needed. Once verified, the physician will change the status to 'Verified', and data marked as 'Verified' can be used in reports. Later on, if the patient updates data or adds new data via the NT app, the status is re-set to Not Verified, and the file will show which data needs to be addressed by the pysician.
I had a few test users look at the app. I found that most would open a form by clicking the Change button, look at a few pages and then click the Save button to close the form. They made no changes to the data, but because they clicked on Save, a new record was created in the PHRRecords file. Now there is a new entry on the desktop app indicating there is new data that requires verification, when in fact no new data was added. My understanding is that code in the "PostAction" embed of a form is run when the user clicks on the Save button, so I want to conditionally control when the code in the PostInsert and PostUpdate runs.
One thought I have is to store the contents of the form record when a form first opens. Then, when the Save button is clicked, compare the current record to the stored record. If they are the same then no code is run. I attempted to do this with the following:
Added: SAV:Record Like(CLI:Record) in the local data, other declarations embed.
Then set: SAV:Record = CLI:Record tried various embeds.
Finally, I wrapped the code mentioned above in a condition, testing to see if the current record was the same as the stored record:
If CLI:Record <> SAV:Record
run code above...
End
I did not get this working and I think this is because I have not retreived the current record properly. So this is where I need assistance. Am I on the right track? Can I conditionally fire the code in the PostInsert/PostUpdate embeds? Or is there a better way to do this?
Thanks,
Jeff