Skip to content

Commit

Permalink
feat: add _pretty in BaseFhirApiService
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinlinlee committed Oct 8, 2023
1 parent 153ddb3 commit 3f9524b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/FHIRApiService/services/base.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const mongoose = require("mongoose");
const FHIR = require("fhir").Fhir;
const _ = require("lodash");
const uuid = require('uuid');
const xmlFormatter = require("xml-formatter");

const { renameCollectionFieldName } = require("../../apiService");
const { validateContainedList } = require("../validateContained");
Expand All @@ -21,6 +22,9 @@ class BaseFhirApiService {
this.response = res;
/** @type { string } */
this.resourceType = resourceType;

this._pretty = req.query["_pretty"];
delete this.request.query["_pretty"];
}

doSuccessResponse(resource) {
Expand Down Expand Up @@ -90,6 +94,7 @@ class BaseFhirApiService {
if (this.response.getHeader("content-type").includes("xml")) {
let fhir = new FHIR();
let xmlItem = fhir.objToXml(item);
if (this._pretty) xmlItem = xmlFormatter(xmlItem);
return this.response.status(code).send(xmlItem);
}
return this.response.status(code).send(item);
Expand Down

0 comments on commit 3f9524b

Please sign in to comment.