testhl7

package
v0.0.0-...-e69eef7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2023 License: Apache-2.0 Imports: 5 Imported by: 5

Documentation

Overview

Package testhl7 contains utility functions and helpers for testing with HL7 messages.

Index

Constants

View Source
const (
	// https://corepointhealth.com/resource-center/hl7-resources/hl7-msh-message-header
	// The message type field here is set to a placerholder "%s". Users should set this type based
	// on the message type they want to parse, e.g. ADT^A01 or ORU_R01.
	//                ┌ Encoding Characters
	//                |     ┌ Sending Application
	//                |     |   ┌ Sending Facility
	//                |     |   |   ┌ Receiving Application
	//                |     |   |   |        ┌ Receiving Facility
	//                |     |   |   |        |    ┌ Date/Time Of Message
	//                |     |   |   |        |    |              ┌ Security
	//                |     |   |   |        |    |              |┌ Message Type
	//                |     |   |   |        |    |              ||  ┌ Message ControlID
	//                |     |   |   |        |    |              ||  |                      ┌ Processing ID
	//                |     |   |   |        |    |              ||  |                      | ┌ Version ID
	//                |     |   |   |        |    |              ||  |                      | |   ┌ Sequence Number
	//                |     |   |   |        |    |              ||  |                      | |   |┌ Continuation Pointer
	//                |     |   |   |        |    |              ||  |                      | |   ||┌ Accept Acknowledgment Type
	//                |     |   |   |        |    |              ||  |                      | |   |||  ┌ Application Acknowledgment Type
	//                |     |   |   |        |    |              ||  |                      | |   |||  |┌ Country Code
	//                |     |   |   |        |    |              ||  |                      | |   |||  ||  ┌ Character Set
	TemplateMSH = "MSH|^~\\&|SAP|SFA|RECEAPPL|RFAC|20141128001635||%s|2014112800163507740000|T|2.3|||AL||44|ASCII"

	// https://corepointhealth.com/resource-center/hl7-resources/hl7-pv1-patient-visit-information-segment
	//               ┌ ID
	//               │ ┌ Patient Class
	//               │ │         ┌ Assigned Patient Location
	//               │ │         │                                       ┌ Admission Type
	//               │ │         │                                       │   ┌ Preadmit Number
	//               │ │         │                                       │   │┌ Prior Patient Location
	SegmentPV1 = "PV1|1|INPATIENT|SFA 10 EAST^Bay01^Bed10^SFA RF^^BED^SFA|28b||^^^^^^" +

		"" + "|C3335432^Jensen^Mark^^^^^^NHSCSLTNBR^PRSNL^^^NONGP^~891257458214^Jensen^Mark^^^^^^DRNBR^PRSNL^^^ORGDR^" +

		"" + "|C3335432^Jensen^Mark^^^^^^NHSCSLTNBR^PRSNL^^^NONGP^~891257458214^Jensen^Mark^^^^^^DRNBR^PRSNL^^^ORGDR^" +

		"" + "||361||||19||||INPATIENT|6153479^^^^VISITID|||||||||" +

		"" + "|||||||||||SFA RF||ACTIVE|||20141127180000"

	// https://corepointhealth.com/resource-center/hl7-resources/hl7-obr-segment
	//               ┌ ID
	//               │ ┌ Placer Order Number
	//               │ │              ┌ Filler Order Number
	//               │ │              │┌ Universal Service ID
	//               │ │              ││                   ┌ Priority
	//               │ │              ││                   │  ┌ Requested Date/Time
	//               │ │              ││                   │  │              ┌ Observation Date/Timer
	//               │ │              ││                   │  │              │              ┌ Observation End Date/Time
	//               │ │              ││                   │  │              │              │              ┌ Collection Volume
	//               │ │              ││                   │  │              │              │              │┌ Collector Identifier
	//               │ │              ││                   │  │              │              │              ││┌ Specimen Action Code
	//               │ │              ││                   │  │              │              │              │││┌ Danger Code
	//               │ │              ││                   │  │              │              │              ││││┌ Relevant Clinical Info.
	//               │ │              ││                   │  │              │              │              │││││┌ Specimen Received Date/Time
	//               │ │              ││                   │  │              │              │              ││││││┌ Specimen Source
	//               │ │              ││                   │  │              │              │              │││││││      ┌ Ordering Provider
	//               │ │              ││                   │  │              │              │              │││││││      │               ┌ Order Callback Phone Number
	//               │ │              ││                   │  │              │              │              │││││││      │               │┌ Placer Field 1
	//               │ │              ││                   │  │              │              │              │││││││      │               ││┌ Placer Field 2
	//               │ │              ││                   │  │              │              │              │││││││      │               │││┌ Filler Field 1
	//               │ │              ││                   │  │              │              │              │││││││      │               ││││┌ Filler Field 2
	//               │ │              ││                   │  │              │              │              │││││││      │               │││││┌ Results Rpt/Status Chng - Date/Time
	//               │ │              ││                   │  │              │              │              │││││││      │               ││││││              ┌ Charge to Practice
	//               │ │              ││                   │  │              │              │              │││││││      │               ││││││              │┌ Diagnostic Serv Sect ID
	//               │ │              ││                   │  │              │              │              │││││││      │               ││││││              ││  ┌ Result Status
	SegmentOBR = "" /* 145-byte string literal not displayed */

	// http://hl7-definition.caristix.com:9010/Default.aspx?version=HL7+v2.3.1&segment=ORC
	//               ┌ ID
	//               │ ┌ Placer Order Number
	//               │ │              ┌ Filler Order Number
	//               │ │              │      ┌ Placer Group Number
	//               │ │              │      │┌ Order status
	//               │ │              │      ││ ┌ Response Flag
	//               │ │              │      ││ │┌ Quantity/Timing
	//               │ │              │      ││ ││┌ Parent Order
	//               │ │              │      ││ │││┌ Transaction Date/Time
	SegmentORC = "ORC|1|20060307110114|XXYYZZ||A||||20060307110114"

	// http://hl7-definition.caristix.com:9010/HL7%20v2.3.1/segment/AL1
	//                 ┌ Allergy Type
	//                 │
	//                 │    ┌ Allergy Identifier, Description and Coding System
	//                 │    │								                                               ┌ Allergy Severity
	//                 │    │								                                               │      ┌ Allergy Reaction
	//                 │    │								                                               │      │    ┌ Allergy Identification Date
	//                 │    │								                                               │      │    │
	SegmentAL1 = "AL1|1|DRUG|##NOMEN##,AL1,ceStruct,allergy,1234,1234567^penicillin^ALLERGY|SEVERE|rash|20180428000000"

	// http://hl7-definition.caristix.com:9010/HL7%20v2.3.1/segment/OBX
	//               ┌ Value Type
	//               │    ┌ Observation Identifier
	//               │    │                            ┌ Observation Sub-ID
	//               │    │                            │┌ Observation Value
	//               │    │                            ││   ┌ Units
	//               │    │                            ││   │           ┌ Reference Range
	//               │    │                            ││   │           │        ┌ Abnormal Flags
	//               │    │                            ││   │           │        │ ┌ Probability
	//               │    │                            ││   │           │        │ │┌ Nature of Abnormal
	//               │    │                            ││   │           │        │ ││┌ Observation Result Status
	//               │    │                            ││   │           │        │ │││ ┌ Date Last Obs Normal Values
	//               │    │                            ││   │           │        │ │││ │┌ User Defined Access Checks
	//               │    │                            ││   │           │        │ │││ ││┌ Date/Time of the Observation
	//               │    │                            ││   │           │        │ │││ │││┌ Producer's ID
	//               │    │                            ││   │           │        │ │││ ││││┌ Responsible Observer
	//               │    │                            ││   │           │        │ │││ │││││
	SegmentOBX  = "OBX|1|NM|lpdc-2012^Creatinine^WinPath||112|UMOLL^UMOLL|66 - 112|A|||F|||||"
	SegmentOBX2 = "OBX|2|ST|testcode^^system||text content||||||F|||||"
	SegmentOBX3 = "OBX|3|DT|testcode^name of testcode^system||20130707||||||F|||||"
	SegmentOBX4 = "OBX|4|TS|testcode^name of testcode^system||20121201120200||||||F|||||"
	SegmentOBX5 = "OBX|5|NM|lpdc-2012^Creatinine^WinPath||[12.0]|UMOLL^UMOLL|66 - 112|A|||F|||||"
	SegmentOBX6 = "OBX|6|ST|testcode^name of testcode^system||text content~||||||F|||||"
	SegmentOBX7 = "OBX|7|NM|lpdc-2012^Creatinine^WinPath||  [12.0]  |UMOLL^UMOLL|66 - 112|A|||F|||||"
	// http://hl7-definition.caristix.com:9010/HL7%20v2.3.1/segment/NTE
	//                 ┌ Source of Comment
	//                 │ ┌ Comment
	//                 │ │                         ┌ Comment Type
	SegmentNTE = "NTE|1|L|NOTE: Submission of serum|"
	// https://corepointhealth.com/resource-center/hl7-resources/hl7-pid-segment
	SegmentPID = "" /* 365-byte string literal not displayed */
	//                  ┌ Reason ID
	//                  │        ┌ Reason Text
	//                  │        │          ┌ Reason Code System
	SegmentPV2  = "PV2||1|reasonID^reasonText^reasonCodeSystem||||||||||||||||||||^^718004"
	SegmentEVN  = "EVN|A01|20151127180000|||216865551019^ZZZDOCTOR^Foo^Bar Baz^^^^^DRNBR^PRSNL^^^ORGDR^"
	SegmentNK11 = "" /* 141-byte string literal not displayed */
	SegmentNK12 = "" /* 132-byte string literal not displayed */
	//                 ┌ Order discipline
	SegmentZCM = "ZCM|1|discipline||||"
)

Variables

View Source
var SegmentMSH = fmt.Sprintf(TemplateMSH, "ADT^A01")

SegmentMSH is an arbitrary MSH segment, for when the type does not matter.

Functions

func AccountStatus

func AccountStatus(t *testing.T, message string) string

AccountStatus returns the PV1.AccountStatus.

func AllAL1

func AllAL1(t *testing.T, message string) []*hl7.AL1

AllAL1 returns all AL1 segments.

func AllDG1

func AllDG1(t *testing.T, message string) []*hl7.DG1

AllDG1 returns all DG1 segments.

func AllOBX

func AllOBX(t *testing.T, message string) []*hl7.OBX

AllOBX returns all OBX segments.

func AllPR1

func AllPR1(t *testing.T, message string) []*hl7.PR1

AllPR1 returns all PR1 segments.

func DeathIndicator

func DeathIndicator(t *testing.T, message string) string

DeathIndicator returns the PatientDeathIndicator.

func DeathTime

func DeathTime(t *testing.T, message string) *time.Time

DeathTime returns the PatientDeathIndicator.

func EVN

func EVN(t *testing.T, message string) *hl7.EVN

EVN returns the message's EVN segment.

func EventDateTime

func EventDateTime(t *testing.T, message string) time.Time

EventDateTime returns the event's date time.

func Fields

func Fields(t *testing.T, messages []string, f func(*testing.T, string) string) []string

Fields computes the given function that returns strings for each message.

func FirstName

func FirstName(t *testing.T, message string) string

FirstName returns the patient's first name from the message.

func MRG

func MRG(t *testing.T, message string) *hl7.MRG

MRG returns the message's MRG segment.

func MRN

func MRN(t *testing.T, message string) string

MRN returns the patient identifier.

func MSA

func MSA(t *testing.T, message string) *hl7.MSA

MSA returns the message's MSA segment.

func MSH

func MSH(t *testing.T, message string) *hl7.MSH

MSH returns the message's MSH segment.

func MessageControlIDFromMSA

func MessageControlIDFromMSA(t *testing.T, message string) string

MessageControlIDFromMSA returns the message control ID from the MSA segment.

func MessageControlIDFromMSH

func MessageControlIDFromMSH(t *testing.T, message string) string

MessageControlIDFromMSH returns the message control ID from the MSH segment.

func MessageDateTime

func MessageDateTime(t *testing.T, message string) time.Time

MessageDateTime returns the message's date time.

func MessageType

func MessageType(t *testing.T, message string) string

MessageType returns this message's message type.

func OBR

func OBR(t *testing.T, message string) *hl7.OBR

OBR returns the message's OBR segment.

func OBX

func OBX(t *testing.T, message string) *hl7.OBX

OBX returns the message's OBX segment.

func OBXFields

func OBXFields(t *testing.T, messages []string, f func(*testing.T, *hl7.OBX) string) [][]string

OBXFields applies the function f to all of the OBX segments in the messages.

func OBXFieldsFromOBXs

func OBXFieldsFromOBXs(t *testing.T, obxs []*hl7.OBX, f func(*testing.T, *hl7.OBX) string) []string

OBXFieldsFromOBXs applies the function f to all of the given OBX segments.

func OBXResultStatus

func OBXResultStatus(t *testing.T, obx *hl7.OBX) string

OBXResultStatus returns the observation result status.

func OBXSetID

func OBXSetID(t *testing.T, obx *hl7.OBX) string

OBXSetID returns the OBX's SetID.

func ORC

func ORC(t *testing.T, message string) *hl7.ORC

ORC returns the message's ORC segment.

func ObservationValue

func ObservationValue(t *testing.T, message string) string

ObservationValue returns this message's OBX observation value.

func OrderStatus

func OrderStatus(t *testing.T, message string) string

OrderStatus returns OrderStatus from the ORC segment.

func PID

func PID(t *testing.T, message string) *hl7.PID

PID returns the message's PID segment.

func PV1

func PV1(t *testing.T, message string) *hl7.PV1

PV1 returns the message's PV1 segment.

func PV2

func PV2(t *testing.T, message string) *hl7.PV2

PV2 returns the message's PV2 segment.

func PV2OrNil

func PV2OrNil(t *testing.T, message string) *hl7.PV2

PV2OrNil returns the message's PV2 segment, or nil if there's no PV2 segment.

func Parse

func Parse(t *testing.T, message string) *hl7.Message

Parse parses the given message.

func PatientClass

func PatientClass(t *testing.T, message string) string

PatientClass returns the PV1.PatientClass.

func PlacerNumber

func PlacerNumber(t *testing.T, message string) string

PlacerNumber returns the PlacerOrderNumber.

func PointOfCare

func PointOfCare(t *testing.T, message string) string

PointOfCare returns the point of care from the PV1.AssignedPatientLocation.

func PriorPatientIdentifierList

func PriorPatientIdentifierList(t *testing.T, message string) []string

PriorPatientIdentifierList returns the PriorPatientIdentifierList from the MRG segment.

func SendingApplication

func SendingApplication(t *testing.T, message string) string

SendingApplication returns the message's sending application.

func SendingFacility

func SendingFacility(t *testing.T, message string) string

SendingFacility returns the message's sending facility.

func TXA

func TXA(t *testing.T, message string) *hl7.TXA

TXA returns the message's TXA segment.

func TimeFields

func TimeFields(t *testing.T, messages []string, f func(*testing.T, string) *time.Time) []*time.Time

TimeFields computes the given function that returns times for each message.

func ValueType

func ValueType(t *testing.T, obx *hl7.OBX) string

ValueType returns the OBX's observation value type.

func VisitNumber

func VisitNumber(t *testing.T, message string) string

VisitNumber returns the VisitNumber ID.

Types

type Sender

type Sender struct {
	// contains filtered or unexported fields
}

Sender is an hl7.Sender that saves all sent messages in a list.

func SenderWithError

func SenderWithError(err error) *Sender

SenderWithError returns a Sender that returns the provided error when Send() is invoked.

func (*Sender) Close

func (s *Sender) Close() error

Close is no-op.

func (*Sender) EraseSentHistory

func (s *Sender) EraseSentHistory()

EraseSentHistory erases the history of sent messages.

func (*Sender) GetSentMessages

func (s *Sender) GetSentMessages() []string

GetSentMessages returns the messages sent by this sender.

func (*Sender) Send

func (s *Sender) Send(message []byte) error

Send saves all sent messages to a list if s.err is nil. Otherwise, it returns s.err.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL