Guest User

Untitled

a guest
Feb 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. unit jms;
  2.  
  3. interface
  4.  
  5. procedure ParseProcessedFile (const filename : string;
  6. each_line : ProcessedLineCallback);
  7.  
  8. implementation
  9.  
  10. uses
  11. sysutils;
  12.  
  13. type
  14. HeaderLineType = record
  15. p_last_name : string;
  16. p_first_name : string;
  17. dos_from : TDateTime;
  18. dos_to : TDateTime;
  19. p_address : string;
  20. p_city : string;
  21. p_state : string;
  22. p_zip : string;
  23. f_name : string;
  24. f_address : string;
  25. f_city : string;
  26. f_state : string;
  27. f_zip : string;
  28. account_number : string;
  29. in_out_network : Boolean;
  30. claim_id : longint;
  31. end;
  32.  
  33. DetailLineType = record
  34. dos_from : TDateTime;
  35. dos_to : TDateTime;
  36. description : string;
  37. revenue_code : string;
  38. hcpcs_cpt_code : string;
  39. modifiers : string;
  40. units : string;
  41. unit_price : string;
  42. charges : string;
  43. tiff_id : string;
  44. end;
  45.  
  46. TotalLineType = record
  47. file_date : string;
  48. detail_line_count : string;
  49. summary_line_count : string;
  50. end;
  51.  
  52. ProcessedLineType = record
  53. pdf_filename : string;
  54. claim_id : longint;
  55. file_id : longint;
  56. returned_date : TDateTime;
  57. end;
  58.  
  59. ProcessedLineCallback = procedure (line : ProcessedLineType);
  60.  
  61. function JmsDateToDate (const date_str : string) : TDateTime;
  62. var
  63. yr, mo, da : word;
  64.  
  65. begin
  66. Val(Copy(date_str, 0, 2), yr);
  67. Val(Copy(date_str, 3, 2), mo);
  68. Val(Copy(date_str, 5, 2), da);
  69.  
  70. JmsDateToDate := EncodeDate (2000 + yr, mo, da);
  71. end;
  72.  
  73. function ParseProcessedLine (const line : string) : ProcessedLineType;
  74. var
  75. underscore_pos : integer;
  76. period_pos : integer;
  77. pipe_pos : integer;
  78.  
  79. begin
  80. underscore_pos := Pos('_', line);
  81. period_pos := Pos('.', line);
  82. pipe_pos := Pos('|', line);
  83.  
  84. Val(Copy(line, 0, underscore_pos-1), ParseProcessedLine.claim_id);
  85. Val(Copy(line, underscore_pos+1, period_pos-underscore_pos-1),
  86. ParseProcessedLine.file_id);
  87.  
  88. ParseProcessedLine.pdf_filename := Copy(line, 0, pipe_pos-1);
  89. ParseProcessedLine.returned_date := JmsDateToDate(Copy(line, pipe_pos+1, 6));
  90. end;
  91.  
  92. procedure ParseProcessedFile (const filename : string; each_line : ProcessedLineCallback);
  93. var
  94. F : text;
  95. L : string;
  96. processed_line : ProcessedLineType;
  97.  
  98. begin
  99. Assign (F, filename);
  100. Reset (F);
  101.  
  102. while not Eof (F) do
  103. begin
  104. Readln (F, L);
  105. processed_line := ParseProcessedLine (L);
  106. each_line (processed_line);
  107. end;
  108. end;
  109.  
  110. begin
  111. end.
Add Comment
Please, Sign In to add comment