Skip to content

Commit

Permalink
prettier fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lmd59 committed Jun 28, 2024
1 parent 48999e8 commit 5ddc135
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 28 deletions.
54 changes: 29 additions & 25 deletions src/services/bulkstatus.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,60 +26,64 @@ async function kickoffImport(request, reply) {
if (!bulkStatus) {
reply.code(404).send(new Error(`Could not find bulk export request with id: ${clientId}`));
}
if (bulkStatus.status === BULKSTATUS_COMPLETED){
if (bulkStatus.status === BULKSTATUS_COMPLETED) {
const parameters = gatherParams(request.method, request.query, request.body, reply);
if(parameters.receiver){

if (parameters.receiver) {
const responseData = await getNDJsonURLs(reply, clientId);
const importManifest = {
"resourceType": "Parameters"
resourceType: 'Parameters'
};

Check warning on line 35 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 35 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
importManifest.parameter = responseData.map(exportFile =>{
importManifest.parameter = responseData.map(exportFile => {

Check warning on line 36 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function

Check warning on line 36 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
return {
"name": "input",
"part": [
name: 'input',
part: [
{
"name": "url",
"valueUrl": exportFile.url
name: 'url',
valueUrl: exportFile.url
}
]
};

Check warning on line 45 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 45 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
});

Check warning on line 46 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 46 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement


// TODO: add provenance?
const headers = {
'accept': 'application/fhir+json',
accept: 'application/fhir+json',
'content-type': 'application/fhir+json'
};

Check warning on line 52 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 52 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
try {
// on success, pass through the response
const results = await axios.post(parameters.receiver, importManifest, { headers });
reply.code(results.status).header('content-location',results.headers['content-location']).send(results.body);
reply.code(results.status).header('content-location', results.headers['content-location']).send(results.body);

Check warning on line 56 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 56 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
} catch (e) {
// on fail, pass through wrapper error 400 that contains contained resource for the operationoutcome from the receiver
let receiverOutcome;
if(e.response.data.resourceType === 'OperationOutcome'){
if (e.response.data.resourceType === 'OperationOutcome') {
receiverOutcome = e.response.data;
}else{
receiverOutcome = createOperationOutcome(e.message, {issueCode: e.status, severity: 'error'});
} else {
receiverOutcome = createOperationOutcome(e.message, { issueCode: e.status, severity: 'error' });

Check warning on line 63 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 63 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

Check warning on line 64 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 64 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 64 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 64 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 64 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 64 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
const outcome = createOperationOutcome(`Import request for id ${clientId} to receiver ${parameters.receiver} failed with the contained error.`, {
issueCode: 400,
severity: 'error'
});
const outcome = createOperationOutcome(
`Import request for id ${clientId} to receiver ${parameters.receiver} failed with the contained error.`,
{
issueCode: 400,
severity: 'error'
}
);

Check warning on line 71 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 71 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
outcome.contained = [receiverOutcome];
reply.code(400).send(outcome);
}

Check warning on line 74 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 74 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}else{
} else {
reply.code(400).send(
createOperationOutcome('The kickoff-import endpoint requires a receiver location be specified in the request Parameters.', {
issueCode: 400,
severity: 'error'
})
createOperationOutcome(
'The kickoff-import endpoint requires a receiver location be specified in the request Parameters.',
{
issueCode: 400,
severity: 'error'
}
)
);

Check warning on line 84 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 84 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

Check warning on line 85 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 85 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 85 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 85 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 85 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 85 in src/services/bulkstatus.service.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
}else{
} else {
reply.code(400).send(
createOperationOutcome(`Export request with id ${clientId} is not yet complete`, {
issueCode: 400,
Expand Down
5 changes: 2 additions & 3 deletions src/util/serviceUtils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const { createOperationOutcome } = require('../util/errorUtils');

/**
Expand All @@ -9,7 +8,7 @@ const { createOperationOutcome } = require('../util/errorUtils');
* @param {Object} reply the response object
* @returns {Object} an object containing a combination of request parameters from both sources
*/
function gatherParams (method, query, body, reply){
function gatherParams(method, query, body, reply) {
if (method === 'POST' && Object.keys(query).length > 0) {
reply.code(400).send(
createOperationOutcome('Parameters must be specified in a request body for POST requests.', {
Expand Down Expand Up @@ -49,4 +48,4 @@ function gatherParams (method, query, body, reply){
return params;
}

module.exports = { gatherParams };
module.exports = { gatherParams };

0 comments on commit 5ddc135

Please sign in to comment.