Re: [Puma-repository-applications] ORC segment
Pascal Units for Medical Applications
Brought to you by:
jwdietrich
From: Johannes W. D. <joh...@ru...> - 2015-02-19 21:23:35
|
HL7 defines a plethora of segments. The PUMA HL7 engine implements only the most common segment types. It is easy, however, to write your own code for custom segments. There are several ways to achieve this. In theory there are five options, but I recommend that you follow the example of the PV1 segment (see below): Option 1: Define the whole message as text string and create a THL7Message object from this string: const EXAMPLE_SEGMENT1 = 'MSH|^~\&|EPIC|EPICADT|SMS|SMSADT|199912271408|CHARRIS|ADT^A04| 1817457|D|2.5|'; EXAMPLE_SEGMENT2 = 'PID||0493575^^^2^ID 1|454721||DOE^JOHN^^^^|DOE^JOHN^^^^|19480203| M||B|254 MYSTREET AVE^^MYTOWN^OH^44123^USA||(216)123-4567|||M|NON| 400003403~1129086|'; EXAMPLE_SEGMENT3 = 'NK1||ROE^MARIE^^^^|SPO||(216)123-4567|| EC|||||||||||||||||||||||||||'; EXAMPLE_SEGMENT4 = 'PV1||O|168 ~219~C~PMA^^^^^^^^^||||277^ALLEN MYLASTNAME^BONNIE^^^^|||||||||| ||2688684||||||||||||||||||||||||| 199912271408||||||002376853'; EXAMPLE_MESSAGE1 = EXAMPLE_SEGMENT1 + SEGMENT_DELIMITER + EXAMPLE_SEGMENT2 + SEGMENT_DELIMITER + EXAMPLE_SEGMENT3 + SEGMENT_DELIMITER + EXAMPLE_SEGMENT4; var TestHL7Message: THL7Message; TestHL7Message := THL7Message.Create('2.5'); TestHL7Message.contentString := EXAMPLE_MESSAGE1; This is a possible but quite inflexible way that may be not very suitable for most real-world applications. Of course, however, you can replace the constants by variables that result from string operations, which will make this code more flexible. Option 2: Define every segment as string and compose your message from single segments: const EXAMPLE_SEGMENT2 = 'PID||0493575^^^2^ID 1|454721||DOE^JOHN^^^^|DOE^JOHN^^^^|19480203| M||B|254 MYSTREET AVE^^MYTOWN^OH^44123^USA||(216)123-4567|||M|NON| 400003403~1129086|'; var TestHL7Message: THL7Message; TestHL7Message := THL7Message.Create('2.5'); TestHL7Message.AllocSegments(EXAMPLE_SEGMENT2); This approach is somewhat more flexible. Option 3: Construct the segment from single fields and your message from segments as required: const EXAMPLE_FIELD1 = '0493575^^^2^ID 1'; EXAMPLE_FIELD2 = '168 ~219~C~PMA^^^^^^^^^'; EXAMPLE_FIELD3 = 'DOE^JOHN^^^^'; EXAMPLE_FIELD4 = '254 MYSTREET AVE^^MYTOWN^OH^44123^USA'; EXAMPLE_FIELD5 = 'BID&Twice a day at institution specified times&HL7xxx^^^^12^h^Y|'; EXAMOLE_FIELD6 = '13.5&18^M~12.0 & 16^F'; var TestHL7Message: THL7Message; TestHL7Message := THL7Message.Create('2.5'); if TestHL7Message.NewSegment = nil then fail('Segment could not be created.') else begin TestHL7Message.FirstSegment.NewOccurrence(''); if TestHL7Message.FirstSegment.FirstOccurrence = nil then fail('Occurrence could not be created.') else begin TestHL7Message.FirstSegment.FirstOccurrence.NewField; if TestHL7Message.FirstSegment.FirstOccurrence.FirstField = nil then fail('Field could not be created.') else TestHL7Message.FirstSegment.FirstOccurrence.FirstField.contentString := EXAMPLE_FIELD3; end; end; This strategy is even more flexible. Option 4: Gradually construct the message from components: var TestHL7Message: THL7Message; TestHL7Message := THL7Message.Create('2.5'); if TestHL7Message.NewSegment = nil then fail('Segment could not be created.') else begin TestHL7Message.FirstSegment.NewOccurrence(''); if TestHL7Message.FirstSegment.FirstOccurrence = nil then fail('Occurrence could not be created.') else begin TestHL7Message.FirstSegment.FirstOccurrence.NewField; if TestHL7Message.FirstSegment.FirstOccurrence.FirstField = nil then fail('Field could not be created.') else begin TestHL7Message.FirstSegment.FirstOccurrence.FirstField.NewComponent; if TestHL7Message.FirstSegment.FirstOccurrence.FirstField.FirstComponent = nil then fail('Component could not be created') else TestHL7Message.FirstSegment.FirstOccurrence.FirstField. FirstComponent.contentString := 'ROE^MARIE^^^^'; end; end; end; And, of course, option 5 constructs your message from sub-components: var TestHL7Message: THL7Message; TestHL7Message := THL7Message.Create('2.5'); TestHL7Message.AllocSegments('empty'); if TestHL7Message.FirstSegment = nil then fail('Segment could not be created.') else begin if TestHL7Message.FirstSegment.FirstOccurrence = nil then fail('Occurrence could not be created.'); end; begin if TestHL7Message.FirstSegment.FirstOccurrence.FirstField = nil then fail('Field could not be created.') else begin TestHL7Message .FirstSegment.FirstOccurrence.FirstField.AllocComponents(''); if TestHL7Message.FirstSegment.FirstOccurrence.FirstField.FirstComponent = nil then fail('Component could not be created') else begin TestHL7Message.FirstSegment.FirstOccurrence.FirstField. FirstComponent.NewSubComponent; if TestHL7Message.FirstSegment.FirstOccurrence.FirstField. FirstComponent.FirstSubComponent = nil then fail('Subcomponent could not be created') else TestHL7Message.FirstSegment.FirstOccurrence.FirstField. FirstComponent.contentString := 'Thomas&Gregory'; end; end; end; This is the most flexible way to do this. The examples contain "fail" functions for FPCUnit. In productivity code you might want to replace them by code that raises an exception, displays a dialog box, writes to a log file etc. Perhaps the best way to create a segment is to combine the options from above. The "PV1" unit uses the following code: procedure SetPV1(message: THL7message; PV1Record: tPV1); var newSegment: THL7Segment; FieldSep: char; theString: ansistring; begin FieldSep := message.Delimiters.FieldSeparator; newSegment := THL7Segment.Create(message, ''); with PV1Record do theString := PV1_ID + FieldSep + SetID + FieldSep + PatientClass + FieldSep + AssignedPatientLocation + FieldSep + AdmissionType + FieldSep + PreadmitNumber + FieldSep + PriorPatientLocation + FieldSep + AttendingDoctor + FieldSep + ReferringDoctor + FieldSep + ConsultingDoctor + FieldSep + HospitalService + FieldSep + TemporaryLocation + FieldSep + PreadmitTestIndicator + FieldSep + ReadmissionIndicator + FieldSep + AdmitSource + FieldSep + AmbulatoryStatus + FieldSep + VIPIndicator + FieldSep + AdmittingDoctor + FieldSep + PatientType + FieldSep + VisitNumber + FieldSep + FinancialClass + FieldSep + ChargePriceIndicator + FieldSep + CourtesyCode + FieldSep + CreditRate + FieldSep + ContractCode + FieldSep + ContractEffectiveDate + FieldSep + ContractAmount + FieldSep + ContractPeriod + FieldSep + InterestCode + FieldSep + TransferToBadDeptCode + FieldSep + TransferToBadDeptDate + FieldSep + BadDeptAgencyCode + FieldSep + BadDeptTransferAmount + FieldSep + BadDeptRecoveryAmount + FieldSep + DeleteAccountIndicator + FieldSep + DeleteAccountDate + FieldSep + DischargeDisposition + FieldSep + DischargedToLocation + FieldSep + DietType + FieldSep + ServicingFacility + FieldSep + BedStatus + FieldSep + AccountStatus + FieldSep + PendingLocation + FieldSep + PriorTemporaryLocation + FieldSep + AdmitDateTime + FieldSep + DischargeDateTime + FieldSep + CurrentPatientBalance + FieldSep + TotalCharges + FieldSep + TotalAdustments + FieldSep + TotalPayments + FieldSep + AlternateVisitID + FieldSep + VisitIndicator + FieldSep + OtherHealthcareProvider + FieldSep + FieldSep + ServiceEpisodeDescription + FieldSep + ServiceEpisodeID + FieldSep; newSegment.contentString := theString; message.AddSegment(newSegment); end; You may use this example to create an ORC segment. Of course you have to follow the syntax of the official HL7 definition for an ORC segment. Please don't hesitate to ask for more help. Good luck, J. W. D. Am 19.02.2015 um 20:41 schrieb Marek Skorupski: > Hi, > > I'm creating HL7 message and I need use some segments.I found PID, > PV1, > OBR units but I can't find ORC in HL7 engine. Is there any other way > to > read/write ORC? > -- > greetings > > Marek Skorupski > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and > Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & > more > Get technology previously reserved for billion-dollar corporations, > FREE > http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk > _______________________________________________ > Puma-repository-applications mailing list > Pum...@li... > https://lists.sourceforge.net/lists/listinfo/puma-repository-applications -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Dr. med. Johannes W. Dietrich -- Oberarzt / Consultant Endocrinologist -- Laboratory XU44, Endocrine Research -- Medical Hospital I, Bergmannsheil University Hospitals -- Ruhr University of Bochum -- Buerkle-de-la-Camp-Platz 1, D-44789 Bochum, NRW, Germany -- Phone: +49:234:302-6400, Fax: +49:234:302-6403 -- eMail: "j.w...@me..." -- WWW: http://www.thyreologie.com.de -- WWW: http://www.uk.rub.de -- Researcher ID: C-3498-2009 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |