Created
September 23, 2020 23:04
-
-
Save SapioBeasley/2b4dde8cf56ff4a8d6e9774434e86192 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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