-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from HBreddam/Testsandvalidation
Data can now be written and read to CSV files. The first test have been created and the first version of a solutionvalidator is ready.
- Loading branch information
Showing
22 changed files
with
1,474 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,45 @@ | ||
|
||
""" | ||
MasterCalendar(startdate::Date,enddate::Date) | ||
Produces a mastercalendar (Dict{Int64,Date}) of weekdays where clinic is open between the start and enddate | ||
# Examples | ||
```julia-repl | ||
julia> MasterCalendar(Date("2019-01-01"),Date("2019-02-01")) | ||
Dict{Int64,Date} with 24 entries: | ||
18 => 2019-01-18 | ||
24 => 2019-01-24 | ||
⋮ => ⋮ | ||
``` | ||
""" | ||
function MasterCalendar(startdate::Date,enddate::Date) | ||
Dict((date-startdate).value+1 => date for date = filter(td -> dayofweek(td) <= 5, startdate:Day(1):enddate)) | ||
end | ||
|
||
""" | ||
MasterCalendar(mastercalendar::Dict{Int64,Date},startdate,enddate) | ||
Produces a mastercalendar (Dict{Int64,Date}) of weekdays where clinic is open. | ||
# Examples | ||
```julia-repl | ||
julia> mc = MasterCalendar(Date("2019-01-01"),Date("2019-02-01")) | ||
Dict{Int64,Date} with 24 entries: | ||
18 => 2019-01-18 | ||
24 => 2019-01-24 | ||
⋮ => ⋮ | ||
julia> MasterCalendar(mc,Date("2019-01-01"),Date("2019-01-10")) | ||
Dict{Int64,Date} with 6 entries: | ||
7 => 2019-01-07 | ||
9 => 2019-01-09 | ||
4 => 2019-01-04 | ||
2 => 2019-01-02 | ||
3 => 2019-01-03 | ||
8 => 2019-01-08 | ||
``` | ||
""" | ||
function MasterCalendar(mastercalendar::Dict{Int64,Date},startdate::Date,enddate::Date) | ||
filter(date -> startdate <date[2] < enddate,mastercalendar) | ||
end | ||
|
||
@enum STATUS free = 1 booked = 2 | ||
mutable struct Timeslot | ||
date::Pair{Int64,Date} | ||
intID::Int | ||
startTime::Time | ||
endTime::Time | ||
|
||
status::STATUS | ||
|
||
Timeslot(date::Pair{Int64,Date},intID::Int,startTime::DateTime,endTime::DateTime)= new(date,intID,Time(startTime),Time(startTime),free) | ||
Timeslot(date::Pair{Int64,Date},intID::Int,startTime::Time,endTime::Time)= new(date,intID,startTime,endTime,free) | ||
|
||
end | ||
|
||
@enum WEEK Odd = 1 Even = 2 | ||
mutable struct Workday | ||
date::Pair{Int64,Date} | ||
timeslots::Array{Timeslot} | ||
|
||
weekday::Int | ||
weektype::WEEK | ||
|
||
Workday() = new((0 =>Date(0)),[]) | ||
Workday(weekday::Int,weektype::WEEK) = new((0 =>Date(0)),[],weekday,weektype) | ||
Workday(date::Pair{Int64,Date},timeslots::Array{Timeslot},weekday::WEEK,weektype::Int) = new(date,timeslots,weekday,weektype) | ||
end | ||
function addTimeslot!(workday::Workday,startTime::Time,endTime::Time) | ||
push!(workday.timeslots,Timeslot(workday.date,length(workday.timeslots)+1,startTime,endTime)) | ||
end | ||
|
||
function addTimeslot!(workday::Workday,startTime::String,endTime::String) | ||
push!(workday.timeslots,Timeslot(workday.date,length(workday.timeslots)+1,Dates.Time(startTime),Dates.Time(endTime))) | ||
end | ||
|
||
|
||
abstract type AbstractCalendar end | ||
|
||
|
||
|
||
struct Calendar <: AbstractCalendar | ||
workdays::Array{Workday} | ||
|
||
Calendar() = new([]) | ||
Calendar(workdays::Array{Workday}) = new(workdays) | ||
end | ||
|
||
function Base.:(+)(cal1::AbstractCalendar, cal2::AbstractCalendar) | ||
newcal = vcat(cal1.workdays,cal2.workdays) | ||
sort!(newcal, by= x ->(x.date,x.weekday) ) | ||
return Calendar(newcal) | ||
end | ||
|
||
|
||
function addWorkday!(calendar::Calendar,workday::Workday,day::Pair{Int64,Date}=(0=>Date(0))) | ||
workday.date = day | ||
for y in workday.timeslots | ||
y.date = day | ||
end | ||
push!(calendar.workdays,workday) | ||
sort!(calendar.workdays,by = x ->(x.date[1],x.weekday)) | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
|
||
function savepatients(object,path::String) | ||
CSVFiles.save(path, object) | ||
end | ||
|
||
function savetimeslots(object,path::String) | ||
CSVFiles.save(path, object) | ||
end | ||
|
||
|
||
function loadtimeslots(path) | ||
colparser = Dict(:startTime => dateformat"H:M:S",:endTime => dateformat"H:M:S") | ||
res = loadtable(path,colparsers=colparser)|> @map((resourceID = _.resourceID, type= _.type,dayID = _.dayID,timeslotID = _.timeslotID,startTime = Time(_.startTime),endTime= Time(_.endTime),booked = _.booked == "true" )) |> collect | ||
return table(res,pkey = [:resourceID,:dayID,:timeslotID]) | ||
end | ||
|
||
|
||
function save(object,path::String) | ||
CSVFiles.save(path, object) | ||
end | ||
|
||
function loadresources(path) | ||
loadtable(path,indexcols= [:intID]) | ||
end | ||
|
||
function loadpatients(path,indexcols=[]) | ||
if length(indexcols) == 0 | ||
loadtable(path,) | ||
else | ||
loadndsparse(path,indexcols) | ||
end | ||
end | ||
function loadTimeDelta(path_TimeDelta::String) | ||
loadndsparse(path_TimeDelta,indexcols=1:2) | ||
end | ||
|
||
function loadvisits(path) | ||
loadtable(path,indexcols= [:intID]) | ||
end | ||
|
||
function loadsolution(path) | ||
loadtable(path;indexcols=[:visitID]) | ||
end |
Binary file not shown.
Oops, something went wrong.