Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Extra Scripts

Add the modifier "Modify Message with HL7 Script" in this window you can add Pascal Script to change your messages

How to use Pascal Script

→ Medical-Objects Transformation IDE →→ write codes(refers to the following examples) → (open HL7 test data) → Load a HL7 test data → (execute script) → → check Input/Output Message in

 


Script Examples

Add TimeZone

No Format
program AddTimeZone;           
                                                                                  
begin                                     
   HL7Data['MSH.6.0'] := AddSpecificTimezone(HL7Data['MSH.6.0'], '+0800');
   HL7Data['OBR.6.0'] := AddLocalTimezone(HL7Data['OBR.6.0']);
end.

Replace TimeZone

No Format
program FixTimeZone;           
                                                                                   
begin                                     
    HL7Data['MSH.6.0'] := HL7TSChangeTimeZoneToLocal(HL7Data['MSH.6.0']);
    HL7Data['OBR.6.0'] := HL7TSChangeTimeZone(HL7Data['OBR.6.0'], '+1200');
    HL7Data['OBR.7.0'] := HL7TSChangeTimeZone(HL7Data['OBR.7.0'], '+1100');
end.

Replace GUID

No Format
program FixGUID;
 
begin
    if(HL7Data['MSH.3.0'] = 'Noosa Radiology') and (HL7Data['MSH.3.0.2'] = 'A5B87B80649C452B-CB015EAA-45934D8F-BE54A230-867A1430A8FCF3A54F99A9D4') then
       HL7Data['MSH.3.1'] := 'X-RAY and Imaging^B960B3FB-7D68-44F1-AFAC-9C64C7ED11D2^GUIDPractice Name^F2107173-8A7B-4C5D-A055-CB5C79C76B7E^GUID';

end.

This program will find the specific GUID in the Sending Facility and replace it with the GUID of your choice. In this case the GUID that we are looking for is Noosa Radiology and it will be replaced with X-Ray and Imaging GUID. 

Copy OBR16 to PV1-9 if PV1-9 target not set

No Format
{ 
  This program copies the provider number from OBR-16 to PV1-9. If PV1 doesnt exist, it will insert it. 
  Only copy the components over if a target ID is not already set in PV1. Try to make it future proof 
  incase the input messages contain PV1-9 values.
}                                                                                                     
   
Program AddPV19;
var 
  i:integer;         
  mshindex: integer;                   
  pv1index:integer;  
  pidindex:integer;  
  targetid: string; 
  j: integer; 

begin             
   pv1index :=-1;
   while i < HL7Data.segmentcount -1 do
   begin
       if HL7Data.segmentname[i] = 'MSH' then
       begin  
           mshindex := i;
           pv1index :=-1;
           pidindex := -1;
       end
       else if HL7data.segmentname[i] = 'PID' then
           pidindex := i
       else if HL7Data.segmentname[i] = 'PV1' then                          
           pv1index :=i
       else if ((HL7Data.segmentname[i] = 'OBR') or (HL7Data.segmentname[i] = 'ORC')) and (pv1index=-1) then
       begin                                   
           HL7Data.insertsegment (PIDINDEX+1, 'PV1');
           pv1index := PIDINDEX+1;
           inc(i);                           
       end;   
       
       if (HL7Data.segmentname[i] = 'OBR') and (pv1index<>-1) then 
       begin     
         if HL7Data.GetFieldvalue(pv1index, 9, 0, 0, 0)=  then
         begin                       
           targetid := HL7Data.GetFieldvalue(i, 16, 0, 0, 0);
           HL7Data.SetFieldvalue(targetid, pv1index, 9,0,0,0); 
           for j := 1 to 6 do
             HL7Data.SetFieldvalue(HL7Data.GetFieldvalue(i, 16, 0, j, 0), pv1index, 9,0,j,0);  
         end;
       end;
       
       inc(i);
   end
end.

 


Available Pascal Scripts

No Format
function HL7TSChangeTimeZoneToLocal(const AHL7TS: string): string;


→ Convert input TimeStamp(AHL7TS) to TimeStamp with local TimeZone

No Format
function HL7TSChangeTimeZone(const AHL7TS: string; const ANewTimeZone: string): string;


→ Convertinput TimeStamp(AHL7TS) to TimeStamp with input TimeZone(ANewTimeZone)

No Format
function AddSpecificTimezone(const AHL7TS, ATimeZone: String): string;


→ Add specific TimeZone information(ATimeZone) to HL7 TimeStamp(AHL7TS)

No Format
function AddLocalTimezone(const AHL7TS: String): string;


→ Add local TimeZone information to HL7 TimeStamp(AHL7TS)

No Format
function StripTimezone(const AHL7TS: String): string;


→ Get and return HL7 TimeStamp without TimeZone information

No Format
function HL7TimeZoneToBiasMinutes(const HL7TimeZone: string): Integer;


→ Calculate bias minutes based on input TimeZone(HL7TimeZone)

No Format
function AgeInYears(ADateOfBirth, ADateOfAge: TDateTime): Integer;


→ Calculate the Age(based on ADateOfBirth and ADateOfAge) in years

No Format
function AgeToDisplayString(ABirthDate, AAgeAtThisDate: TDateTime): string;


→ Converts directly a Age to a display string

No Format
function AutoCompleteDate(const AText: string; AddTime: Boolean = False): string;


→ Adds the next most significant date part with separator

No Format
function DateStrToHL7DT(const AEditText: String; AAccept2DigitYears: Boolean = True; AddTimestamp:Boolean = True): string;


→ Convert a user-input date to a HL7 date string

No Format
procedure ScanDateStr(const ADateStr: string; out ADay, AMonth, AYear: string);


→ Given a delimited date string, returns the day, month and year parts

No Format
function HL7DTDecode(const AHL7DT: string; out AYear, AMonth, ADay: Integer): Boolean;


→ Decode a HL7 date into the year, month and day parts

→ Returns -1 for parts which are not present. If not even a year is present, returns False otherwise True

No Format
function HL7DTEncode(AYear, AMonth, ADay: Integer): string;


→ Encode a HL7 date from the input AYear, AMonth and ADay parts

No Format
function HL7TMDecode(const AHL7TM: string; out AHour, AMinute, ASecond: Integer; out AFractionalSecond: Double): Boolean;


→ Decode a HL7 time into the hour, minute and second parts (with fractional seconds if it exists)

No Format
function HL7TMEncode(AHour, AMinute: Integer; ASecond: Integer = -1; AFractionalSecond: Double = -1): string;


→ Encode a HL7 time from the AHour, AMinuteand and ASecond parts (with fractional seconds if it exists)

No Format
function HL7TSStripTimezone(const AHL7TS: string): string;


→ Return a HL7 TimeStamp without TimeZone

No Format
function HL7TMStripTimezone(const AHL7TM: string): string;


→ Return a HL7 Time without TimeZone

No Format
function HL7TSToLocalTS(const AHL7TS: string; AIncludeTimeZone: Boolean = True): string;


→ Convert a HL7 TimeStamp to local TimeStamp (with or without TimeZone)

No Format
function HL7LocalTimeZone: string;


→ Get and return local TimeZone

No Format
function HL7TimeZoneFromTS(const AHL7TS: string): string;


→ Get and return TimeZone information from the input TimeStamp(AHL7TS)

No Format
function HL7TimeZoneFromTM(const AHL7TM: string): string;


→ Get and return TimeZone information from the input Time(AHL7TM)

No Format
function HL7TMGetFractionalSecond(const AHL7TM: string; out AFractionalSecond: Double): Boolean;


→ Get fractional parts of second and return Boolean value(false or true)

No Format
function HL7TSEncode(AYear: Integer;
AMonth: Integer = -1;
ADay: Integer = -1;
AHour: Integer = -1;
AMinute: Integer = -1;
ASecond: Integer = -1;
AFractionalSecond: Double = -1.0): string;


→ Encode a HL7 TimeStamp from the input AYear, AMonth, ADay, AHour, AMinute, ASecond and AFractionalSecond parts

No Format
function HL7TSAddDay(const ADateStr: string; AIncrement: Integer = +1): string;


→ Add days(AIncrement) to Input(ADateStr) and return the result

→ Takes a HL7 date (or date/time) input and returns a date (or date/time)

No Format
function HL7TSAddMonth(const ADateStr: string; AIncrement: Integer = +1): string;


→ Add months(AIncrement) to Input(ADateStr) and return the result

No Format
function HL7TSAddYear(const ADateStr: string; AIncrement: Integer = +1): string;


→ Add years(AIncrement) to Input(ADateStr) and return the result

No Format
function HL7TSToTDateTime(AHL7DateTime: string): TDateTime;


→ Convert a HL7 TimeStamp(AHL7DateTime) to TDateTime type

No Format
function HL7DTToTDateTime(AHL7Date: string): TDateTime;


→ Convert a HL7 Date(AHL7Date) to TDateTime type

No Format
function HL7TMToTDateTime(AHL7Time: string): TDateTime;


→ Convert a HL7 Time(AHL7Time) to TDateTime type

No Format
function HL7TSToSQLText(const AHL7TS: string): string;


→ Convert a HL7 TimeStamp(AHL7TS) to SQL Text('dd/mm/yyyy')

No Format
function HL7DTToDisplayString(const AHL7DT: string; const ADisplayFormat: string = 'd?m?yyyy'): string;


→ Convert directly from a HL7 Date to a display string

No Format
function HL7TMToDisplayString(const AHL7TM: string; const ADisplayFormat: string = 'hh:nn'): string;


→ Convert directly from a HL7 Time to a display string

No Format
function HL7TSToDisplayString(const AHL7TS: string; const ADisplayFormat: string = 'd.m.yyyy hh:nn'): string;


→ Convert directly from a HL7 TimeStamp to a display string

No Format
function HL7TSToReverseGregorian(const AHL7TS: string): string;


→ Convert HL7 TimeStamp(AHL7TS) to Reverse Gregorian('yyyymmddhhnnsszzz')

No Format
function HL7TSToHL7DT(const AHL7TS: string): string;


→ Convert HL7 TimeStamp(AHL7TS) to HL7 Date

No Format
function HL7TSToHL7TM(const AHL7TS: string): string;


→ Convert HL7 TimeStamp(AHL7TS) to HL7 Time

No Format
function TDateTimeToHL7DT(AInput:TDateTime): string;


→ Convert TDateTime(AInput) to HL7 Date

No Format
function HL7TSToDatabaseText(const AHL7TS: string): string;


→ Convert HL7 TimeStamp(AHL7TS) to Database Text('yyyy-mm-dd hh:mm:ss')

No Format
function HL7TSToTDateTimeDef(AHL7TS: String; Default:TDateTime): TDateTime;


→ Convert a HL7 TimeStamp(AHL7TS) to TDateTime with Default value

No Format
function MedicalDirectorDateToHL7DT(MD_Date:String): string;


→ Convert Medical Director Date to HL7 Date

No Format
function LongMonthStringtoMonth(const AMonth:String): Word;


→ Convert month string to month integer

No Format
function MinutesToHL7TM(const Minutes:Integer): string;


→ Convert minutes(Minutes) to HL7 Time

No Format
function HL7TMtoMinutes(const HL7TM:String): Integer;


→ Convert HL7 Time(HL7TM) to minutes

No Format
function TDateTimeToHL7DateTimeAutoPrecision(AInput: TDateTime; AIncludeTimeZone: Boolean = False): string;


→ Convert TDateTime(AInput) to HL7 DateTime with auto precision step

No Format
function HL7TMtoOBXDisplayString(const AHL7TM:String): string;


→ Convert directly from a HL7 Time to a OBX display string

No Format
function XMLDateTimeToHL7TS(XMLDateTime: String): string;


→ Convert XML DateTime to HL7 TimeStamp

No Format
function DateTimeXMLToString(ADate: TDateTime): string;


→ Convert the TDateTime ADate to a string according to the W3C date/time specification

No Format
function HL7DateToXMLFormat(ADate: String): string;


→ Convert HL7 Date(ADate) to XML format

No Format
function HL7DTAddDays(const AHL7DT: string; Days :integer): String;


→ Add days(Days) to Input(AHL7DT) and return the result

No Format
function IsHL7TSValid(const HL7Date: string): Boolean;


→ Check if HL7 TimeStamp is valid

No Format
function ActualBiasMinutes: Integer;


→ Calculate an actual Bias Minutes based on the status of TimeZone

var

No Format
HL7Data: THL7Scriptable


No Format
THL7Scriptable = class(TObject)
public
constructor Create;
destructor Destroy; override;
procedure Clear;
function ComponentCount(const SegmentIndex: Integer; const FieldNo: Integer;
const RepeatNo: Integer = 0): Integer;
function SubComponentCount(const SegmentIndex: Integer; const FieldNo: Integer;
const RepeatNo: Integer ; const ComponentNo: Integer): Integer;
procedure DeleteRepeat(const SegmentIndex: Integer; const FieldNo: Integer;
const RepeatNo: Integer );
procedure DeleteSegment(const Index: Integer);
function FieldCount(const SegmentIndex: Integer): Integer;
function GetFieldvalue(const SegmentIndex, FieldNo: Integer; const RepeatNo:
Integer = 0; const ComponentNo: Integer = 0; const SubComponentNo: Integer
= 0): string;
function IndexofSegment(const SegmentName: String): Integer;
procedure SetFieldvalue(const Value: String; const SegmentIndex, FieldNo:
Integer; const RepeatNo: Integer = 0; const ComponentNo: Integer = 0; const
SubComponentNo: Integer = 0);
procedure InsertSegment(const Index:Integer; const SegmentName: String);
procedure LoadFromFile(const AFilename: String);
procedure LoadFromStream(AStream: TStream);
function RepeatCount(const SegmentIndex: Integer; const FieldNo: Integer):
Integer;
procedure SaveToFile(const AFilename: String);
function SegmentCount: Integer;
property asString: string read GetasString write SetasString;
property Raw: Boolean read GetRaw write SetRaw;
property SegmentName[Index: Integer]: string read GetSegmentName;
property Value[Index: String]: string read GetValue write SetValue; default;
end;


More functions should be kept updatedThere are more functions. Contact the helpdesk for further assistance.

Table of Contents
outlinetrue
stylenone