To send an HL7 request to a laboratory, you must send the file to the laboratory, so you must first create the file.
String fileName = "testOrder.txt" StreamWriter sr = new StreamWriter(fileName)
Now add the lines one by one, the first line should be MSH (message header tag), which looks like this: MSH | ^ ~ \ & amp; | HDL | LCA | Lis | TEST9999 | 199807311532 || ORU ^ R01 | 3629 | P | 2.2
so your line of code will look like this:
sr.WriteLine("MSH|^~\&|" + _YOURAPPLICATIONNAME + "|" + _YOURHOSPITAL + "|" + _RECEIVINGAPPLICATIONNAME + "|" + _RECEIVINGLAB + "|" + _DATETIME + "||ORU^R01|" + _IDOFORDERINYOURDATABASE + "|P|2.2");
Then you need to add the PID line to your file, for example: PID | 2 | 2161348462 | 20809880170 | 1614614 | 20809880170 ^ TESTPAT || 19760924 | M ||| ^^^^ 00000-0000 ||||||| 86427531 ^^^ 03 | SSN # HERE
therefore, you must tell your stream entry to write the line above in the file, but obviously also change the values ββin this line, as you did for the MSH segment, the PID specifications can be found at http://www.corepointhealth.com/resource-center / hl7-resources / hl7-pid-segment
After that, you need to add the lines ORC and OBR to the file as: ORC | Nw | 8642753100012 ^ LIS | 20809880170 ^ HDL |||||| 19980727000000 ||| HAVILAND OBR | 1 | 8642753100012 ^ LIS | 20809880170 ^ LCS | 008342 ^ TOP RESPIRATORY CULTURE ^ L ||| 19980727175800 |||||| SS # 634748641 CH14885 SRC: THROA SRC: Foam | 19980727000000 |||||| 20809880170 || 19980730041800 || BN | F
Replace the desired values ββin these lines. This will make your test request file complete. If the doctor gave further comments, you can add another line of the NTE tag, for example: NTE | 1 | L | MORAXELLA (BRANHAMELLA) CATARRHALIS
When your file is full, now you can send it to the laboratory, the important thing in your file is ORU ^ R01 in the MSH tag, which tells the laboratory that this is a test request. Later, the laboratory will send you an HL7 file with the same MSH, PID, ORC and OBR tags, as well as OBX tags that will have the test results. In the MSH tag, you sent the order ID of your database, so when the laboratory sends it back, you can check what order this file came for.
You can read the file line by line by dividing the line of each line against "|" and extract the necessary data and put it in the database.
I hope this would give you a better idea of ββwhat and how you should do.