Skip to content

Commit

Permalink
fix: remove reference to pipe encoding and content-type
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed May 27, 2023
1 parent 37481f3 commit 7dc4436
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -16,7 +16,7 @@ Docsmith is a RESTful API, built using Node.js and the [Fastify](https://fastify
- DOC to TXT
- DOCX to HTML
- DOCX to TXT
- HL7v2 to JSON ("vertical bar" encoded)
- HL7 v2.x to JSON
- HTML to TXT
- PDF to HTML
- PDF to TXT
Expand Down
4 changes: 2 additions & 2 deletions src/config/index.js
Expand Up @@ -274,9 +274,9 @@ async function getConfig() {
"Endpoints used for the conversion of DOCX documents",
},
{
name: "HL7v2",
name: "HL7 v2.x",
description:
'Endpoints used for the conversion of "vertical bar" encoded HL7 v2.x messages',
"Endpoints used for the conversion of HL7 v2.x messages",
},
{
name: "HTML",
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/hl7v2-to-json/index.js
Expand Up @@ -4,7 +4,7 @@ const hl7v2 = require("@redoxengine/redox-hl7-v2");
/**
* @author Frazer Smith
* @description Pre-handler plugin that uses redox-hl7-v2 to convert string containing
* "vertical bar" encoded HL7 v2.x in `req.body` to JSON.
* HL7 v2.x in `req.body` to JSON.
* `req` object is decorated with `conversionResults.body` holding the converted document.
* @param {object} server - Fastify instance.
*/
Expand All @@ -25,14 +25,14 @@ async function plugin(server) {
// }

try {
const results = parser.parse(req.body.toString());
const results = parser.parse(req.body);
req.conversionResults.body = results;
} catch (err) {
} catch {
/**
* redox-hl7-v2 will throw if the HL7 v2 message provided
* by client is malformed or invalid, thus client error code
*/
throw server.httpErrors.badRequest(err.message);
throw server.httpErrors.badRequest();
}
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/routes/hl7v2/json/index.js
Expand Up @@ -24,14 +24,14 @@ async function route(server, options) {
}

server.addContentTypeParser(
"text/plain",
"text/hl7v2",
{ parseAs: "string" },
async (_req, payload) => {
/**
* The Content-Type header can be spoofed so is not trusted implicitly,
* this checks the payload is a "vertical bar" encoded HL7 v2.x message
* this checks the payload is an HL7 v2.x message
*/
if (!payload.startsWith("MSH|")) {
if (!payload.startsWith("MSH")) {
throw server.httpErrors.unsupportedMediaType();
}

Expand Down
10 changes: 5 additions & 5 deletions src/routes/hl7v2/json/schema.js
@@ -1,6 +1,6 @@
const S = require("fluent-json-schema");

const tags = ["HL7v2"];
const tags = ["HL7 v2.x"];

/**
* Fastify uses AJV for JSON Schema Validation,
Expand All @@ -11,11 +11,11 @@ const tags = ["HL7v2"];
*/
const hl7v2ToJsonPostSchema = {
tags,
summary: 'Convert "vertical bar" encoded HL7 v2.x message to JSON',
summary: "Convert HL7 v2.x message to JSON",
description:
'Returns the result of converting a "vertical bar" HL7 v2.x document to JSON format.',
operationId: "posthl7v2ToJson",
consumes: ["text/plain"],
"Returns the result of converting an HL7 v2.x message to JSON format.",
operationId: "postHl7v2ToJson",
consumes: ["text/hl7v2"],
produces: ["application/json"],
response: {
200: S.object().additionalProperties(true),
Expand Down

0 comments on commit 7dc4436

Please sign in to comment.