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

(Rick) #1

Looking for a someone who can help solving this issue described below …

Saw that there are already topics with more or less the same subject, however not a suitable solution for this example.

I try to use a template with keywords in the subject “documents” for a specific client. Do the procedure as mentioned in: https://www.open-emr.org/wiki/index.php/Templates_for_Patient_Documents.

After selecting a template and fetch I receive the warning: see attached document.

After closing the warning, the file could be downloaded, however instead of the document text, the following text appears in the document:
Site ID is missing from session data!

See details in attachment (print screen)

Can anyone help me out?

OpenEMR Version
Using openemr version 4.2.2

I’m using: Firefox

Operating System
I’m using: windows 10



Left block:
open “name-form.odt”

Right block:
C;\Users…odt.part could not be saved, because the source file could not be read.
try again later, or contact the server administrator.

After closing the warning, the file could be downloaded, however instead of the document text, the following text appears: Site ID is missing from session data!

(Donna Robinson) #2

I’ve seen this error often due to a simple caching issue. Try to clear your cache in the browser.

(Rick) #3

Hi Donna,
Thank you for your response. Unfortunately, the catching didn’t do the trick.

Do you have any other ideas?

(Jerry P) #4

This is kicked off via a smarty template. Try clearing smarty cache at:

(Rick) #5

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

Do you have any other ideas?

(Jerry P) #6

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?

(Rick) #7

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)

(Rick) #8

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

(Jerry P) #9

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.

(Jerry P) #10

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:

(Rick) #11

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?

(Jerry P) #12

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?

(Rick) #13

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?

(Jerry P) #14

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.

(Rick) #15

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 …

(Jerry P) #16

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)

(Rick) #17

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!

(Jerry P) #18

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.

(Rick) #19

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

(Jerry P) #20

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.