Skip to content
ozinus edited this page Aug 21, 2019 · 7 revisions
  • Install MongoDB
  • Make sure the path is set. https://stackoverflow.com/questions/24306398/how-to-add-mongo-commands-to-path-on- mac-osx (for MacOS)
  • Run MongoDB server: by typing mongod on the terminal (mac os) - make sure it is running.
  • Run the client: Open new terminal window and type in mongo
  • View existing databases: type : "show dbs"
  • Create new database: type "use PatientsDB"
  • View the list of databases or to verify the above db got created. type : "shows dbs" PatientDb should be in the output.
  • type in "use PatientsDB"
  • Create table/collection Patients by executing this on the terminal: "db.CreateCollection("Patients");"
  • Populate the database like this: Two records:
  • type the below command on the terminal: - two db.Patients.insert() command below. Just copy and past those on the command prompt.It will create two records.

db.Patients.insert( { "lastName" : "Smith", "firstName" : "Fred", "town" : "Arlington", "Medications" : [ { "medname" : "morphine", "dose" : "10mg", "startDate" : "10/10/15" }, { "medname" : "acetaminophen", "dose" : "325mg", "startDate" : "10/11/15", "stopDate" : "10/14/15" }, { "medname" : "furosemide", "dose" : "20mg", "startDate" : "10/31/15" } ],

"temperature" : 5, "pulse" : 10

})

db.Patients.insert( { "lastName" : "Jones", "firstName" : "Sally", "town" : "Milford", "Medications" : [ { "medname" : "morphine", "dose" : "15mg", "startDate" : "10/11/15" }, { "medname" : "coumadin", "dose" : "5mg", "startDate" : "10/15/15" }, { "medname" : "lovenox", "dose" : "100mg/mL", "startDate" : "10/31/15", "stopDate" : "11/2/15" } ], "pulse" : 20, "temperature" : 10 } )

  • to verify the records were created fine type this command "db.Patients.find({}).pretty();" You should see the output as below: (Object ids will be different for you).

{ "_id" : ObjectId("5d5d83a1a7feae330ae5013e"), "lastName" : "Smith", "firstName" : "Fred", "town" : "Arlington", "Medications" : [ { "medname" : "morphine", "dose" : "10mg", "startDate" : "10/10/15" }, { "medname" : "acetaminophen", "dose" : "325mg", "startDate" : "10/11/15", "stopDate" : "10/14/15" }, { "medname" : "furosemide", "dose" : "20mg", "startDate" : "10/31/15" } ], "temperature" : 5, "pulse" : 10 } { "_id" : ObjectId("5d5d8424a7feae330ae5013f"), "lastName" : "Jones", "firstName" : "Sally", "town" : "Milford", "Medications" : [ { "medname" : "morphine", "dose" : "15mg", "startDate" : "10/11/15" }, { "medname" : "coumadin", "dose" : "5mg", "startDate" : "10/15/15" }, { "medname" : "lovenox", "dose" : "100mg/mL", "startDate" : "10/31/15", "stopDate" : "11/2/15" } ], "pulse" : 20, "temperature" : 10 }

  • Install nodejs on your environment.

  • Run the web api project on the node js - Once you download the project in VS code, run the command - npm start and this app will run on the port 3002 (can be modified in server.js)- this is the port where client will point to.

  • There are other dependencies which should bring on their own as they are part of package.json of the project. Those are the following 4 packages. "body-parser": "^1.19.0" (npm install body-parser --save) , "cors": "^2.8.5" ( npm install cors --save), "express": "^4.17.1" (npm install express --save), "mongoose": "^5.6.9" (npm install mongoose --save)

Clone this wiki locally