Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull data from Filename #12

Open
davidl923 opened this issue May 1, 2024 · 1 comment
Open

Pull data from Filename #12

davidl923 opened this issue May 1, 2024 · 1 comment

Comments

@davidl923
Copy link

I need to take a date out of the filename to add to the HL7 output.
Filename example: MRMC_Epic_Demo_2024-2-29.txt
Not sure how to do this in the Transformer to use to strip away the "MRMC_Epic_Demo_" and ".txt"

@Hueli
Copy link

Hueli commented May 1, 2024

I think the question would be better placed in the “nextgenhealthcare / connect” repostitory.

I assume that the SourceConnector is a FileReader. In this case, the name of the file is in the SourceMap under 'originalFilename'. The date could then be extracted into a variable 'dateFileName'.

var originalFilename = sourceMap.get('originalFilename') + '';
var dateFileName = originalFilename.replace(/^.*?(\d{4}-\d{1,2}-\d{1,2})$\.txt/i,“$1”);

The regular expression works as long as the file name ends with a date in the format (yyyy-m[m]-d[d]) and the extension .txt (case insesitive).

There are certainly more elegant methods, but this one works.

Is this the solution to the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants