Skip to content
This repository was archived by the owner on Nov 22, 2018. It is now read-only.

Commit c3a495b

Browse files
committed
Merge pull request #3 from PhysiciansDataCollaborative/dev
Added 3rd Next
2 parents bdc2283 + 5e98ad4 commit c3a495b

File tree

5 files changed

+126
-0
lines changed

5 files changed

+126
-0
lines changed

3rdNext_import.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
#
3+
# Import 3rd Next
4+
#
5+
#
6+
# Exit on errors or uninitialized variables
7+
set -e -o nounset
8+
9+
10+
# Start in data folder
11+
#
12+
cd /data/3rdNext
13+
14+
15+
# Create a list of text files
16+
#
17+
FILES=$(find . -maxdepth 1 -type f -name "*.txt")
18+
19+
20+
# Import each text file and move it to archived
21+
#
22+
for f in ${FILES}
23+
do
24+
mongoimport --db query_composer_development --collection thirdnexts --type json --file ${f}
25+
done

filterProviders.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Filters out providers based on id's and the initiative they are in.
3+
*
4+
* @param providerId {string} - the provider identifier to filter against.
5+
* @param initiative {string} - the initiative identifier. One of:
6+
* - "PPh" : polypharmacy
7+
*
8+
* @returns - true if the provider is part of the specified initiative
9+
* false otherwise.
10+
*/
11+
function filterProviders(providerId, initiative){
12+
13+
//check that we have valid inputs
14+
if ( !providerId || !initiative ) {
15+
16+
return false;
17+
18+
}
19+
20+
var inits = {
21+
22+
"PPh" : [
23+
"cpsid", //currently contains some test values.
24+
"PROVIDER1",
25+
"PROVIDER2"
26+
]
27+
};
28+
29+
30+
//check that the initiative is valid.
31+
if ( inits[initiative] === undefined ){
32+
33+
return false;
34+
35+
}
36+
37+
if( inits[initiative].indexOf(providerId) > -1 ){
38+
39+
return true;
40+
41+
}else{
42+
43+
return false;
44+
45+
}
46+
47+
}

mongodb_init.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,19 @@ set -e -o nounset
1313
sleep 5
1414

1515

16+
# Create thirdnexts collection
17+
#
18+
mongo query_composer_development --eval 'db.createCollection("thirdnexts")'
19+
20+
1621
# Set db keys to prevent duplicates
1722
#
1823
mongo query_composer_development --eval \
1924
'printjson( db.users.ensureIndex({ username : 1 }, { unique : true }))'
2025
mongo query_composer_development --eval \
2126
'printjson( db.endpoints.ensureIndex({ base_url : 1 }, { unique : true }))'
27+
mongo query_composer_development --eval \
28+
'printjson( db.thirdnexts.ensureIndex({ clinic: 1, date:1 }, { unique: true }))'
2229

2330

2431
# Import admin and user accounts

provider_add.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
#
3+
# Halt on errors or uninitialized variables
4+
#
5+
set -e -o nounset
6+
7+
8+
# Expected input
9+
#
10+
# $0 this script
11+
# $1 Doctor (clinician) ID
12+
13+
14+
# Check parameters
15+
#
16+
if([ $# -lt 1 ]||[ $# -gt 1 ])
17+
then
18+
echo
19+
echo "Unexpected number of parameters."
20+
echo
21+
echo "Usage: providers_add.sh [doctorID]"
22+
echo
23+
exit
24+
fi
25+
26+
27+
# Set variables from parameters
28+
#
29+
DOCTOR=${1}
30+
31+
32+
# Get script directory and target file
33+
#
34+
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
35+
TARGET=${DIR}/providers.txt
36+
37+
38+
# Add provider
39+
#
40+
if(! grep --quiet ${DOCTOR} ${TARGET} )
41+
then
42+
echo ${DOCTOR} | sudo tee -a ${TARGET}
43+
fi

providers.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# List provider IDs here
2+
#
3+
cpsid
4+
91604

0 commit comments

Comments
 (0)