Skip to content

Instantly share code, notes, and snippets.

@SapioBeasley
Created September 23, 2020 23:04
Show Gist options
  • Select an option

  • Save SapioBeasley/2b4dde8cf56ff4a8d6e9774434e86192 to your computer and use it in GitHub Desktop.

Select an option

Save SapioBeasley/2b4dde8cf56ff4a8d6e9774434e86192 to your computer and use it in GitHub Desktop.
this.app.post('', jsonParser, async (req: Request, res: Response) => {
try {
const stage = 'AlignersShipped';
const { fields: { summary: patientNumber } } = req.body;
const opportunities = await findOpportunityByPatientNumber(conn, patientNumber);
if (opportunities.length > 1) {
console.log('More than on Opp')
return res.send(400);
}
// Update SF opp stage
await updateOpportunityStage(conn, opportunities[0].Id, stage);
const querySpec = {
query: 'SELECT * FROM c WHERE c.patientNumber = @patientNumber',
parameters: [
{
name: '@patientNumber',
value: patientNumber
}
]
};
const results = await cosmosdb.getPatients(querySpec);
const [fetchedPatient] = results.resources;
fetchedPatient.stage = stage;
await cosmosdb.updateOne(fetchedPatient)
console.log('done')
return res.sendStatus(200);
} catch (e) {
console.log(e.message)
return res.sendStatus(400)
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment