PID and PV1 Segments from HL7 Dictionary

To see the details of the PID segment from the HL7 Dictionary take the following steps:

  1. Select HL7Connect | HL7 Dictionary
  2. When offered the list of versions select 2.3.1
  3. Choose Segments then type PID
  4. You should have the following screen:

    Screen Shot

  5. Repeat the above process to get a view of the PV1 segment

The Conversion Table

From the PID and PV1 segment definitions we determine that the conversion table should be as follows:

Index    Field Name    Location in database
0    SeqNo    Ignored
1    MRN    PID-3-1
2    Surname    PID-5-1
3    Firstname    PID-5-2
4    MiddleNames    PID-5-3
5    Date of Birth    PID-7
6    Sex    PID-8
7    Address1    PID-11-1
8    Address2    PID-11-2
9    Suburb    PID-11-3
10    State    PID-11-4
11    Postcode/Zip Code    PID-11-5
12    Date Registered    Ignored
13    Financial Code    PV1-20

The Conversion Script

The following script populates these values:

Language    Script
VBScript   
    function Convert(aEvent)
      set m = aEvent.Msg
      m.Version = "2.3.1"
      m.Event = "A08"
      m.MessageType = "ADT"
      m.MsgID = "testid"
      m.AddMSHForBuild
      m.AddSegment("EVN")
      m.AddSegment("PID")
      m.AddSegment("PV1")
      m.Element("PID-3-1").AsString  = aEvent.Fields.items(1)        ' MRN
      m.Element("PID-5-1").AsString  = aEvent.Fields.items(2)        ' Surname
      m.Element("PID-5-2").AsString  = aEvent.Fields.items(3)        ' Firstname
      m.Element("PID-5-3").AsString  = aEvent.Fields.items(4)        ' MiddleNames
      m.Element("PID-7").AsString    = aEvent.Fields.items(5)        ' Date of Birth
      m.Element("PID-8").AsString    = aEvent.Fields.items(6)        ' Sex
      m.Element("PID-11-1").AsString = aEvent.Fields.items(7)        ' Address1
      m.Element("PID-11-2").AsString = aEvent.Fields.items(8)        ' Address2
      m.Element("PID-11-3").AsString = aEvent.Fields.items(9)        ' Suburb
      m.Element("PID-11-4").AsString = aEvent.Fields.items(10)       ' State
      m.Element("PID-11-5").AsString = aEvent.Fields.items(11)       ' Postcode
      m.Element("PV1-20").AsString   = aEvent.Fields.items(13)       ' Financial Code
    end function
   
Javascript

  
    function Convert(aEvent){
      var m; // message
      m = aEvent.Msg;
      m.Version = '2.3.1';
      m.Event = 'A08';
      m.MessageType = 'ADT';
      m.MsgID = 'testid';
      m.AddMSHForBuild;
      m.AddSegment('EVN');
      m.AddSegment('PID');
      m.AddSegment('PV1');
      m.Element('PID-3-1').AsString  = aEvent.Fields.items(1);        // MRN
      m.Element('PID-5-1').AsString  = aEvent.Fields.items(2);        // Surname
      m.Element('PID-5-2').AsString  = aEvent.Fields.items(3);        // Firstname
      m.Element('PID-5-3').AsString  = aEvent.Fields.items(4);        // MiddleNames
      m.Element('PID-7').AsString    = aEvent.Fields.items(5);        // Date of Birth
      m.Element('PID-8').AsString    = aEvent.Fields.items(6);        // Sex
      m.Element('PID-11-1').AsString = aEvent.Fields.items(7);        // Address1
      m.Element('PID-11-2').AsString = aEvent.Fields.items(8);        // Address2
      m.Element('PID-11-3').AsString = aEvent.Fields.items(9);        // Suburb
      m.Element('PID-11-4').AsString = aEvent.Fields.items(10);       // State
      m.Element('PID-11-5').AsString = aEvent.Fields.items(11);       // Postcode
      m.Element('PV1-20').AsString   = aEvent.Fields.items(13);       // Financial Code
    };
   

Update the "convert6.js" or "convert6.vbs" with this updated script (This script should replace the previous version).

Running this script will give a screen similar to the following:

Screen Shot


© Kestral Computing P/L 2000-2010.