This repository has been archived by the owner on Nov 22, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+OSCAR files modified by PDC - Dockerfile, 3rdNext
- Loading branch information
1 parent
6f35d9a
commit aa87c24
Showing
7 changed files
with
757 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
# Dockerfile for the PDC's Customized OSCAR 12 E2E exporter service | ||
# | ||
# | ||
# Modified OSCAR 12 build. Import SQL, filter and export to aggregate data-gathering endpoint. | ||
# Steps from https://github.com/scoophealth/SCOOP-doc/wiki/OSCAR-Setup-Guide. | ||
# | ||
# Example: | ||
# sudo docker pull pdcbc/oscar_e2e | ||
# sudo docker run -d --name=oscar -h oscar --restart=always \ | ||
# --link gateway:gateway \ | ||
# -v /encrypted/docker/import/:/e2e/:ro \ | ||
# pdcbc/oscar | ||
# | ||
# Linked containers | ||
# - Gateway: --link gateway:gateway | ||
# | ||
# Folder paths | ||
# - SQL import: -v </path/>:/e2e/:ro | ||
# | ||
# | ||
FROM phusion/baseimage | ||
MAINTAINER [email protected] | ||
|
||
|
||
# Update system, add repo and install packages | ||
# | ||
ENV DEBIAN_FRONTEND noninteractive | ||
RUN echo 'deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main' \ | ||
>> /etc/apt/sources.list.d/webupd8team-java-trusty.list; \ | ||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886; \ | ||
echo oracle-java6-installer shared/accepted-oracle-license-v1-1 \ | ||
select true | /usr/bin/debconf-set-selections | ||
RUN apt-get update; \ | ||
apt-get install --no-install-recommends -y \ | ||
libmysql-java \ | ||
mysql-server \ | ||
oracle-java6-installer \ | ||
tomcat6; \ | ||
apt-get autoclean; \ | ||
apt-get clean; \ | ||
rm -rf \ | ||
/var/lib/apt/lists/* \ | ||
/tmp/* \ | ||
/var/tmp/* \ | ||
/usr/share/doc/ \ | ||
/usr/share/doc-base/ \ | ||
/usr/share/man/ | ||
|
||
|
||
# Configure Tomcat6 | ||
# | ||
ENV JAVA_HOME="/usr/lib/jvm/java-6-oracle" | ||
ENV CATALINA_HOME="/usr/share/tomcat6" | ||
ENV CATALINA_BASE="/var/lib/tomcat6" | ||
# | ||
RUN mkdir -p \ | ||
${CATALINA_HOME}/server/classes/ \ | ||
${CATALINA_HOME}/shared/classes/ | ||
|
||
|
||
# OSCAR 12 WebARchive (.war) and properties | ||
# | ||
WORKDIR ${CATALINA_BASE}/webapps/ | ||
COPY ./war/oscar12.war.* ./ | ||
RUN cat oscar12.war.* > oscar12.war; \ | ||
rm oscar12.war.* | ||
COPY src/main/resources/oscar_mcmaster.properties /usr/share/tomcat6/oscar12.properties | ||
RUN sed -i \ | ||
-e "s/^#*db_username *=.*/db_username = root/" \ | ||
-e "s/^#*db_password *=.*/db_password=superInsecure/" \ | ||
-e "s/^#*db_name *=.*/db_name = oscar_12_1\?zeroDateTimeBehavior=round&useOldAliasMetadataBehavior=true&jdbcCompliantTruncation=false/" \ | ||
-e "s/^#*E2E_URL *=.*/E2E_URL = http:\/\/gateway:3001\/records\/create/" \ | ||
-e "s/^#*program *=.*/program = off/" \ | ||
-e "s/^#*ModuleNames *= *E2E/ModuleNames = E2E/" \ | ||
-e "s/^#*CASEMANAGEMENT *=.*/CASEMANAGEMENT = all/" \ | ||
/usr/share/tomcat6/oscar12.properties | ||
|
||
|
||
# Start MySQL and create database | ||
# | ||
WORKDIR /app/ | ||
COPY ./database/mysql/ . | ||
RUN service mysql start; \ | ||
mysqladmin -u root password superInsecure; \ | ||
./createdatabase_bc.sh root superInsecure oscar_12_1; \ | ||
rm -rf \ | ||
/var/lib/apt/lists/* \ | ||
/tmp/* \ | ||
/var/tmp/* \ | ||
/app/ | ||
|
||
|
||
# Cron and script for SQL/E2E import/export | ||
# | ||
WORKDIR / | ||
RUN SCRIPT=/run_export.sh; \ | ||
( \ | ||
echo "# Run SQL/E2E import/export (boot, daily 3:30 AM PDT = 10:30 AM UTC)"; \ | ||
echo "@reboot ${SCRIPT} > /import.log"; \ | ||
echo "30 10 * * * ${SCRIPT}"; \ | ||
) \ | ||
| crontab -; \ | ||
( \ | ||
echo "#!/bin/bash"; \ | ||
echo ""; \ | ||
echo ""; \ | ||
echo "# Set variables"; \ | ||
echo "#"; \ | ||
echo "E2E_DIFF=\${E2E_DIFF:-off}"; \ | ||
echo "E2E_DIFF_DAYS=\${E2E_DIFF_DAYS:-14}"; \ | ||
echo ""; \ | ||
echo ""; \ | ||
echo "# Configure oscar12.properties"; \ | ||
echo "#"; \ | ||
echo 'sed -i \'; \ | ||
echo ' -e "s/^#*E2E_DIFF *=.*/E2E_DIFF = ${E2E_DIFF}/" \'; \ | ||
echo ' -e "s/^#*E2E_DIFF_DAYS *=.*/E2E_DIFF_DAYS = ${E2E_DIFF_DAYS}/" \'; \ | ||
echo "/usr/share/tomcat6/oscar12.properties"; \ | ||
echo ""; \ | ||
echo ""; \ | ||
echo "# Start MySQL and import dumps"; \ | ||
echo "#"; \ | ||
echo "service mysql start"; \ | ||
echo 'find /e2e/ -name "*.sql" | \'; \ | ||
echo " while read IN"; \ | ||
echo " do"; \ | ||
echo ' mysql --user=root --password=superInsecure oscar_12_1 < "${IN}"'; \ | ||
echo " done"; \ | ||
echo ""; \ | ||
echo ""; \ | ||
echo "# Start Tomcat6"; \ | ||
echo "#"; \ | ||
echo "mkdir -p /tmp/tomcat6-tmp/"; \ | ||
echo "/sbin/setuser tomcat6 /usr/lib/jvm/java-6-oracle/bin/java \\"; \ | ||
echo " -Djava.util.logging.config.file=/var/lib/tomcat6/conf/logging.properties \\"; \ | ||
echo " -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager \\"; \ | ||
echo " -Djava.awt.headless=true -Xmx1024m -Xms1024m -XX:MaxPermSize=512m -server \\"; \ | ||
echo " -Djava.endorsed.dirs=/usr/share/tomcat6/endorsed -classpath /usr/share/tomcat6/bin/bootstrap.jar \\"; \ | ||
echo " -Dcatalina.base=/var/lib/tomcat6 -Dcatalina.home=/usr/share/tomcat6 \\"; \ | ||
echo " -Djava.io.tmpdir=/tmp/tomcat6-tmp org.apache.catalina.startup.Bootstrap start"; \ | ||
) \ | ||
>> ${SCRIPT}; \ | ||
chmod +x ${SCRIPT} | ||
|
||
|
||
# Volume | ||
# | ||
VOLUME /e2e/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
# | ||
# Exit on errors or unitialized variables | ||
# | ||
set -e -o nounset | ||
|
||
|
||
# Save script directory and change to it | ||
# | ||
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | ||
cd ${DIR} | ||
|
||
|
||
# Replace any class files | ||
# | ||
if([ -f ReportDate.class ]||[ -f ThirdNextAppointment.class ]) | ||
then | ||
rm *.class | ||
fi | ||
# | ||
javac ReportDate.java | ||
javac ThirdNextAppointment.java | ||
|
||
|
||
# Run ThirdNextAppointment.java, classpath to connector | ||
# | ||
mkdir -p reports/ | ||
java -cp ".:mysql-connector-java-3.0.11.jar" ThirdNextAppointment | ||
|
||
|
||
# Move output to data/sync directory | ||
# | ||
mkdir -p ../../../sync/ | ||
mv reports/* ../../../sync/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# endpoint_3rdNext | ||
3rd next available appointment scripting and exporting |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
/* | ||
* Determines date for specific weekday, example Tuesday, on preceeding weeks | ||
* back to a specified earliest date. | ||
* @author rrusk | ||
*/ | ||
//package thirdnextappointment; | ||
|
||
import java.io.File; | ||
//import java.io.IOException; | ||
import java.text.ParseException; | ||
import java.text.SimpleDateFormat; | ||
import java.util.ArrayList; | ||
import java.util.Calendar; | ||
import java.util.Date; | ||
import java.util.GregorianCalendar; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
/** | ||
* | ||
* @author rrusk | ||
*/ | ||
public class ReportDate { | ||
|
||
static final ClassLoader loader = ReportDate.class.getClassLoader(); | ||
|
||
public ClassLoader getLoader() { | ||
return loader; | ||
} | ||
|
||
static private int setWeekDay(String weekDay) { | ||
String matchDay = weekDay.toUpperCase(); | ||
int result; | ||
if (matchDay.startsWith("MON")) { | ||
result = Calendar.MONDAY; | ||
} else if (matchDay.startsWith("TUE")) { | ||
result = Calendar.TUESDAY; | ||
} else if (matchDay.startsWith("WED")) { | ||
result = Calendar.WEDNESDAY; | ||
} else if (matchDay.startsWith("THU")) { | ||
result = Calendar.THURSDAY; | ||
} else if (matchDay.startsWith("FRI")) { | ||
result = Calendar.FRIDAY; | ||
} else if (matchDay.startsWith("SAT")) { | ||
result = Calendar.SATURDAY; | ||
} else { // must be Sunday | ||
result = Calendar.SUNDAY; | ||
} | ||
return result; | ||
} | ||
|
||
/** | ||
* | ||
* @param earliestDate in format "yyyy-MM-dd" | ||
* @param weekDay with String value, for example "TUESDAY". | ||
* @return array of strings containing dates of specified weekday | ||
*/ | ||
static public ArrayList<String> getDates(String earliestDate, String weekDay) { | ||
ArrayList<String> weekdayArrayList = new ArrayList<String>(); | ||
|
||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); | ||
Date earliestReportDate; | ||
try { | ||
earliestReportDate = dateFormat.parse(earliestDate); | ||
} catch (ParseException ex) { | ||
Logger.getLogger(ReportDate.class.getName()).log(Level.SEVERE, null, ex); | ||
return weekdayArrayList; | ||
} | ||
Calendar cal = Calendar.getInstance(); | ||
cal.setTime(earliestReportDate); | ||
|
||
Calendar calendar = Calendar.getInstance(); | ||
int day = calendar.get(Calendar.DAY_OF_WEEK); | ||
|
||
Date reportDate = calendar.getTime(); | ||
|
||
int cutoffYear = cal.get(Calendar.YEAR); | ||
int cutoffMonth = cal.get(Calendar.MONTH); | ||
int cutoffDayOfMonth = cal.get(Calendar.DAY_OF_MONTH); | ||
GregorianCalendar gCal = | ||
new GregorianCalendar(cutoffYear, cutoffMonth, cutoffDayOfMonth); | ||
Date cutoffDate = gCal.getTime(); | ||
|
||
int theWeekday = setWeekDay(weekDay); | ||
|
||
boolean includeToday = true; | ||
while (day != theWeekday) { | ||
includeToday = false; | ||
calendar.add(Calendar.DATE, 1); | ||
day = calendar.get(Calendar.DAY_OF_WEEK); | ||
} | ||
|
||
if (includeToday) { | ||
int year = calendar.get(Calendar.YEAR); | ||
int month = calendar.get(Calendar.MONTH); | ||
int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH); | ||
reportDate = new GregorianCalendar(year, month, dayOfMonth).getTime(); | ||
weekdayArrayList.add(dateFormat.format(reportDate)); | ||
} | ||
|
||
while (reportDate.after(cutoffDate)) { | ||
calendar.add(Calendar.DATE, -7); | ||
int year = calendar.get(Calendar.YEAR); | ||
int month = calendar.get(Calendar.MONTH); | ||
int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH); | ||
reportDate = new GregorianCalendar(year, month, dayOfMonth).getTime(); | ||
if (reportDate.after(cutoffDate) || reportDate.equals(cutoffDate)) { | ||
weekdayArrayList.add(dateFormat.format(reportDate)); | ||
} | ||
}; | ||
return weekdayArrayList; | ||
} | ||
|
||
public static void main(String[] args) { | ||
|
||
/* File fd = new File("."); // current directory | ||
File[] files = fd.listFiles(); | ||
for (File file : files) { | ||
if (file.isDirectory()) { | ||
System.out.print("directory:"); | ||
} else { | ||
System.out.print(" file:"); | ||
} | ||
try { | ||
System.out.println(file.getCanonicalPath()); | ||
} catch (IOException ex) { | ||
Logger.getLogger(ReportDate.class.getName()).log(Level.SEVERE, null, ex); | ||
} | ||
} | ||
*/ | ||
ReportDate rd = new ReportDate(); | ||
ArrayList<String> tuesdays = rd.getDates("2014-04-01", "TUESDAY"); | ||
|
||
String filepath = null; | ||
for (int i = 0; i < tuesdays.size(); i++) { | ||
filepath = "./reports/thirdnextappt_" + tuesdays.get(i) + ".txt"; | ||
|
||
File f = new File(filepath); | ||
if (!f.exists()) { | ||
System.out.println("file '" + filepath + "' doesn't exist"); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.