Does anyone know of a way to export all of the images in a patient's chart to individual image files? We can identify these images very easily using the script below, but decoding the VARBINARY IMAGE column and turning each one into an image file on a drive is giving us difficulties. I created an SSIS package to export these files, but this just produces a lot of files that cannot be opened by an image viewer.
Has anyone ever successfully done this? Before I have someone go image by image and use the Windows Snipping Tool on each, I wanted to see if anyone has a better solution.
This looks like it can be done on Oracle, but I'm looking for a solution for SQL Server: https://centricityusers.com/forum/retrieve-docimages/
SELECT IMAGE , TITLE as ImageName
FROM DOCIMAGES I
WHERE I.PID = 'PID GOES HERE'
I was able to get an image out of the CPS demo database using this. BPC should be installed on a machine where SQL Server Management Studio is. After running the command the 4 prompts came up. I hit enter for all but the prefix-length where I entered 0. Ended up with a picture of soap bubbles:
D:\Program Files\Microsoft SQL Server\110\Tools\Binn>bcp "SELECT IMAGE FROM dbo.DOCIMAGES where PIC_ID = 1418292919001310" queryout "d:\pdf\test.jpg" -S localhost -d demo -U sa -P password
Enter the file storage type of field IMAGE [varbinary(max)]:
Enter prefix-length of field IMAGE [8]: 0
Enter length of field IMAGE [0]:
Enter field terminator [none]:
Do you want to save this format information in a file? [Y/n] n
Starting copy...
1 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total : 328 Average : (3.05 rows per sec.)
D:\Program Files\Microsoft SQL Server\110\Tools\Binn>
There were my references:
https://blog.falafel.com/liberate-files-sql-varbinary/