Templates for Patient Documents: Site ID is missing from session data!

Hi Jerry,
Thank you for your response. Unfortunately, the clearing smarty cache didn’t do the trick.

Do you have any other ideas?

I recently cleaned off my 4.2.2 and 5.0.0 test versions from my dev systems so best I can do for testing is 5.0.1, which works for me on a basic text template.(this code hasn’t been touched much since 4.2)
Though you’re using an xml(word) document, what is being returned is a session issue error being returned by call to globals(educated guess).
I would expect a php error. Can you check your php error log. Please i’m only interested in errors, no warnings or notices.

Also, can you share the document/template you’re trying to render here?

Hi Jerry,

Below the logview and template/ document I want to fetch …
Logview.docx (21.5 KB)

Template/ document …
Aanvraagformulier MRI onderzoe2.docx (18.1 KB)

And the template with .odt
Aanvraagformulier MRI onderzoek1.odt (21.7 KB)

Hi Jerry,
Above I have a logview and template/document I try to render.
Is this the logview you mentioned?

Morning Rick,
Nope I was looking for your php error log. No worries for now. I was able to restore my 4.2.2 dev version, wow, that brings back memories. :slight_smile: and will see what I see.
Stay tuned.

@rickzimm
Are you using Miscellaneous->Document Templates or download via Patient Documents?
I can download but template tags aren’t substituting (that I can figure out) however, not recreating your issue.

Sure would be nice to get a look at your php error log after the template download failure!
On windows and xampp, log can be retrieved via xampp control panel under Logs->PHP or file path
\xampp\php\logs most likely…

Oh, check out coming to 5.0.3 and may patch to 5.0.2:

I also downloaded via Patients documents and I placed the document directly in the folder via FTP. The idea is to use the keywords, which saves time to fill in separately. The fetch option should work with keywords. FYI The openemr application is installed on an external server by a provider, not installed on my computer with xampp.
I tried to find the php error log in Windows and installed xampp on my PC. However, for both, I cannot find a php error log on my pc.

To make sure … tags (substitution) are the same as keywords?

Php logs will be on external providers server. Works for me. Tags/keywords/thingamajigs all the same.
Best to upload your template using Miscellaneous->Document Templates upload so ensure file permission will be correct. Have you tried this?

Also uploaded the template as mentioned. Uploading works fine, downloading will give the same warning. Note: the placed document via FTP, I also gave it unlimited permission, same warning still exists.
Can I retrieve the php logs via FTP or PHPMyAdmin?

Yes if you can find the log. On ubuntu most likely at /var/log/apache2. If windows server I don’t know. Depends where admin set them up. We don’t want access log but error log. Try Google for various o.s paths containing php logs.

Sofar no error logs found. The folder in the /var/logs is empty. It’s a Unix and appache configuration.
I have sent an email to my provider for helping me out about the error logs. I will keep you updated …

Hi @rickzimm
I tried your template on my v5.0.2 ubuntu 16.04 production server with a failure. Not same as you ie Site ID is missing from session data! but, a corrupted word doc instead!!

It’s your symptom “Site ID is missing from session data!” that has me befuddled. Does this appear in the document that is finally downloaded? Can you put a screenshot up of the downloaded doc result?

Do you have any custom code? If so, anything that would affect documents etc?

I planned to stick this issue out with you as i’m a tenacious old man. :slight_smile: I may need to send you a custom script with some troubleshooting hooks…

Also, can you get to a terminal(ssh) to run command line search. (for error logs)

It appears in the document as a result: Doc1.docx (149.1 KB)

Do you mean custom code in the document that will be fetched?
Sofar as I know there is no custom code, what kind of custom code are you thinking about?

I have a windows computer and as connection I use the app FillZilla client. I don’t have access to a terminal. What I can do is installing PuTTY, to make unix commands possible. Is that workable?

Thank you for helping me out!

By custom code I mean in addition to released OpenEMR code.
If you have SFTP/FTP then good chance SSH is enabled. No worries now though but if I were you i’d set myself up with putty access.
With fillzilla you should be able to find error logs or goto /etc/php5/apache2/php.ini or /etc/php/apache2/php.ini (depends on how installed) if this is ubuntu and look for error_log in ini file. default is error_log = /var/log/php_errors.log I think.
If the logs were never turned on, now’s your chance. Like I said, Google is your friend and should help once you know what OS your using.

Meantime, now I know that the error is written in your document then I may be able to recreate.
Also, have you tried another simple text document with maybe just the patient name tag/keyword?
Try that.

There is no additional code implemented in openemr.

The logs folder is still empty, because it’s not enabled … I will use google to find a solution how to enable this.

I also have tried a simple text document … unfortunately with the same result.

Note: there is no php.ini file, I use htaccess, will use this to enable error logs.
Will keep you posted!

Found a good site over Advanced PHP Error Handling via htaccess:
Advanced PHP Error Handling via htaccess

Hi Rick,
I love our forum application. Probably one of the best in the wild but, I have got to figure out how to dictate, instead of type. :slight_smile:

I have tested this issue everyway I can think to test. I can’t even force the error. I believe this will come down to something in your environment/setup.
Couple points:

  • Error log will most likely help solve.
  • Something is amiss with your temp directory. Path AppData/Temp suggests PHP can’t create the file from the tempnam file path. Meaning it will fall back to a system default. From manual:
    Note : If PHP cannot create a file in the specified dir parameter, it falls back on the system default. On NTFS this also happens if the specified dir contains more than 65534 files.

In your download dialog the extra extension to filename in header that reads “name-form.odt.openem”, our code does not add that extension.

  • Note also the filename in the right error alert “gaSCA65C.odt.part”. We prepend the temp file with ‘OED’ e.g $fname = tempnam($GLOBALS[‘temporary_files_dir’], ‘OED’); and it looks like app is trying to download a multipart file or fails during start of download i.e the added ext .part!
  • Go to temp directory on local and note if there are any abandoned temp files. Also, clear temp folders.
  • You could try hard coding a known good path for temp files in source file interface/patient_file/download_template.php $fname = tempnam($someknownpath, ‘OED’);

Best I can do for now.

Hi Jerry,
Started to figure out the temp file part.

  • .part extensie is added by Firefox, in case of: a partly download or the right sources are not installed on the computer or a virus or the file is damaged. In this case the right app is on my computer: firefox. So naming and add the .part extensie (gaSCA65C.odt.part) does Firefox.

  • Cleared the local temp folder. The issue still exist after clearing temp folder.

I prepared the server for error logs using the instructions mentioned https://perishablepress.com/advanced-php-error-handling-via-htaccess/#comments].
Later today, I hope to have a PHP error log …

I will keep you posted, thank you very much for helping!

Yes but FF/browser should not be changing temp file name! Those are set in the header for the download.
Also remember that you need to create an empty file in the log directory for the php error file name you setup. Apache won’t create for you and will appear as if php logs aren’t turned on(I believe)…

Bring up your browser console then download template and checkout the request url header to see exactly what is being sent to browser. See screenshot below.

Is there a way to alter this temp filename in FF, without the.part?

I have created an empty file in the log folder. Should there any code in there, or just complete empty?

Below the print-screens including the browser console info:
1st: info only when the warning appears;
2nd: info after the warning is turned off.

AD 1. afbeelding
AD 2.

Can you make something out of it?

Question regarding …
You could try hard coding a known good path for temp files in source file interface/patient_file/download_template.php $fname = tempnam($someknownpath, ‘OED’);
You mean to change ($GLOBALS[‘temporary_files_dir’] into a path to the local temp folder on my computer? Absolute path?