Anders,
I understand that Elizabeth and Kevin were discussing the option of having you use knitr for the letter, which is a good idea. But here is my solution via Javascript. Although I'm sure there are other more optimal ways of coding this, the idea is still pretty good to use.
The structure is setup in two parts:
1. The customize participant view that will have javascript code to obtain the participantId from the URL.
2. The wiki page that will then take that participantId, perform a query using the Javascript API against that participantId, then populate the values in the wiki as a letter.
To use the code, the following needs to be done before you begin:
1. You will need to know what dataset you want to pull information from. In my example, I added additional fields to my Demographics dataset (First Name, Last Name, etc) and updated a few of my records to have actual values there.
2. You will need to create a wiki page for the letter.
Once you have taken care of those two pre-requisites, you can use the attached javascript code examples and customize them as you need to.
In my example, this is what the code does:
1. I access my participant record and the javascript code within the Customized Participant View adds a link that points to a wiki I made earlier and pushes that participant ID into it:
Screenshot -
http://awesomescreenshot.com/0a64bz3x45
The URL that the link points to looks like this:
http://localhost:8080/labkey/wiki/home/Demo%20Study/page.view?name=Letter&participantId=125478&_print=1
2. The wiki page then obtains the participant ID and uses it in the Javascript API as a filter for its query.
3. I allowed the wiki page to first show me the results of the query (the instructions on how to do this is explained in the code), which looked like this:
125478 ARV urn:lsid:labkey.com:Study.Data-25:5001.125478 2008/04/28 00:00:00 74 123 Main St 98125 WA John Seattle m Smith
4. So the query provided extra data that I didn't need, so I then made the wiki page show me the results again using another format (also explained in the code), which renders like this:
This is 125478
This is ARV
This is urn:lsid:labkey.com:Study.Data-25:5001.125478
This is 2008/04/28
This is 00:00:00
This is 74
This is 123
This is Main
This is St
This is 98125
This is WA
This is John
This is Seattle
This is m
This is Smith
This then lets me see what values I have to use for my actual letter.
5. I then format the HTML code for the letter and then let the wiki page render one final time, which gives me a printable screen:
Screenshot -
http://awesomescreenshot.com/0144bz4t30
---------
Definitely give this a consideration along with the knitr one as well to determine what will work best for your internal workflows.
Let me know if you have any further questions.
Regards,
Jon