config

package
v0.0.0-...-a467797 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package config provides functionality for the configuration of Simulated Hospital, especially around loading such configuration from files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadNotesConfig

func LoadNotesConfig(ctx context.Context, directory string) (map[string][]ClinicalNote, error)

LoadNotesConfig loads all the files in the sample notes directory. Each sample note in the directory have to be named in the <filename>.<extension> format. We rely on this formatting to extract the ContentType of the document. Files not named in the right format will be skipped.

Types

type AbnormalFlags

type AbnormalFlags struct {
	AboveHighNormal string `yaml:"above_high_normal"`
	BelowLowNormal  string `yaml:"below_low_normal"`
}

AbnormalFlags are the abnormal flag values to set in the OBX.8 Abnormal Flags field. Values: http://hl7-definition.caristix.com:9010/HL7%20v2.2/table/Default.aspx?version=HL7+v2.2&table=0078

type Address

type Address struct {
	// Cities contains a list of cities for address.
	Cities []string
	// Streets contains a list of street suffixes for addresses.
	Streets []string
	// Country is the Country to set in the XAD.6 Country field.
	Country string
	// Types contains a list of types of addresses to be set in the
	// XAD.7 Address Type field.
	Types []string
}

Address contains data for generating the address.

type ClinicalNote

type ClinicalNote struct {
	DocumentFileName string
	Path             string
	ContentType      string
}

ClinicalNote represents a document that contains a clinical note.

type CodeMapping

type CodeMapping struct {
	FHIR FHIRMapping
}

CodeMapping contains mappings from FHIR to those defined in the HL7 configuration.

type Data

type Data struct {
	Allergy      DataAllergy
	PatientName  PatientName
	Address      Address
	Nouns        []string
	Surnames     []string
	FirstNames   *FirstNamesByCensus
	Diagnoses    []MappableWeightedValue
	Procedures   []MappableWeightedValue
	Allergies    []MappableWeightedValue
	Ethnicities  []sample.WeightedValue
	PatientClass []sample.WeightedValue
	// NotesConfig maps file extensions with available list of sample notes.
	NotesConfig       map[string][]ClinicalNote
	ClinicalNoteTypes []string
}

Data contains data for generating HL7 messages.

func LoadData

func LoadData(ctx context.Context, f DataFiles, hc *HL7Config) (*Data, error)

LoadData loads the data configuration from the given data files.

type DataAllergy

type DataAllergy struct {
	// Reactions contains the possible types of allergy reactions to be set in
	// the AL1.5.AllergyReaction field.
	Reactions []string
	// Percentage is a percentage of people with allergies, from 0 to 100.
	Percentage int
	// MaximumAllergies is the maximum number of allergies generated per person.
	MaximumAllergies int `yaml:"maximum_allergies"`
}

DataAllergy contains data for generating allergies.

type DataFiles

type DataFiles struct {
	DataConfig        string
	Nouns             string
	Surnames          string
	Girls             string
	Boys              string
	Procedures        string
	Diagnoses         string
	Allergies         string
	Ethnicities       string
	PatientClass      string
	SampleNotesDir    string
	ClinicalNoteTypes string
}

DataFiles are the files to load data configuration from. All fields are required.

type DocumentStatus

type DocumentStatus struct {
	// Authenticated means that the document is authenticated.
	Authenticated string `yaml:"authenticated"`
}

DocumentStatus is set in the OBR.25 Result Status field for a Clinical Note.

type FHIRMapping

type FHIRMapping struct {
	CodingSystems map[string]string `yaml:"coding_systems"`
	// AllergySeverities contains the mapping from FHIR allergy severities to those defined in the HL7 configuration.
	// Reference: https://www.hl7.org/fhir/valueset-reaction-event-severity.html
	AllergySeverities map[string][]string `yaml:"allergy_severities"`
	// AllergyTypes contains the mapping from FHIR allergy categories to those defined in the HL7 configuration.
	// Reference: https://www.hl7.org/fhir/valueset-allergy-intolerance-category.html
	AllergyTypes map[string][]string `yaml:"allergy_types"`
}

FHIRMapping contains the mappings from FHIR value sets to those defined in the HL7 configuration.

type FirstNamesByCensus

type FirstNamesByCensus struct {
	Girls *Names
	Boys  *Names
}

FirstNamesByCensus represents Girls and Boys name grouped by their popularity by year.

type Gender

type Gender struct {
	Male    string
	Female  string
	Unknown string
}

Gender are the values to set in the PID.8 Sex field. Values: http://hl7-definition.caristix.com:9010/HL7%20v2.3.1/segment/PID?version=HL7%20v2.3.1&table=0001

type HL7Allergy

type HL7Allergy struct {
	// Types is a list of the possible types of allergy types to be set in the AL1.2.AllergyTypes field.
	Types []string
	// Severities is a list of the possible types of allergy severities to be set in the AL1.4.AllergySeverity field.
	Severities []string
	// CodingSystem is the allergy coding system to be set in the CE.3.NameOfCodingSystem field in the
	// AL1.3.AllergyCode/Mnemonic/Description.
	CodingSystem string `yaml:"coding_system"`
}

HL7Allergy contains the configuration for AL1 segment (allergies).

type HL7Config

type HL7Config struct {
	Allergy HL7Allergy

	Diagnosis HL7Diagnosis

	Document HL7Document

	Procedure HL7Procedure

	OrderControl OrderControl `yaml:"order_control"`

	ResultStatus ResultStatus `yaml:"result_status"`

	DocumentStatus DocumentStatus `yaml:"document_status"`

	OrderStatus OrderStatus `yaml:"order_status"`

	PatientClass PatientClass `yaml:"patient_class"`

	PatientAccountStatus PatientAccountStatus `yaml:"patient_account_status"`

	Gender Gender

	AbnormalFlags AbnormalFlags `yaml:"abnormal_flags"`

	// PrimaryFacility is the patient's primary facility.
	// If none of the PrimaryFacility fields are set, we want the entire PD1.3 Patient Primary Facility field to be
	// empty in the resulting HL7 message instead of a having field with separators but empty values.
	// Making PrimaryFacility a pointer is an easy way to detect when all fields are unset.
	PrimaryFacility *PrimaryFacility `yaml:"primary_facility"`

	// HospitalService is the default value to be set in the PV1.10-Hospital Service field.
	// This is overridden per pathway by the pathway's Consultant.
	HospitalService string `yaml:"hospital_service"`

	// CodingSystem is the default coding system of Order Profiles and their Test Types.
	// It is used to construct the Coded Element.
	CodingSystem string `yaml:"coding_system"`

	Mapping CodeMapping
}

HL7Config is the configuration for HL7 messages where the values are important for HL7 compliance or specific uses of the HL7 standard.

func LoadHL7Config

func LoadHL7Config(ctx context.Context, fileName string) (*HL7Config, error)

LoadHL7Config loads the HL7 configuration from the given file.

type HL7Diagnosis

type HL7Diagnosis struct {
	// Types is a list of the possible types of diagnosis to be set in the DG1.6.DiagnosisTypes field.
	Types []string
	// CodingSystem is the diagnosis coding system to be set in the CE.3.NameOfCodingSystem field in the
	// DG1.3.Diagnosis Code - DG1.
	CodingSystem string `yaml:"coding_system"`
}

HL7Diagnosis is the configuration for DG1 segment (diagnosis).

type HL7Document

type HL7Document struct {
	// Types is the document types to be set in the TXA.2.DocumentType field.
	Types []string
}

HL7Document contains configuration for a TXA segment (document).

type HL7Procedure

type HL7Procedure struct {
	// Types is the possible types of procedure to be set in the PR1.6.ProcedureTypes field.
	Types []string
	// CodingSystem is the procedure coding system to be set in the CE.3.NameOfCodingSystem field in the
	// PR1.3.Procedure Code.
	CodingSystem string `yaml:"coding_system"`
}

HL7Procedure is the configuration for PR1 segment (procedure).

type Header struct {
	// Default is the default configuration for all messages.
	// Required.
	Default HeaderForType `yaml:"default"`
	// ORU is the configuration for ORU messages.
	// Optional. If not present, ORU messages will use the Default.
	ORU *HeaderForType
}

Header contains the configuration of the Message Header (MSH segment).

func LoadHeaderConfig

func LoadHeaderConfig(ctx context.Context, fileName string) (*Header, error)

LoadHeaderConfig loads the Header configuration from the given file.

type HeaderForType

type HeaderForType struct {
	// SendingApplication is the value to set in MSH-3 Sending Application.
	SendingApplication string `yaml:"sending_application"`
	// SendingFacility is the value to set in MSH-4 Sending Facility.
	SendingFacility string `yaml:"sending_facility"`
	// ReceivingApplication is the value to set in MSH-5 Receiving Application.
	ReceivingApplication string `yaml:"receiving_application"`
	// ReceivingFacility is the value to set in MSH-6 Receiving Facility.
	ReceivingFacility string `yaml:"receiving_facility"`
}

HeaderForType contains the fields in the Message Header (MSH segment). All fields must be present.

type MappableWeightedValue

type MappableWeightedValue struct {
	WeightedVal sample.WeightedValue
	Mapping     Mapping
}

MappableWeightedValue is used where a mapping needs to be kept alongside the WeightedValue when loading data.

type Mapping

type Mapping struct {
	Key   string
	Value string
}

Mapping represents a key value pair.

type Names

type Names struct {
	// ByYear contains a list of names that were popular at the time period
	// up to a given year. Eg. if the map contains the following data:
	// 1904: [Mary], 1914: [Dory], 1924: [Florence]
	// it means, that:
	// - Mary was the most popular name in the time period up to 1904, and since
	//   there is no more historical data, it would be also used as the most
	//   popular name for the whole time period preceding 1904,
	// - Dory was the most popular name in the time period between 1905 - 1914,
	// - Florence was the most popular name in the time period between 1915 - 1924
	//   and since there is no newer data, it would be also used as the most
	//   popular name for all the years succeeding 1924.
	// Note that the time periods don't have to be equal in length.
	ByYear map[int][]string
	// All contains the list of all unique names present in ByYear map,
	// regardless of the time period when they were popular.
	All []string
	// MinYear is the minimum year present in the ByYear map.
	MinYear int
	// MaxYear is the maximum year present in the ByYear map.
	MaxYear int
}

Names contains the division of names per year, and a list of all names.

type OrderControl

type OrderControl struct {
	// New represents a New Order.
	New string
	// OK means that the Order/service is accepted & OK.
	OK string
	// WithObservations is the order control value for a status of "Observations/Performed Service to follow" (the results
	// have arrived).
	WithObservations string `yaml:"with_observations"`
}

OrderControl contains the values for the ORC.1 Order Control field. Values: http://hl7-definition.caristix.com:9010/HL7%20v2.3.1/Default.aspx?version=HL7+v2.3.1&table=0119

type OrderStatus

type OrderStatus struct {
	// Completed means that the order is completed.
	Completed string
	// InProcess means that the status is in process, unspecified.
	InProcess string `yaml:"in_process"`
}

OrderStatus for the ORC.5 Order Status field. Values: http://hl7-definition.caristix.com:9010/HL7%20v2.3.1/Default.aspx?version=HL7%20v2.5.1&table=0038

type PatientAccountStatus

type PatientAccountStatus struct {
	// Arrived means that the patient has been admitted.
	Arrived string
	// Cancelled means that the admission has been cancelled, e.g. the visit or a pending admission
	// has been cancelled.
	Cancelled string
	// Finished means that the patient encounter has finished and the patient is no longer admitted.
	Finished string
	// Planned means that the patient is going to be admitted, but it not admitted yet.
	Planned string
}

PatientAccountStatus are the patient account status values to set in the PV1.41.AccountStatus field.

type PatientClass

type PatientClass struct {
	// Outpatient is the default patient class for newly created patients and outpatients.
	Outpatient string
	// Inpatient is the patient class for inpatients (set after an ADT^A01 Admission message).
	Inpatient string
}

PatientClass are the patient class values to set in the PV1.2.PatientClass field. Values: http://hl7-definition.caristix.com:9010/Default.aspx?version=HL7%20v2.5.1&table=0004

type PatientClassAndType

type PatientClassAndType struct {
	Class string
	Type  string
}

PatientClassAndType represents a class and type pair.

type PatientName

type PatientName struct {
	// Degrees contains the list of degrees for patient names.
	Degrees []string
	// DegreePercentage  is a percentage of people with degrees, from 0 to 100.
	DegreePercentage int `yaml:"degree_percentage"`
	// Suffixes contains a list of suffixes for patient names.
	Suffixes []string
	// SuffixPercentage is a percentage of people with suffixes, from 0 to 100.
	SuffixPercentage int `yaml:"suffix_percentage"`
	// FemalePrefixes contains a list of female name prefixes.
	FemalePrefixes []string `yaml:"female_prefixes"`
	// MalePrefixes contains a list of male name prefixes.
	MalePrefixes []string `yaml:"male_prefixes"`
	// MiddlenamePercentage is a percentage of people with middlenames,
	// from 0 to 100.
	MiddlenamePercentage int `yaml:"middlename_percentage"`
}

PatientName contains data for generating patient name.

type PrimaryFacility

type PrimaryFacility struct {
	// OrganizationName is the XON.1 (Organization name).
	OrganizationName string `yaml:"organization_name"`
	// IDNumber is the XON.3 (ID Number).
	// The ID is of type string in the HL7 XON data type:
	// http://hl7-definition.caristix.com:9010/HL7%20v2.3.1/segment/PD1?version=HL7%20v2.3.1&dataType=XON.
	// We use a string because it allows for more generic values.
	IDNumber string `yaml:"id_number"`
}

PrimaryFacility is the Primary Facility to set in the PD1.3 Patient Primary Facility field. Type XON. http://hl7-definition.caristix.com:9010/HL7%20v2.3.1/segment/PD1

type RecordWithFreq

type RecordWithFreq struct {
	Value  map[string]string
	Weight uint
}

RecordWithFreq stores a record as a list of strings (e.g. from CSV) and its associated frequency value.

type ResultStatus

type ResultStatus struct {
	// Final means that the results are stored and verified. Can only be changed with a corrected result.
	Final string
	// Corrected means that the record coming over is a correction and thus replaces a final result.
	Corrected string
}

ResultStatus for the OBR.25 Result Status field. Values: http://hl7-definition.caristix.com:9010/HL7%20v2.3.1/Default.aspx?version=HL7%20v2.5.1&table=0123

Jump to

Keyboard shortcuts

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