How To Generate a 999/997 Acknowledgement EDI Data Using NodeJS

In this tutorial we’ll discuss how generate a 999 or 997 Acknowledgement EDI using NodeJS.  After validating EDI data using the EDIValidator component acknowledgment data can be generated.

EDIValidator takes two parameters, a validation rules file and the EDI data to validate.   The overall validation process looks like the diagram below.

 

 

A validation rule file contains all the data elements, segments, and loop meta data pertaining to a specific implementation guide.

The first step is to load and validate EDI data.  In this tutorial we will validate  5010 271 EDI data.

The Code

const edi = require(‘rdpcrystal-edi-library’);
const fs = require(‘fs’);
 
//Create a validator instance

let validator = new edi.EDIValidator();

//Load a 5010 270 Validation Rules File
let validationRules = fs.readFileSync(‘Validation Rules/5010/Rules_5010_270_005010X279A1.Rules’).toString();

//Set the validation rules data
//Validation rules are found in the RDPCrystalInstallation\Validation Rules directory
validator.EDIRulesFileData = validationRules;
 
//Validate and also load the data into memory
validator.LoadValidatedData = true;
 
//Set EDI data to load and validate
validator.EDIDataString = “ISA*00*……….*01*SECRET….*ZZ*SUBMITTERS.ID..*ZZ*RECEIVERS.ID…*030101*1253*^*00501*000000905*1*T*:~” +
    “GS*Hk*SENDER CODE*RECEIVERCODE*19991231*0802*1*X*005010X279A1~” +
    “ST*271*1234*005010X279A1~” +
    “BHT*0022*13*10001234*20060501*1319~” +
    “HL*1**20*1~” +
    “NM1*PR*2*ABC COMPANY*****PI*842610001~” +
    “HL*2*1*21*1~” +
    “NM1*1P*2*BONE AND JOINT CLINIC*****SV*2000035~” +
    “HL*3*2*22*0~” +
    “TRN*1*93175-012547*9877281234~” +
    “NM1*IL*1*SMITH*ROBERT****MI*11122333301~” +
    “DMG*D8*19430519~” +
    “DTP*291*D8*20060501~” +
    “EQ*30~” +
    “SE*13*1234~” +
    “GE*1*1~” +
    “IEA*1*000000905~”;
 
validator.validate();

The second step is to generate 999 Acknowledgement data from the EDIValidator

The Code

let ack999Generator = new edi.Ack999Generator();
let ackDocument = ack999Generator.generate(validator);
 
console.log(ackDocument.generateEDIData());

Sample 999 Output

ISA*00*……….*01*SECRET….*ZZ*RECEIVERS.ID…*ZZ*SUBMITTERS.ID..*190828*1207*^*00501*       1*1*T*:~GS*FA*RECEIVERCODE*SENDER CODE*20190828*1207*1*X*005010X231A1~ST*999*   1*005010X231A1~AK1*HS*1*005010X279A1~AK2*271*1234*005010X279A1~IK5*A~AK9*P*1*1*1~SE*6*   1~GE*1*1~IEA*1*        1~

 

Similarly the Ack997Generator component can be used to generate 997 Acknowledgment data.

Now that was easy!

 

 

Take Charge Of EDI

RDPCrystal EDI Library

trial2