Guest User

Untitled

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