Azure FHIR: Get RawResource in Plain Text - azure

I've just started my research on the "Azure FHIR SQL Server Version".
I had some issues trying to get the Json Resource in plain text, since It is stored compressed in the database (as shown in the following lines):
select r.RawResource from dbo.Resource r where r.IsHistory=0 and r.IsDeleted=0;
RAWRESOURCE
0x1F8B080000000000000A8492CB4EC2501086E7519AAE344122F7E04A4274618C90C8CEB8282D60136E2985A08477F79B39A71513D034E77466CECC3FFF5C0E124A2613D9C84AB64831F2483E65CD3F943BCE00EB4C22594A2A5FFC73FE2BB4502A9C5412EF579786B4898AA4234DEE1BB99531783152137B225DA431D6485A481DF408FB546AC8131FD9F0B839FA9E5BB10FDC1B64CDBD4572F966782C3999D9153F9463C949DF94E994A33E1AF366483BFCE7E014F5D561D4E2AB733A76B7398AF56E68111528D2CE47E4A069B4BE2D795D94487D7053EB538C3D300E01D608CEAABF4A0FCDD5A71C527B71CCFE8B0E3D1BAD74CE8999C1E2A4AA0D33D31E4DBC3564821F362765573953F71575D7E49A1C4D3EED429BBBEBBB781E53A50886F30B982F641C59C7356F1F2DB3ED5AC93DF32A62AB25FBCB99A6F8EEFFC8129CE409E4D17BFFCC2CE1737B5D7458F3B80E3B1CED790FEC2AF14F44ECFCA60432B49D4A2CCB83E7159035C352B50D69A10FE0A8B10DEB63319F18949C6A1CD36734ADDAD5B126DEEDF1DC7AA35BFADB2F00BDE3BDB5475BDBE2ACC41B1AC3ADAFF428DF000000FFFF
I tried different ways to get it, however no one was successful.
select cast(r.RawResource as varchar(max)) VarcharResource,
CONVERT(varchar(max), r.RawResource, 0) VarcharResource2
from dbo.Resource r where r.IsHistory=0 and r.IsDeleted=0;
VarcharResource2
‹ „’ËNÂP†çQš®4A""÷àJBtaŒÈθ(-`n)… „w÷›9§Ð4çtfÎÌ?ÿ\J&ÙÈJ¶H1òH>eÍ?”;Î ëL""YJ*_üsþ+´P*œTïW—†´‰Š¤#M1x1R{""]¤1ÖHZHôûTjÈÙð¸9úž[±ÜdͽErùfx,9™Ù?”cÉIߔ锣>ófH;üçàõÕaÔâ«s:v·9Šõnh(ÒÎGä i´¾-y]”H}pSëSŒ=0ÖΪ¿JÍÕ§R{qÌþ‹=­tΉ™Á⤪3ÓM¼5d‚6'eW9S÷u×äšM>íB›»ë»xS¥†ó˜/dYÇ5o-³íZÉ=ó*b«%ûË™¦øîÿÈœä äÑ{ÿÌ,ás{]tXó¸;íyì*ñODìü¦2´J,˃ç5ÃRµi¡à¨±ëc1Ÿ”œjÓg4­ÚÕ±&ÞíñÜz£[úÛ/ ½ã½µG[Ûâ¬Äí¯ô(ß ÿÿ
Anybody knows the correct way to get back the Json in plain text?
Thanks

The resources are Gzipped, so something like:
string rawResource;
using (rawResourceStream)
using (var gzipStream = new GZipStream(rawResourceStream, CompressionMode.Decompress))
using (var reader = new StreamReader(gzipStream, ResourceEncoding))
{
rawResource = await reader.ReadToEndAsync();
}

Related

AzureIoTHub: How to send telemetry data in JSON format?

I used the example repo of Azure für sending telemetry data: https://github.com/Azure/azure-iot-arduino/tree/master/examples/esp8266/iothub_ll_telemetry_sample
I did not modify any code. This is the important part:
const char* telemetry_msg = "test_message";
message_handle = IoTHubMessage_CreateFromString(telemetry_msg);
result = IoTHubDeviceClient_LL_SendEventAsync(device_ll_handle, message_handle, send_confirm_callback, NULL);
Why does my body-result looks like an ASCII array? (Note: Using Azure IoT explorer)
Is it meant to be an array like this. Do I have to unpack this array on the other side?
I want to be able to send the data in JSON format like the azure device simulator does:
Nevermind, figured it out. The following example will send data in JSON format:
char telemetry_msg_buffer[80];
sprintf(telemetry_msg_buffer, "{\"temperature\":11.11,\"humidity\":12.12,\"scale\":\"13.13\"}");
message_handle = IoTHubMessage_CreateFromString(telemetry_msg_buffer);

Parse attribute of Media Element

I want to parse url attribute from the XML and show image in image control (the one reffered to by the URL) in listbox from the following feed link: http://feeds.bbci.co.uk/news/rss.xml
My code is:
var ComingNewsFromUri = from rss in XElement.Parse(e.Result).Descendants("item")
select new NewsItems
{
Title = rss.Element("title").Value,
PubDate = rss.Element("pubDate").Value,
Description = rss.Element("description").Value
};
For RSS, I would recommend using SyndicationFeed and SyndicationItem....does all the parsing and converting to objects automatically and brilliantly for you.
http://ryanhayes.net/blog/how-to-build-an-rss-feed-reader-in-windows-phone-7part-i-retrieving-parsing-and-displaying-post-titles/
I have an RSS feed app on the store myself using SyndicationFeed and it is very reliable and convenient.
Here is another sample by Microsoft
http://code.msdn.microsoft.com/wpapps/RSS-Reader-Sample-1702775f

Reading Signature lines using OpenXMlSDK

I just started office development and have been trying to read a word 2013 document that holds signature fields in it using open xml sdk
can some one help me how to do that.
using (var document = WordprocessingDocument.Open(#"D:\Temp_Folder\tempfile.docx", false))
{
var docPart = document.MainDocumentPart;
}
I have tried reading word file using ELdos (SBOffice) I can get signature lines but not able to get full details related to Signature Lines like Suggested Signer and Suggested Signer email.
Can some one suggest me which I have to prefer OpenXMLSDK or Eldos(SBOffice) bcz i need to find signature fields and then sign them by custom certificate using Third party Signing Service.
The best way would be to use the OpenXMLSDKTool to open the document and it will show you the code necessary to replicate it. I believe it would be within a shape something like
using (var document = WordprocessingDocument.Open("YourDoc.docx", false)
{
var signature = document.MainDocumentPart.Document.Descendant<DocumentFormat.OpenXML.VML.Office.SignatureLine>().FirstOrDefault();
var suggestedSigner = signature.SuggestedSigner;
var suggestedSignerTitle = signature.SuggestedSigner2;
var suggestedSignerEmail = signature.SuggestedSIgnerEmail;
}
You could get the actual signature image in this same area.

Reading/Editing XLIFF using C#

I need to parse an XLIFF file using C#, but I'm having some trouble. These files are fairly complex, containing a huge amount of nodes.
Basically, all I need to do is read the source node from each trans-unit node, do some processing on it, and insert the processed text into the corresponding target node (which will always be present, but empty).
An example of one of the nodes I need to parse would be (the whole file may contain 100s of these):
<trans-unit id="0000000002" datatype="text" restype="string">
<source>Windows Update is not installed</source>
<target/>
<iws:segment-metadata tm_score="0.00" ws_word_count="6" max_segment_length="0">
<iws:status target_content="placeholders_only"/>
</iws:segment-metadata>
<iws:boundary-seg sequence="bs20721"/>
<iws:markup-seg sequence="0000000001">
</trans-unit>
The trans-unit nodes can be buried deep in the files, the header section contains a lot of data. I'd like to use LINQ to XML to read the data, but I'm not having any luck getting it to work. Here's my current code (just trying to read and output the source nodes from the file:
XDocument doc = XDocument.Load(path);
Console.WriteLine("Before loop");
foreach (var transUnitNode in doc.Descendants("trans-unit"))
{
Console.WriteLine("In loop");
XElement sourceNode = transUnitNode.Element("source");
XElement targetNode = transUnitNode.Element("target");
Console.WriteLine("Source: " + sourceNode.Value);
}
I never see 'In loop' and I don't know why, can someone tell me what I'm doing wrong here, or suggest a better way to achieve what I'm trying to do here?
Thanks.
Try
XNamespace df = doc.Root.Name.Namespace;
foreach (XElement transUnitNode in doc.Descendants(df + "trans-unit"))
{
XElement sourceNode = transUnitNode.Element(df + "source");
// and so one, use the df namespace object to qualify any elements names
}
See also http://msdn.microsoft.com/en-us/library/bb387093.aspx.

How to get the blob data from Oracle in C#4.0?

Here i have a requriment to read the data from Oracle DB.In that one column is defined as BLOB.using that data i need to frame the insert query like this "insert into emp values('100','John',EMP_PIC);
Here emp_pic is defined as BLOB.Please suggest me some idea's about this.I am using C#4.0.
perhaps you can use this sample project based on this link. I hope this help.
http://www.codeproject.com/Articles/13365/Insert-retrieve-an-image-into-from-a-blob-field-in
if you wanna get value from blob data using OracleDataReader just convert first byte to image using this:
private Image byteArrayToImage(byte[] byteArrayIn)
{
MemoryStream ms = new MemoryStream(byteArrayIn);
ms.Position = 0;
Image returnImage = Image.FromStream(ms);
return returnImage;
}
then read data blob like this:
picFileData.Image = byteArrayToImage(dr["EMP_PIC"] as byte[]); // dr is OracleDataReader dr;
picFileData is PictureBox from visual studio and EMP_PIC is blob column in Oracle
Try to use LINQ to SQL. This is very useful.

Resources