cda

package module
v0.0.0-...-2054ad7 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: BSD-3-Clause Imports: 3 Imported by: 0

README

Go CDA

Go CDA is a Clinical Document Architecture parsing library for the Go programming language. CDA's are used extensively in health care. This library was developed to parse Pathology reports saved in the CDA format.

This library is still a work in progress and the documentation will be extended with more examples in due course.

Install

go get github.com/PaulBradley/go-cda

Example Usage

// parse the CDA document
clinicalDocument, err = cda.Parse(string(data))
if err != nil {
    log.Fatal(err.Error())
}

Example Output

Once the CDA document has been parsed, it's easy to output the discrete data items in any format. Typically this would be a HTML report.

+------------------+---------------------+
|    DATA ITEM     |        VALUE        |
+------------------+---------------------+
| Accession #      | C12439170           |
+------------------+---------------------+
| Status Code      | completed           |
+------------------+---------------------+
| Document Title   | Laboratory Report   |
+------------------+---------------------+
| Custodian        | Holby City Hospital |
+------------------+---------------------+
| Report Date/Time | 20190814141433+0100 |
+------------------+---------------------+
| Language Code    | en-GB               |
+------------------+---------------------+
| Given Name       | Hadley              |
+------------------+---------------------+
| Surname          | Bradley             |
+------------------+---------------------+
| DOB              | 19851110            |
+------------------+---------------------+
| Gender           | Male                |
+------------------+---------------------+

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClinicalDocument

type ClinicalDocument struct {
	RawXML string `xml:",innerxml"`
	Title  string `xml:"title"`

	Code                   []codeSystem            `xml:"code"`
	EffectiveTime          []effectiveTime         `xml:"effectiveTime"`
	IDs                    []id                    `xml:"id"`
	LanguageCode           []languageCode          `xml:"languageCode"`
	RealmCode              []realmCode             `xml:"realmCode"`
	VersionNumber          []versionNumber         `xml:"versionNumber"`
	RecordTarget           []recordTarget          `xml:"recordTarget"`
	Custodian              []custodian             `xml:"custodian>assignedCustodian>representedCustodianOrganization"`
	Authors                []author                `xml:"author"`
	IntendedRecipients     []intendedRecipient     `xml:"informationRecipient>intendedRecipient"`
	EncompassingEncounter  []encompassingEncounter `xml:"componentOf>encompassingEncounter"`
	StructuredBodySections []structuredBodySection `xml:"component>structuredBody>component"`
	// contains filtered or unexported fields
}

ClinicalDocument holds the parsed values from the supplied CDA XML document

func Parse

func Parse(clinicalDocument string) (ClinicalDocument, error)

Parse accepts the CDA document as a string and passes it to the XML Unmarshal function to map the data items into in the struct fields.

func (*ClinicalDocument) DoFormatDisplayAddress

func (cda *ClinicalDocument) DoFormatDisplayAddress(a addr) string

DoFormatDisplayAddress formats an address by concatenating the address segments

func (*ClinicalDocument) DoFormatDisplayName

func (cda *ClinicalDocument) DoFormatDisplayName(p person) string

DoFormatDisplayName formats a name by concatenating, if present, the following values: - Prefix, Given, Family, Suffix

func (*ClinicalDocument) DoReformatDateTimeFields

func (cda *ClinicalDocument) DoReformatDateTimeFields() error

DoReformatDateTimeFields parses the date/time fields and applies the formatting mask passed via DoSetDateFormat() & DoSetDateTimeFormat()

func (*ClinicalDocument) DoSetDateFormat

func (cda *ClinicalDocument) DoSetDateFormat(format string)

DoSetDateFormat sets the format to be applied to date fields like DOB

func (*ClinicalDocument) DoSetDateTimeFormat

func (cda *ClinicalDocument) DoSetDateTimeFormat(format string)

DoSetDateTimeFormat sets the format to be applied to date/time fields like effectiveTime

func (cda *ClinicalDocument) DoSetReportLogo(URL string)

DoSetReportLogo sets a URL to a logo to be used within the HTML report.

func (*ClinicalDocument) DoSetReportStyleSheet

func (cda *ClinicalDocument) DoSetReportStyleSheet(URL string)

DoSetReportStyleSheet sets a URL to an external style sheet to be used within the HTML report.

func (*ClinicalDocument) DoSwitchBR

func (cda *ClinicalDocument) DoSwitchBR(replaceWith string)

DoSwitchBR replaces the carriage return text within LabReports from \.br\ to the string supplied in the replaceWith parameter

func (*ClinicalDocument) GenerateReport

func (cda *ClinicalDocument) GenerateReport() string

GenerateReport returns a formatted HTML 5 report

Jump to

Keyboard shortcuts

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