Open wiredsister opened 3 years ago
Sample code for a Human being:
module Human = struct
type t =
{
details: details;
blood_type: blood_type;
body_size: body_size;
hla_class_I: hla_class_I;
hla_class_II: hla_class_II;
(* Dictionary: Key:ICD10_CODE, Value:TEST_RESULT *)
icd_10_codes: (disease, bool option) Hashtbl.t
}
and details =
{
name : string;
email: string;
primary_phone: string;
birthdate: Date.t;
waitlist_start: Date.t;
availability: availability;
}
and blood_type =
| A_Pos
| A_Neg
| B_Pos
| B_Neg
| AB_Pos
| AB_Neg
| O_Pos
| O_Neg
(** This is a hypothetical, might be
best suited to be bands of kg *)
and body_size =
| Infant
| Toddler
| Child
| Small_Female
| Small_Male
| Average_Female
| Average_Male
| Large_Female
| Large_Male
and zipcode = string
(* TODO: ICD_10_CODE MAPPING *)
and disease = string
and availability =
| Can_Be_Contacted_and_Transplant_Ready
| Can_Be_Contacted_and_NOT_Transplant_Ready
| Can_NOT_Be_Contacted_and_Transplant_Ready
| Can_NOT_Be_Contacted_and_NOT_Transplant_Ready
and entrytime = Date.t
and hla_class_I = string
and hla_class_II = string
(* TODO: Research severity grades and how they differ between prognoses *)
and status =
| Dying
| Critical
| Stable
| Nominal
let has_disease (patient:t) (disease:disease) : bool = begin
let { icd_10_codes = tags; _ } = patient in
if Hashtbl.mem tags disease
then
let test_results = Hashtbl.find tags disease in
match test_results with
| Some results -> results
(*
Is there a reason to distinguish "inconclusive" vs tested and negative?
If so, that can be represented here...
*)
| None -> false
(*
Is there a reason to distinguish "untested" vs tested and negative?
If so, that can be represented here...
*)
else false
end
let is_CMV_negative (p:t) = not (has_disease p "P35.1")
let is_EBV_negative (p:t) = not (has_disease p "B27.9")
let is_COVID_19_negative (p:t) = not (has_disease p "U07.1")
let create
(details:details)
(blood_type:blood_type)
(hla_class_I:hla_class_I)
(hla_class_II:hla_class_II)
(body_size:body_size)=
{
hla_class_I = hla_class_I;
hla_class_II = hla_class_II;
details = details;
blood_type = blood_type;
icd_10_codes = Hashtbl.create (~random=true) 70000;
body_size = body_size;
}
end
Sample code for a patient:
module Patient(O: PatientOrganToBeReplaced) = struct
type t = Human.t * info
and vitals = {
(**
Mg/dL, or milligrams per deciliter, is a measurement that indicates
the amount of a particular substance (such as glucose) in a specific
amount of blood.
Source: https://www.webmd.com/diabetes/qa/what-does-mgdl-mean *)
bilirubin: mg * dL;
(**
An equivalent is the amount of a substance that will react with a certain number
of hydrogen ions. A milliequivalent is one-thousandth of an equivalent.
Source: https://hartfordhospital.org/health-wellness/health-resources/health-library/detail?id=stm159429&lang=en-us *)
serum_sodium: mEq * l;
}
(** Milligrams fluid volume *)
and mg = float
(** Decilitre *)
and dL = float
(** A milliequivalent is one-thousandth of an equivalent *)
and mEq = float
(** Liter fluid volume *)
and l = float
(**
CCVHD = Continuous Veno-Venous Hemodialysis
SCT = Serum Creatine Test *)
and
has_had_CVVHD_for_24H_a_week_prior_to_SCT = bool
(**
CCVHD = Continuous Veno-Venous Hemodialysis
SCT = Serum Creatine Test *)
and has_had_dialysis_twice_a_week_prior_to_SCT = bool
(**
The International Normalized Ratio of Prothrombin Time *)
and inr = float
and info = {
zipcode: Human.zipcode;
body_size: Human.body_size;
vitals: vitals;
identification: Uuidm.t;
}
let seeking = O.seeking
end
Notes: 1/2/07 Meeting
POST : organ_submission ->
Ok<tracking_id, barcode_sticker_to_print>, Err
type organ_transplant = | Heart_And_Lungs | Heart | BilateralLungs | Left_Lung | Right_Lung | Intestines | Liver | Pancreas | Dual_Kidney | Right_Kidney | Left_Kidney | Other of string
type availability =
| Can_Be_Contacted_and_Transplant_Ready
| Can_Be_Contacted_and_NOT_Transplant_Ready
| Can_NOT_Be_Contacted_and_Transplant_Ready
| Can_NOT_Be_Contacted_and_NOT_Transplant_Ready
{ organ_intake_version: VERSION_STRING; organ_transplant_type: ALPHA_NUM_STRING; organ: STRING; intake_facility: STRING; intake_location: ZIPCODE_STRING; donor: nullable details : { name : string; email: string; primary_phone: string; birthdate: Date.t; waitlist_start: Date.t; availability: string e.g. "Can_Be_Contacted_and_Transplant_Ready"; }, required blood_type: blood_type e.g. "AB_Neg" "A_Pos", required body_size: body_size "Large_female", HLA_Class_I: string, HLA_Class_II: string, ( Dictionary: Key:ICD10_CODE, Value:TEST_RESULT ) icd_10_codes: JavaScript Arr, e.g. [ "P35.1" ] } }
Scenario 1:
"Given I am a user who is an OPO (Organ Procurement Organization), And I'd like to submit a new organ via an API, ... "
Scenario 2:
"Given I am a user who is a Surgeon,
And I'd like to get a match for an organ on behalf of my patient,
...
"
GET : patient_match_request -> Ok
@yanlow ☝️ added my notes from our discussion here for the POST
https://github.com/wiredsister/OpenTransplant/issues/24
☝️ Example intake form
Need to create JSON document