c# - Better method of handling/reading these files (HCFA medical claim form) -



c# - Better method of handling/reading these files (HCFA medical claim form) -

i'm looking suggestions on improve approaches handling scenario reading file in c#; specific scenario people wouldn't familiar unless involved in health care, i'm going give quick explanation first.

i work health plan, , receive claims doctors in several ways (edi, paper, etc.). paper form standard medical claims "hcfa" or "cms 1500" form. of our contracted doctors utilize software allows claims generated , saved in hcfa "layout", in text file (so, think of beingness paper form, without background/boxes/etc). i've attached image of dummy claim file shows like.

the claim info extracted text files , converted xml. whole process works ok, i'd create improve , easier maintain. there 1 major challenge applies scenario: each doctor's office may submit these text files in different layouts. meaning, doc might have patient's name on line 10, starting @ character 3, while doc b might send file name starts on line 11 @ character 4, , on. yes, should doing enforcing standard layout must adhered doctors wish submit in manner. however, management said (the developers) had handle different possibilities ourselves , may not inquire them special, want maintain relationships.

currently, there "mapping table" set 1 row each different doctor's office. table has columns each field (e.g. patient name, fellow member id number, date of birth etc). each of these gets value based on first file received doc (we manually set map). so, column patient_name might defined in mapping table "10,3,25" meaning name starts on line 10, @ character 3, , can 25 characters long. has been painful process, both in terms of (a) creating map each doc - tedious, , (b) maintainability, alter layout , have remap whole thing doctor.

the file read in, line line, , each line added

list<string>

once done, following, map info , read through list of file lines , field values (recall each mapped field value "10,3,25" (without quotes)):

claimmap m = claimmap.getmapfordoctor(17); list<hcfa_claim> claimset = new list<hcfa_claim>(); foreach (list<string> cl in claims) //claims list<list<string>>, have list<string> each claim in text file (it can have more one, , file split separate claims before in process) { hcfa_claim c = new hcfa_claim(); c.patient = new patient(); c.patient.fullname = cl[int32.parse(m.name.split(',')[0]) - 1].substring(int32.parse(m.name.split(',')[1]) - 1, int32.parse(m.name.split(',')[2])).trim(); //...and on... claimset.add(c); }

sorry long...but felt background/explanation necessary. there better/more creative ways of doing this?

you need work on dry (don't repeat yourself) principle separating concerns. example, code posted appears have explicit knowledge of:

how parse claim map, and how utilize claim map parse list of claims.

so there @ to the lowest degree 2 responsibilities straight relegated 1 method. i'd recommend changing claimmap class more representative of it's supposed represent:

public class claimmap { public claimmapfield name{get;set;} ... } public class claimmapfield { public int startingline{get;set;} // have parser subtract 1 when creating this, create 0-based. public int startingcharacter{get;set;} public int maxlength{get;set;} }

note claimmapfield represents in code spent considerable time explaining in english. reduces need lengthy documentation. m.name.split calls can consolidated single method knows how create claimmapfields out of original text file. if ever need alter way claimmaps represented in text file, have alter 1 point in code.

now code more this:

c.patient.fullname = cl[map.name.startingline].substring(map.name.startingcharacter, map.name.maxlength).trim(); c.patient.address = cl[map.address.startingline].substring(map.address.startingcharacter, map.address.maxlength).trim(); ...

but wait, there's more! time see repetition in code, that's code smell. why not extract out method here:

public string parsemapfield(claimmapfield field, list<string> claim) { homecoming claim[field.startingline].substring(field.startingcharacter, field.maxlength).trim(); }

now code can more this:

hcfa_claim c = new hcfa_claim { patient = new patient { fullname = parsemapfield(map.name, cl), address = parsemapfield(map.address, cl), } };

by breaking code smaller logical pieces, can see how each piece becomes easy understand , validate visually. cut down risk of copy/paste errors, , when there bug or new requirement, typically have alter 1 place in code instead of every line.

c# file text

Comments

Popular posts from this blog

delphi - blogger via idHTTP : error 400 bad request -

c++ - compiler errors when initializing EXPECT_CALL with function which has program_options::variables_map as parameter -

How do I check if an insert was successful with MySQLdb in Python? -