Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,36 @@
|
|||
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).
|
||||
|
||||
summaryDates(Id, Lastname, LastDate) :-
|
||||
aggregate(max(Ts),
|
||||
Score^Date^(visit(Id, Date, Score), Date \= '', parse_time(Date, iso_8601, Ts)),
|
||||
MaxTs),
|
||||
format_time(atom(LastDate), '%Y-%m-%d', MaxTs),
|
||||
patient(Id,Lastname).
|
||||
|
||||
summaryScores(Id, Lastname, Sum, Mean) :-
|
||||
aggregate(r(sum(Score),count), Date^(visit(Id, Date, Score), Score \= nan), r(Sum,Count)),
|
||||
patient(Id,Lastname),
|
||||
Mean is Sum/Count.
|
||||
|
||||
test :-
|
||||
summaryDates(Id, Lastname, LastDate),
|
||||
writeln(summaryDates(Id, Lastname, LastDate)),
|
||||
fail.
|
||||
|
||||
test :-
|
||||
summaryScores(Id, Lastname, ScoreSum, ScoreMean),
|
||||
writeln(summaryScores(Id, Lastname, ScoreSum, ScoreMean)),
|
||||
fail.
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
:- import bagMax/2, bagCount/2, bagSum/2, bagReduce/4 from aggregs.
|
||||
:- import julian_date/7, date_string/3 from iso8601.
|
||||
:- import load_csv/2, add_cvt_type_hook/2 from proc_files.
|
||||
|
||||
?- add_cvt_type_hook(date,date_converter(_,_)).
|
||||
|
||||
date_converter(Atom,Date) :- date_string('YYYY-MM-DD',Date,Atom).
|
||||
|
||||
:- load_csv('visit.csv',visit(integer,date,float)).
|
||||
:- load_csv('patient.csv',patient(integer,atom)).
|
||||
|
||||
is_nan(Number) :- X is Number, X =\= Number.
|
||||
|
||||
summaryDates(Id, Lastname, LastDate) :-
|
||||
bagMax(date_number(Id), LastDateNumber),
|
||||
patient(Id,Lastname),
|
||||
julian_date(LastDateNumber, Y, M, D, _, _, _),
|
||||
date_converter(LastDate, date(Y,M,D)).
|
||||
|
||||
summaryScores(Id, Lastname, Sum, Mean) :-
|
||||
bagSum(scores(Id), Sum),
|
||||
bagCount(scores(Id), Count),
|
||||
Mean is Sum/Count,
|
||||
patient(Id,Lastname).
|
||||
|
||||
test :-
|
||||
summaryDates(Id,Lastname,LastDate),
|
||||
writeln(summaryDates(Id,Lastname,LastDate)), fail.
|
||||
|
||||
test :-
|
||||
summaryScores(Id, Lastname, ScoreSum, ScoreMean),
|
||||
writeln(summaryScores(Id, Lastname, ScoreSum, ScoreMean)), fail.
|
||||
|
||||
/* Put hilog declarations together */
|
||||
|
||||
date_number(Id)(Number) :-
|
||||
visit(Id, date(Y,M,D), _),
|
||||
julian_date(Number, Y, M, D, _, _, _).
|
||||
|
||||
scores(Id)(Score) :-
|
||||
visit(Id, _, Score),
|
||||
\+is_nan(Score).
|
||||
|
||||
:- hilog maximum.
|
||||
maximum(X,Y,Z) :- X @> Y -> Z=X ; Z=Y.
|
||||
:- hilog sum.
|
||||
sum(X,Y,Z) :- Z is X+Y.
|
||||
:- hilog successor.
|
||||
successor(X,_Y,Z) :- Z is X+1.
|
||||
Loading…
Add table
Add a link
Reference in a new issue