-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved results inside a field class so that it can have different functions // also for chaining later on #4
- Loading branch information
Showing
5 changed files
with
92 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {Segment} from "./segment"; | ||
|
||
export interface ISegment { | ||
/* Name of the segment */ | ||
name: string; | ||
/* The data of the segment */ | ||
data: Segment | ||
/*Content of the HL7 */ | ||
content: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import EventEmitter from "events"; | ||
|
||
|
||
|
||
export class Field extends EventEmitter { | ||
/** @internal */ | ||
_data: string | string[] | {} | ||
/** @internal */ | ||
_dataType?: any; | ||
/** @internal */ | ||
_internalName: string | ||
/** @internal */ | ||
_name?: string; | ||
|
||
/** | ||
* | ||
* @since 1.0.0 | ||
* @param data | ||
* @param name */ | ||
constructor(data: string | string[] | {}, name: string) { | ||
super(); | ||
|
||
this._data = data | ||
this._internalName = name | ||
|
||
// @todo Assign Long name based of field and HL7 Standards Types | ||
// @todo Assign Field types | ||
|
||
} | ||
|
||
/** | ||
* Get Name of Field based off HL7 Spec being used. | ||
* @description This is not fully implemented yet. | ||
* @example is_patient_name | ||
* @since 1.0.0*/ | ||
// async getName(): Promise<string> { | ||
// | ||
// } | ||
|
||
/** | ||
* Get field Data Type | ||
* @description This is not fully implemented yet. | ||
* */ | ||
// async getDataType(): Promise<any> { | ||
// | ||
// } | ||
|
||
/** Get Value of Field | ||
* @since 1.0.0*/ | ||
async getValue(): Promise<string | string[] | {}> { | ||
this.emit('field.getValue') | ||
return this._data | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import { Client } from './client.js' | ||
import { Listener } from './listener.js' | ||
import {ISegment, Parser } from './parser.js' | ||
import { Parser } from './parser.js' | ||
import { Segment } from './segment.js' | ||
import { Field } from './field' | ||
import { ISegment } from './declaration.js' | ||
|
||
export default Client | ||
export { Client, Listener, Parser, Segment, ISegment } | ||
export { Client, Listener, Parser, Segment, ISegment, Field } | ||
|
||
export type { ClientOptions, ClientListenerOptions, ParserOptions, ParserProcessRawData } from './normalize.js' | ||
export type { HL7ClientError, HL7ClientFatalError } from './exception.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters