Skip to content

Commit 0f6ca65

Browse files
committed
Walk through README and make updates
1 parent a9f0eb1 commit 0f6ca65

File tree

3 files changed

+40
-38
lines changed

3 files changed

+40
-38
lines changed

README.md

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Medication sig parser.
66

77
Instructions for Linux:
88

9+
Clone repo and cd into `parserx` directory.
10+
911
Create virutal environment
1012

1113
```
@@ -29,66 +31,55 @@ Info on MySQLClient: https://pypi.org/project/mysqlclient/
2931

3032
Gunicorn/Nginx: https://realpython.com/django-nginx-gunicorn/#replacing-wsgiserver-with-gunicorn
3133

34+
Inital setup of MySQL
35+
36+
```
37+
sudo mysql_secure_installation
38+
```
39+
40+
Follow prompts to create root user password and accept default settings.
41+
3242
```
3343
sudo mysql
34-
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'mynewpassword';
44+
CREATE USER 'parserx'@'localhost' IDENTIFIED BY 'P@ssw0rd';
3545
GRANT ALL PRIVILEGES ON parserx.* TO 'parserx'@'localhost' WITH GRANT OPTION;
46+
quit
3647
```
3748

38-
Terminal
49+
(back in terminal)
3950

4051
```
4152
mysql -u parserx -p
42-
<enter password>
43-
drop database parserx;
53+
<enter password = P@ssw0rd>
54+
drop database if exists parserx;
4455
create database parserx;
4556
quit
57+
```
58+
59+
(back in terminal)
60+
61+
```
4662
source venv/bin/activate
4763
python manage.py makemigrations
4864
python manage.py makemigrations sig
4965
python manage.py migrate
5066
python manage.py createsuperuser
5167
<follow createsuperuser prompts>
52-
python manage.py runserver 0.0.0.0:8000
68+
python manage.py runserver localhost:8000
5369
```
5470

55-
Postman
56-
57-
1.) Authenticate with superuser
58-
POST localhost:8000/auth/token/login/
59-
Headers
60-
Content-Type application/json
61-
Body
62-
{
63-
"username": "jrlegrand",
64-
"password": "<password>"
65-
}
66-
Response
67-
{
68-
"auth_token": "<auth token>"
69-
}
70-
71-
2.) Run ParseRx on csv file via API
72-
POST localhost:8000/csv_sig/
73-
Headers
74-
Content-Type application/json
75-
Authorization Token <auth token>
76-
77-
NOTE: to change the csv file that the API runs:
78-
- Go to parserx/sig/views
79-
- Edit filepath in the create method of CsvSigCreateViewSet
80-
- The csv file is stored in parserx/parsers/csv
81-
8271

8372
## Authenticate and parse a sig via the API
8473

74+
Recommend using Postman
75+
8576
1.) Authenticate with user
8677
POST localhost:8000/auth/token/login/
8778
Headers
8879
Content-Type application/json
8980
Body
9081
{
91-
"username": "<username>",
82+
"username": "<superuser username>",
9283
"password": "<password>"
9384
}
9485
Response
@@ -101,10 +92,19 @@ POST localhost:8000/sig/
10192
Headers
10293
Content-Type application/json
10394
Authorization Token <auth token>
95+
Body
96+
{
97+
"sig_text": "take 1-2 tabs po qid prn anxiety x7d"
98+
}
10499

105100

106101
## Parsing / reparsing an entire CSV of sigs
107102

103+
NOTE: to change the csv file that the API runs:
104+
- Go to parserx/sig/views
105+
- Edit filepath in the create method of CsvSigCreateViewSet
106+
- The csv file is stored in parserx/parsers/csv
107+
108108
Edit the name of the csv file in parserx.io/sig/views.py to be the csv you want to parse.
109109
***NOTE: ensure you have converted it to just one column full of sigs with no header.
110110

@@ -116,7 +116,7 @@ Headers
116116
Content-Type application/json
117117
Body
118118
{
119-
"username": "<username>",
119+
"username": "<superuser username>",
120120
"password": "<password>"
121121
}
122122
Response
@@ -133,13 +133,15 @@ Authorization Token <auth token>
133133

134134
## Submiting batch sig reviews to ParseRx via API (feedback loop)
135135

136+
This would be for a "customer" that is receiving parsed sigs and wants to send back some feedback as a batch every night via the API.
137+
136138
1.) Get auth token from ParseRx
137139
POST api.parserx.io/auth/token/login/
138140
Headers
139141
Content-Type application/json
140142
Body
141143
{
142-
"username": "<username>",
144+
"username": "<customer username>",
143145
"password": "<password>"
144146
}
145147
Response

parsers/sig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def get_max_dose_per_day(self, match_dict):
120120

121121
def parse(self, sig_text):
122122
match_dict = dict(self.match_dict)
123-
match_dict['original_sig_text'] = sig_text
123+
#match_dict['original_sig_text'] = sig_text
124124
sig_text = self.get_normalized_sig_text(sig_text)
125125
match_dict['sig_text'] = sig_text
126126
for parser_type, parsers in self.parsers.items():

parserx/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# SECURITY WARNING: don't run with debug turned on in production!
2626
DEBUG = True
2727

28-
ALLOWED_HOSTS = ['localhost']
28+
ALLOWED_HOSTS = ['*']
2929

3030
CSRF_TRUSTED_ORIGINS=['https://api.parserx.io']
3131

@@ -102,7 +102,7 @@
102102
'ENGINE': 'django.db.backends.mysql',
103103
'NAME': 'parserx',
104104
'USER': 'parserx',
105-
'PASSWORD': 'password',
105+
'PASSWORD': 'P@ssw0rd',
106106
}
107107
}
108108

0 commit comments

Comments
 (0)