{"id":16372475,"url":"https://github.com/mgwidmann/medicine_tracker","last_synced_at":"2026-03-13T18:30:23.629Z","repository":{"id":22005268,"uuid":"25330430","full_name":"mgwidmann/medicine_tracker","owner":"mgwidmann","description":"Simple inventory tracking application to track medicine.","archived":false,"fork":false,"pushed_at":"2014-10-18T20:48:53.000Z","size":320,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-31T17:20:09.728Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mgwidmann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-17T01:03:13.000Z","updated_at":"2014-10-17T01:34:36.000Z","dependencies_parsed_at":"2022-08-20T15:31:16.318Z","dependency_job_id":null,"html_url":"https://github.com/mgwidmann/medicine_tracker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgwidmann%2Fmedicine_tracker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgwidmann%2Fmedicine_tracker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgwidmann%2Fmedicine_tracker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgwidmann%2Fmedicine_tracker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mgwidmann","download_url":"https://codeload.github.com/mgwidmann/medicine_tracker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239921881,"owners_count":19718842,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T03:11:31.248Z","updated_at":"2026-03-13T18:30:23.577Z","avatar_url":"https://github.com/mgwidmann.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"Medicine Tracker\n================\n\nSimple inventory tracking application to track medicine.\n\n## Installation\n\n### Run bundler\n\n   bundle install\n\n### Setup the database\n\n   rake db:setup\n\n### Running the server\n\n   unicorn_rails\n\n### Visit [http://localhost:8080/](http://localhost:8080)\n\n### System Information\n\nRuby: Developed on 2.1.1p76 -- Should work for 1.9.3+\n\nDatabase: SQLite3 was chosen because this is not meant to be a production application.\n\n## Tests\n\n### Run RSpec\n\n    rspec\n\nA test suite coverage tool is checked in (simply for distribution purposes so others need not run the test suite to generate it). To view the coverage report, simply open the `coverage/index.html` file in your browser.\n\n### CURL\n\nAfter starting up the server, below is an example list of capabilities.\n\n#### Signing In\n\nThe `rake db:seed` task will create a test user for you. If you already ran the `rake db:setup` task, this has been done for you.\n\nThe users credentials are: test@test.com/password\n\nSubmit the curl request as follows, **this is required before making any other requests!**. You will receive a 401 response otherwise.\n\n    curl -b cookies -c cookies -H \"Content-Type: application/json\" -XPOST http://localhost:8080/users/sign_in.json -d '{\"user\":{\"email\":\"test@test.com\",\"password\":\"password\"}}'\n\n    {\"success\":true}\n\nNotice the `-b cookies -c cookies`, this is curl's cookie jar. You'll need to make sure every request has `-b cookies -c cookies` in order to keep you signed in.\n\nAlso, any request which sends in JSON data such as this one, will also need the content type header to specify how to parse the request body.\n\n#### Creating a package\n\nWe want to be able to create a new package with two different drugs in it. The first being \"Propofol\", which has been mixed from two separate containers and so it has two different expiration dates. Second, a drug named \"Epinephrine\" with just a single expiration date. Here's how we would curl it:\n\n    curl -b cookies -c cookies -H \"Content-Type: application/json\" -XPOST http://localhost:8080/packages.json -d '{\"package\":{\"name\": \"cURLed package\", \"drugs\":[{\"name\":\"Propofol\",\"expiration_dates\":[\"2013/10/11\",\"2013/01/30\"]},{\"name\":\"Epinephrine\",\"expiration_dates\":[\"2014/10/11\"]}]}}'\n\n    {\"id\":1,\"name\":\"cURLed package\",\"serial\":null,\"created_at\":\"2014-10-18T05:10:47.735Z\",\"updated_at\":\"2014-10-18T05:10:47.735Z\",\"drugs\":[{\"id\":1,\"name\":\"Propofol\",\"created_at\":\"2014-10-18T05:10:47.736Z\",\"updated_at\":\"2014-10-18T05:10:47.736Z\",\"package_id\":1,\"expiration_dates\":[{\"id\":1,\"date\":\"2013-10-11\",\"created_at\":\"2014-10-18T05:10:47.737Z\",\"updated_at\":\"2014-10-18T05:10:47.737Z\",\"drug_id\":1},{\"id\":2,\"date\":\"2013-01-30\",\"created_at\":\"2014-10-18T05:10:47.738Z\",\"updated_at\":\"2014-10-18T05:10:47.738Z\",\"drug_id\":1}]},{\"id\":2,\"name\":\"Epinephrine\",\"created_at\":\"2014-10-18T05:10:47.739Z\",\"updated_at\":\"2014-10-18T05:10:47.739Z\",\"package_id\":1,\"expiration_dates\":[{\"id\":3,\"date\":\"2014-10-11\",\"created_at\":\"2014-10-18T05:10:47.739Z\",\"updated_at\":\"2014-10-18T05:10:47.739Z\",\"drug_id\":2}]}]}\n\n#### Updating the package\n\nWe need to update the package as well, we can add new drugs to the existing package with the following statement. Be sure to update the URL to change the ID of the package if you are updating anything other than `1` as shown below.\n\n    curl -b cookies -c cookies -H \"Content-Type: application/json\" -XPUT http://localhost:8080/packages/1.json -d '{\"package\":{\"drugs\":[{\"name\":\"Epinephrine\",\"expiration_dates\":[\"2013/10/11\"]}]}}'\n\nNo response is returned for a successful update (this is very UNIX like, no response for success).\n\n#### Listing out all packages\n\nPerforming a GET request on `/packages.json` will give a more detailed view of all packages.\n\n    curl -b cookies -c cookies -XGET http://localhost:8080/packages.json\n\n    [{\"id\":1,\"created_at\":\"2014-10-18T05:10:47.735Z\",\"updated_at\":\"2014-10-18T05:10:47.735Z\",\"drugs\":[\"Propofol\",\"Epinephrine\",\"Epinephrine\"],\"expiration_date\":\"2013-01-30\",\"url\":\"http://localhost:8080/packages/1.json\"}]\n\nWe can see that this one package contains 3 drugs: \"Propofol\", \"Epinephrine\", and \"Epinephrine\". Of all of them, the date when the package will first begin to expire is 2013-01-30. If you look at the examples above, its because of the Propofol, it has two expiration dates with one of them being 2013-01-30.\n\n#### Nested Data\n\n##### Drugs\n\nSay we want to zoom in on the data contained within a particular package, just the drugs of a package that we know the ID of. We can use nested routing to retrieve just those objects.\n\n    curl -b cookies -c cookies -XGET http://localhost:8080/packages/1/drugs.json\n\n    [{\"id\":1,\"name\":\"Propofol\",\"created_at\":\"2014-10-18T05:10:47.736Z\",\"updated_at\":\"2014-10-18T05:10:47.736Z\",\"expiration_date\":\"2013-01-30\",\"package_id\":1,\"url\":\"http://localhost:8080/packages/1/drugs/1.json\",\"package_url\":\"http://localhost:8080/packages/1.json\"},{\"id\":2,\"name\":\"Epinephrine\",\"created_at\":\"2014-10-18T05:10:47.739Z\",\"updated_at\":\"2014-10-18T05:10:47.739Z\",\"expiration_date\":\"2014-10-11\",\"package_id\":1,\"url\":\"http://localhost:8080/packages/1/drugs/2.json\",\"package_url\":\"http://localhost:8080/packages/1.json\"},{\"id\":3,\"name\":\"Epinephrine\",\"created_at\":\"2014-10-18T05:14:12.371Z\",\"updated_at\":\"2014-10-18T05:14:12.371Z\",\"expiration_date\":\"2013-10-11\",\"package_id\":1,\"url\":\"http://localhost:8080/packages/1/drugs/3.json\",\"package_url\":\"http://localhost:8080/packages/1.json\"}]\n\nWe can also create new drugs for a specific package. Since we are zooming, we need only specify the drug data.\n\n    curl -b cookies -c cookies -H \"Content-Type: application/json\" -XPOST http://localhost:8080/packages/1/drugs.json -d '{\"drug\":{\"name\":\"AnotherDrug\",\"expiration_dates\":[\"2014-10-30\"]}}'\n\n    {\"id\":5,\"name\":\"AnotherDrug\",\"created_at\":\"2014-10-18T05:38:27.269Z\",\"updated_at\":\"2014-10-18T05:38:27.269Z\",\"package_id\":1,\"expiration_dates\":[{\"id\":6,\"date\":\"2014-10-30\",\"created_at\":\"2014-10-18T05:38:27.270Z\",\"updated_at\":\"2014-10-18T05:38:27.270Z\",\"drug_id\":5}]}\n\nOr fetch a specific drug that we know the ID of:\n\n    curl -b cookies -c cookies -XGET http://localhost:8080/packages/1/drugs/5.json\n\n    {\"id\":5,\"name\":\"AnotherDrug\",\"created_at\":\"2014-10-18T05:38:27.269Z\",\"updated_at\":\"2014-10-18T05:38:27.269Z\",\"expiration_date\":\"2014-10-30\",\"package_id\":1,\"url\":\"http://localhost:8080/packages/1/drugs/5.json\",\"package_url\":\"http://localhost:8080/packages/1.json\"}\n\nAnd even update that drug if we need to change something:\n\n    curl -b cookies -c cookies -H \"Content-Type: application/json\" -XPUT http://localhost:8080/packages/1/drugs/5.json -d '{\"drug\":{\"name\":\"ChangedName\"}}'\n\nNo response is returned, this is expected and it means the update was successful. You can always fetch it to see:\n\n    curl -b cookies -c cookies -XGET http://localhost:8080/packages/1/drugs/5.json\n\n    {\"id\":5,\"name\":\"ChangedName\",\"created_at\":\"2014-10-18T05:38:27.269Z\",\"updated_at\":\"2014-10-18T05:43:13.362Z\",\"expiration_date\":\"2014-10-30\",\"package_id\":1,\"url\":\"http://localhost:8080/packages/1/drugs/5.json\",\"package_url\":\"http://localhost:8080/packages/1.json\"}\n\nRemoving a drug can be done also. (Notice I'm removing a different drug than the `5` we've been using)\n\n    curl -b cookies -c cookies -XDELETE http://localhost:8080/packages/1/drugs/2.json\n\nAgain, no response in this case is a good response.\n\n##### Expiration Dates\n\nZooming in further to the expiration dates is also possible.\n\n    curl -b cookies -c cookies -XGET http://localhost:8080/packages/1/drugs/5/expiration_dates.json\n\n    [{\"id\":6,\"date\":\"2014-10-30\",\"created_at\":\"2014-10-18T05:38:27.270Z\",\"updated_at\":\"2014-10-18T05:38:27.270Z\",\"drug_id\":5,\"url\":\"http://localhost:8080/packages/1/drugs/5/expiration_dates/6.json\",\"drug_url\":\"http://localhost:8080/packages/1/drugs/5.json\"}]\n\nAnd adding a new date is also simple.\n\n    curl -b cookies -c cookies -H \"Content-Type: application/json\" -XPOST http://localhost:8080/packages/1/drugs/5/expiration_dates.json -d '{\"expiration_date\":{\"date\":\"2015-12-31\"}}'\n\n    {\"id\":7,\"date\":\"2015-12-31\",\"created_at\":\"2014-10-18T05:50:57.589Z\",\"updated_at\":\"2014-10-18T05:50:57.589Z\",\"drug_id\":5}\n\nWe can fetch just that expiration date back again as well.\n\n    curl -b cookies -c cookies -XGET http://localhost:8080/packages/1/drugs/5/expiration_dates/7.json\n\n    {\"id\":7,\"date\":\"2015-12-31\",\"created_at\":\"2014-10-18T05:50:57.589Z\",\"updated_at\":\"2014-10-18T05:50:57.589Z\",\"drug_id\":5,\"url\":\"http://localhost:8080/packages/1/drugs/5/expiration_dates/7.json\",\"drug_url\":\"http://localhost:8080/packages/1/drugs/5.json\"}\n\nSame with updating it (though this sounds like it may be some kind of health code violation).\n\n    curl -b cookies -c cookies -H \"Content-Type: application/json\" -XPUT http://localhost:8080/packages/1/drugs/5/expiration_dates/7.json -d '{\"expiration_date\":{\"date\":\"2016-01-30\"}}'\n\nNo response again, good. Lastly we can delete it, there will not be a response for that either:\n\n    curl -b cookies -c cookies -XDELETE http://localhost:8080/packages/1/drugs/5/expiration_dates/7.json\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgwidmann%2Fmedicine_tracker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmgwidmann%2Fmedicine_tracker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgwidmann%2Fmedicine_tracker/lists"}