How to document Mappings programmatically
Lately I was asked interesting question, the one which has no answer in Chameleon but fairly easy resolved in Iguana Translator.
One wants to have Mappings to be programmatically documented. To add this documentation to given Interface documentation (may be to send it to vendor or to a client? or simply have in-house documentation in good order and human readable form?)
Our famous ‘HL7 to Database’ example got expanded, and here is what I got:
table ['adt_encounter_doctors.doctor_id']='PV1.Referring_Doctor.ID_Number' ['adt_patients.last_name']='PID.Patient_Name.Family_Name.Surname' ['adt_patients.first_name']='PID.Patient_Name.Given_Name' ['adt_addresses.id']='MSH.Message Control ID' ['adt_addresses.street']='PID.Patient_Address.Street_Address.Street_or_Mailing_Address' ['adt_encounter_doctors.id']='PV1.Set_ID_-_PV1' ['adt_patients.dob']='PID.Date/Time_of_Birth' ['adt_patients.gender']='PID.Administrative_Sex'
Neat? I think ‘yes’. Once User has this table populated with plain text, its content can be put to any sort of use. Easily stored as TXT or CSV file, or displayed as HTML, or other usable methods.
All it takes if three simple functions in shared module I named ‘documentMappings’.
Current ‘public’ functions, in this shared module, handle HL7 to DB mappings, taking advantage of three not public functions.
More public functions can be added, to accommodate for other types of data processing, taking advatage of same three internal functions.
Three internal functions are general and can possibly handle both HL7 anbd X12 data. For now I tested with HL7 only, but it should work with X12 too.
Comments welcome, and the project is attached.
Next step is to use data documented by this example for HTML report generated by ‘hl7doc’ module from our Wiki.
We will use ‘Comments’ fields, offered by hl7doc module.
All it takes is to add to module ‘hl7doc’ < http://help.interfaceware.com/kb/181#hierarchical> function:
function hl7doc.setComments(tt,name) for k,v in pairs(tt) do k=name..'_'..k:gsub(' ',''):gsub('%.','_') Comments[k]=v end return Comments end
Call this function from main() by passing as parameter the table returned from ‘documentMappings’ module.
The function dm.returnMappings() returns table of all Mappings, even if they have no data in Fields to map.
The function hl.generateDoc(Msg,’c:\\temp\\z’) builds HTML with Mappings of only populated with data fields.
Project is attached and comments welcome.
Attachments:You must be logged in to view attached files.
You must be logged in to reply to this topic.