# krushnamajhi/hl7-dotnetcore architecture

> Architecture diagram of the GitHub repository krushnamajhi/hl7-dotnetcore, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/krushnamajhi/hl7-dotnetcore
- Repository: https://github.com/krushnamajhi/hl7-dotnetcore

## Overview

HL7-dotnetcore is a lightweight .NET library for constructing, parsing, inspecting, modifying, and serializing HL7 2.x messages; it does not provide transport or version-specific conformance validation. The principal workflow is a caller supplying a message to `Message`, which parses it into nested segment/field/component data for access and edits, then serializes it again. The README also documents MLLP frame extraction and ACK/NACK generation. The graph reflects the sampled implementation; some `Message` operations are only partially excerpted, so uncertain internal call paths are omitted.

Main entry points: [`src/MessageHelper.cs`](https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/MessageHelper.cs) (MessageHelper), [`src/Message.cs`](https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/Message.cs) (Message), [`src/Field.cs`](https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/Field.cs) (Field), [`src/Segment.cs`](https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/Segment.cs) (Segment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_message_api["Message API"]
  node_message["Message<br/>[Message.cs]"]
  node_ack["ACK / NACK<br/>[Message.cs]"]
end

subgraph group_model["Message Model"]
  node_segment["Segment<br/>[Segment.cs]"]
  node_field["Field<br/>[Field.cs]"]
  node_component["Component<br/>[Component.cs]"]
  node_subcomponent["SubComponent<br/>[SubComponent.cs]"]
  node_element["MessageElement<br/>[MessageElement.cs]"]
  node_collections["Element collections<br/>[FieldCollection.cs]"]
end

subgraph group_utilities["Encoding Utilities"]
  node_encoding["HL7Encoding<br/>[Encoding.cs]"]
  node_helper["MessageHelper<br/>[MessageHelper.cs]"]
  node_errors["HL7Exception<br/>[HL7Exception.cs]"]
end

node_caller(("Library caller"))
node_mllp_peer(("MLLP frame source"))

node_caller -->|"supplies message"| node_message
node_message -->|"parses segments"| node_segment
node_message -->|"serializes segments"| node_segment
node_message -->|"splits message"| node_helper
node_message -->|"evaluates delimiters"| node_encoding
node_message -->|"creates response"| node_ack
node_segment -->|"parses fields"| node_field
node_segment -->|"splits fields"| node_helper
node_field -->|"parses components"| node_component
node_field -->|"parses repetitions"| node_field
node_field -->|"splits values"| node_helper
node_component -->|"parses subcomponents"| node_subcomponent
node_component -->|"splits values"| node_helper
node_component -->|"decodes values"| node_encoding
node_segment -->|"stores fields"| node_collections
node_field -->|"stores components"| node_collections
node_caller -->|"extracts MLLP"| node_helper
node_mllp_peer -->|"provides frames"| node_helper
node_helper -->|"returns messages"| node_caller
node_caller -->|"frames message"| node_helper
node_helper -->|"returns bytes"| node_caller
node_caller -->|"accesses or edits"| node_message
node_message -->|"returns serialization"| node_caller

click node_message "https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/Message.cs"
click node_ack "https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/Message.cs"
click node_segment "https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/Segment.cs"
click node_field "https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/Field.cs"
click node_component "https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/Component.cs"
click node_subcomponent "https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/SubComponent.cs"
click node_element "https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/MessageElement.cs"
click node_collections "https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/FieldCollection.cs"
click node_encoding "https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/Encoding.cs"
click node_helper "https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/MessageHelper.cs"
click node_errors "https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/HL7Exception.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_message,node_ack toneBlue
class node_segment,node_field,node_component,node_subcomponent,node_element,node_collections toneAmber
class node_encoding,node_helper,node_errors toneMint
class node_caller,node_mllp_peer toneIndigo
```

## Components

### Message API

- [Message](https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/Message.cs): `src/Message.cs`
- [ACK / NACK](https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/Message.cs): `src/Message.cs`

### Message Model

- [Segment](https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/Segment.cs): `src/Segment.cs`
- [Field](https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/Field.cs): `src/Field.cs`
- [Component](https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/Component.cs): `src/Component.cs`
- [SubComponent](https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/SubComponent.cs): `src/SubComponent.cs`
- [MessageElement](https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/MessageElement.cs): `src/MessageElement.cs`
- [Element collections](https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/FieldCollection.cs): `src/FieldCollection.cs`

### Encoding Utilities

- [HL7Encoding](https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/Encoding.cs): `src/Encoding.cs`
- [MessageHelper](https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/MessageHelper.cs): `src/MessageHelper.cs`
- [HL7Exception](https://github.com/krushnamajhi/hl7-dotnetcore/blob/master/src/HL7Exception.cs): `src/HL7Exception.cs`

### Other components

- **Library caller**
- **MLLP frame source**

## Connections

- Library caller → Message: supplies message
- Message → Segment: parses segments
- Message → Segment: serializes segments
- Message → MessageHelper: splits message
- Message → HL7Encoding: evaluates delimiters
- Message → ACK / NACK: creates response
- Segment → Field: parses fields
- Segment → MessageHelper: splits fields
- Field → Component: parses components
- Field → Field: parses repetitions
- Field → MessageHelper: splits values
- Component → SubComponent: parses subcomponents
- Component → MessageHelper: splits values
- Component → HL7Encoding: decodes values
- Segment → Element collections: stores fields
- Field → Element collections: stores components
- Library caller → MessageHelper: extracts MLLP
- MLLP frame source → MessageHelper: provides frames
- MessageHelper → Library caller: returns messages
- Library caller → MessageHelper: frames message
- MessageHelper → Library caller: returns bytes
- Library caller → Message: accesses or edits
- Message → Library caller: returns serialization
