# Logic for parsing HL7 Message

{% hint style="info" %}
Rooster may receive HL7 messages with different segments than those extracted from your interface system. For example, while the ordering doctor may be in PRT 2 in your HL7, our system retrieves it from ORC12.1 instead.
{% endhint %}

| Accession No                                                                                                                          | <p>LIS & others - OBR 3.1<br>Beaker - ORC 4.1<br></p>                                                                                                                       |
| ------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| orderedByMCR / ordering doctor                                                                                                        | <p>LIS & others - OBR 16.1<br>Beaker & RIS - ORC 12.1</p>                                                                                                                   |
| orderedLocation                                                                                                                       | ORC 13                                                                                                                                                                      |
| <p>hospitalService<br><br>AKA specialtyCode<br></p>                                                                                   | <p>Everything else: PV1 10<br><br><strong>RAD (rispacs)</strong>: PV1 52</p>                                                                                                |
| patientUIN                                                                                                                            | <p>PID 3.1<br><br><br><strong>NOTE:</strong> ADT uses PID 2.1 because it’s ngemr, lab is sap</p>                                                                            |
| patientBirthdate                                                                                                                      | PID 7                                                                                                                                                                       |
| MSH Timestamp                                                                                                                         | MSH 7                                                                                                                                                                       |
| message control ID                                                                                                                    | MSH 10                                                                                                                                                                      |
| procedureCode                                                                                                                         | OBR 4.1                                                                                                                                                                     |
| specimen source                                                                                                                       | SPM 8.2 if exists, else OBR 15                                                                                                                                              |
| specimen type                                                                                                                         | SPM 4.2                                                                                                                                                                     |
| specimen collection time                                                                                                              | SPM 17                                                                                                                                                                      |
| testResultCode (**lab**)                                                                                                              | OBX 3.1                                                                                                                                                                     |
| <p>testResultValue (<strong>lab / ecg</strong>)<br><br>will either be string or number depending on filter for testResultCode<br></p> | <p>OBX 5<br><br><br><strong>NOTE:</strong> if OBX 2 is “SN”, it’s a structured number eg. a ratio, safe to remove all the <code>^</code> delmiters and read as a string</p> |
| testResultValue (**rad / pathology**)                                                                                                 | OBX 8                                                                                                                                                                       |
| r1Flag (**rad**)                                                                                                                      | ZPF 3                                                                                                                                                                       |
| admitDatetime                                                                                                                         | PV1.44                                                                                                                                                                      |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://guide.rooster.gov.sg/testing-and-system-logic/logic-for-parsing-hl7-message.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
