diff --git a/appointment-import/.classpath b/appointment-import/.classpath deleted file mode 100644 index f7b62f180179a74fbb8400870e0e56b071065daa..0000000000000000000000000000000000000000 --- a/appointment-import/.classpath +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" output="target/classes" path="src/main/java"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="src" output="target/test-classes" path="src/test/java"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="output" path="target/classes"/> -</classpath> diff --git a/appointment-import/.gitignore b/appointment-import/.gitignore deleted file mode 100644 index ad708984880d5452a04d9a6a243c0c0cde201ce7..0000000000000000000000000000000000000000 --- a/appointment-import/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/target/ -/log.txt diff --git a/appointment-import/.project b/appointment-import/.project deleted file mode 100644 index eee5e1c7df61a5e6865e9a8584bb8c4c4becfe6a..0000000000000000000000000000000000000000 --- a/appointment-import/.project +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>appointment-import</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.m2e.core.maven2Builder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.jdt.core.javanature</nature> - <nature>org.eclipse.m2e.core.maven2Nature</nature> - </natures> -</projectDescription> diff --git a/appointment-import/.settings/org.eclipse.core.resources.prefs b/appointment-import/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 04cfa2c1a8566d64dd12fcf7a8e895fe02e1856f..0000000000000000000000000000000000000000 --- a/appointment-import/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,6 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding//src/main/resources=UTF-8 -encoding//src/test/java=UTF-8 -encoding//src/test/resources=UTF-8 -encoding/<project>=UTF-8 diff --git a/appointment-import/.settings/org.eclipse.jdt.core.prefs b/appointment-import/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index bbcbc93486d53c73668b275ea5daf41b66ba9c41..0000000000000000000000000000000000000000 --- a/appointment-import/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/appointment-import/.settings/org.eclipse.m2e.core.prefs b/appointment-import/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index 14b697b7bbb0d85e8d8ee19141a2a92d9ce211be..0000000000000000000000000000000000000000 --- a/appointment-import/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/appointment-import/pom.xml b/appointment-import/pom.xml deleted file mode 100644 index a2244ee9c27fc393f0190108de420b7cb272a67c..0000000000000000000000000000000000000000 --- a/appointment-import/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <groupId>smash</groupId> - <artifactId>appointment-import</artifactId> - <version>0.0.1-SNAPSHOT</version> - <packaging>jar</packaging> - - <name>appointment-import</name> - <url>http://maven.apache.org</url> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.12</version> - <scope>test</scope> - </dependency> -<dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <version>1.2.17</version> -</dependency> -<dependency> - <groupId>org.apache.poi</groupId> - <artifactId>poi-ooxml</artifactId> - <version>3.15</version> -</dependency> -<dependency> - <groupId>commons-cli</groupId> - <artifactId>commons-cli</artifactId> - <version>1.3.1</version> -</dependency> - </dependencies> - - <build> - <plugins> -<plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.5.1</version> - <configuration> - <source>1.7</source> - <target>1.7</target> - </configuration> -</plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-assembly-plugin</artifactId> - <configuration> - <source>1.7</source> - <target>1.7</target> - <archive> - <manifest> - <addClasspath>true</addClasspath> - <mainClass>smash.appointment.parse.Main</mainClass> - </manifest> - </archive> - <descriptorRefs> - <descriptorRef>jar-with-dependencies</descriptorRef> - </descriptorRefs> - </configuration> - </plugin> - </plugins> - </build> - -</project> diff --git a/appointment-import/src/main/java/smash/appointment/parse/AppointmentDao.java b/appointment-import/src/main/java/smash/appointment/parse/AppointmentDao.java deleted file mode 100644 index ab5871502c8445b74fb03c13d8f988b1a8acb664..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/AppointmentDao.java +++ /dev/null @@ -1,142 +0,0 @@ -package smash.appointment.parse; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - -public class AppointmentDao { - Logger logger = Logger.getLogger(AppointmentDao.class); - private List<AppointmentEntry> appointments = new ArrayList<>(); - - public void addAppointments(List<AppointmentEntry> appointmentsToAdd) { - for (AppointmentEntry appointmentEntry : appointmentsToAdd) { - addAppointment(appointmentEntry); - } - } - - /** - * @return the appointments - * @see #appointments - */ - public List<AppointmentEntry> getAppointments() { - return appointments; - } - - /** - * @param appointments - * the appointments to set - * @see #appointments - */ - public void setAppointments(List<AppointmentEntry> appointments) { - this.appointments = appointments; - } - - public List<Visit> getVisits() throws ParseException { - List<Visit> result = new ArrayList<>(); - Map<Subject, List<AppointmentEntry>> subjectAppointments = new HashMap<>(); - for (AppointmentEntry entry : appointments) { - if (subjectAppointments.get(entry.getSubject()) == null) { - subjectAppointments.put(entry.getSubject(), new ArrayList<AppointmentEntry>()); - } - subjectAppointments.get(entry.getSubject()).add(entry); - } - for (Subject subject : subjectAppointments.keySet()) { - result.addAll(getVisitsForSubject(subject, subjectAppointments.get(subject))); - } - return result; - } - - private List<Visit> getVisitsForSubject(Subject subject, List<AppointmentEntry> list) throws ParseException { - Comparator<AppointmentEntry> comparator = new Comparator<AppointmentEntry>() { - - @Override - public int compare(AppointmentEntry o1, AppointmentEntry o2) { - String date1 = o1.getDay().substring(0, 10); - String date2 = o2.getDay().substring(0, 10); - if (date1.compareTo(date2) == 0) { - if (o1.getTypes().contains(AppointmentType.LEVEL_AQUEST) || o1.getTypes().contains(AppointmentType.LEVEL_A_TQ)) { - return -1; - } else if (o2.getTypes().contains(AppointmentType.LEVEL_AQUEST) || o2.getTypes().contains(AppointmentType.LEVEL_A_TQ)) { - return 1; - } else { - return 0; - } - } else { - return date1.compareTo(date2); - } - } - }; - Collections.sort(list, comparator); - - List<Visit> result = new ArrayList<>(); - Visit currentVisit = new Visit(subject); - for (AppointmentEntry appointmentEntry : list) { - if (appointmentEntry.getTypes().contains(AppointmentType.LEVEL_AQUEST) || appointmentEntry.getTypes().contains(AppointmentType.LEVEL_A_TQ)) { - if (currentVisit.getAppointments().size() > 0) { - if (shouldBeFinished(currentVisit.getEndDate())) { - currentVisit.setFinished(true); - } - result.add(currentVisit); - } - - currentVisit = new Visit(subject); - currentVisit.addAppointment(appointmentEntry); - } else { - String date = currentVisit.getLastAppointmentDate(); - if (date.equals(appointmentEntry.getDay().substring(0, 10))) { - currentVisit.getLastAppointment().addTypes(appointmentEntry.getTypes()); - String source = appointmentEntry.getSource() + "\n" + currentVisit.getLastAppointment().getSource(); - currentVisit.getLastAppointment().setSource(source); - } else { - currentVisit.addAppointment(appointmentEntry); - } - } - } - if (currentVisit.getAppointments().size() > 0) { - result.add(currentVisit); - } - if (shouldBeFinished(currentVisit.getEndDate())) { - currentVisit.setFinished(true); - if (!subject.isDead() && !subject.isResigned()) { - result.add(createNextVisit(currentVisit)); - } - } - return result; - } - - protected Visit createNextVisit(Visit currentVisit) throws ParseException { - Visit visit = new Visit(currentVisit.getSubject()); - Calendar date = Calendar.getInstance(); - String dateStr = currentVisit.getStartDate(); - date.setTime(DATE_FORMATTER.parse(dateStr)); - if (currentVisit.getSubject().getType().equals(SubjectType.CONTROL)) { - date.add(Calendar.YEAR, 4); - } else { - date.add(Calendar.YEAR, 1); - } - visit.setStartDate(DATE_FORMATTER.format(date.getTime())); - return visit; - } - - private static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd"); - - protected boolean shouldBeFinished(String endDate) { - Calendar today_minus_two_months = Calendar.getInstance(); - today_minus_two_months.add(Calendar.MONTH, -2); - return DATE_FORMATTER.format(today_minus_two_months.getTime()).compareTo(endDate) > 0; - } - - public void addAppointment(AppointmentEntry appointment) { - appointments.add(appointment); - - } - -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/AppointmentEntry.java b/appointment-import/src/main/java/smash/appointment/parse/AppointmentEntry.java deleted file mode 100644 index 4b8001727ff44fdd7e46e3a9fa5f35695d0e02e7..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/AppointmentEntry.java +++ /dev/null @@ -1,165 +0,0 @@ -package smash.appointment.parse; - -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -public class AppointmentEntry { - private String day; - private String time; - private String duration; - private Subject subject; - private Set<AppointmentType> types = new HashSet<>(); - private String source; - private String location; - - - /** - * @return the time - * @see #time - */ - public String getTime() { - if (time == null || time.trim().isEmpty()) { - return "09:00"; - } else { - return time; - } - } - - /** - * @param time - * the time to set - * @see #time - */ - public void setTime(String time) { - this.time = time; - } - - /** - * @return the subject - * @see #subject - */ - public Subject getSubject() { - return subject; - } - - /** - * @param subject - * the subject to set - * @see #subject - */ - public void setSubject(Subject subject) { - this.subject = subject; - } - - /** - * @return the type - * @see #type - */ - public Set<AppointmentType> getTypes() { - return types; - } - - /** - * @param type - * the type to set - * @see #type - */ - public void addType(AppointmentType type) { - this.types.add(type); - } - - /** - * @return the day - * @see #day - */ - public String getDay() { - return day; - } - - /** - * @param day - * the day to set - * @see #day - */ - public void setDay(String day) { - this.day = day; - } - - /** - * @return the source - * @see #source - */ - public String getSource() { - return source; - } - - /** - * @param source - * the source to set - * @see #source - */ - public void setSource(String source) { - this.source = source; - } - - @Override - public String toString() { - return day + " " + time + " " + subject + " " + types + "\t\t[source: " + source + "]"; - } - - /** - * @return the duration - * @see #duration - */ - public String getDuration() { - if (duration == null || duration.trim().isEmpty()) { - int count = 0; - for (AppointmentType type : types) { - count += type.getTime(); - } - return count + ""; - } - return duration; - } - - /** - * @param duration - * the duration to set - * @see #duration - */ - public void setDuration(String duration) { - this.duration = duration; - } - - public void addTypes(AppointmentType[] typesToAdd) { - for (AppointmentType appointmentType : typesToAdd) { - addType(appointmentType); - } - - } - - public void addTypes(Collection<AppointmentType> typesToAdd) { - for (AppointmentType appointmentType : typesToAdd) { - addType(appointmentType); - } - - } - - /** - * @return the location - * @see #location - */ - public String getLocation() { - return location; - } - - /** - * @param location the location to set - * @see #location - */ - public void setLocation(String location) { - this.location = location; - } -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/AppointmentSqlExporter.java b/appointment-import/src/main/java/smash/appointment/parse/AppointmentSqlExporter.java deleted file mode 100644 index 4c669334a76b25c7a1ebe5959bbb4e771df61346..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/AppointmentSqlExporter.java +++ /dev/null @@ -1,56 +0,0 @@ -package smash.appointment.parse; - -import java.util.Calendar; - -public class AppointmentSqlExporter extends SqlExporter { - - public String toSql(AppointmentEntry appointment) { - StringBuilder result = new StringBuilder(""); - - result.append("insert into web_appointment ("); - result.append("datetime_when, "); - result.append("length, "); - result.append("status, "); - result.append("comment, "); - result.append("location_id, "); - result.append("visit_id) "); - - result.append("values ("); - result.append(getStringVal(appointment.getDay() + " " + appointment.getTime() + "+00") + ","); - result.append(getStringVal(appointment.getDuration()) + ","); - if (isBefore(appointment, Calendar.getInstance())) { - result.append("'FINISHED',"); - } else { - result.append("'SCHEDULED',"); - } - result.append(getStringVal(appointment.getSource()) + ","); - switch (appointment.getLocation().substring(0, 1)) { - case ("L"): - result.append("(select id from web_location where name = 'LIH'),"); - break; - case ("F"): - result.append("(select id from web_location where name = 'Flying Team'),"); - break; - case ("P"): - result.append("(select id from web_location where name = 'PRC'),"); - break; - default: - throw new RuntimeException("Unknown location: " + appointment.getLocation()); - } - result.append("(select max(id) from web_visit)"); - result.append(");\n"); - - for (AppointmentType type : appointment.getTypes()) { - result.append("\tinsert into web_appointment_appointment_types ("); - result.append("appointment_id, "); - result.append("appointmenttype_id) "); - result.append("values ("); - result.append("(select max(id) from web_appointment),"); - result.append("(select id from web_appointmenttype where code=" + getStringVal(type.getAbbreviation()) + ") "); - result.append(");\n"); - } - - return result.toString(); - } - -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/AppointmentType.java b/appointment-import/src/main/java/smash/appointment/parse/AppointmentType.java deleted file mode 100644 index a4e9aec8774b7cec2379e17d3e78ae89c7f42168..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/AppointmentType.java +++ /dev/null @@ -1,33 +0,0 @@ -package smash.appointment.parse; - -public enum AppointmentType { - LEVEL_BV(90,"BV"), // - LEVEL_BG(30,"BG"), // - LEVEL_SB(30,"SB"), // - - LEVEL_A_TQ(120,"A_TQ"), // - LEVEL_AN(60,"AN"), // - LEVEL_ANP(60,"ANP"), // - LEVEL_ASAMP(60,"ASAMP"), // - LEVEL_AWELC(15,"AWELC"), // - LEVEL_AQUEST(0,"AQUEST"), // - LEVEL_B(90,"B"), // - LEVEL_B_M_POWER(70,"mPower"), // - OTHER(60,"OTHER"), // - ; - - private int time; - private String abbreviation; - - private AppointmentType(int defaultTime, String abbreviation) { - this.time=defaultTime; - this.abbreviation=abbreviation; - } - public int getTime() { - return time; - } - public String getAbbreviation() { - return abbreviation; - } - -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/AppointmentTypeCollection.java b/appointment-import/src/main/java/smash/appointment/parse/AppointmentTypeCollection.java deleted file mode 100644 index 0799c0e5124e2c6eefb519059962135947c39885..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/AppointmentTypeCollection.java +++ /dev/null @@ -1,82 +0,0 @@ -package smash.appointment.parse; - -public enum AppointmentTypeCollection { - LEVEL_A_BV_BG(new AppointmentType[] { AppointmentType.LEVEL_ANP, AppointmentType.LEVEL_BV, AppointmentType.LEVEL_BG }, // - new String[] { "BV + BG + neuro level A" }), // - LEVEL_A_B(new AppointmentType[] { AppointmentType.LEVEL_ANP, AppointmentType.LEVEL_B }, // - new String[] { "level B + level A neuro" }), // - - LEVEL_B_BV_SB(new AppointmentType[] { AppointmentType.LEVEL_B, AppointmentType.LEVEL_BV, AppointmentType.LEVEL_SB }, // - new String[] { "level B + BV + SB" }), // - - LEVEL_B_BV_BG(new AppointmentType[] { AppointmentType.LEVEL_B, AppointmentType.LEVEL_BV, AppointmentType.LEVEL_BG }, // - new String[] { "level B + BV + BG" }), // - - LEVEL_B_BG(new AppointmentType[] { AppointmentType.LEVEL_B, AppointmentType.LEVEL_BG }, // - new String[] { "level B + BG" }), // - - LEVEL_B_BV(new AppointmentType[] { AppointmentType.LEVEL_B, AppointmentType.LEVEL_BV }, // - new String[] { "level B + BV" }), // - - LEVEL_BV_BG_SB_MPOWER( - new AppointmentType[] { AppointmentType.LEVEL_BV, AppointmentType.LEVEL_BG, AppointmentType.LEVEL_SB, AppointmentType.LEVEL_B_M_POWER, }, // - new String[] { "evel BV + BG + SB + mPower", "BV + BG + SB + mPower" }), // - - LEVEL_BG_SB_MPOWER( - new AppointmentType[] { AppointmentType.LEVEL_BG, AppointmentType.LEVEL_SB, AppointmentType.LEVEL_B_M_POWER, }, // - new String[] { "level BG + SB + mPower" }), // - LEVEL_BV_BG_SB(new AppointmentType[] { AppointmentType.LEVEL_BV, AppointmentType.LEVEL_BG, AppointmentType.LEVEL_SB }, // - new String[] { "evel BV + BG + SB", "BV + BG + SB" }), // - LEVEL_BV_SB_NEURO(new AppointmentType[] { AppointmentType.LEVEL_BV, AppointmentType.LEVEL_SB, AppointmentType.LEVEL_AN }, // - new String[] { "BV + SB + neuro" }), // - LEVEL_BV_SB_M_POWER(new AppointmentType[] { AppointmentType.LEVEL_BV, AppointmentType.LEVEL_SB, AppointmentType.LEVEL_B_M_POWER}, // - new String[] { "BV + SB + mPower" }), // - LEVEL_BV_SB(new AppointmentType[] { AppointmentType.LEVEL_BV, AppointmentType.LEVEL_SB }, // - new String[] { "evel BV + SB", "BV + SB" }), // - LEVEL_BV_BG(new AppointmentType[] { AppointmentType.LEVEL_BV, AppointmentType.LEVEL_BG }, // - new String[] { "evel BV + BG", "BV + BG" }), // - LEVEL_BG_SB(new AppointmentType[] { AppointmentType.LEVEL_BG, AppointmentType.LEVEL_SB }, // - new String[] { "evel BG + SB", "BG + SB" }), // - LEVEL_BV(new AppointmentType[] { AppointmentType.LEVEL_BV }, // - new String[] { "evel BV", "BV" }), // - LEVEL_BG(new AppointmentType[] { AppointmentType.LEVEL_BG }, // - new String[] { "evel BG", "BG" }), // - LEVEL_SB(new AppointmentType[] { AppointmentType.LEVEL_SB }, // - new String[] { "evel SB", "SB" }), // - - LEVEL_A_TQ(new AppointmentType[] { AppointmentType.LEVEL_A_TQ }, // - new String[] { "TQ" }), // - LEVEL_A(new AppointmentType[] { AppointmentType.LEVEL_AWELC, AppointmentType.LEVEL_AN, AppointmentType.LEVEL_ANP, AppointmentType.LEVEL_AQUEST, AppointmentType.LEVEL_ASAMP, }, // - new String[] { "level A" }), // - LEVEL_B(new AppointmentType[] { AppointmentType.LEVEL_B }, // - new String[] { "evel B" }), // - LEVEL_B_M_POWER(new AppointmentType[] { AppointmentType.LEVEL_B_M_POWER }, // - new String[] { "mPower" }), // - OTHER(new AppointmentType[] {AppointmentType.OTHER}, // - new String[] {}), // - ; - private String[] queryStrings; - private AppointmentType[] types; - - private AppointmentTypeCollection(AppointmentType[] types, String[] queryStrings) { - this.queryStrings = queryStrings; - this.types = types; - } - - /** - * @return the queryStrings - * @see #queryStrings - */ - public String[] getQueryStrings() { - return queryStrings; - } - - /** - * @return the types - * @see #types - */ - public AppointmentType[] getTypes() { - return types; - } - -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/CellParser.java b/appointment-import/src/main/java/smash/appointment/parse/CellParser.java deleted file mode 100644 index bfd6940fcf13b38ed6c8e2279e953bc515f70192..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/CellParser.java +++ /dev/null @@ -1,167 +0,0 @@ -package smash.appointment.parse; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.log4j.Logger; - -public class CellParser { - Logger logger = Logger.getLogger(CellParser.class); - - private SubjectDao subjectDao; - - Pattern timePattern = Pattern.compile("^[0-9][0-9]\\:[0-9][0-9]"); - - public String extractTime(String content) { - String result = null; - Matcher matcher = timePattern.matcher(content); - if (matcher.find()) { - result = matcher.group(); - } - return result; - } - - public String removeTime(String content) { - Matcher matcher = timePattern.matcher(content); - if (matcher.find()) { - content = matcher.replaceFirst("").trim(); - } - return content; - } - - public AppointmentEntry parseAppointment(String query, String defaultTime) { - AppointmentEntry result = new AppointmentEntry(); - - String time = extractTime(query); - if (time != null) { - query = removeTime(query); - } else { - time = defaultTime; - } - result.setTime(time); - - Subject subject = extractSubject(query); - result.setSubject(subject); - if (subject!=null) { - result.setLocation(subject.getToBeSeenAt()); - } else { - result.setLocation("PRC"); - } - - AppointmentTypeCollection type = extractType(query); - if (type == null) { - result.addType(AppointmentType.OTHER); - } else { - result.addTypes(type.getTypes()); - } - - result.setSource(query); - return result; - } - - public AppointmentTypeCollection extractType(String query) { - - String simplifiedQuery = Utils.simplifyString(query); - - AppointmentTypeCollection result = null; - - String usedString = null; - for (AppointmentTypeCollection type : AppointmentTypeCollection.values()) { - boolean matchFound = false; - for (String string : type.getQueryStrings()) { - if (!matchFound) { - String simplifiedString = Utils.simplifyString(string); - - if (simplifiedQuery.contains(simplifiedString)) { - matchFound = true; - if (result == null) { - result = type; - usedString = string; - } else { - if (string.contains(usedString)) { - result = type; - usedString = string; - } else if (usedString.contains(string)) { - // new one is a substring of old - } else { // if there is no substring then we might have a problem - AppointmentTypeCollection newType = result; - if (usedString.length() < string.length()) { - usedString = string; - newType = type; - } - logger.warn("More than one type possible for query: " + query + ". Type 1: " + result + ". Type 2: " + type + ". Choosing: " + newType); - result = newType; - } - } - - } - } - } - } - return result; - } - - private Subject extractSubject(String query) { - Subject result = null; - String simplifiedQuery = Utils.simplifyString(query); - - SubjectIndexer[] mainIndices = new SubjectIndexer[] { // - new NameSurnameIndexer(), // - new SurnameNameIndexer(), // - new NdNumberIndexer(),// - }; - - result = getByIndices(query, simplifiedQuery, mainIndices); - if (result == null) { - SubjectIndexer[] secondaryIndices = new SubjectIndexer[] { // - new SurnameIndexer(), // - }; - result = getByIndices(query, simplifiedQuery, secondaryIndices); - } - return result; - } - - private Subject getByIndices(String query, String simplifiedQuery, SubjectIndexer[] mainIndices) { - Subject result = null; - for (Subject subject : subjectDao.getSubjects()) { - boolean matchFound = false; - for (SubjectIndexer indexer : mainIndices) { - if (!matchFound) { - if (indexer.match(subject, simplifiedQuery)) { - matchFound = true; - if (result == null) { - result = subject; - } else { - Subject newResult = result; - if (indexer.isBetter(subject, result)) { - newResult = subject; - } - logger.warn( - "[" + indexer.getClass().getSimpleName() + "]" + "More than one subject possible for query: " + query + ". Subject 1: " + result - + ". Subject 2: " + subject + ". Choosing: " + newResult); - result = newResult; - } - } - } - } - } - return result; - } - - /** - * @return the subjectDao - * @see #subjectDao - */ - public SubjectDao getSubjectDao() { - return subjectDao; - } - - /** - * @param subjectDao - * the subjectDao to set - * @see #subjectDao - */ - public void setSubjectDao(SubjectDao subjectDao) { - this.subjectDao = subjectDao; - } -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/DuplicateRemoveParser.java b/appointment-import/src/main/java/smash/appointment/parse/DuplicateRemoveParser.java deleted file mode 100644 index 42fd910a1072f1c6a5e9b34353e655086c93344f..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/DuplicateRemoveParser.java +++ /dev/null @@ -1,48 +0,0 @@ -package smash.appointment.parse; - -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.IOException; - -public class DuplicateRemoveParser { - private SubjectDao subjectDao; - - public void removeDuplicates(String filename) throws IOException { - try (BufferedReader br = new BufferedReader(new FileReader(filename))) { - String line; - while ((line = br.readLine()) != null) { - String tmp[] = line.split("\t"); - Subject subject = subjectDao.getByScreeningNumber(tmp[0]); - if (subject == null) { - throw new InvalidArgumentException("Cannot find subject with id: " + tmp[0]); - } - for (int i = 1; i < tmp.length; i++) { - Subject duplicate = subjectDao.getByScreeningNumber(tmp[i]); - - if (duplicate == null) { - throw new InvalidArgumentException("Cannot find subject with id: " + tmp[i]); - } - subjectDao.removeDuplicate(subject, duplicate, "DUPLICATES: " + tmp[0] + ", " + tmp[i]); - } - } - } - - } - - /** - * @return the subjectDao - * @see #subjectDao - */ - public SubjectDao getSubjectDao() { - return subjectDao; - } - - /** - * @param subjectDao - * the subjectDao to set - * @see #subjectDao - */ - public void setSubjectDao(SubjectDao subjectDao) { - this.subjectDao = subjectDao; - } -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/InvalidArgumentException.java b/appointment-import/src/main/java/smash/appointment/parse/InvalidArgumentException.java deleted file mode 100644 index 7ae0e2d841f43d0e697de94a088e2091823cda56..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/InvalidArgumentException.java +++ /dev/null @@ -1,14 +0,0 @@ -package smash.appointment.parse; - -public class InvalidArgumentException extends RuntimeException { - - public InvalidArgumentException(String string) { - super(string); - } - - /** - * - */ - private static final long serialVersionUID = 1L; - -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/LihControlMappingParser.java b/appointment-import/src/main/java/smash/appointment/parse/LihControlMappingParser.java deleted file mode 100644 index f0dc3de54d5f514defb6c882e3a20abb4d7dbd47..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/LihControlMappingParser.java +++ /dev/null @@ -1,162 +0,0 @@ -package smash.appointment.parse; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.poi.ss.usermodel.Row; - -public class LihControlMappingParser extends SubjectParser { - - @Override - protected String parseScreeningNumber(Row row) { - String number = getString(row.getCell(0)); - if (number.trim().isEmpty()) { - return ""; - } else { - if (number.length() == 1) { - number = "00" + number; - } else if (number.length() == 2) { - number = "0" + number; - } - return "L-" + number; - } - } - - @Override - protected String parseName(Row row) { - return getString(row.getCell(8)); - } - - @Override - protected String parseSurname(Row row) { - return getString(row.getCell(9)); - } - - @Override - protected String parseNdNumber(Row row) { - String number = getString(row.getCell(7)); - - if (number.equalsIgnoreCase("PK") ||number.equalsIgnoreCase("CHEM") || number.equalsIgnoreCase("Flying Team")) { - number = ""; - } - return number; - } - - @Override - protected String getSheetName() { - return "Sheet1"; - } - - @Override - protected int getInitRow() { - return 1; - } - - @Override - protected String parseBirthDate(Row row) { - return ""; - } - - @Override - protected String parsemPowerId(Row row) { - return ""; - } - - @Override - protected String parseAddDate(Row row) { - return getDate(row.getCell(1), Calendar.getInstance()); - } - - @Override - protected String parseReferal(Row row) { - return ""; - } - - @Override - protected String parseDiagnosisYear(Row row) { - return ""; - } - - @Override - protected String parseMail(Row row) { - return ""; - } - - @Override - protected String parsePhone3(Row row) { - return ""; - } - - @Override - protected String parsePhone2(Row row) { - return ""; - } - - @Override - protected String parsePhone1(Row row) { - return getString(row.getCell(10)); - } - - @Override - protected String parseCity(Row row) { - return ""; - - } - - @Override - protected String parseCountry(Row row) { - return ""; - } - - @Override - protected String parseZipCode(Row row) { - return ""; - } - - @Override - protected String parseAddress(Row row) { - return ""; - } - - @Override - protected String parseRemarks(Row row) { - return ""; - } - - @Override - protected String parseDiagnosis(Row row) { - return ""; - } - - @Override - protected SubjectType parseType(Row row) { - return SubjectType.CONTROL; - } - - @Override - protected List<String> parseLanguages(Row row) { - return new ArrayList<>(); - } - - @Override - protected String parseToBeSeenAt(Row row) { - return "L"; - } - - @Override - protected boolean parseDead(Row row) { - return false; - } - - @Override - protected boolean parseResigned(Row row) { - return false; - } - - @Override - protected boolean parsePostponed(Row row) { - return false; - } - -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/LihControlParser.java b/appointment-import/src/main/java/smash/appointment/parse/LihControlParser.java deleted file mode 100644 index 5dd580f688af72c2d69b5b346a94110e14cbddd7..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/LihControlParser.java +++ /dev/null @@ -1,273 +0,0 @@ -package smash.appointment.parse; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.poi.ss.usermodel.Color; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.xssf.usermodel.XSSFColor; - -public class LihControlParser extends SubjectParser { - - @Override - protected String parseScreeningNumber(Row row) { - String number = getString(row.getCell(0)); - if (number.trim().isEmpty()) { - return ""; - } else { - return "L-" + number; - } - } - - @Override - protected String parseName(Row row) { - return getString(row.getCell(2)); - } - - @Override - protected String parseSurname(Row row) { - return getString(row.getCell(1)); - } - - @Override - protected String parseNdNumber(Row row) { - return ""; - } - - @Override - protected String getSheetName() { - return "Screening log"; - } - - @Override - protected int getInitRow() { - return 1; - } - - @Override - protected String parseBirthDate(Row row) { - return getDate(row.getCell(5), null); - } - - @Override - protected String parsemPowerId(Row row) { - return ""; - } - - private static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd"); - - @Override - protected String parseAddDate(Row row) { - return DATE_FORMATTER.format(Calendar.getInstance().getTime()); - } - - @Override - protected String parseReferal(Row row) { - return ""; - } - - @Override - protected String parseDiagnosisYear(Row row) { - return ""; - } - - @Override - protected String parseMail(Row row) { - return getString(row.getCell(8)); - } - - @Override - protected String parsePhone3(Row row) { - return ""; - } - - @Override - protected String parsePhone2(Row row) { - return getString(row.getCell(7)); - } - - @Override - protected String parsePhone1(Row row) { - return getString(row.getCell(6)); - } - - @Override - protected String parseCity(Row row) { - return getString(row.getCell(12)); - - } - - @Override - protected String parseCountry(Row row) { - String zipCode = parseZipCode(row); - if (zipCode!=null) { - if (zipCode.startsWith("L")) { - return "Luxembourg"; - } else if (zipCode.startsWith("D")){ - return "Deutschland"; - } else if (zipCode.startsWith("F")){ - return "France"; - } else if (zipCode.startsWith("B")){ - return "Belgique"; - } - } - return ""; - } - - @Override - protected String parseZipCode(Row row) { - return getString(row.getCell(11)); - } - - @Override - protected String parseAddress(Row row) { - return getString(row.getCell(9)) + ", " + getString(row.getCell(10)); - } - - @Override - protected String parseRemarks(Row row) { - List<String> remarks = new ArrayList<>(); - String info = getString(row.getCell(4)); - if (!info.trim().isEmpty()) { - remarks.add("PD family relation=" + info); - } - remarks.add(getString(row.getCell(13))); - remarks.add(getComments(row.getCell(14))); - remarks.add(getComments(row.getCell(15))); - remarks.add(getComments(row.getCell(16))); - remarks.add("Inclusion="+getString(row.getCell(17))); - remarks.add(getString(row.getCell(18))); - remarks.add(getString(row.getCell(19))); - String result = ""; - for (String string : remarks) { - if (!string.trim().isEmpty()) { - result += string.trim() + "\n"; - } - } - return result; - } - - @Override - protected String parseDiagnosis(Row row) { - return ""; - } - - @Override - protected SubjectType parseType(Row row) { - return SubjectType.CONTROL; - } - - @Override - protected List<String> parseLanguages(Row row) { - List<String> result = new ArrayList<>(); - - String languages = getString(row.getCell(3)); - String langAbbreviations[] = new String[] {}; - if (languages.indexOf(",") >= 0) { - langAbbreviations = languages.split(","); - } else if (languages.indexOf("+") >= 0) { - langAbbreviations = languages.split("\\+"); - } else { - langAbbreviations = languages.split("/"); - } - for (String string : langAbbreviations) { - if (!string.trim().isEmpty()) { - result.add(getMappedLanguage(string.trim())); - } - } - return result; - } - - protected String getMappedLanguage(String abbreviation) { - switch (abbreviation.toUpperCase()) { - case ("F"): - return "French"; - case ("D"): - return "German"; - case ("A"): - return "German"; - case ("E"): - return "Spanish"; - case ("ALL"): - return "German"; - case ("GB"): - return "English"; - case ("P"): - return "Portuguese"; - case ("PT"): - return "Portuguese"; - case ("ENG"): - return "English"; - case ("EN"): - return "English"; - case ("FR"): - return "French"; - case ("L"): - return "Luxembourgish"; - case ("LUX"): - return "Luxembourgish"; - } - logger.warn("Unknown language abbreviation: " + abbreviation); - return ""; - } - - @Override - protected String parseToBeSeenAt(Row row) { - return "L"; - } - - @Override - protected boolean parseDead(Row row) { - return false; - } - - @Override - protected boolean parsePostponed(Row row) { - Color color = row.getCell(0).getCellStyle().getFillForegroundColorColor(); - if (color == null) { - return false; - } - - XSSFColor c = (XSSFColor) color; - String colorString = c.getARGBHex().substring(2); - switch (colorString) { - case ("FFC000"):// orange - return false; - case ("FFFF00"):// yellow - return false; - case ("FF0000"):// red - return false; - case ("FF3399"):// pink - return true; - case ("00B050"):// green - return false; - } - throw new RuntimeException(parseName(row) + " " + parseSurname(row) + ": Unknown color: " + colorString); - } - - @Override - protected boolean parseResigned(Row row) { - Color color = row.getCell(0).getCellStyle().getFillForegroundColorColor(); - if (color == null) { - return false; - } - - XSSFColor c = (XSSFColor) color; - String colorString = c.getARGBHex().substring(2); - switch (colorString) { - case ("FFC000"):// orange - return false; - case ("FFFF00"):// yellow - return false; - case ("FF0000"):// red - return true; - case ("FF3399"):// pink - return false; - case ("00B050"):// green - return false; - } - throw new RuntimeException(parseName(row) + " " + parseSurname(row) + ": Unknown color: " + colorString); - } -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/Main.java b/appointment-import/src/main/java/smash/appointment/parse/Main.java deleted file mode 100644 index 8db86858cfbbcdc461ed881ffc9775cb65551231..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/Main.java +++ /dev/null @@ -1,185 +0,0 @@ -package smash.appointment.parse; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.CommandLineParser; -import org.apache.commons.cli.DefaultParser; -import org.apache.commons.cli.HelpFormatter; -import org.apache.commons.cli.Option; -import org.apache.commons.cli.Options; -import org.apache.commons.cli.ParseException; -import org.apache.log4j.Logger; - -public class Main { - private static Logger logger = Logger.getLogger(Main.class); - - SubjectDao subjectDao = new SubjectDao(); - AppointmentDao appointmentDao = new AppointmentDao(); - - public void run(String[] args) throws Exception { - - Options options = new Options(); - Option agenda = Option.builder().required().argName("file").hasArg().desc("PRC agenda").longOpt("agenda").build(); - Option subjects = Option.builder().required().argName("file").hasArg().desc("PRC subjects").longOpt("subjects").build(); - Option controls = Option.builder().required().argName("file").hasArg().desc("PRC controls").longOpt("controls").build(); - Option flyingTeam = Option.builder().required().argName("file").hasArg().desc("PRC flying-team").longOpt("flying-team").build(); - Option lihControls = Option.builder().required().argName("file").hasArg().desc("LIH controls").longOpt("lih-controls").build(); - Option lihMappingControls = Option.builder().required().argName("file").hasArg().desc("LIH controls mapping").longOpt("lih-mapping").build(); - Option redCap = Option.builder().required().argName("file").hasArg().desc("RedCap appointments").longOpt("red-cap").build(); - Option redCapCalendar = Option.builder().required().argName("file").hasArg().desc("RedCap calendar sql").longOpt("red-cap-calendar").build(); - Option duplicates = Option.builder().required().argName("file").hasArg().desc("duplicates").longOpt("duplicates").build(); - options.addOption(agenda); - - options.addOption(subjects); - options.addOption(controls); - options.addOption(flyingTeam); - options.addOption(lihControls); - options.addOption(lihMappingControls); - options.addOption(redCap); - options.addOption(redCapCalendar); - options.addOption(duplicates); - - CommandLineParser parser = new DefaultParser(); - try { - CommandLine line = parser.parse(options, args); - - String subjectsFile = line.getOptionValue("subjects"); - for (Subject subject : processPrcSubjects(subjectsFile)) { - subjectDao.addSubject(subject, "[" + subjectsFile + ";" + subject.getScreeningNumber() + ";" + subject.getName() + " " + subject.getSurname() + "]"); - } - - String controlsFile = line.getOptionValue("controls"); - for (Subject subject : processPrcControls(controlsFile)) { - subjectDao.addSubject(subject, "[" + controlsFile + ";" + subject.getScreeningNumber() + ";" + subject.getName() + " " + subject.getSurname() + "]"); - } - - String flyingTeamFile = line.getOptionValue("flying-team"); - for (Subject subject : processFlyingTeamControls(flyingTeamFile)) { - subjectDao.addSubject(subject, "[" + flyingTeamFile + ";" + subject.getScreeningNumber() + ";" + subject.getName() + " " + subject.getSurname() + "]"); - } - - String lihMappingControlsFile = line.getOptionValue("lih-mapping"); - for (Subject subject : processLihMappingControls(lihMappingControlsFile)) { - subjectDao.addSubject( - subject, "[" + lihMappingControlsFile + ";" + subject.getScreeningNumber() + ";" + subject.getName() + " " + subject.getSurname() + "]"); - } - - String lihControlsFile = line.getOptionValue("lih-controls"); - for (Subject subject : processLihControls(lihControlsFile)) { - subjectDao - .addSubject(subject, "[" + lihControlsFile + ";" + subject.getScreeningNumber() + ";" + subject.getName() + " " + subject.getSurname() + "]"); - } - - String duplicatesFile = line.getOptionValue("duplicates"); - removeDuplicates(duplicatesFile); - - subjectDao.addSubject(Visit.UNKNOWN, ""); - - String agendaFile = line.getOptionValue("agenda"); - Calendar today = Calendar.getInstance(); - today.set(Calendar.HOUR, 5); - appointmentDao.addAppointments(processPrcAppointments(agendaFile, today)); - - String redCapFile = line.getOptionValue("red-cap"); - appointmentDao.addAppointments(processRedCapAppointments(redCapFile)); - - String redCapCalendarFile = line.getOptionValue("red-cap-calendar"); - appointmentDao.addAppointments(processRedCapCalendar(redCapCalendarFile)); - - System.out.println("delete from web_visit_appointment_types;"); - System.out.println("delete from web_appointment_appointment_types;"); - System.out.println("delete from web_subject_languages;"); - System.out.println("delete from web_appointment;"); - System.out.println("delete from web_visit;"); - System.out.println("delete from web_subject;"); - - SubjectSqlExporter subjectSqlExporter = new SubjectSqlExporter(); - // logger.debug("SUBJECTS: "); - for (Subject subject : subjectDao.getSubjects()) { - System.out.println(subjectSqlExporter.toSql(subject)); - } - - VisitSqlExporter visitSqlExporter = new VisitSqlExporter(); - List<Visit> visits = appointmentDao.getVisits(); - for (int i = 0; i < visits.size(); i++) { - Visit visit = visits.get(i); - System.out.println(visitSqlExporter.toSql(visit)); - } - - } catch (ParseException exp) { - System.out.println(exp.getMessage()); - HelpFormatter formatter = new HelpFormatter(); - formatter.printHelp("java -jar file.jar", options); - } - } - - private List<AppointmentEntry> processRedCapCalendar(String redCapCalendarFile) throws FileNotFoundException, IOException { - RedcapCalendarParser redcapCalendarParser = new RedcapCalendarParser(); - redcapCalendarParser.setSubjectDao(subjectDao); - Calendar date = Calendar.getInstance(); - date.set(Calendar.HOUR, 0); - return redcapCalendarParser.parse(redCapCalendarFile, date); - } - - private void removeDuplicates(String duplicatesFile) throws IOException { - logger.info("PROCESSING FILE: " + duplicatesFile); - DuplicateRemoveParser parser = new DuplicateRemoveParser(); - parser.setSubjectDao(subjectDao); - parser.removeDuplicates(duplicatesFile); - } - - private List<AppointmentEntry> processRedCapAppointments(String agendaFile) throws Exception { - logger.info("PROCESSING FILE: " + agendaFile); - RedcapParser parser = new RedcapParser(); - parser.setSubjectDao(subjectDao); - return parser.parse(agendaFile); - } - - private List<Subject> processLihMappingControls(String lihMappingControlsFile) throws Exception { - logger.info("PROCESSING FILE: " + lihMappingControlsFile); - LihControlMappingParser parser = new LihControlMappingParser(); - return parser.processExcel(lihMappingControlsFile); - } - - private List<Subject> processLihControls(String lihControlsFile) throws Exception { - logger.info("PROCESSING FILE: " + lihControlsFile); - LihControlParser parser = new LihControlParser(); - return parser.processExcel(lihControlsFile); - } - - private List<Subject> processFlyingTeamControls(String flyingTeamFile) throws Exception { - logger.info("PROCESSING FILE: " + flyingTeamFile); - PrcFlyingParser parser = new PrcFlyingParser(); - return parser.processExcel(flyingTeamFile); - } - - private List<Subject> processPrcControls(String controlsFile) throws Exception { - logger.info("PROCESSING FILE: " + controlsFile); - PrcControlParser parser = new PrcControlParser(); - return parser.processExcel(controlsFile); - } - - private List<AppointmentEntry> processPrcAppointments(String agendaFile, Calendar minDate) throws Exception { - logger.info("PROCESSING FILE: " + agendaFile); - XlsxCalendarProcessor processor = new XlsxCalendarProcessor(); - processor.setSubjectDao(subjectDao); - List<AppointmentEntry> entries = processor.processExcel(agendaFile, minDate); - - return entries; - } - - public static void main(String[] args) throws Exception { - new Main().run(args); - } - - private List<Subject> processPrcSubjects(String subjectsFile) throws Exception { - logger.info("PROCESSING FILE: " + subjectsFile); - PrcSubjectsParser parser = new PrcSubjectsParser(); - return parser.processExcel(subjectsFile); - } - -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/NameSurnameIndexer.java b/appointment-import/src/main/java/smash/appointment/parse/NameSurnameIndexer.java deleted file mode 100644 index 2ed820ad2e1b4609692d2eaf7233254a6784c0fc..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/NameSurnameIndexer.java +++ /dev/null @@ -1,9 +0,0 @@ -package smash.appointment.parse; - -public class NameSurnameIndexer extends SubjectIndexer { - - public String getIndexedString(Subject subject) { - return Utils.simplifyString(subject.getName() + subject.getSurname()); - } - -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/NdNumberIndexer.java b/appointment-import/src/main/java/smash/appointment/parse/NdNumberIndexer.java deleted file mode 100644 index cd96a4a1a0149f439d7436689350279fe87d92fb..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/NdNumberIndexer.java +++ /dev/null @@ -1,9 +0,0 @@ -package smash.appointment.parse; - -public class NdNumberIndexer extends SubjectIndexer { - - public String getIndexedString(Subject subject) { - return Utils.simplifyString(subject.getNdNumber()); - } - -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/PrcControlParser.java b/appointment-import/src/main/java/smash/appointment/parse/PrcControlParser.java deleted file mode 100644 index 7a7ec376543578b77ca3db1e2fb2206e79479f89..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/PrcControlParser.java +++ /dev/null @@ -1,165 +0,0 @@ -package smash.appointment.parse; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.Row; - -public class PrcControlParser extends SubjectParser { - - @Override - protected String parseScreeningNumber(Row row) { - String number = getString(row.getCell(13)); - if (number.trim().isEmpty()) { - return ""; - } else { - if (number.length() == 1) { - number = "00" + number; - } else if (number.length() == 2) { - number = "0" + number; - } - return "P-" + number; - } - } - - @Override - protected String parseName(Row row) { - return getString(row.getCell(1)); - } - - @Override - protected String parseSurname(Row row) { - return getString(row.getCell(0)); - } - - @Override - protected String parseNdNumber(Row row) { - return getString(row.getCell(12)); - } - - @Override - protected String getSheetName() { - return "Contrôles"; - } - - @Override - protected int getInitRow() { - return 1; - } - - @Override - protected String parseBirthDate(Row row) { - return parseDateOfBirth(row.getCell(11)); - } - - @Override - protected String parsemPowerId(Row row) { - return ""; - } - - @Override - protected String parseAddDate(Row row) { - return getDate(row.getCell(9), Calendar.getInstance()); - } - - @Override - protected String parseReferal(Row row) { - return ""; - } - - @Override - protected String parseDiagnosisYear(Row row) { - return ""; - } - - @Override - protected String parseMail(Row row) { - return getString(row.getCell(8)); - } - - @Override - protected String parsePhone3(Row row) { - return ""; - } - - @Override - protected String parsePhone2(Row row) { - return getString(row.getCell(7)); - } - - @Override - protected String parsePhone1(Row row) { - return getString(row.getCell(6)); - } - - @Override - protected String parseCity(Row row) { - return getString(row.getCell(4)); - } - - @Override - protected String parseCountry(Row row) { - return getString(row.getCell(5)); - } - - @Override - protected String parseZipCode(Row row) { - return getString(row.getCell(3)); - } - - @Override - protected String parseAddress(Row row) { - return getString(row.getCell(2)); - } - - @Override - protected String parseRemarks(Row row) { - String remark1 = getString(row.getCell(10)); - String remark2 = ""; - - String result = ""; - if (!remark1.trim().isEmpty()) { - result = result + remark1 + "\n"; - } - if (!remark2.trim().isEmpty()) { - result = result + remark2 + "\n"; - } - return result; - } - - @Override - protected String parseDiagnosis(Row row) { - return ""; - } - - @Override - protected SubjectType parseType(Row row) { - return SubjectType.CONTROL; - } - - @Override - protected List<String> parseLanguages(Row row) { - return new ArrayList<>(); - } - - @Override - protected String parseToBeSeenAt(Row row) { - return "P"; - } - @Override - protected boolean parseDead(Row row) { - return false; - } - - @Override - protected boolean parseResigned(Row row) { - return false; - } - - @Override - protected boolean parsePostponed(Row row) { - return false; - } -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/PrcFlyingParser.java b/appointment-import/src/main/java/smash/appointment/parse/PrcFlyingParser.java deleted file mode 100644 index 1ee25fa2de02e448063e86233b9bf137288c0a65..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/PrcFlyingParser.java +++ /dev/null @@ -1,171 +0,0 @@ -package smash.appointment.parse; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.Row; - -public class PrcFlyingParser extends SubjectParser { - - @Override - protected String parseScreeningNumber(Row row) { - String number = getString(row.getCell(22)); - if (number.trim().isEmpty()) { - return ""; - } else { - if (number.length() == 1) { - number = "00" + number; - } else if (number.length() == 2) { - number = "0" + number; - } - return "F-" + number; - } - } - - @Override - protected String parseName(Row row) { - return getString(row.getCell(1)); - } - - @Override - protected String parseSurname(Row row) { - return getString(row.getCell(0)); - } - - @Override - protected String parseNdNumber(Row row) { - return getString(row.getCell(21)); - } - - @Override - protected String getSheetName() { - return "Leudelange"; - } - - @Override - protected int getInitRow() { - return 2; - } - - @Override - protected String parseBirthDate(Row row) { - return parseDateOfBirth(row.getCell(23)); - } - - @Override - protected String parsemPowerId(Row row) { - return ""; - } - - @Override - protected String parseAddDate(Row row) { - return getDate(row.getCell(13),Calendar.getInstance()); - } - - @Override - protected String parseReferal(Row row) { - return getString(row.getCell(12)); - } - - @Override - protected String parseDiagnosisYear(Row row) { - return ""; - } - - @Override - protected String parseMail(Row row) { - return getString(row.getCell(9)); - } - - @Override - protected String parsePhone3(Row row) { - return ""; - } - - @Override - protected String parsePhone2(Row row) { - return getString(row.getCell(8)); - } - - @Override - protected String parsePhone1(Row row) { - return getString(row.getCell(7)); - } - - @Override - protected String parseCity(Row row) { - return getString(row.getCell(5)); - } - - @Override - protected String parseCountry(Row row) { - return getString(row.getCell(6)); - } - - @Override - protected String parseZipCode(Row row) { - return getString(row.getCell(4)); - } - - @Override - protected String parseAddress(Row row) { - return getString(row.getCell(3)); - } - - @Override - protected String parseRemarks(Row row) { - String remark1 = getString(row.getCell(10)); - String remark2 = getString(row.getCell(19)); - - String result = ""; - if (!remark1.trim().isEmpty()) { - result = result + remark1 + "\n"; - } - if (!remark2.trim().isEmpty()) { - result = result + remark2 + "\n"; - } - return result; - } - - @Override - protected String parseDiagnosis(Row row) { - return getString(row.getCell(11)); - } - - @Override - protected SubjectType parseType(Row row) { - String str = getString(row.getCell(2)).toLowerCase().trim(); - if (str.startsWith("c")) { - return SubjectType.CONTROL; - } else if (str.startsWith("p")) { - return SubjectType.PATIENT; - } - return SubjectType.PATIENT; - } - - @Override - protected List<String> parseLanguages(Row row) { - return new ArrayList<>(); - } - @Override - protected String parseToBeSeenAt(Row row) { - return "F"; - } - - @Override - protected boolean parseDead(Row row) { - return false; - } - - @Override - protected boolean parseResigned(Row row) { - return false; - } - @Override - protected boolean parsePostponed(Row row) { - return false; - } - -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/PrcSubjectsParser.java b/appointment-import/src/main/java/smash/appointment/parse/PrcSubjectsParser.java deleted file mode 100644 index 5badd40394a25d065d17796f3547427dc34c6d42..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/PrcSubjectsParser.java +++ /dev/null @@ -1,213 +0,0 @@ -package smash.appointment.parse; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.poi.hssf.util.HSSFColor; -import org.apache.poi.ss.usermodel.Color; -import org.apache.poi.ss.usermodel.IndexedColors; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.xssf.usermodel.XSSFColor; - -public class PrcSubjectsParser extends SubjectParser { - - @Override - protected String parseScreeningNumber(Row row) { - String number = getString(row.getCell(25)); - if (number.trim().isEmpty()) { - return ""; - } else { - if (number.length() == 1) { - number = "00" + number; - } else if (number.length() == 2) { - number = "0" + number; - } - return "P-" + number; - } - } - - @Override - protected String parseName(Row row) { - return getString(row.getCell(1)); - } - - @Override - protected String parseSurname(Row row) { - return getString(row.getCell(0)); - } - - @Override - protected String parseNdNumber(Row row) { - return getString(row.getCell(22)); - } - - @Override - protected String getSheetName() { - return "Feuil1"; - } - - @Override - protected int getInitRow() { - return 1; - } - - @Override - protected String parseBirthDate(Row row) { - return parseDateOfBirth(row.getCell(27)); - } - - @Override - protected String parsemPowerId(Row row) { - return getString(row.getCell(23)); - } - - @Override - protected String parseAddDate(Row row) { - return getDate(row.getCell(14), Calendar.getInstance()); - } - - @Override - protected String parseReferal(Row row) { - return getString(row.getCell(13)); - } - - @Override - protected String parseDiagnosisYear(Row row) { - return getString(row.getCell(11)); - } - - @Override - protected String parseMail(Row row) { - return getString(row.getCell(10)); - } - - @Override - protected String parsePhone3(Row row) { - return getString(row.getCell(9)); - } - - @Override - protected String parsePhone2(Row row) { - return getString(row.getCell(8)); - } - - @Override - protected String parsePhone1(Row row) { - return getString(row.getCell(7)); - } - - @Override - protected String parseCity(Row row) { - return getString(row.getCell(5)); - } - - @Override - protected String parseCountry(Row row) { - return getString(row.getCell(6)); - } - - @Override - protected String parseZipCode(Row row) { - return getString(row.getCell(4)); - } - - @Override - protected String parseAddress(Row row) { - return getString(row.getCell(3)); - } - - @Override - protected String parseRemarks(Row row) { - String remark1 = getString(row.getCell(2)); - String remark2 = getString(row.getCell(20)); - - String result = ""; - if (!remark1.trim().isEmpty()) { - result = result + remark1 + "\n"; - } - if (!remark2.trim().isEmpty()) { - result = result + remark2 + "\n"; - } - return result; - } - - @Override - protected String parseDiagnosis(Row row) { - return getString(row.getCell(12)); - } - - @Override - protected SubjectType parseType(Row row) { - return SubjectType.PATIENT; - } - - @Override - protected List<String> parseLanguages(Row row) { - return new ArrayList<>(); - } - - @Override - protected String parseToBeSeenAt(Row row) { - return "P"; - } - - @Override - protected boolean parseDead(Row row) { - Color color = row.getCell(0).getCellStyle().getFillForegroundColorColor(); - if (color == null) { - return false; - } - if (color instanceof XSSFColor) { - return true; - } - if (color instanceof HSSFColor) { - HSSFColor hssfColor = (HSSFColor) color; - if (hssfColor.getHexString().equalsIgnoreCase("0:0:0")) { - return false; - } else { - return true; - } - } - return false; - } - - @Override - protected boolean parseResigned(Row row) { - try { - int colorId = row.getSheet().getWorkbook().getFontAt(row.getCell(0).getCellStyle().getFontIndex()).getColor(); - // special case for black - if (colorId == 32767) { - return false; - } - IndexedColors color = IndexedColors.fromInt(colorId); - switch (color) { - case RED: - return true; - case SEA_GREEN: - return false; - case PINK: - return false; - case PLUM: - return false; - case BLUE: - return false; - case BLACK: - return false; - case GREEN: - return false; - default: - logger.debug("Unknown font color: " + color); - return false; - } - } catch (Exception e) { - logger.error("Problem with parsing color for subject: " + parseName(row) + " " + parseSurname(row), e); - return false; - } - } - - @Override - protected boolean parsePostponed(Row row) { - return false; - } -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/RedcapCalendarParser.java b/appointment-import/src/main/java/smash/appointment/parse/RedcapCalendarParser.java deleted file mode 100644 index e9b86aee73fc5c1b014fbef24a416eb8e8b8ec08..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/RedcapCalendarParser.java +++ /dev/null @@ -1,162 +0,0 @@ -package smash.appointment.parse; - -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.log4j.Logger; - -public class RedcapCalendarParser { - Logger logger = Logger.getLogger(RedcapCalendarParser.class); - - private SubjectDao subjectDao; - - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd"); - - public List<AppointmentEntry> parse(String filename, Calendar minDate) throws FileNotFoundException, IOException { - List<AppointmentEntry> result = new ArrayList<>(); - try (BufferedReader br = new BufferedReader(new FileReader(filename))) { - String line; - while ((line = br.readLine()) != null) { - if (!line.startsWith("INSERT INTO")) { - continue; - } - String tmp[] = line.substring(line.indexOf("(")).split("\\),\\(", -1); - for (String string : tmp) { - AppointmentEntry entry = processEntry(string, minDate); - if (entry != null) { - result.add(entry); - } - } - } - } - return result; - } - - private AppointmentEntry processEntry(String string, Calendar minDate) { - AppointmentEntry result = new AppointmentEntry(); - if (string.startsWith("(")) { - string = string.substring(1); - } - if (string.endsWith(")")) { - string = string.substring(0, string.length() - 1); - } - string = string.replaceAll("\\\\'", "__quota__"); - string = string.replaceAll("'", "\""); - string = string.replaceAll("__quota__", "'"); - String fields[] = string.split(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)", -1); - String ndNumber = fields[1].replaceAll("\"", ""); - String day = fields[6].replaceAll("\"", ""); - String time = fields[7].replaceAll("\"", ""); - - String query = fields[10].replaceAll("\"", ""); - - if (query.equals("") || query.equals("NULL")) { - return null; - } - - if (minDate != null) { - if (day.compareTo(dateFormatter.format(minDate.getTime())) < 0) { - return null; - } - } - if (ndNumber.equals("NDtest_internal") || ndNumber.equals("NDtest_external")) { - return null; - } - - Subject subject = null; - if (!ndNumber.equalsIgnoreCase("NULL")) { - subject = subjectDao.getByNdNumber(ndNumber); - if (subject == null) { - logger.warn("Cannot find subject with nd number: " + ndNumber); - } - } - if (subject == null) { - subject = findSubject(query); - } - if (subject != null && !subject.getToBeSeenAt().toLowerCase().startsWith("l")) { - return null; - } - result.setLocation("LIH"); - result.setDay(day); - result.setTime(time); - result.setSource("From redcap: " + query); - result.setSubject(subject); - result.addTypes(getTypes(query)); - if (result.getTypes().contains(AppointmentType.OTHER)) { - logger.warn("Cannot find types for: " + query); - } - if (result.getTypes().contains(AppointmentType.LEVEL_ASAMP)) { - return result; - } else { - logger.debug("Skipping LIH appointment: " + query); - return null; - } - } - - CellParser cellParser = new CellParser(); - - private List<AppointmentType> getTypes(String query) { - List<AppointmentType> result = new ArrayList<>(); - AppointmentTypeCollection collection = cellParser.extractType(query); - if (collection == null) { - int index = query.indexOf("_"); - if (index >= 0) { - query = query.substring(index); - if (query.startsWith("_lev a_")) { - collection = AppointmentTypeCollection.LEVEL_A; - } else { - index = query.indexOf("_", 1); - if (index >= 0) { - query = query.substring(index); - if (query.startsWith("_lev a_")) { - collection = AppointmentTypeCollection.LEVEL_A; - } - } - } - } - if (collection == null) { - collection = AppointmentTypeCollection.OTHER; - } - } - for (AppointmentType appointmentType : collection.getTypes()) { - result.add(appointmentType); - } - - return result; - } - - private Subject findSubject(String query) { - String id = query.split("_")[0]; - id = "L-" + id; - Subject result = subjectDao.getByScreeningNumber(id); - if (result == null) { - logger.warn("Cannot find subject for query: " + query); - } - return result; - } - - /** - * @return the subjectDao - * @see #subjectDao - */ - public SubjectDao getSubjectDao() { - return subjectDao; - } - - /** - * @param subjectDao - * the subjectDao to set - * @see #subjectDao - */ - public void setSubjectDao(SubjectDao subjectDao) { - this.subjectDao = subjectDao; - } -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/RedcapMissingSqlExporter.java b/appointment-import/src/main/java/smash/appointment/parse/RedcapMissingSqlExporter.java deleted file mode 100644 index 3a15d6c16bf49e2e55f8f5562b3e0439696fb95c..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/RedcapMissingSqlExporter.java +++ /dev/null @@ -1,52 +0,0 @@ -package smash.appointment.parse; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -public class RedcapMissingSqlExporter { - static SubjectDao subjectDao = new SubjectDao(); - - public static void main(String[] args) throws Exception { - List<Subject> subjects = new ArrayList<>(); - for (int count =0 ;count<10000;count++) { - String nd = count+""; - while (nd.length()<4) { - nd = "0"+nd; - } - Subject subject = new Subject("name "+nd, "surname"+nd, "ND"+nd, count+""); - - String screening = nd; - if (screening.startsWith("0")) { - screening = screening.substring(1); - } - subject.setScreeningNumber("P-"+screening); - subject.setToBeSeenAt("PRC"); - if (count>=3000) { - screening=screening.substring(1); - subject.setScreeningNumber("L-"+screening); - subject.setToBeSeenAt("LIH"); - } - if (count>=7000) { - subject.setScreeningNumber("F-"+nd); - subject.setToBeSeenAt("FLYING TEAM"); - } - subjects.add(subject); - } - subjectDao.setSubjects(subjects); - - RedcapCalendarParser parser = new RedcapCalendarParser(); - parser.setSubjectDao(subjectDao); - Calendar date = Calendar.getInstance(); - date.set(2017, 2, 21, 1, 0, 0); - List<AppointmentEntry> entries = parser.parse("E:/redcap_events_calendar-20032017.sql", date); - - VisitSqlExporter sqlExporter = new VisitSqlExporter(); - for (AppointmentEntry entry: entries) { - Visit visit = new Visit(entry.getSubject()); - visit.addAppointment(entry); - visit.setStartDate(entry.getDay()); - System.out.println(sqlExporter.toSql(visit)); - } - } -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/RedcapParser.java b/appointment-import/src/main/java/smash/appointment/parse/RedcapParser.java deleted file mode 100644 index 77daba4800f5cb51d19bd23ef250805d335e67d0..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/RedcapParser.java +++ /dev/null @@ -1,212 +0,0 @@ -package smash.appointment.parse; - -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; - -public class RedcapParser { - Logger logger = Logger.getLogger(RedcapParser.class); - - private SubjectDao subjectDao; - - public List<AppointmentEntry> parse(String filename) throws FileNotFoundException, IOException { - List<AppointmentEntry> result = new ArrayList<>(); - try (BufferedReader br = new BufferedReader(new FileReader(filename))) { - int lineNumber = 0; - String line; - while ((line = br.readLine()) != null) { - lineNumber++; - if (lineNumber == 1) { - continue; - } - String tmp[] = line.split("\t", -1); - - String ndNumber = tmp[0]; - Subject subject = subjectDao.getByNdNumber(ndNumber); - if (subject == null) { - logger.warn("Cannot find subject with id: " + ndNumber); - } else { - if (tmp.length < 8) { - logger.warn("Invalid row (not enough cells): " + line); - } else { - subject.addLanguage(tmp[4]); - subject.addLanguage(tmp[5]); - subject.addLanguage(tmp[6]); - subject.addLanguage(tmp[7]); - if (!tmp[3].trim().isEmpty()) { - subject.setSex(tmp[3]); - } - if (!tmp[2].trim().isEmpty()) { - subject.setBirthDate(tmp[2]); - } - - List<AppointmentEntry> subjectAppointments = new ArrayList<>(); - if (!tmp[9].isEmpty()) { - subjectAppointments.add(createEntryLevelA(tmp[9], tmp[10], subject)); - } - - if (!tmp[13].isEmpty()) { - subjectAppointments.add(createEntryLevelB(tmp[13], tmp[14], subject)); - } - - if (!tmp[17].isEmpty()) { - subjectAppointments.add(createEntryLevelBG(tmp[17], tmp[18], subject)); - } - - if (!tmp[21].isEmpty()) { - subjectAppointments.add(createEntryLevelBV(tmp[21], tmp[22], subject)); - } - - if (!tmp[41].isEmpty()) { - subjectAppointments.add(createEntryLevelSB(tmp[41], subject)); - } - - if (!tmp[45].isEmpty()) { - subjectAppointments.add(createEntryLevelMPower(tmp[45], subject)); - } - - result.addAll(subjectAppointments); - } - } - - } - } - return result; - - } - - private AppointmentEntry createEntryLevelMPower(String from, Subject subject) { - AppointmentEntry entry = new AppointmentEntry(); - String date = getDate(from); - entry.setDay(date); - entry.setSubject(subject); - entry.setSource("Imported from RedCap"); - entry.addType(AppointmentType.LEVEL_B_M_POWER); - entry.setLocation(subject.getToBeSeenAt()); - return entry; - } - - private AppointmentEntry createEntryLevelSB(String from, Subject subject) { - AppointmentEntry entry = new AppointmentEntry(); - String date = getDate(from); - entry.setDay(date); - entry.setSubject(subject); - entry.setSource("Imported from RedCap"); - entry.addType(AppointmentType.LEVEL_SB); - entry.setLocation(subject.getToBeSeenAt()); - return entry; - } - - private AppointmentEntry createEntryLevelBV(String from, String to, Subject subject) { - AppointmentEntry entry = new AppointmentEntry(); - String date = getDate(from); - String date2 = getDate(to); - if (!date.equals(date2)) { - logger.warn("Different start and end date for level BV appointment. Subject: " + subject.getNdNumber()); - } - entry.setDay(date); - entry.setSubject(subject); - entry.setSource("Imported from RedCap"); - entry.addType(AppointmentType.LEVEL_BV); - entry.setLocation(subject.getToBeSeenAt()); - return entry; - } - - private AppointmentEntry createEntryLevelBG(String from, String to, Subject subject) { - AppointmentEntry entry = new AppointmentEntry(); - String date = getDate(from); - String date2 = getDate(to); - if (!date.equals(date2)) { - logger.warn("Different start and end date for level BG appointment. Subject: " + subject.getNdNumber()); - } - entry.setDay(date); - entry.setSubject(subject); - entry.setSource("Imported from RedCap"); - entry.addType(AppointmentType.LEVEL_BG); - entry.setLocation(subject.getToBeSeenAt()); - return entry; - } - - private AppointmentEntry createEntryLevelB(String from, String to, Subject subject) { - AppointmentEntry entry = new AppointmentEntry(); - String date = getDate(from); - String date2 = getDate(to); - if (!date.equals(date2)) { - logger.warn("Different start and end date for level B appointment. Subject: " + subject.getNdNumber()); - } - entry.setDay(date); - entry.setSubject(subject); - entry.setSource("Imported from RedCap"); - entry.addType(AppointmentType.LEVEL_B); - entry.setLocation(subject.getToBeSeenAt()); - return entry; - } - - private AppointmentEntry createEntryLevelA(String from, String to, Subject subject) { - AppointmentEntry entry = new AppointmentEntry(); - String date = getDate(from); - String date2 = getDate(to); - if (!date.equals(date2)) { - logger.warn("Different start and end date for level A appointment. Subject: " + subject.getNdNumber() + "; " + date + ", " + date2); - } - String time = getTime(from); - String duration = getDuration(from, to); - entry.setDay(date); - entry.setDuration(duration); - entry.setSubject(subject); - entry.setSource("Imported from RedCap"); - entry.setTime(time); - entry.addTypes(AppointmentTypeCollection.LEVEL_A.getTypes()); - entry.setLocation(subject.getToBeSeenAt()); - return entry; - } - - private String getDuration(String string, String string2) { - if (string2.isEmpty()) { - return null; - } - String time1 = getTime(string); - String time2 = getTime(string2); - - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - - LocalDateTime dateTime1 = LocalDateTime.parse("2014-11-25 " + time1 + ":00", formatter); - LocalDateTime dateTime2 = LocalDateTime.parse("2014-11-25 " + time2 + ":00", formatter); - - long diffInMinutes = java.time.Duration.between(dateTime1, dateTime2).toMinutes(); - - return diffInMinutes + ""; - } - - private String getTime(String string) { - return string.split(" ")[1]; - } - - private String getDate(String string) { - return string.split(" ")[0]; - } - - /** - * @return the subjectDao - * @see #subjectDao - */ - public SubjectDao getSubjectDao() { - return subjectDao; - } - - /** - * @param subjectDao - * the subjectDao to set - * @see #subjectDao - */ - public void setSubjectDao(SubjectDao subjectDao) { - this.subjectDao = subjectDao; - } -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/SqlExporter.java b/appointment-import/src/main/java/smash/appointment/parse/SqlExporter.java deleted file mode 100644 index a5c19bb25f2b4a06d5d88b9cedcce94ae89d028b..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/SqlExporter.java +++ /dev/null @@ -1,52 +0,0 @@ -package smash.appointment.parse; - -import java.text.SimpleDateFormat; -import java.util.Calendar; - -public class SqlExporter { - - private static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd"); - - public SqlExporter() { - super(); - } - - protected boolean isBefore(AppointmentEntry entry, Calendar minDate) { - String entryDate = entry.getDay(); - String beforeDate = DATE_FORMATTER.format(minDate.getTime()); - if (entryDate.compareTo(beforeDate) < 0) { - return true; - } else { - return false; - } - } - - protected String getStringVal(String arg) { - if (arg == null) { - return "null"; - } else if (arg.isEmpty()) { - return "''"; - } else { - return "'" + arg.replace("'", "''") + "'"; - } - } - - protected String getIntVal(String diagnosisYear) { - if (diagnosisYear == null || diagnosisYear.trim().isEmpty()) { - return "0"; - } else { - return diagnosisYear; - } - } - - protected String getDateVal(String arg) { - if (arg == null) { - return "null"; - } else if (arg.isEmpty()) { - return "null"; - } else { - return "'" + arg + "'"; - } - } - -} \ No newline at end of file diff --git a/appointment-import/src/main/java/smash/appointment/parse/Subject.java b/appointment-import/src/main/java/smash/appointment/parse/Subject.java deleted file mode 100644 index ec606f964af36cd450bff91e7b022663a8df5fe9..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/Subject.java +++ /dev/null @@ -1,598 +0,0 @@ -package smash.appointment.parse; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; - -public class Subject { - Logger logger = Logger.getLogger(Subject.class); - - private String name; - private String surname; - private String ndNumber; - private String screeningNumber; - private String sex = ""; - private String remarks; - private String birthDate; - private String address; - private String zipCode; - private String country; - private String city; - private String phone1; - private String phone2; - private String phone3; - private String mail; - private String diagnosisYear; - private String diagnosis; - private String referal; - private String addDate; - private String mPowerId; - private SubjectType type; - private String toBeSeenAt; - private boolean dead = false; - private boolean resigned = false; - private boolean postponed = false; - - private List<String> languages = new ArrayList<>(); - - public Subject(String name, String surname, String ndNumber, String screeningNumber) { - this.setName(name); - this.setSurname(surname); - this.setNdNumber(ndNumber); - this.setScreeningNumber(screeningNumber); - } - - /** - * @return the name - * @see #name - */ - public String getName() { - return name; - } - - /** - * @param name - * the name to set - * @see #name - */ - public void setName(String name) { - if (name != null && name.length() > 50) { - logger.warn("Name too long. Trimming: " + name); - name = name.substring(0, 50); - } - this.name = name; - } - - /** - * @return the surname - * @see #surname - */ - public String getSurname() { - return surname; - } - - /** - * @param surname - * the surname to set - * @see #surname - */ - public void setSurname(String surname) { - if (surname != null && surname.length() > 50) { - logger.warn("Surname too long. Trimming: " + surname); - surname = surname.substring(0, 50); - } - this.surname = surname; - } - - /** - * @return the ndNumber - * @see #ndNumber - */ - public String getNdNumber() { - return ndNumber; - } - - /** - * @param ndNumber - * the ndNumber to set - * @see #ndNumber - */ - public void setNdNumber(String ndNumber) { - this.ndNumber = ndNumber; - } - - /** - * @return the screeningNumber - * @see #screeningNumber - */ - public String getScreeningNumber() { - return screeningNumber; - } - - /** - * @param screeningNumber - * the screeningNumber to set - * @see #screeningNumber - */ - public void setScreeningNumber(String screeningNumber) { - this.screeningNumber = screeningNumber; - } - - @Override - public String toString() { - return this.getName() + " " + this.getSurname() + " (" + this.getNdNumber() + "; " + this.getScreeningNumber() + ")"; - } - - public void addLanguage(String string) { - if (!string.trim().isEmpty() && !string.equalsIgnoreCase("OTHER")) { - if (!languages.contains(string)) { - this.languages.add(string); - } - } - } - - /** - * @return the sex - * @see #sex - */ - public String getSex() { - return sex; - } - - /** - * @param sex - * the sex to set - * @see #sex - */ - public void setSex(String sex) { - this.sex = sex; - } - - /** - * @return the birthDate - * @see #birthDate - */ - public String getBirthDate() { - return birthDate; - } - - /** - * @param birthDate - * the birthDate to set - * @see #birthDate - */ - public void setBirthDate(String birthDate) { - this.birthDate = birthDate; - } - - /** - * @return the languages - * @see #languages - */ - public List<String> getLanguages() { - return languages; - } - - /** - * @param languages - * the languages to set - * @see #languages - */ - public void setLanguages(List<String> languages) { - this.languages = languages; - } - - /** - * @return the remarks - * @see #remarks - */ - public String getRemarks() { - return remarks; - } - - /** - * @param remarks - * the remarks to set - * @see #remarks - */ - public void setRemarks(String remarks) { - this.remarks = remarks; - } - - /** - * @return the address - * @see #address - */ - public String getAddress() { - return address; - } - - /** - * @param address - * the address to set - * @see #address - */ - public void setAddress(String address) { - this.address = address; - } - - /** - * @return the zipCode - * @see #zipCode - */ - public String getZipCode() { - return zipCode; - } - - /** - * @param zipCode - * the zipCode to set - * @see #zipCode - */ - public void setZipCode(String zipCode) { - if (zipCode != null && zipCode.length() > 7) { - logger.warn("Surname too long. Ignoring: " + zipCode); - this.zipCode = ""; - } else { - this.zipCode = zipCode; - } - } - - /** - * @return the country - * @see #country - */ - public String getCountry() { - return country; - } - - /** - * @param country - * the country to set - * @see #country - */ - public void setCountry(String country) { - this.country = country; - } - - /** - * @return the city - * @see #city - */ - public String getCity() { - return city; - } - - /** - * @param city - * the city to set - * @see #city - */ - public void setCity(String city) { - this.city = city; - } - - /** - * @return the phone1 - * @see #phone1 - */ - public String getPhone1() { - return phone1; - } - - /** - * @param phone1 - * the phone1 to set - * @see #phone1 - */ - public void setPhone1(String phone1) { - if (phone1 != null && phone1.length() > 20) { - logger.warn("Invalid phone. Ignoring: " + phone1); - } else if (phone1 != null) { - this.phone1 = phone1.replace(",", "").replace(" ", ""); - } - } - - /** - * @return the phone2 - * @see #phone2 - */ - public String getPhone2() { - return phone2; - } - - /** - * @param phone2 - * the phone2 to set - * @see #phone2 - */ - public void setPhone2(String phone2) { - if (phone2 != null && phone2.length() > 20) { - logger.warn("Invalid phone. Ignoring: " + phone2); - } else if (phone2 != null) { - this.phone2 = phone2.replace(",", "").replace(" ", ""); - } - } - - /** - * @return the phone3 - * @see #phone3 - */ - public String getPhone3() { - return phone3; - } - - /** - * @param phone3 - * the phone3 to set - * @see #phone3 - */ - public void setPhone3(String phone3) { - if (phone3 != null && phone3.length() > 20) { - logger.warn("Invalid phone. Ignoring: " + phone3); - } else if (phone3 != null) { - this.phone3 = phone3.replace(",", "").replace(" ", ""); - } - } - - /** - * @return the mail - * @see #mail - */ - public String getMail() { - return mail; - } - - /** - * @param mail - * the mail to set - * @see #mail - */ - public void setMail(String mail) { - this.mail = mail; - } - - /** - * @return the diagnosisYear - * @see #diagnosisYear - */ - public String getDiagnosisYear() { - return diagnosisYear; - } - - /** - * @param diagnosisYear - * the diagnosisYear to set - * @see #diagnosisYear - */ - public void setDiagnosisYear(String diagnosisYear) { - this.diagnosisYear = diagnosisYear; - } - - /** - * @return the diagnosis - * @see #diagnosis - */ - public String getDiagnosis() { - return diagnosis; - } - - /** - * @param diagnosis - * the diagnosis to set - * @see #diagnosis - */ - public void setDiagnosis(String diagnosis) { - this.diagnosis = diagnosis; - } - - /** - * @return the referal - * @see #referal - */ - public String getReferal() { - return referal; - } - - /** - * @param referal - * the referal to set - * @see #referal - */ - public void setReferal(String referal) { - this.referal = referal; - } - - /** - * @return the mPowerId - * @see #mPowerId - */ - public String getmPowerId() { - return mPowerId; - } - - /** - * @param mPowerId - * the mPowerId to set - * @see #mPowerId - */ - public void setmPowerId(String mPowerId) { - this.mPowerId = mPowerId; - } - - /** - * @return the addDate - * @see #addDate - */ - public String getAddDate() { - return addDate; - } - - /** - * @param addDate - * the addDate to set - * @see #addDate - */ - public void setAddDate(String addDate) { - this.addDate = addDate; - } - - /** - * @return the type - * @see #type - */ - public SubjectType getType() { - return type; - } - - /** - * @param type - * the type to set - * @see #type - */ - public void setType(SubjectType type) { - this.type = type; - } - - public void update(Subject subject, String errorPrefix) { - setName(getMergedValue("name", this.getName(), subject.getName(), errorPrefix)); - setSurname(getMergedValue("surname", this.getSurname(), subject.getSurname(), errorPrefix)); - setNdNumber(getMergedValue("ndNumber", this.getNdNumber(), subject.getNdNumber(), errorPrefix)); - setScreeningNumber(getMergedValue("screeningNumber", this.getScreeningNumber(), subject.getScreeningNumber(), errorPrefix)); - setSex(getMergedValue("sex", this.getSex(), subject.getSex(), errorPrefix)); - setRemarks(getMergedValue("remarks", this.getRemarks(), subject.getRemarks(), errorPrefix)); - setBirthDate(getMergedValue("birthDate", this.getBirthDate(), subject.getBirthDate(), errorPrefix)); - setAddress(getMergedValue("address", this.getAddress(), subject.getAddress(), errorPrefix)); - setZipCode(getMergedValue("zipCode", this.getZipCode(), subject.getZipCode(), errorPrefix)); - setCountry(getMergedValue("country", this.getCountry(), subject.getCountry(), errorPrefix)); - setCity(getMergedValue("city", this.getCity(), subject.getCity(), errorPrefix)); - setPhone1(getMergedValue("phone1", this.getPhone1(), subject.getPhone1(), errorPrefix)); - setPhone2(getMergedValue("phone2", this.getPhone2(), subject.getPhone2(), errorPrefix)); - setPhone3(getMergedValue("phone3", this.getPhone3(), subject.getPhone3(), errorPrefix)); - setMail(getMergedValue("mail", this.getMail(), subject.getMail(), errorPrefix)); - setDiagnosisYear(getMergedValue("diagnosisYear", this.getDiagnosisYear(), subject.getDiagnosisYear(), errorPrefix)); - setDiagnosis(getMergedValue("diagnosis", this.getDiagnosis(), subject.getDiagnosis(), errorPrefix)); - setReferal(getMergedValue("referal", this.getReferal(), subject.getReferal(), errorPrefix)); - setAddDate(getMergedValue("addDate", this.getAddDate(), subject.getAddDate(), errorPrefix, true)); - setmPowerId(getMergedValue("mPowerId", this.getmPowerId(), subject.getmPowerId(), errorPrefix)); - setType(getMergedValue("type", this.getType(), subject.getType(), errorPrefix)); - setResigned(this.isResigned() && subject.isResigned()); - setDead(this.isDead() || subject.isDead()); - setPostponed(this.isPostponed() && subject.isPostponed()); - // override only when to be seen by flying team - if (subject.getToBeSeenAt() != null && subject.getToBeSeenAt().equals("F")) { - setToBeSeenAt(subject.getToBeSeenAt()); - } - addLanguages(subject.getLanguages()); - } - - private SubjectType getMergedValue(String string, SubjectType existingValue, SubjectType newValue, String errorPrefix) { - if (existingValue == null) { - return newValue; - } else if (newValue == null) { - return existingValue; - } else if (existingValue.equals(newValue)) { - return existingValue; - } else { - logger.warn(errorPrefix + "New " + string + " differs from old one. (new: " + newValue + ", " + existingValue + "). Skipping"); - return existingValue; - } - } - - private String getMergedValue(String string, String existingValue, String newValue, String errorPrefix) { - return getMergedValue(string, existingValue, newValue, errorPrefix, false); - } - - private String getMergedValue(String string, String existingValue, String newValue, String errorPrefix, boolean ignoreMessage) { - if (existingValue == null || existingValue.trim().isEmpty()) { - return newValue; - } else if (newValue == null || newValue.trim().isEmpty()) { - return existingValue; - } else if (existingValue.trim().toLowerCase().contains(newValue.trim().toLowerCase())) { - return existingValue; - } else if (newValue.trim().toLowerCase().contains(existingValue.trim().toLowerCase())) { - return newValue; - } else { - if (!ignoreMessage) { - logger.warn(errorPrefix + "New " + string + " differs from old one. (new: " + newValue + ", " + existingValue + "). Skipping"); - } - return existingValue; - } - } - - /** - * @return the toBeSeenAt - * @see #toBeSeenAt - */ - public String getToBeSeenAt() { - return toBeSeenAt; - } - - /** - * @param toBeSeenAt - * the toBeSeenAt to set - * @see #toBeSeenAt - */ - public void setToBeSeenAt(String toBeSeenAt) { - this.toBeSeenAt = toBeSeenAt; - } - - /** - * @return the dead - * @see #dead - */ - public boolean isDead() { - return dead; - } - - /** - * @param dead - * the dead to set - * @see #dead - */ - public void setDead(boolean dead) { - this.dead = dead; - } - - /** - * @return the resigned - * @see #resigned - */ - public boolean isResigned() { - return resigned; - } - - /** - * @param resigned - * the resigned to set - * @see #resigned - */ - public void setResigned(boolean resigned) { - this.resigned = resigned; - } - - public void addLanguages(List<String> langs) { - for (String string : langs) { - addLanguage(string); - } - } - - /** - * @return the postponed - * @see #postponed - */ - public boolean isPostponed() { - return postponed; - } - - /** - * @param postponed - * the postponed to set - * @see #postponed - */ - public void setPostponed(boolean postponed) { - this.postponed = postponed; - } - -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/SubjectDao.java b/appointment-import/src/main/java/smash/appointment/parse/SubjectDao.java deleted file mode 100644 index 7d78c4d363d6509150f560fd46445fbd59fa670e..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/SubjectDao.java +++ /dev/null @@ -1,113 +0,0 @@ -package smash.appointment.parse; - -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; - -public class SubjectDao { - Logger logger = Logger.getLogger(SubjectDao.class); - private List<Subject> subjects = new ArrayList<>(); - - public void addSubject(Subject subject, String errorPrefix) { - if (subject.getNdNumber() != null && !Utils.simplifyString(subject.getNdNumber()).isEmpty()) { - Subject existing = getByNdNumber(subject.getNdNumber()); - if (existing != null) { - if (!existing.getScreeningNumber().equals(subject.getScreeningNumber())) { - logger.error(errorPrefix + " Nd number taken by subject: " + existing.getScreeningNumber()); - return; - } - } - } - Subject existing = getByScreeningNumber(subject.getScreeningNumber()); - if (existing != null) { - existing.update(subject, errorPrefix); - } else { - subjects.add(subject); - } - } - - Subject getByScreeningNumber(String screeningNumber) { - for (Subject s : subjects) { - for (String number: s.getScreeningNumber().split(";")) { - if (screeningNumber.equals(number.trim())) { - return s; - } - } - } - return null; - } - - public void readFile(String filename) throws IOException { - try (BufferedReader br = new BufferedReader(new FileReader(filename))) { - String line; - int lineCount = 1; - while ((line = br.readLine()) != null) { - String tmp[] = line.split("\t"); - addSubject(new Subject(tmp[0], tmp[1], tmp[2], tmp[3]), "[" + filename + ":" + lineCount + "]"); - lineCount++; - } - } - } - - /** - * @return the subjects - * @see #subjects - */ - public List<Subject> getSubjects() { - return subjects; - } - - /** - * @param subjects - * the subjects to set - * @see #subjects - */ - public void setSubjects(List<Subject> subjects) { - this.subjects = subjects; - } - - public Subject getByNdNumber(String ndNumber) { - ndNumber = Utils.simplifyString(ndNumber); - for (Subject s : subjects) { - if (ndNumber.equalsIgnoreCase(s.getNdNumber())) { - return s; - } - } - return null; - } - - public void addSubjects(List<Subject> processPrcSubjects, String errorPrefix) { - for (Subject subject : processPrcSubjects) { - addSubject(subject, errorPrefix); - } - } - - public void removeDuplicate(Subject subject1, Subject subject2, String errorPrefix) { - String screeningNumber1 = subject1.getScreeningNumber().trim(); - String screeningNumber2 = subject2.getScreeningNumber().trim(); - String screeningNumber = null; - if (screeningNumber1.toLowerCase().contains(screeningNumber2.toLowerCase())) { - screeningNumber = screeningNumber1; - } else if (screeningNumber2.toLowerCase().contains(screeningNumber1.toLowerCase())) { - screeningNumber = screeningNumber2; - } else { - screeningNumber = screeningNumber1 + "; " + screeningNumber2; - } - subject1.setScreeningNumber(screeningNumber); - subject2.setScreeningNumber(screeningNumber); - if (!subject1.getNdNumber().trim().isEmpty() && !subject2.getNdNumber().trim().isEmpty() - && !subject1.getNdNumber().trim().equals(subject2.getNdNumber().trim())) { - throw new InvalidArgumentException("Two different nd numbers: " + subject1.getNdNumber() + ", " + subject2.getNdNumber()); - } - - String remarks = (subject1.getRemarks()+"\n"+subject2.getRemarks()).trim(); - subject1.setRemarks(remarks); - subject1.update(subject2, errorPrefix); - subjects.remove(subject2); - } - -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/SubjectIndexer.java b/appointment-import/src/main/java/smash/appointment/parse/SubjectIndexer.java deleted file mode 100644 index b120fdc9ccb1cf77902c71b1427d8fdde344801d..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/SubjectIndexer.java +++ /dev/null @@ -1,25 +0,0 @@ -package smash.appointment.parse; - -import org.apache.log4j.Logger; - -public abstract class SubjectIndexer { - Logger logger = Logger.getLogger(SubjectIndexer.class); - - public abstract String getIndexedString(Subject subject); - - public boolean match(Subject subject, String simplifiedQuery) { - String indexedString = getIndexedString(subject); - if (indexedString.length() == 0) { - return false; - } - // logger.debug("Check: " + simplifiedQuery + " against: " + indexedString); - if (simplifiedQuery.startsWith(indexedString)) { - return true; - } - return false; - } - - public boolean isBetter(Subject subject, Subject oldSubject) { - return getIndexedString(subject).length() > getIndexedString(oldSubject).length(); - } -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/SubjectParser.java b/appointment-import/src/main/java/smash/appointment/parse/SubjectParser.java deleted file mode 100644 index 557f48063f285a57e2196c23d1b29f1a0786fdc9..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/SubjectParser.java +++ /dev/null @@ -1,250 +0,0 @@ -package smash.appointment.parse; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.Iterator; -import java.util.List; - -import org.apache.log4j.Logger; -import org.apache.poi.EncryptedDocumentException; -import org.apache.poi.hssf.usermodel.HSSFDateUtil; -import org.apache.poi.openxml4j.exceptions.InvalidFormatException; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.CellType; -import org.apache.poi.ss.usermodel.Comment; -import org.apache.poi.ss.usermodel.DataFormatter; -import org.apache.poi.ss.usermodel.RichTextString; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.ss.usermodel.WorkbookFactory; - -public abstract class SubjectParser { - private static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd"); - Logger logger = Logger.getLogger(SubjectParser.class); - DataFormatter df = new DataFormatter(); - - public List<Subject> processExcel(String filename) throws EncryptedDocumentException, InvalidFormatException, IOException, ParseException { - List<Subject> result = new ArrayList<>(); - InputStream inp = new FileInputStream(filename); - Workbook workbook = WorkbookFactory.create(inp); - Iterator<Sheet> sheetIter = workbook.sheetIterator(); - while (sheetIter.hasNext()) { - Sheet sheet = sheetIter.next(); - String name = sheet.getSheetName().trim(); - if (name.trim().toLowerCase().equals(getSheetName().toLowerCase())) { - result.addAll(processSheet(sheet)); - } else { - logger.debug(filename + "Skipping sheet: " + name); - } - } - return result; - } - - private List<Subject> processSheet(Sheet sheet) { - List<Subject> result = new ArrayList<>(); - int rowCount = sheet.getPhysicalNumberOfRows(); - for (int rowId = getInitRow(); rowId < rowCount; rowId++) { - Row subjectRow = sheet.getRow(rowId); - Subject subject = parseSubject(subjectRow); - if (subject != null) { - result.add(subject); - } - } - return result; - } - - private Subject parseSubject(Row row) { - String screeningNumber = parseScreeningNumber(row); - if (screeningNumber == null || screeningNumber.isEmpty()) { - String name = getString(row.getCell(0)) + " " + getString(row.getCell(1)); - if (!name.trim().isEmpty()) { - logger.debug("Skipping row: (" + name + ")"); - } - return null; - } - String name = parseName(row); - String surname = parseSurname(row); - String ndNumber = parseNdNumber(row); - Subject result = new Subject(name, surname, ndNumber, screeningNumber); - - result.setRemarks(parseRemarks(row)); - result.setAddress(parseAddress(row)); - result.setZipCode(parseZipCode(row)); - result.setCity(parseCity(row)); - result.setCountry(parseCountry(row)); - result.setPhone1(parsePhone1(row)); - result.setPhone2(parsePhone2(row)); - result.setPhone3(parsePhone3(row)); - result.setMail(parseMail(row)); - result.setDiagnosisYear(parseDiagnosisYear(row)); - result.setDiagnosis(parseDiagnosis(row)); - result.setReferal(parseReferal(row)); - result.setAddDate(parseAddDate(row)); - result.setmPowerId(parsemPowerId(row)); - result.setBirthDate(parseBirthDate(row)); - result.setType(parseType(row)); - result.addLanguages(parseLanguages(row)); - result.setToBeSeenAt(parseToBeSeenAt(row)); - result.setDead(parseDead(row)); - result.setResigned(parseResigned(row)); - result.setPostponed(parsePostponed(row)); - - return result; - } - - protected abstract boolean parseDead(Row row); - - protected abstract boolean parsePostponed(Row row); - - protected abstract boolean parseResigned(Row row); - - protected abstract String parseToBeSeenAt(Row row); - - protected abstract List<String> parseLanguages(Row row); - - protected abstract SubjectType parseType(Row row); - - protected abstract String parseBirthDate(Row row); - - protected abstract String parsemPowerId(Row row); - - protected abstract String parseAddDate(Row row); - - protected abstract String parseReferal(Row row); - - protected abstract String parseDiagnosisYear(Row row); - - protected abstract String parseDiagnosis(Row row); - - protected abstract String parseMail(Row row); - - protected abstract String parsePhone3(Row row); - - protected abstract String parsePhone2(Row row); - - protected abstract String parsePhone1(Row row); - - protected abstract String parseCity(Row row); - - protected abstract String parseCountry(Row row); - - protected abstract String parseZipCode(Row row); - - protected abstract String parseAddress(Row row); - - protected abstract String parseRemarks(Row row); - - protected abstract String parseScreeningNumber(Row row); - - protected abstract String parseName(Row row); - - protected abstract String parseSurname(Row row); - - protected abstract String parseNdNumber(Row row); - - protected abstract String getSheetName(); - - protected abstract int getInitRow(); - - protected String getString(Cell cell) { - if (cell == null) { - return ""; - } - if (cell.getCellTypeEnum().equals(CellType.STRING)) { - return cell.getStringCellValue().trim(); - } - return df.formatCellValue(cell).trim(); - } - - protected String getComments(Cell cell) { - Comment comment = cell.getCellComment(); - if (comment != null) { - RichTextString richTextString = comment.getString(); - if (richTextString != null) { - return richTextString.getString(); - - } - } - return ""; - } - - protected String getDate(Cell cell, Calendar defaultDate) { - String defaultDateString = ""; - if (defaultDate != null) { - defaultDateString = DATE_FORMATTER.format(defaultDate.getTime()); - } - if (cell == null) { - return defaultDateString; - } - String result = null; - if (cell.getCellTypeEnum().equals(CellType.STRING)) { - result = getString(cell); - } else if (HSSFDateUtil.isCellDateFormatted(cell)) { - Date date = cell.getDateCellValue(); - if (date != null) { - result = DATE_FORMATTER.format(date); - } else { - result = defaultDateString; - } - } else { - result = getString(cell); - } - if (result == null || result.trim().isEmpty()) { - result = defaultDateString; - } - result = fixDate(result, defaultDateString); - return result; - } - - protected String fixDate(String result) { - return fixDate(result, null); - } - - protected String fixDate(String result, String defaultDateString) { - result = result.replaceAll("\\?", ""); - result = result.replaceAll("jan", "01"); - result = result.replaceAll("fev", "02"); - result = result.replaceAll("mar", "03"); - result = result.replaceAll("avr", "04"); - result = result.replaceAll("may", "05"); - result = result.replaceAll("aou", "08"); - result = result.replaceAll("cot", "08"); - result = result.replaceAll("sep", "09"); - result = result.replaceAll("oct", "10"); - if (result.trim().isEmpty()) { - result = defaultDateString; - } else if (result.length() != 10) { - logger.warn("Invalid date. Ignoring: " + result); - result = defaultDateString; - } - if (result.indexOf("/") >= 0) { - String tmp[] = result.split("/"); - result = tmp[2] + "-" + tmp[1] + "-" + tmp[0]; - } - if (result.length() == 10 && result.charAt(2) == '-') { - String tmp[] = result.split("-"); - result = tmp[2] + "-" + tmp[1] + "-" + tmp[0]; - } - return result; - } - - protected String parseDateOfBirth(Cell cell) { - String date = getString(cell).replaceAll(" ", ""); - if (date.length() < 8) { - return ""; - } - String year = date.substring(0, 4); - String month = date.substring(4, 6); - String day = date.substring(6, 8); - String result = year + "-" + month + "-" + day; - return result; - } - -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/SubjectSqlExporter.java b/appointment-import/src/main/java/smash/appointment/parse/SubjectSqlExporter.java deleted file mode 100644 index 5c59412dfbd387afab381b8e4d824dc47a7baa4d..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/SubjectSqlExporter.java +++ /dev/null @@ -1,95 +0,0 @@ -package smash.appointment.parse; - -public class SubjectSqlExporter extends SqlExporter { - - public String toSql(Subject subject) { - StringBuilder result = new StringBuilder(""); - - result.append("insert into web_subject ("); - result.append("sex, "); - result.append("last_name, "); - result.append("first_name, "); - result.append("comments,"); - result.append("address,"); - result.append("postal_code, "); - result.append("city, "); - result.append("country, "); - result.append("phone_number,"); - result.append("phone_number_2,"); - result.append("phone_number_3,"); - result.append("email,"); - result.append("year_of_diagnosis,"); - result.append("diagnosis,"); - result.append("referral,"); - result.append("date_added,"); - result.append("nd_number,"); - result.append("mpower_id,"); - result.append("screening_number,"); - result.append("default_location_id,"); - result.append("type,"); - result.append("dead,"); - result.append("default_written_communication_language_id,"); - result.append("resigned,"); - result.append("postponed,"); - result.append("date_born) "); - - result.append("values ("); - result.append(getStringVal(subject.getSex()) + ","); - result.append(getStringVal(subject.getSurname()) + ","); - result.append(getStringVal(subject.getName()) + ","); - result.append(getStringVal(subject.getRemarks()) + ","); - result.append(getStringVal(subject.getAddress()) + ","); - result.append(getStringVal(subject.getZipCode()) + ","); - result.append(getStringVal(subject.getCity()) + ","); - result.append(getStringVal(subject.getCountry()) + ","); - result.append(getStringVal(subject.getPhone1()) + ","); - result.append(getStringVal(subject.getPhone2()) + ","); - result.append(getStringVal(subject.getPhone3()) + ","); - result.append(getStringVal(subject.getMail()) + ","); - result.append(getIntVal(subject.getDiagnosisYear()) + ","); - result.append(getStringVal(subject.getDiagnosis()) + ","); - result.append(getStringVal(subject.getReferal()) + ","); - result.append(getDateVal(subject.getAddDate()) + ","); - result.append(getStringVal(subject.getNdNumber()) + ","); - result.append(getStringVal(subject.getmPowerId()) + ","); - result.append(getStringVal(subject.getScreeningNumber()) + ","); - switch (subject.getToBeSeenAt()) { - case ("L"): - result.append("(select id from web_location where name = 'LIH'),"); - break; - case ("F"): - result.append("(select id from web_location where name = 'Flying Team'),"); - break; - case ("P"): - result.append("(select id from web_location where name = 'PRC'),"); - break; - default: - throw new RuntimeException("Unknown location: " + subject.getToBeSeenAt()); - } - - result.append(getStringVal(subject.getType().toString().substring(0, 1)) + ","); - result.append(subject.isDead() + ","); - if (subject.getLanguages().size()>0) { - result.append("(select id from web_language where name=" + getStringVal(subject.getLanguages().get(0)) + "),"); - } else { - result.append("null,"); - } - result.append(subject.isResigned() + ","); - result.append(subject.isPostponed() + ","); - result.append(getDateVal(subject.getBirthDate())); - result.append(");\n"); - - for (String langueage : subject.getLanguages()) { - result.append("insert into web_subject_languages ("); - result.append("subject_id, "); - result.append("language_id) "); - result.append("values ("); - result.append("(select max(id) from web_subject), "); - result.append("(select id from web_language where name=" + getStringVal(langueage) + ") "); - result.append(");\n"); - } - - return result.toString(); - } - -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/SubjectType.java b/appointment-import/src/main/java/smash/appointment/parse/SubjectType.java deleted file mode 100644 index a1ef995b0ccebeb8a0500126b8df6cad8f95177d..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/SubjectType.java +++ /dev/null @@ -1,5 +0,0 @@ -package smash.appointment.parse; - -public enum SubjectType { - PATIENT, CONTROL; -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/SurnameIndexer.java b/appointment-import/src/main/java/smash/appointment/parse/SurnameIndexer.java deleted file mode 100644 index 10c1a29f3e39236ed33c0c819e6a30d4420de99c..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/SurnameIndexer.java +++ /dev/null @@ -1,9 +0,0 @@ -package smash.appointment.parse; - -public class SurnameIndexer extends SubjectIndexer { - - public String getIndexedString(Subject subject) { - return Utils.simplifyString(subject.getSurname()); - } - -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/SurnameNameIndexer.java b/appointment-import/src/main/java/smash/appointment/parse/SurnameNameIndexer.java deleted file mode 100644 index 7de6d7c4ef96e23ee9b75a72fa5d32eb1f6b5ad1..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/SurnameNameIndexer.java +++ /dev/null @@ -1,9 +0,0 @@ -package smash.appointment.parse; - -public class SurnameNameIndexer extends SubjectIndexer { - - public String getIndexedString(Subject subject) { - return Utils.simplifyString(subject.getSurname() + subject.getName()); - } - -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/Utils.java b/appointment-import/src/main/java/smash/appointment/parse/Utils.java deleted file mode 100644 index 916487ba6948c86609d8a4e273f5b4bed574121b..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/Utils.java +++ /dev/null @@ -1,7 +0,0 @@ -package smash.appointment.parse; - -public class Utils { - public static String simplifyString(String query) { - return query.replaceAll("[\\s\\-©]", "").toLowerCase().replaceAll("\\(c\\)", ""); - } -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/Visit.java b/appointment-import/src/main/java/smash/appointment/parse/Visit.java deleted file mode 100644 index 98b2a896b1b67821ce78a64ec5901a4f2344aeee..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/Visit.java +++ /dev/null @@ -1,134 +0,0 @@ -package smash.appointment.parse; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.log4j.Logger; - -public class Visit { - static Subject UNKNOWN; - static { - UNKNOWN = new Subject("NOBODY", "", "", "---"); - UNKNOWN.setType(SubjectType.CONTROL); - UNKNOWN.setAddDate("1900-01-01"); - UNKNOWN.setAddress(""); - UNKNOWN.setZipCode(""); - UNKNOWN.setCity(""); - UNKNOWN.setCountry(""); - UNKNOWN.setmPowerId(""); - UNKNOWN.setReferal(""); - UNKNOWN.setRemarks(""); - UNKNOWN.setDiagnosis(""); - UNKNOWN.setToBeSeenAt("P"); - } - Logger logger = Logger.getLogger(Visit.class); - - private Subject subject; - private List<AppointmentEntry> appointments = new ArrayList<>(); - - private String startDate; - private boolean finished = false; - - public Visit(Subject subject) { - if (subject == null) { - subject = UNKNOWN; - } - this.subject = subject; - } - - public void addAppointment(AppointmentEntry entry) { - appointments.add(entry); - } - - /** - * @return the appointments - * @see #appointments - */ - public List<AppointmentEntry> getAppointments() { - return appointments; - } - - /** - * @param appointments - * the appointments to set - * @see #appointments - */ - public void setAppointments(List<AppointmentEntry> appointments) { - this.appointments = appointments; - } - - public String getLastAppointmentDate() { - if (appointments.size() == 0) { - return "1900-01-01"; - } - return getLastAppointment().getDay().substring(0, 10); - } - - public AppointmentEntry getLastAppointment() { - if (appointments.size() > 0) { - return appointments.get(appointments.size() - 1); - } else { - return null; - } - } - - public String getStartDate() { - if (appointments.size() > 0) { - return appointments.get(0).getDay().substring(0, 10); - } else if (startDate == null) { - return "1900-01-01"; - } else { - return startDate; - } - } - - private static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd"); - - public String getEndDate() throws ParseException { - Calendar calendar = Calendar.getInstance(); - calendar.setTime(DATE_FORMATTER.parse(getStartDate())); - calendar.add(Calendar.MONTH, 3); - return DATE_FORMATTER.format(calendar.getTime()); - } - - /** - * @return the subject - * @see #subject - */ - public Subject getSubject() { - return subject; - } - - /** - * @param subject - * the subject to set - * @see #subject - */ - public void setSubject(Subject subject) { - this.subject = subject; - } - - public void setStartDate(String newDate) { - this.startDate = newDate; - } - - /** - * @return the finished - * @see #finished - */ - public boolean isFinished() { - return finished; - } - - /** - * @param finished the finished to set - * @see #finished - */ - public void setFinished(boolean finished) { - this.finished = finished; - } - -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/VisitSqlExporter.java b/appointment-import/src/main/java/smash/appointment/parse/VisitSqlExporter.java deleted file mode 100644 index ad544f75172a77252da124a601d60cccff4d87d5..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/VisitSqlExporter.java +++ /dev/null @@ -1,31 +0,0 @@ -package smash.appointment.parse; - -import java.text.ParseException; -import java.util.Calendar; - -public class VisitSqlExporter extends SqlExporter { - AppointmentSqlExporter appointmentSqlExporter = new AppointmentSqlExporter(); - public String toSql(Visit visit) throws ParseException { - StringBuilder result = new StringBuilder(""); - - result.append("insert into web_visit ("); - result.append("subject_id, "); - result.append("datetime_begin, "); - result.append("datetime_end, "); - result.append("post_mail_sent, "); - result.append("is_finished)"); - - result.append("values ("); - result.append("(SELECT id from web_subject where screening_number like "+getStringVal('%'+visit.getSubject().getScreeningNumber()+'%') + "),"); - result.append(getStringVal(visit.getStartDate()) + ","); - result.append(getStringVal(visit.getEndDate()) + ","); - result.append("false,"); - result.append(visit.isFinished()); - result.append(");\n"); - for (AppointmentEntry entry: visit.getAppointments()) { - result.append(appointmentSqlExporter.toSql(entry)+"\n"); - } - - return result.toString(); - } -} diff --git a/appointment-import/src/main/java/smash/appointment/parse/XlsxCalendarProcessor.java b/appointment-import/src/main/java/smash/appointment/parse/XlsxCalendarProcessor.java deleted file mode 100644 index 57040b275b38bed01495b615d2a2e94b66b5c6fc..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/java/smash/appointment/parse/XlsxCalendarProcessor.java +++ /dev/null @@ -1,181 +0,0 @@ -package smash.appointment.parse; - -import java.io.FileInputStream; -import java.io.InputStream; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.log4j.Logger; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.CellType; -import org.apache.poi.ss.usermodel.FormulaEvaluator; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.ss.usermodel.WorkbookFactory; - -public class XlsxCalendarProcessor { - Logger logger = Logger.getLogger(XlsxCalendarProcessor.class); - - private SubjectDao subjectDao; - - public List<AppointmentEntry> processExcel(String filename, Calendar minDate) throws Exception { - List<AppointmentEntry> result = new ArrayList<AppointmentEntry>(); - InputStream inp = new FileInputStream(filename); - Workbook workbook = WorkbookFactory.create(inp); - Iterator<Sheet> sheetIter = workbook.sheetIterator(); - while (sheetIter.hasNext()) { - Sheet sheet = sheetIter.next(); - String name = sheet.getSheetName().trim(); - if (name.contains("2017")) { - String monthName = name.split(" ")[0]; - String monthNumber = parseMonth(monthName); - result.addAll(processSheet(sheet, "2017-" + monthNumber)); - } else { - logger.debug("Skipping sheet: " + name); - } - } - if (minDate != null) { - Set<AppointmentEntry> toBeRemoved = new HashSet<>(); - - for (AppointmentEntry entry : result) { - if (isBefore(entry, minDate)) { - toBeRemoved.add(entry); - } - } - result.removeAll(toBeRemoved); - } - - return result; - } - - private static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd"); - - private boolean isBefore(AppointmentEntry entry, Calendar minDate) { - String entryDate = entry.getDay(); - String beforeDate = DATE_FORMATTER.format(minDate.getTime()); - if (entryDate.compareTo(beforeDate) < 0) { - return true; - } else { - return false; - } - } - - int[] dayColumns = new int[] { 3, 4, 5, 6, 7 }; - - int[] weekStartRows = new int[] { 5, 23, 41, 59, 77, 95 }; - - int hourColum = 0; - int dayOfMonthRowOffset = 0; - int calendarRowStartOffset = 3; - int calendarRowEndOffset = 18; - - private List<AppointmentEntry> processSheet(Sheet sheet, String string) { - FormulaEvaluator evaluator = sheet.getWorkbook().getCreationHelper().createFormulaEvaluator(); - - List<AppointmentEntry> result = new ArrayList<AppointmentEntry>(); - - CellParser parser = new CellParser(); - parser.setSubjectDao(subjectDao); - - for (int weekOffset : weekStartRows) { - Row weekRow = sheet.getRow(weekOffset + dayOfMonthRowOffset); - for (int dayColumnOffset : dayColumns) { - Cell dayCell = weekRow.getCell(dayColumnOffset); - String dayOfMonth = "0"; - evaluator.evaluateInCell(dayCell); - if (dayCell.getCellTypeEnum().equals(CellType.NUMERIC)) { - dayOfMonth = ((int) dayCell.getNumericCellValue()) + ""; - } else { - dayOfMonth = dayCell.getStringCellValue(); - } - if (dayOfMonth.length() == 1) { - dayOfMonth = "0" + dayOfMonth; - } - if (!dayOfMonth.equals("00") && !dayOfMonth.trim().isEmpty()) { - String day = string + "-" + dayOfMonth; - - String hour = "08:00"; - for (int hourOffset = calendarRowStartOffset; hourOffset < calendarRowEndOffset; hourOffset++) { - Row hourRow = sheet.getRow(weekOffset + hourOffset); - - Cell hourCell = hourRow.getCell(hourColum); - if (hourCell.getCellTypeEnum().equals(CellType.NUMERIC)) { - - SimpleDateFormat formatTime = new SimpleDateFormat("HH:mm"); - String hourString = formatTime.format(hourCell.getDateCellValue()); - - if (isHour(hourString)) { - hour = hourString; - } - } - - Cell queryCell = hourRow.getCell(dayColumnOffset); - if (queryCell != null) { - if (queryCell.getCellTypeEnum().equals(CellType.STRING)) { - String query = queryCell.getStringCellValue(); - - if (query != null && !query.isEmpty()) { - AppointmentEntry entry = parser.parseAppointment(query, hour); - entry.setDay(day); - - result.add(entry); - } - } else if (!queryCell.getCellTypeEnum().equals(CellType.BLANK)) { - logger - .warn("Skipping cell: " + queryCell.getAddress() + ", " + queryCell.getSheet().getSheetName() + ", type: " + queryCell.getCellTypeEnum()); - } - } - } - } - } - - } - return result; - } - - Pattern timePattern = Pattern.compile("^[0-9][0-9]\\:[0-9][0-9]"); - - private boolean isHour(String hourString) { - Matcher matcher = timePattern.matcher(hourString); - return matcher.find(); - } - - private String parseMonth(String monthName) throws ParseException { - Date date = new SimpleDateFormat("MMMM", Locale.ENGLISH).parse(monthName); - Calendar cal = Calendar.getInstance(); - cal.setTime(date); - String result = (cal.get(Calendar.MONTH) + 1) + ""; - if (result.length() == 1) { - result = "0" + result; - } - return result; - } - - /** - * @return the subjectDao - * @see #subjectDao - */ - public SubjectDao getSubjectDao() { - return subjectDao; - } - - /** - * @param subjectDao - * the subjectDao to set - * @see #subjectDao - */ - public void setSubjectDao(SubjectDao subjectDao) { - this.subjectDao = subjectDao; - } -} diff --git a/appointment-import/src/main/resources/log4j.properties b/appointment-import/src/main/resources/log4j.properties deleted file mode 100644 index 7ad74adebca3440ce16615072190de60dbdf4fc9..0000000000000000000000000000000000000000 --- a/appointment-import/src/main/resources/log4j.properties +++ /dev/null @@ -1,15 +0,0 @@ -log4j.rootLogger=CONSOLE, R - -#Set the behavior of the CONSOLE appender -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.Threshold=FATAL -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d %5p [%t] (%F:%L) - %m%n -#log4j.appender.CONSOLE.layout.ConversionPattern=%m%n - -#Set the behavior of the FILE appender -log4j.appender.R=org.apache.log4j.FileAppender -log4j.appender.R.File=log.txt -log4j.appender.R.layout=org.apache.log4j.PatternLayout -log4j.appender.R.layout.ConversionPattern=%d %5p [%t] (%F:%L) - %m%n -log4j.appender.R.Threshold=DEBUG diff --git a/appointment-import/src/test/java/smash/appointment/parse/AllTests.java b/appointment-import/src/test/java/smash/appointment/parse/AllTests.java deleted file mode 100644 index e9008b24281f818d57cc80746159043bb57a33cc..0000000000000000000000000000000000000000 --- a/appointment-import/src/test/java/smash/appointment/parse/AllTests.java +++ /dev/null @@ -1,27 +0,0 @@ -package smash.appointment.parse; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -@RunWith(Suite.class) -@SuiteClasses({ AppointmentDaoTest.class, // - CellParserTest.class, // - DuplicateRemoveParserTest.class, // - LihControlMappingParserTest.class, // - LihControlParserTest.class, // - PrcControlParserTest.class, // - PrcFlyingParserTest.class, // - PrcSubjectsParserTest.class, // - RedcapCalendarParserTest.class, // - RedcapParserTest.class, // - - SubjectDaoTest.class, // - SubjectParserTest.class, // - VisitTest.class, // - XlsxCalendarProcessorTest.class, // -}) - -public class AllTests { - -} diff --git a/appointment-import/src/test/java/smash/appointment/parse/AppointmentDaoTest.java b/appointment-import/src/test/java/smash/appointment/parse/AppointmentDaoTest.java deleted file mode 100644 index c0339f690a2c346a0aaf65a7865f8824996bd79b..0000000000000000000000000000000000000000 --- a/appointment-import/src/test/java/smash/appointment/parse/AppointmentDaoTest.java +++ /dev/null @@ -1,120 +0,0 @@ -package smash.appointment.parse; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.text.ParseException; - -import org.apache.log4j.Logger; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; - -public class AppointmentDaoTest { - Logger logger = Logger.getLogger(AppointmentDaoTest.class); - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void getVisits() throws ParseException { - Subject subject1 = new Subject("a", "b", "c", "d"); - AppointmentEntry appointment = new AppointmentEntry(); - appointment.setSubject(subject1); - appointment.setDay("2026-02-02"); - appointment.addType(AppointmentType.LEVEL_AQUEST); - - AppointmentEntry appointment2 = new AppointmentEntry(); - appointment2.setSubject(subject1); - appointment2.setDay("2026-02-02"); - appointment2.addType(AppointmentType.LEVEL_B); - - AppointmentEntry appointment3 = new AppointmentEntry(); - appointment3.setSubject(subject1); - appointment3.setDay("2021-02-02"); - appointment3.addType(AppointmentType.LEVEL_AQUEST); - - AppointmentDao appointmentDao = new AppointmentDao(); - appointmentDao.addAppointment(appointment); - appointmentDao.addAppointment(appointment2); - appointmentDao.addAppointment(appointment3); - assertEquals(2, appointmentDao.getVisits().size()); - } - - @Test - public void getVisits2() throws ParseException { - Subject subject1 = new Subject("a", "b", "c", "d"); - Subject subject2 = new Subject("a1", "b1", "c1", "d1"); - AppointmentEntry appointment = new AppointmentEntry(); - appointment.setSubject(subject1); - appointment.setDay("2026-02-02"); - appointment.addType(AppointmentType.LEVEL_AQUEST); - - AppointmentEntry appointment3 = new AppointmentEntry(); - appointment3.setSubject(subject2); - appointment3.setDay("2026-02-02"); - appointment3.addType(AppointmentType.LEVEL_B); - - AppointmentDao appointmentDao = new AppointmentDao(); - appointmentDao.addAppointment(appointment); - appointmentDao.addAppointment(appointment3); - assertEquals(2, appointmentDao.getVisits().size()); - } - - @Test - public void getShouldBeFinished() { - AppointmentDao appointmentDao = new AppointmentDao(); - assertTrue(appointmentDao.shouldBeFinished("2014-01-01")); - assertTrue(appointmentDao.shouldBeFinished("2017-01-01")); - assertFalse(appointmentDao.shouldBeFinished("2018-01-01")); - } - - @Test - public void createNextVisitForControl() throws ParseException { - Subject subject = new Subject("a", "b", "c", "d"); - subject.setType(SubjectType.CONTROL); - AppointmentEntry appointment3 = new AppointmentEntry(); - appointment3.setSubject(subject); - appointment3.setDay("2016-02-02"); - appointment3.addType(AppointmentType.LEVEL_B); - - Visit visit = new Visit(subject); - visit.addAppointment(appointment3); - - AppointmentDao appointmentDao = new AppointmentDao(); - Visit nextVisit = appointmentDao.createNextVisit(visit); - assertNotNull(nextVisit); - assertTrue(nextVisit.getStartDate().startsWith("2020")); - } - - @Test - public void createNextVisitForPatient() throws ParseException { - Subject subject = new Subject("a", "b", "c", "d"); - subject.setType(SubjectType.PATIENT); - AppointmentEntry appointment3 = new AppointmentEntry(); - appointment3.setSubject(subject); - appointment3.setDay("2016-02-02"); - appointment3.addType(AppointmentType.LEVEL_B); - - Visit visit = new Visit(subject); - visit.addAppointment(appointment3); - - AppointmentDao appointmentDao = new AppointmentDao(); - Visit nextVisit = appointmentDao.createNextVisit(visit); - assertNotNull(nextVisit); - assertTrue(nextVisit.getStartDate().startsWith("2017")); - } - -} diff --git a/appointment-import/src/test/java/smash/appointment/parse/CellParseTestCase.java b/appointment-import/src/test/java/smash/appointment/parse/CellParseTestCase.java deleted file mode 100644 index a43dcbc578952867a0cd36fcbd74d1284fbc3466..0000000000000000000000000000000000000000 --- a/appointment-import/src/test/java/smash/appointment/parse/CellParseTestCase.java +++ /dev/null @@ -1,15 +0,0 @@ -package smash.appointment.parse; - -class CellParseTestCase { - String query; - Subject subject; - String time; - AppointmentType[] types; - - public CellParseTestCase(String query, Subject subject, String time, AppointmentType[] types) { - this.query = query; - this.subject = subject; - this.time = time; - this.types = types; - } -}; diff --git a/appointment-import/src/test/java/smash/appointment/parse/CellParserTest.java b/appointment-import/src/test/java/smash/appointment/parse/CellParserTest.java deleted file mode 100644 index 1c0290fe7f9426312100b8adf7654d94586fb4c9..0000000000000000000000000000000000000000 --- a/appointment-import/src/test/java/smash/appointment/parse/CellParserTest.java +++ /dev/null @@ -1,157 +0,0 @@ -package smash.appointment.parse; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -import org.apache.log4j.Logger; -import org.junit.Before; -import org.junit.Test; - -public class CellParserTest extends TestBase { - Logger logger = Logger.getLogger(CellParserTest.class); - - List<CellParseTestCase> testCases; - CellParser parser; - - @Before - public void setUp() { - super.setUp(); - - parser = new CellParser(); - parser.setSubjectDao(subjectDao); - - testCases = new ArrayList<CellParseTestCase>(); - - testCases.add(new CellParseTestCase("Piotr Gawron level A FU V3", piotrGawron, null, AppointmentTypeCollection.LEVEL_A.getTypes())); - testCases.add(new CellParseTestCase("09:00 Jan Kowalski-Nowak level A", janKowalskiNowak, "09:00", AppointmentTypeCollection.LEVEL_A.getTypes())); - testCases.add( - new CellParseTestCase( - "ND0002 l664574645 (sms)evel BV © + SB ©", janKowalskiNowak, null, new AppointmentType[] { AppointmentType.LEVEL_BV, AppointmentType.LEVEL_SB })); - testCases.add(new CellParseTestCase("ND0001 654654631 level B ©", piotrGawron, null, new AppointmentType[] { AppointmentType.LEVEL_B })); - testCases.add( - new CellParseTestCase( - "John Doe BV + BG + SB", johnDoe, null, new AppointmentType[] { AppointmentType.LEVEL_BV, AppointmentType.LEVEL_BG, AppointmentType.LEVEL_SB })); - testCases.add(new CellParseTestCase("Kowalski-Nowak m-Power", janKowalskiNowak, null, new AppointmentType[] { AppointmentType.LEVEL_B_M_POWER })); - testCases.add(new CellParseTestCase("ND0004 Name BV ©", cateKowalsky, null, new AppointmentType[] { AppointmentType.LEVEL_BV })); - testCases.add( - new CellParseTestCase("ND0004 level BV (c) + SB ©", cateKowalsky, null, new AppointmentType[] { AppointmentType.LEVEL_BV, AppointmentType.LEVEL_SB })); - testCases.add( - new CellParseTestCase( - "Cate Kowalsky level BV + BG + SB + m-Power", cateKowalsky, null, - new AppointmentType[] { AppointmentType.LEVEL_BV, AppointmentType.LEVEL_BG, AppointmentType.LEVEL_SB, AppointmentType.LEVEL_B_M_POWER })); - testCases.add(new CellParseTestCase("sb name level A", null, null, AppointmentTypeCollection.LEVEL_A.getTypes())); - testCases.add(new CellParseTestCase("Andrew Dude level A FU V3", andrewDude, null, AppointmentTypeCollection.LEVEL_A.getTypes())); - testCases.add( - new CellParseTestCase( - "Gawron Piotr BV + BG + neuro level A (FU)", piotrGawron, null, - new AppointmentType[] { AppointmentType.LEVEL_ANP, AppointmentType.LEVEL_BV, AppointmentType.LEVEL_BG })); - - testCases.add( - new CellParseTestCase( - "Gawron Piotr level B © + level A neuro ©", piotrGawron, null, new AppointmentType[] { AppointmentType.LEVEL_ANP, AppointmentType.LEVEL_B })); - - testCases.add( - new CellParseTestCase( - "Gawron Piotr level B © + BV © + SB ©", piotrGawron, null, - new AppointmentType[] { AppointmentType.LEVEL_B, AppointmentType.LEVEL_BV, AppointmentType.LEVEL_SB })); - - testCases.add( - new CellParseTestCase( - "Gawron Piotr level B + BV + BG", piotrGawron, null, - new AppointmentType[] { AppointmentType.LEVEL_B, AppointmentType.LEVEL_BV, AppointmentType.LEVEL_BG })); - - testCases.add( - new CellParseTestCase("Gawron Piotr level B + BG", piotrGawron, null, new AppointmentType[] { AppointmentType.LEVEL_B, AppointmentType.LEVEL_BG })); - testCases.add( - new CellParseTestCase( - "Gawron Piotr level B © + BV © + SB ©", piotrGawron, null, - new AppointmentType[] { AppointmentType.LEVEL_B, AppointmentType.LEVEL_BV, AppointmentType.LEVEL_SB })); - testCases.add( - new CellParseTestCase( - "Gawron Piotr level BG + SB + M-Power", piotrGawron, null, - new AppointmentType[] { AppointmentType.LEVEL_BG, AppointmentType.LEVEL_SB, AppointmentType.LEVEL_B_M_POWER })); - - testCases.add( - new CellParseTestCase("Gawron Piotr level B + BV", piotrGawron, null, new AppointmentType[] { AppointmentType.LEVEL_B, AppointmentType.LEVEL_BV })); - testCases.add( - new CellParseTestCase( - "Gawron Piotr level BG + SB + M-Power", piotrGawron, null, - new AppointmentType[] { AppointmentType.LEVEL_BG, AppointmentType.LEVEL_SB, AppointmentType.LEVEL_B_M_POWER })); - testCases.add( - new CellParseTestCase( - "Gawron Piotr BV © + SB © + neuro", piotrGawron, null, - new AppointmentType[] { AppointmentType.LEVEL_BV, AppointmentType.LEVEL_SB, AppointmentType.LEVEL_AN })); - testCases.add( - new CellParseTestCase( - "Gawron Piotr BV © + SB © + M-Power", piotrGawron, null, - new AppointmentType[] { AppointmentType.LEVEL_BV, AppointmentType.LEVEL_SB, AppointmentType.LEVEL_B_M_POWER })); - - - - } - - @Test - public void testExtractTime() { - for (CellParseTestCase testCase : testCases) { - String result = parser.extractTime(testCase.query); - assertEquals("Invalid time parsed from query: " + testCase.query, testCase.time, result); - } - } - - @Test - public void testRemoveTime() { - for (CellParseTestCase testCase : testCases) { - String result = parser.removeTime(testCase.query); - if (testCase.time == null) { - assertEquals("query after removing time should be the same for query: " + testCase.query, testCase.query, result); - } else { - assertFalse(testCase.query.equals(result)); - } - } - } - - @Test - public void testRemoveTime2() { - String result = parser.removeTime("09:00 John Doe level B"); - assertEquals("John Doe level B", result); - } - - @Test - public void testExtractAppointment() { - String defaultTime = "23:55"; - for (CellParseTestCase testCase : testCases) { - AppointmentEntry appointment = parser.parseAppointment(testCase.query, defaultTime); - if (testCase.time != null) { - assertEquals("Invalid time parsed from query: " + testCase.query, testCase.time, appointment.getTime()); - } else { - assertEquals("Invalid time parsed from query (default value expected): " + testCase.query, defaultTime, appointment.getTime()); - } - assertEquals("Invalid subject parsed from query: " + testCase.query, testCase.subject, appointment.getSubject()); - assertTrue( - "Invalid type parsed from query: " + testCase.query + " expected: " + Arrays.asList(testCase.types) + "; found: " + appointment.getTypes(), - equalTypes(Arrays.asList(testCase.types), appointment.getTypes())); - } - } - - private boolean equalTypes(List<AppointmentType> types, Collection<AppointmentType> types2) { - for (AppointmentType type : types) { - if (!types2.contains(type)) { - return false; - } - } - for (AppointmentType type : types2) { - if (!types.contains(type)) { - return false; - } - } - - return true; - } - -} diff --git a/appointment-import/src/test/java/smash/appointment/parse/DuplicateRemoveParserTest.java b/appointment-import/src/test/java/smash/appointment/parse/DuplicateRemoveParserTest.java deleted file mode 100644 index 7b0786742db14bd4b5f49b4636cfbe99dab481bf..0000000000000000000000000000000000000000 --- a/appointment-import/src/test/java/smash/appointment/parse/DuplicateRemoveParserTest.java +++ /dev/null @@ -1,45 +0,0 @@ -package smash.appointment.parse; - -import static org.junit.Assert.*; - -import java.io.IOException; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; - -public class DuplicateRemoveParserTest { - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void test() throws IOException { - DuplicateRemoveParser parser = new DuplicateRemoveParser(); - - SubjectDao subjectDao = new SubjectDao(); - - subjectDao.addSubject(new Subject("First", "Last", "","P-113"), null); - subjectDao.addSubject(new Subject("First", "Last", "","P-114"), null); - subjectDao.addSubject(new Subject("A", "B", "","P-115"), null); - subjectDao.addSubject(new Subject("C", "D", "","P-116"), null); - - assertEquals(4, subjectDao.getSubjects().size()); - - parser.setSubjectDao(subjectDao); - parser.removeDuplicates("testFiles/duplicates.txt"); - - assertEquals(2, subjectDao.getSubjects().size()); - } - -} diff --git a/appointment-import/src/test/java/smash/appointment/parse/LihControlMappingParserTest.java b/appointment-import/src/test/java/smash/appointment/parse/LihControlMappingParserTest.java deleted file mode 100644 index b281fe89d51262e0f562e36a481c3124b0567d7c..0000000000000000000000000000000000000000 --- a/appointment-import/src/test/java/smash/appointment/parse/LihControlMappingParserTest.java +++ /dev/null @@ -1,80 +0,0 @@ -package smash.appointment.parse; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -import org.apache.log4j.Logger; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; - -public class LihControlMappingParserTest extends TestBase { - Logger logger = Logger.getLogger(LihControlMappingParserTest.class); - - LihControlMappingParser processor = new LihControlMappingParser(); - - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - } - - private static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd"); - - @Test - public void test() throws Exception { - List<Subject> entries = processor.processExcel("testFiles/lihControlMappingExample.xlsx"); - assertTrue(entries.size() > 0); - - Subject subject = entries.get(0); - assertEquals("L-001", subject.getScreeningNumber()); - assertEquals("Piotrek", subject.getName()); - assertEquals("Gawron", subject.getSurname()); - assertEquals("", subject.getAddress()); - assertEquals("", subject.getZipCode()); - assertEquals("", subject.getCity()); - assertEquals("", subject.getCountry()); - assertEquals("343", subject.getPhone1()); - assertEquals("", subject.getPhone2()); - assertEquals("", subject.getPhone3()); - assertEquals("", subject.getMail()); - assertEquals("", subject.getDiagnosisYear()); - assertEquals("", subject.getDiagnosis()); - assertEquals("", subject.getReferal()); - assertEquals("2015-08-03", subject.getAddDate()); - assertEquals("ND3333", subject.getNdNumber()); - assertEquals("", subject.getBirthDate()); - - for (Subject s:entries) { - DATE_FORMATTER.parse(s.getAddDate()); - } - } - - - @Test - public void testFixDate() throws Exception { - DATE_FORMATTER.parse(processor.fixDate("2016-cot-31")); - Date d = DATE_FORMATTER.parse(processor.fixDate("25-11-1951")); - assertEquals("1951-11-25",DATE_FORMATTER.format(d)); - DATE_FORMATTER.parse(processor.fixDate("1957??-10-25")); - DATE_FORMATTER.parse(processor.fixDate("2016?-sep-12")); - DATE_FORMATTER.parse(processor.fixDate("2016-aou-26")); - DATE_FORMATTER.parse(processor.fixDate("2016-avr-14")); - DATE_FORMATTER.parse(processor.fixDate("2016-fev-03")); - DATE_FORMATTER.parse(processor.fixDate("-","2016-01-01")); - } - -} diff --git a/appointment-import/src/test/java/smash/appointment/parse/LihControlParserTest.java b/appointment-import/src/test/java/smash/appointment/parse/LihControlParserTest.java deleted file mode 100644 index 9cd3eb203b49d97fd123e824112c6a952d55e983..0000000000000000000000000000000000000000 --- a/appointment-import/src/test/java/smash/appointment/parse/LihControlParserTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package smash.appointment.parse; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.apache.log4j.Logger; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; - -public class LihControlParserTest extends TestBase { - Logger logger = Logger.getLogger(LihControlParserTest.class); - - LihControlParser processor = new LihControlParser(); - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testParseLang() throws Exception { - assertEquals("English", processor.getMappedLanguage("EN")); - } - - @Test - public void test() throws Exception { - List<Subject> entries = processor.processExcel("testFiles/lihControlExample.xlsx"); - assertTrue(entries.size() > 0); - - Subject subject = entries.get(0); - assertEquals("L-001", subject.getScreeningNumber()); - assertEquals("Name", subject.getName()); - assertEquals("Surname", subject.getSurname()); - assertTrue(subject.getRemarks().contains("001 rdv 01/09/2015 9h jyf")); - assertTrue(subject.getRemarks().contains("PD family relation=pd info")); - assertEquals("11, Rue blabla", subject.getAddress()); - assertEquals("L-3322", subject.getZipCode()); - assertEquals("Luxembourg", subject.getCity()); - assertEquals("Luxembourg", subject.getCountry()); - assertEquals("123456789", subject.getPhone1()); - assertEquals("321654", subject.getPhone2()); - assertEquals("", subject.getPhone3()); - assertEquals("email@pt.lu", subject.getMail()); - assertEquals("", subject.getDiagnosisYear()); - assertEquals("", subject.getDiagnosis()); - assertEquals("", subject.getReferal()); - assertNotNull(subject.getAddDate()); - assertEquals("", subject.getNdNumber()); - assertEquals("1937-01-03", subject.getBirthDate()); - assertTrue(subject.getRemarks().contains("some other remark")); - assertTrue(subject.getRemarks().contains("at home: NMS + RFQ 1 + RFQ 2 + REM + PDSS: manque une page ds RFQ => Linda pr level b 09/09/15")); - assertTrue(subject.getLanguages().contains("French")); - assertTrue(subject.getLanguages().contains("German")); - } -} diff --git a/appointment-import/src/test/java/smash/appointment/parse/PrcControlParserTest.java b/appointment-import/src/test/java/smash/appointment/parse/PrcControlParserTest.java deleted file mode 100644 index 8c44d431a5bd0ff46906d9394ae003a13436e5a1..0000000000000000000000000000000000000000 --- a/appointment-import/src/test/java/smash/appointment/parse/PrcControlParserTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package smash.appointment.parse; - -import static org.junit.Assert.*; - -import java.util.List; - -import org.apache.log4j.Logger; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; - -public class PrcControlParserTest extends TestBase { - Logger logger = Logger.getLogger(PrcSubjectsParserTest.class); - - PrcControlParser processor = new PrcControlParser(); - - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void test() throws Exception { - List<Subject> entries = processor.processExcel("testFiles/prcControlesExample.xlsx"); - assertTrue(entries.size() > 0); - - Subject subject = entries.get(0); - assertEquals("P-333", subject.getScreeningNumber()); - assertEquals("CCC", subject.getName()); - assertEquals("BBB", subject.getSurname()); - assertTrue(subject.getRemarks().contains("note")); - assertEquals("DDD", subject.getAddress()); - assertEquals("L-2423", subject.getZipCode()); - assertEquals("Luxembourg", subject.getCity()); - assertEquals("Luxembourg", subject.getCountry()); - assertEquals("123", subject.getPhone1()); - assertEquals("456", subject.getPhone2()); - assertEquals("", subject.getPhone3()); - assertEquals("mail@mail.lu", subject.getMail()); - assertEquals("", subject.getDiagnosisYear()); - assertEquals("", subject.getDiagnosis()); - assertEquals("", subject.getReferal()); - assertEquals("2016-03-29", subject.getAddDate()); - assertEquals("ND3333", subject.getNdNumber()); - assertEquals("1999-09-10", subject.getBirthDate()); - } - - -} diff --git a/appointment-import/src/test/java/smash/appointment/parse/PrcFlyingParserTest.java b/appointment-import/src/test/java/smash/appointment/parse/PrcFlyingParserTest.java deleted file mode 100644 index 6c34a90a4af6520dc27a332f18662fc711e06d90..0000000000000000000000000000000000000000 --- a/appointment-import/src/test/java/smash/appointment/parse/PrcFlyingParserTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package smash.appointment.parse; - -import static org.junit.Assert.*; - -import java.util.List; - -import org.apache.log4j.Logger; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; - -public class PrcFlyingParserTest extends TestBase { - Logger logger = Logger.getLogger(PrcSubjectsParserTest.class); - - PrcFlyingParser processor = new PrcFlyingParser(); - - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void test() throws Exception { - List<Subject> entries = processor.processExcel("testFiles/prcFlyingTeam.xlsx"); - assertTrue(entries.size() > 0); - - Subject subject = entries.get(0); - assertEquals("F-222", subject.getScreeningNumber()); - assertEquals(SubjectType.CONTROL, subject.getType()); - assertEquals("DOE", subject.getSurname()); - assertEquals("John", subject.getName()); - assertTrue(subject.getRemarks().contains("notes")); - assertEquals("8, rue des Nowhere", subject.getAddress()); - assertEquals("F-57100", subject.getZipCode()); - assertEquals("Paris", subject.getCity()); - assertEquals("France", subject.getCountry()); - assertEquals("001234325435", subject.getPhone1()); - assertEquals("666", subject.getPhone2()); - assertEquals("", subject.getPhone3()); - assertEquals("mail@address.lu", subject.getMail()); - assertEquals("", subject.getDiagnosisYear()); - assertEquals("BLA", subject.getDiagnosis()); - assertEquals("DR", subject.getReferal()); - assertEquals("2016-07-06", subject.getAddDate()); - assertTrue(subject.getRemarks().contains("Questionnaires OK")); - assertEquals("ND2222", subject.getNdNumber()); - assertEquals("1945-01-02", subject.getBirthDate()); - } - - -} diff --git a/appointment-import/src/test/java/smash/appointment/parse/PrcSubjectsParserTest.java b/appointment-import/src/test/java/smash/appointment/parse/PrcSubjectsParserTest.java deleted file mode 100644 index 86f9568717977c12266a21fccd6e6f0c1acaabaf..0000000000000000000000000000000000000000 --- a/appointment-import/src/test/java/smash/appointment/parse/PrcSubjectsParserTest.java +++ /dev/null @@ -1,85 +0,0 @@ -package smash.appointment.parse; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.apache.log4j.Logger; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; - -public class PrcSubjectsParserTest extends TestBase { - Logger logger = Logger.getLogger(PrcSubjectsParserTest.class); - - PrcSubjectsParser processor = new PrcSubjectsParser(); - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void test() throws Exception { - List<Subject> entries = processor.processExcel("testFiles/prcSubjectsExample.xlsx"); - assertTrue(entries.size() > 0); - - Subject subject = entries.get(0); - assertEquals("P-111", subject.getScreeningNumber()); - assertEquals("abcdef", subject.getSurname()); - assertEquals("Piotr", subject.getName()); - assertTrue(subject.getRemarks().contains("this is remark")); - assertEquals("Jaskolki, 6", subject.getAddress()); - assertEquals("D-66636", subject.getZipCode()); - assertEquals("Trier", subject.getCity()); - assertEquals("Deutschland", subject.getCountry()); - assertEquals("0049123455676", subject.getPhone1()); - assertEquals("tel2", subject.getPhone2()); - assertEquals("tel3", subject.getPhone3()); - assertEquals("piotr.cos@uni.lu", subject.getMail()); - assertEquals("1999", subject.getDiagnosisYear()); - assertEquals("unknown", subject.getDiagnosis()); - assertEquals("PG", subject.getReferal()); - assertEquals("2015-10-14", subject.getAddDate()); - assertTrue(subject.getRemarks().contains("Questionnaires OK")); - assertEquals("ND1111", subject.getNdNumber()); - assertEquals("m_id", subject.getmPowerId()); - assertEquals("1972-01-02", subject.getBirthDate()); - assertFalse(subject.isDead()); - assertFalse(subject.isResigned()); - - subject = entries.get(1); - assertTrue(subject.isDead()); - assertTrue(subject.isResigned()); - - subject = entries.get(2); - assertFalse(subject.isDead()); - assertFalse(subject.isResigned()); - - subject = entries.get(3); - assertFalse(subject.isDead()); - assertFalse(subject.isResigned()); - - subject = entries.get(4); - assertFalse(subject.isDead()); - assertTrue(subject.isResigned()); - - - subject = entries.get(5); - assertFalse(subject.isDead()); - - subject = entries.get(6); - assertFalse(subject.isDead()); - } -} diff --git a/appointment-import/src/test/java/smash/appointment/parse/RedcapCalendarParserTest.java b/appointment-import/src/test/java/smash/appointment/parse/RedcapCalendarParserTest.java deleted file mode 100644 index 2a9a17fae5e05b342e817ba4fd29e4d0d7bf8d49..0000000000000000000000000000000000000000 --- a/appointment-import/src/test/java/smash/appointment/parse/RedcapCalendarParserTest.java +++ /dev/null @@ -1,76 +0,0 @@ -package smash.appointment.parse; - -import static org.junit.Assert.*; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; - -public class RedcapCalendarParserTest extends TestBase{ - RedcapCalendarParser parser = new RedcapCalendarParser(); - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() { - super.setUp(); - parser.setSubjectDao(subjectDao); - List<Subject> subjects = new ArrayList<>(); - for (int count =0 ;count<10000;count++) { - String nd = count+""; - while (nd.length()<4) { - nd = "0"+nd; - } - Subject subject = new Subject("name "+nd, "surname"+nd, "ND"+nd, count+""); - - String screening = nd; - if (screening.startsWith("0")) { - screening = screening.substring(1); - } - subject.setScreeningNumber("P-"+screening); - subject.setToBeSeenAt("PRC"); - if (count>=3000) { - screening=screening.substring(1); - subject.setScreeningNumber("L-"+screening); - subject.setToBeSeenAt("LIH"); - } - if (count>=7000) { - subject.setScreeningNumber("F-"+nd); - subject.setToBeSeenAt("FLYING TEAM"); - } - subjects.add(subject); - } - subjectDao.setSubjects(subjects); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testParse() throws Exception{ - List<AppointmentEntry> result = parser.parse("testFiles/redcap_calendar.sql", null); - assertEquals(2, result.size()); - } - -// @Test -// public void test() throws Exception{ -// List<AppointmentEntry> result = parser.parse("c:/Users/piotr.gawron/Desktop/tmp/prc/redcap_events_calendar.sql", Calendar.getInstance()); -// } - - @Test - public void testParse2() throws Exception{ - Calendar future =Calendar.getInstance(); - future.set(Calendar.YEAR, 4000); - List<AppointmentEntry> result = parser.parse("testFiles/redcap_calendar.sql", future); - assertEquals(0, result.size()); - } - -} diff --git a/appointment-import/src/test/java/smash/appointment/parse/RedcapParserTest.java b/appointment-import/src/test/java/smash/appointment/parse/RedcapParserTest.java deleted file mode 100644 index ba1be9f13d5c784e651537a48585808616e1cba9..0000000000000000000000000000000000000000 --- a/appointment-import/src/test/java/smash/appointment/parse/RedcapParserTest.java +++ /dev/null @@ -1,74 +0,0 @@ -package smash.appointment.parse; - -import static org.junit.Assert.*; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.List; - -import org.apache.log4j.Logger; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; - -public class RedcapParserTest extends TestBase{ - Logger logger = Logger.getLogger(RedcapParserTest.class); - RedcapParser parser = new RedcapParser(); - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() { - super.setUp(); - parser.setSubjectDao(subjectDao); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testParseFile() throws FileNotFoundException, IOException { - List<AppointmentEntry> entries = parser.parse("testFiles/redcap_imp.txt"); - assertTrue(entries.size() > 0); - assertEquals(3, subjectDao.getByNdNumber("ND0001").getLanguages().size()); - - int levelACount = 0; - int levelBCount = 0; - int levelBVCount = 0; - int levelBGCount = 0; - int levelSBCount = 0; - int levelMPowerCount = 0; - for (AppointmentEntry appointmentEntry : entries) { - if (appointmentEntry.getTypes().contains(AppointmentType.LEVEL_AQUEST)) { - levelACount++; - } - if (appointmentEntry.getTypes().contains(AppointmentType.LEVEL_B)) { - levelBCount++; - } - if (appointmentEntry.getTypes().contains(AppointmentType.LEVEL_BG)) { - levelBGCount++; - } - if (appointmentEntry.getTypes().contains(AppointmentType.LEVEL_BV)) { - levelBVCount++; - } - if (appointmentEntry.getTypes().contains(AppointmentType.LEVEL_SB)) { - levelSBCount++; - } - if (appointmentEntry.getTypes().contains(AppointmentType.LEVEL_B_M_POWER)) { - levelMPowerCount++; - } - } - assertTrue(levelACount > 0); - assertTrue(levelBCount > 0); - assertTrue(levelBVCount > 0); - assertTrue(levelBGCount > 0); - assertTrue(levelSBCount > 0); - assertTrue(levelMPowerCount > 0); - - } - -} diff --git a/appointment-import/src/test/java/smash/appointment/parse/SubjectDaoTest.java b/appointment-import/src/test/java/smash/appointment/parse/SubjectDaoTest.java deleted file mode 100644 index 0585aa0d9e9f918d3cb37745ea58a8c81b3e0826..0000000000000000000000000000000000000000 --- a/appointment-import/src/test/java/smash/appointment/parse/SubjectDaoTest.java +++ /dev/null @@ -1,88 +0,0 @@ -package smash.appointment.parse; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; - -public class SubjectDaoTest { - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testReadFile() throws Exception { - SubjectDao subjectDao = new SubjectDao(); - subjectDao.readFile("testFiles/subjects.txt"); - assertEquals(2, subjectDao.getSubjects().size()); - assertEquals("Piotr", subjectDao.getSubjects().get(0).getName()); - } - - @Test - public void testDuplicateRem() throws Exception { - Subject subject1 = new Subject("A", "B", "C", "D"); - subject1.setToBeSeenAt(""); - Subject subject2 = new Subject("A", "B", "", "E"); - subject2.setToBeSeenAt(""); - SubjectDao subjectDao = new SubjectDao(); - - subjectDao.addSubject(subject1, null); - subjectDao.addSubject(subject2, null); - subjectDao.removeDuplicate(subject1, subject2, null); - - assertEquals(1, subjectDao.getSubjects().size()); - assertTrue(subject1.getScreeningNumber().contains("D")); - assertTrue(subject1.getScreeningNumber().contains("E")); - assertEquals("C", subject1.getNdNumber()); - } - - @Test - public void testDuplicateRem2() throws Exception { - Subject subject1 = new Subject("A", "B", "C", "D"); - subject1.setToBeSeenAt(""); - Subject subject2 = new Subject("A", "B", "", "E"); - subject2.setToBeSeenAt(""); - SubjectDao subjectDao = new SubjectDao(); - - subjectDao.addSubject(subject1, null); - subjectDao.addSubject(subject2, null); - subjectDao.removeDuplicate(subject2, subject1, null); - - assertEquals(1, subjectDao.getSubjects().size()); - assertTrue(subject2.getScreeningNumber().contains("D")); - assertTrue(subject2.getScreeningNumber().contains("E")); - assertEquals("C", subject2.getNdNumber()); - } - - @Test - public void testDuplicateRem3() throws Exception { - try { - Subject subject1 = new Subject("A", "B", "C", "D"); - subject1.setToBeSeenAt(""); - Subject subject2 = new Subject("A", "B", "X", "E"); - subject2.setToBeSeenAt(""); - SubjectDao subjectDao = new SubjectDao(); - - subjectDao.addSubject(subject1, null); - subjectDao.addSubject(subject2, null); - subjectDao.removeDuplicate(subject2, subject1, null); - - fail("Exception expected"); - } catch (InvalidArgumentException e) { - } - } - -} diff --git a/appointment-import/src/test/java/smash/appointment/parse/SubjectParserTest.java b/appointment-import/src/test/java/smash/appointment/parse/SubjectParserTest.java deleted file mode 100644 index a9efafaf25f0c43f333bd4afa97c370dddc5c4ce..0000000000000000000000000000000000000000 --- a/appointment-import/src/test/java/smash/appointment/parse/SubjectParserTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package smash.appointment.parse; - -import static org.junit.Assert.*; - -import java.util.Calendar; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; - -public class SubjectParserTest { - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testParseDate() { - SubjectParser parser = new PrcControlParser(); - assertEquals("", parser.getDate(null, null)); - } - -} diff --git a/appointment-import/src/test/java/smash/appointment/parse/TestBase.java b/appointment-import/src/test/java/smash/appointment/parse/TestBase.java deleted file mode 100644 index b9663f46e9e6dfe9a395fecd0166b97de4ef75e0..0000000000000000000000000000000000000000 --- a/appointment-import/src/test/java/smash/appointment/parse/TestBase.java +++ /dev/null @@ -1,25 +0,0 @@ -package smash.appointment.parse; - -public class TestBase { - SubjectDao subjectDao; - - Subject piotrGawron = new Subject("Piotr", "Gawron", "ND0001", "1"); - Subject janKowalskiNowak = new Subject("Jan", "Kowalski-Nowak", "ND0002", "2"); - Subject johnDoe = new Subject("John", "Doe", "ND0003", "3"); - Subject cateKowalsky = new Subject("Cate", "Kowalsky", "ND0004", "4"); - Subject andrewDude = new Subject(" Andrew ", " Dude ", "ND0005", "5"); - Subject unknownDude = new Subject(" Unknownnnnnnnn ", " Dude ", "ND0006", "6"); - - public void setUp() { - subjectDao = new SubjectDao(); - - subjectDao.addSubject(new Subject("Piotr Marcin", "Gawron", "ND1005", "1005"), null); - subjectDao.addSubject(piotrGawron, null); - subjectDao.addSubject(janKowalskiNowak, null); - subjectDao.addSubject(johnDoe, null); - subjectDao.addSubject(cateKowalsky, null); - subjectDao.addSubject(andrewDude, null); - subjectDao.addSubject(unknownDude, null); - } - -} diff --git a/appointment-import/src/test/java/smash/appointment/parse/VisitTest.java b/appointment-import/src/test/java/smash/appointment/parse/VisitTest.java deleted file mode 100644 index fd3eb2d963d5699e12d1abc642d67070226e9a3a..0000000000000000000000000000000000000000 --- a/appointment-import/src/test/java/smash/appointment/parse/VisitTest.java +++ /dev/null @@ -1,48 +0,0 @@ -package smash.appointment.parse; - -import static org.junit.Assert.*; - -import java.text.ParseException; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; - -public class VisitTest { - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testGetStartDate() { - Subject subject = new Subject("!", "", "4", "5"); - Visit visit = new Visit(subject); - AppointmentEntry entry = new AppointmentEntry(); - entry.setSubject(subject); - entry.setDay("2015-02-01 8:00"); - visit.addAppointment(entry); - assertEquals("2015-02-01", visit.getStartDate()); - } - - @Test - public void testGetEndDate() throws ParseException { - Subject subject = new Subject("!", "", "4", "5"); - Visit visit = new Visit(subject); - AppointmentEntry entry = new AppointmentEntry(); - entry.setSubject(subject); - entry.setDay("2015-02-01 8:00"); - visit.addAppointment(entry); - assertEquals("2015-05-01", visit.getEndDate()); - } - -} diff --git a/appointment-import/src/test/java/smash/appointment/parse/XlsxCalendarProcessorTest.java b/appointment-import/src/test/java/smash/appointment/parse/XlsxCalendarProcessorTest.java deleted file mode 100644 index 8e23b0a920bfd4ef3d4f0c218a767e502bae523b..0000000000000000000000000000000000000000 --- a/appointment-import/src/test/java/smash/appointment/parse/XlsxCalendarProcessorTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package smash.appointment.parse; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.io.FileNotFoundException; -import java.util.Calendar; -import java.util.List; - -import org.apache.log4j.Logger; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; - -public class XlsxCalendarProcessorTest extends TestBase { - Logger logger = Logger.getLogger(XlsxCalendarProcessorTest.class); - - XlsxCalendarProcessor processor = new XlsxCalendarProcessor(); - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() { - super.setUp(); - processor.setSubjectDao(subjectDao); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testReadExcel() throws Exception { - List<AppointmentEntry> entries = processor.processExcel("testFiles/calendarExample.xlsx", Calendar.getInstance()); - assertTrue(entries.size() > 0); - } - -} diff --git a/appointment-import/src/test/resources/log4j.properties b/appointment-import/src/test/resources/log4j.properties deleted file mode 100644 index e108a78cf8570a6f5bfc3e00dfaee3c45a1e829e..0000000000000000000000000000000000000000 --- a/appointment-import/src/test/resources/log4j.properties +++ /dev/null @@ -1,8 +0,0 @@ -#Set root logger 's level and its appender to an appender called CONSOLE which is defined below. -log4j.rootLogger=debug, CONSOLE - -#Set the behavior of the CONSOLE appender -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d %5p [%t] (%F:%L) - %m%n -#log4j.appender.CONSOLE.layout.ConversionPattern=%m%n diff --git a/appointment-import/testFiles/calendarExample.xlsx b/appointment-import/testFiles/calendarExample.xlsx deleted file mode 100644 index b8a0e42b59245f10692d9739ade2a0e8e4cc8b03..0000000000000000000000000000000000000000 Binary files a/appointment-import/testFiles/calendarExample.xlsx and /dev/null differ diff --git a/appointment-import/testFiles/duplicates.txt b/appointment-import/testFiles/duplicates.txt deleted file mode 100644 index 3c7625d5e81df7be3e2efea220146ef0a1fda1f7..0000000000000000000000000000000000000000 --- a/appointment-import/testFiles/duplicates.txt +++ /dev/null @@ -1,2 +0,0 @@ -P-113 P-114 -P-115 P-116 \ No newline at end of file diff --git a/appointment-import/testFiles/lihControlExample.xlsx b/appointment-import/testFiles/lihControlExample.xlsx deleted file mode 100644 index 526e749bdf8cb818d13e98b763afb22b3ec3b071..0000000000000000000000000000000000000000 Binary files a/appointment-import/testFiles/lihControlExample.xlsx and /dev/null differ diff --git a/appointment-import/testFiles/lihControlMappingExample.xlsx b/appointment-import/testFiles/lihControlMappingExample.xlsx deleted file mode 100644 index 4d54795013bdb361399cc256f0c51ae913af2cf5..0000000000000000000000000000000000000000 Binary files a/appointment-import/testFiles/lihControlMappingExample.xlsx and /dev/null differ diff --git a/appointment-import/testFiles/prcControlesExample.xlsx b/appointment-import/testFiles/prcControlesExample.xlsx deleted file mode 100644 index a3143cb40d39499dd598cea9f473fe6c49f1f2f3..0000000000000000000000000000000000000000 Binary files a/appointment-import/testFiles/prcControlesExample.xlsx and /dev/null differ diff --git a/appointment-import/testFiles/prcFlyingTeam.xlsx b/appointment-import/testFiles/prcFlyingTeam.xlsx deleted file mode 100644 index 891faa078123cf6c7d6d0b676afc1ce763df549a..0000000000000000000000000000000000000000 Binary files a/appointment-import/testFiles/prcFlyingTeam.xlsx and /dev/null differ diff --git a/appointment-import/testFiles/prcSubjectsExample.xlsx b/appointment-import/testFiles/prcSubjectsExample.xlsx deleted file mode 100644 index 986303d98419537e3952a2d557457cb85f468693..0000000000000000000000000000000000000000 Binary files a/appointment-import/testFiles/prcSubjectsExample.xlsx and /dev/null differ diff --git a/appointment-import/testFiles/redcap_calendar.sql b/appointment-import/testFiles/redcap_calendar.sql deleted file mode 100644 index c6586541fe09946d50bf9716e3fa1652a3f2eafd..0000000000000000000000000000000000000000 --- a/appointment-import/testFiles/redcap_calendar.sql +++ /dev/null @@ -1,68 +0,0 @@ --- MySQL dump 10.13 Distrib 5.5.54, for debian-linux-gnu (x86_64) --- --- Host: localhost Database: redcap --- ------------------------------------------------------ --- Server version 5.5.54-0ubuntu0.14.04.1 - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Table structure for table `redcap_events_calendar` --- - -DROP TABLE IF EXISTS `redcap_events_calendar`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `redcap_events_calendar` ( - `cal_id` int(10) NOT NULL AUTO_INCREMENT, - `record` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `project_id` int(10) DEFAULT NULL, - `event_id` int(10) DEFAULT NULL, - `baseline_date` date DEFAULT NULL, - `group_id` int(10) DEFAULT NULL, - `event_date` date DEFAULT NULL, - `event_time` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'HH:MM', - `event_status` int(2) DEFAULT NULL COMMENT 'NULL=Ad Hoc, 0=Due Date, 1=Scheduled, 2=Confirmed, 3=Cancelled, 4=No Show', - `note_type` int(2) DEFAULT NULL, - `notes` text COLLATE utf8_unicode_ci, - `extra_notes` text COLLATE utf8_unicode_ci, - PRIMARY KEY (`cal_id`), - KEY `event_id` (`event_id`), - KEY `group_id` (`group_id`), - KEY `project_date` (`project_id`,`event_date`), - KEY `project_record` (`project_id`,`record`), - CONSTRAINT `redcap_events_calendar_ibfk_1` FOREIGN KEY (`event_id`) REFERENCES `redcap_events_metadata` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `redcap_events_calendar_ibfk_2` FOREIGN KEY (`group_id`) REFERENCES `redcap_data_access_groups` (`group_id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `redcap_events_calendar_ibfk_3` FOREIGN KEY (`project_id`) REFERENCES `redcap_projects` (`project_id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2107 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Calendar Data'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `redcap_events_calendar` --- - -LOCK TABLES `redcap_events_calendar` WRITE; -/*!40000 ALTER TABLE `redcap_events_calendar` DISABLE KEYS */; -INSERT INTO `redcap_events_calendar` VALUES (7,NULL,12,NULL,NULL,NULL,'2015-05-06','08:00',NULL,NULL,'Patient, Level A',NULL),(8,NULL,12,NULL,NULL,NULL,'2015-05-06','12:00',NULL,NULL,'Patient Level A',NULL),(1336,'ND0333',12,41,'2016-10-27',NULL,'2018-09-07','',0,NULL,'',NULL); -/*!40000 ALTER TABLE `redcap_events_calendar` ENABLE KEYS */; -UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- Dump completed on 2017-03-03 15:52:47 diff --git a/appointment-import/testFiles/redcap_imp.txt b/appointment-import/testFiles/redcap_imp.txt deleted file mode 100644 index 8065e5c6c17ca5d0d5803ba08831feb0798a0406..0000000000000000000000000000000000000000 --- a/appointment-import/testFiles/redcap_imp.txt +++ /dev/null @@ -1,8 +0,0 @@ -Subject ID Event Name Date/Time of Birth Sex Language: most fluent Language: second most fluent Language: third most fluent Language: fourth most fluent Basic assessment (Level A) Basic assessment: start date Basic assessment: end date Basic assessment: number of visits Detailed neuropsychological assessment (Level B) Detailed neuropsychological assessment: start date Detailed neuropsychological assessment: end date Detailed neuropsychological assessment: number of visits Detailed motor assessment (Level B) Detailed motor assessment: start date Detailed motor assessment: end date Detailed motor assessment: number of visits Detailed sensory assessment (Level B) Detailed sensory assessment: start date Detailed sensory assessment: end date Detailed sensory assessment: number of visits PSP (Level B) PSP: start date PSP: end date PSP: number of visits Blood Blood: date Urine Urine: date CSF CSF: date Imaging Imaging: date Stool Stool: collection acceptance by patient Stool: collection date proposed Stool: date collected Skin biopsy Skin biopsy: date Saliva Saliva: date mPower mPower: date -ND0001 Visit 1 1955-10-24 10:44 M Polish German French Yes 2015-01-04 10:14 2015-03-04 14:18 1 Yes 2015-03-04 Yes 2015-03-04 Yes 2016-10-20 Yes 2015-03-04 2015-03-11 -ND0001 Visit 2 Yes 2016-12-12 09:34 2017-01-24 10:46 2 -ND0002 Visit 1 1956-05-22 14:53 M Polish Yes 2015-03-04 14:56 2015-03-04 17:43 1 Yes 2015-07-29 2015-07-29 1 No No No Yes 2015-05-13 Yes 2015-05-13 No No No No Yes 2015-05-13 -ND0002 Visit 2 Yes 2016-01-18 10:00 2016-01-18 13:10 1 Yes 2016-05-26 2016-05-26 1 Yes 2016-01-18 Yes 2016-01-18 Yes Yes 2016-05-26 2016-05-26 Yes 2016-05-26 Yes 2016-01-18 -ND0003 Visit 1 1957-07-15 09:21 F Polish German Rusian English Yes 2015-03-11 09:25 2015-03-11 14:58 1 Yes 2015-11-12 2015-11-12 1 Yes 2015-03-11 Yes 2015-03-11 Yes 2015-03-11 -ND0003 Visit 2 Yes 2016-04-27 11:31 2016-05-11 13:30 2 Yes 2016-06-16 2016-06-16 1 Yes 2016-08-18 2016-08-18 1 Yes 2016-04-27 Yes 2016-04-27 Yes Yes 2016-04-27 2016-04-28 Yes 2016-07-28 Yes 2016-04-27 -ND0003 Visit 3 \ No newline at end of file diff --git a/appointment-import/testFiles/subjects.txt b/appointment-import/testFiles/subjects.txt deleted file mode 100644 index c55594f7ee41d31b0b81aaf1b38b46eb949d5bb4..0000000000000000000000000000000000000000 --- a/appointment-import/testFiles/subjects.txt +++ /dev/null @@ -1,2 +0,0 @@ -Piotr Gawron ND0001 1 -John Doe ND0002 2