Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,10 @@
|
|||
// datetime.cpp
|
||||
#include <ctime>
|
||||
#include <cstdint>
|
||||
extern "C" {
|
||||
int64_t from date(const char* string) {
|
||||
struct tm tmInfo = {0};
|
||||
strptime(string, "%Y-%m-%d", &tmInfo);
|
||||
return mktime(&tmInfo); // localtime
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
/* rosetta.dl */
|
||||
#define NaN to_float("NaN")
|
||||
.functor from_date(date:symbol) : number
|
||||
.decl Patient(id:number, lastname:symbol)
|
||||
.decl Visit(id:number, date:symbol, score:float)
|
||||
.decl SummaryDates(id:number, lastname:symbol, last_date:symbol)
|
||||
.decl SummaryScores(id:number, lastname:symbol, score_sum:float, score_mean:float)
|
||||
.decl MissingDates(x:number)
|
||||
|
||||
Patient(1001,"Hopper").
|
||||
Patient(4004,"Wirth").
|
||||
Patient(3003,"Kemeny").
|
||||
Patient(2002,"Gosling").
|
||||
Patient(5005,"Kurtz").
|
||||
|
||||
Visit(2002,"2020-09-10",6.8).
|
||||
Visit(1001,"2020-09-17",5.5).
|
||||
Visit(4004,"2020-09-24",8.4).
|
||||
Visit(2002,"2020-10-08",NaN).
|
||||
Visit(1001,"",6.6).
|
||||
Visit(3003,"2020-11-12",NaN).
|
||||
Visit(4004,"2020-11-05",7.0).
|
||||
Visit(1001,"2020-11-19",5.3).
|
||||
|
||||
MissingDates(@from_date("")) :- true.
|
||||
|
||||
SummaryDates(id, lastname, last_date) :-
|
||||
Patient(id,lastname),
|
||||
last_timestamp = max ts: {Visit(id, date, _), ts = @from_date(date), !MissingDates(ts)},
|
||||
Visit(id, last_date, _), last_timestamp = @from_date(last_date).
|
||||
SummaryScores(id, lastname, score_sum, score_mean) :-
|
||||
Patient(id,lastname),
|
||||
score_sum = sum score: {Visit(id, _, score), score != NaN},
|
||||
score_mean = mean score: {Visit(id, _, score), score != NaN}.
|
||||
.output SummaryDates
|
||||
.output SummaryScores
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
g++ -shared -fPIC datetime.cpp -o libfunctors.so
|
||||
souffle -D- rosetta.dl
|
||||
Loading…
Add table
Add a link
Reference in a new issue