anchor.diff:                  current_medicalno=MedicalNo,
                   records=RecordToAdd ++ Records0}
       end,
  -
       C#ctx{line_no = LineNo+1}.
  +
  +%% @doc The data file may have records that should be same key but in
  +%% un-sorted order; merge all of them here.
  +merge_same_keys([], Acc) ->
  +    Acc;
  +merge_same_keys([H|L], []) ->
  +    merge_same_keys(L, [H]);
  +merge_same_keys([H1|L1], [H2|L2] = Acc) ->
  +    case {dpcs_ff1:key(H1), dpcs_ff1:key(H2)} of
  +        {K, K} ->
  +            merge_same_keys(L1, [dpcs_ff1:merge(H1, H2)|L2]);
  +        _ ->
  +            merge_same_keys(L1, [H1|Acc])
  +    end.
   
   -spec new(Cocd :: iolist(),
             Kanjaid :: iolist(),
  
positive.code: from_file(Filename, [YYYYMM, _HospitalID], _Logger) ->
      F = fun(Line, Ctx) ->  parse_line(Line, YYYYMM, Ctx) end,
      {ok, Ctx1} = japanese:fold_all_lines(Filename, F, #ctx{}),
      #ctx{records=Records, line_no=_LineNo} = Ctx1,
      {ok, lists:reverse(Records)}.
  
  -spec from_file(filename:filename(), list(), pid(), fun()) -> {ok, #dpcs_ff1{}}.
  
negative.code:     end.
  
  -spec merge(#dpcs_ff1{}, #dpcs_ff1{}) -> #dpcs_ff1{}.
  merge(#dpcs_ff1{key=K, cocd=C, kanjaid=Kid, stay=Stay1, wards=Wards1} = L,
        #dpcs_ff1{key=K, cocd=C, kanjaid=Kid, stay=Stay2, wards=Wards2}) ->
      Stay = case {Stay1, Stay2} of
                 {_, null} -> Stay1;
                 {null, _} -> Stay2;
                 {{S1}, {S2}} -> {orddict:merge(S1, S2)}
             end,
      Wards = Wards1 ++ Wards2,
      L#dpcs_ff1{stay=Stay, wards=Wards}.
  
  -spec merge_fields(orddict:orddict(), orddict:orddict()) -> orddict:orddict().
  merge_fields(LFields, RFields) ->
  