public static async Task Run([BlobTrigger("hl7data/{name}", Connection = "hl7landingblobconn")] Stream myBlob, string name, [CosmosDB( databaseName: "hl7jsondb", collectionName: "hl7messages", ConnectionStringSetting = "CosmosDBConnection")] DocumentClient client, ILogger log) { string requestBody = await new StreamReader(myBlob).ReadToEndAsync(); JObject jobj = HL7ToXmlConverter.ConvertToJObject(requestBody); var inserted = await client.UpsertDocumentAsync(UriFactory.CreateDocumentCollectionUri("hl7jsondb", "hl7messages"), jobj); log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes"); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req, ILogger log) { log.LogInformation("C# HL7toJSON HTTP trigger function fired"); string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); try { JObject o = HL7ToXmlConverter.ConvertToJObject(requestBody); return(new JsonResult(o["hl7message"])); } catch (Exception e) { log.LogError(e, e.Message); return(new BadRequestObjectResult("Error: " + e.Message)); } }
// <span class="code-SummaryComment"><summary></span> /// Converts an HL7 message into a JSON Object from it's XML representation of the same message. /// <span class="code-SummaryComment"></summary></span> /// <span class="code-SummaryComment"><param name="sHL7">The HL7 to convert</param></span> /// <span class="code-SummaryComment"><returns></returns></span> public static string ConvertToJSON(string sHL7) { JObject o = HL7ToXmlConverter.ConvertToJObject(sHL7); return(JsonConvert.SerializeObject(o["hl7message"])); }