Skip to content

Instantly share code, notes, and snippets.

@jasonboukheir
Last active February 1, 2019 22:31
Show Gist options
  • Save jasonboukheir/1737896e1c63efe02beb72e07adb7971 to your computer and use it in GitHub Desktop.
Save jasonboukheir/1737896e1c63efe02beb72e07adb7971 to your computer and use it in GitHub Desktop.
using Karuna;
public class EventSDKSample {
void CreateEventHandler() {
// Check user is logged in. If they are not we log them in
// and wait for a successful response before creating the event.
if (User.CurrentUser.Username == null) {
API.Create(new Login() {
Username = "karunademo",
Password = "Karuna1!"
}).AddListeners(
onSuccess: (_request, _response) => { CreateEvent(); }
);
return;
}
// otherwise we can continue without waiting for login...
CreateEvent();
}
void CreateEvent() {
var e = new Karuna.Event() {
Created = DateTime.Now,
EventType = "My event type",
EventValue = "My event value",
// The patient still needs to be added,
// but will look like so
// Patient = Patient.CurrentPatient
};
API.Create(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment