Skip to content

MedicalEdiFileService

Implements IMedicalEdiFileService, reading and validating EDI 999 functional-acknowledgment files: parsing a file from disk into an Edi999File, checking its envelope/segment structure and batch type, and extracting the acknowledgment status (IK5), rejected-segment details (IK3), and originating batch number (AK1) from its segments.

Purpose

  • Reads a 999 transaction-set file from disk into a strongly typed IEdiFile/Edi999File, logging and rethrowing on read failure.
  • Validates that a parsed EDI file has the expected ISA/IEA envelope structure and matches an expected transaction-set (batch) type.
  • Extracts the originating batch number, acknowledgment response segment, and any rejected (IK3) detail segments from a 999 file.
  • Determines whether an acknowledgment response indicates the original file was accepted or rejected.

Context

  • Namespace: SAIF.Services.Edi
  • Assembly/package: SAIF.Services (packaged inside the SAIF.SAIFCode.Core NuGet package)

Public members

Member Signature Purpose
MedicalEdiFileService(...) public MedicalEdiFileService(IUserProfileService prof) Stores the user-profile collaborator, requiring it to be non-null (the profile itself is not otherwise used by the members shown).
Read999TransactionSet public static IEdiFile Read999TransactionSet(string filepath, ILogWriter controlLog) Reads and parses the EDI file at filepath into an Edi999File, logging the full exception text to controlLog and rethrowing if the read fails.
IsFileStructureValid public bool IsFileStructureValid(IEdiFile file) Returns true when file's first segment is ISA and its last segment is IEA, confirming a well-formed EDI envelope.
IsFileBatchTypeValid public bool IsFileBatchTypeValid(IEdiFile file, string batchType) Returns true when file contains an ST segment whose transaction-set identifier code matches batchType.
GetBatchNumberFrom999File public long GetBatchNumberFrom999File(IEdiFile file) Returns the control number from file's AK1 segment, identifying which original batch this 999 acknowledges.
GetIk5SegmentResponseCode public Ik5Segment GetIk5SegmentResponseCode(IEdiFile file) Returns the parsed IK5 segment (overall acknowledgment response) from file's first matching segment.
IsSegmentValid public bool IsSegmentValid(Ik5Segment ik5Segment) Returns false when ik5Segment is null, true otherwise.
HasFileBeenAccepted public bool HasFileBeenAccepted(Ik5Segment ik5Segment) Returns false when ik5Segment.ResponseCode is "R" (rejected), true for any other response code.
GetIk3Segments public IList<Ik3Segment> GetIk3Segments(IEdiFile file) Returns every IK3 (transaction-set-level rejection detail) segment found in file, parsed to Ik3Segment.

Behavioral notes

  • Read999TransactionSet is exposed both as a public static method and as an explicit IMedicalEdiFileService.Read999TransactionSet interface implementation that simply forwards to the static method, so the interface-typed call and the static call share identical behavior*.
  • Read999TransactionSet uses SAIF.Common.Files.Edi.EdiManager to build and read the file, then wraps the result in Edi999File before returning.
  • HasFileBeenAccepted treats any response code other than the literal "R" as accepted, including unexpected/unknown codes*.

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • Services/SAIF.Services/Edi/MedicalEdiFileService.cs