private void OnEnumNote() { List <int> notelist = null; if (NotebookApi.NotebookList(NotebookId, NotebookPass, ref notelist)) { NoteList = notelist; Console.WriteLine("Id为{0}的Notebook中 有如下Note", NotebookId); foreach (var obj in NoteList) { Console.WriteLine("Id : {0}", obj); Tuple <int, string, string> note = null; if (NoteApi.NoteGet(NotebookId, NotebookPass, obj, ref note)) { Console.WriteLine("Type : {0}", note.Item1); Console.WriteLine("Name : {0}", note.Item2); Console.WriteLine("Data : {0}", note.Item3); } else { Console.WriteLine("获取失败"); } } } else { Console.WriteLine("获取数据失败"); } Console.ReadKey(); }
private void OnNoteCreate() { Console.WriteLine("输入Type"); int type = 0; if (int.TryParse(Console.ReadLine().Trim(), out type)) { Console.WriteLine("输入Name"); string notename = Console.ReadLine(); Console.WriteLine("输入Data"); string notedata = Console.ReadLine(); int noteid = 0; if (NoteApi.NoteCreate(NotebookId, NotebookPass, notename, type, notedata, ref noteid)) { Console.WriteLine("创建成功"); } else { Console.WriteLine("创建失败"); } } else { Console.WriteLine("Type错误"); } Console.ReadKey(); }
public TaggedTextArray getCrisisNotes(string fromDate, string toDate, int nrpts) { TaggedTextArray result = new TaggedTextArray(); string msg = MdwsUtils.isAuthorizedConnection(_mySession); if (msg != "OK") { result.fault = new FaultTO(msg); } else if (fromDate == "") { result.fault = new FaultTO("Missing fromDate"); } else if (toDate == "") { result.fault = new FaultTO("Missing toDate"); } if (result.fault != null) { return(result); } try { NoteApi api = new NoteApi(); IndexedHashtable t = api.getCrisisNotes(_mySession.ConnectionSet, fromDate, toDate, nrpts); return(new TaggedTextArray(t)); } catch (Exception e) { result.fault = new FaultTO(e); return(result); } }
public TaggedNoteArrays getNotesWithText(string fromDate, string toDate, int nNotes) { TaggedNoteArrays result = new TaggedNoteArrays(); if (!_mySession.ConnectionSet.IsAuthorized) { result.fault = new FaultTO("Connections not ready for operation", "Need to login?"); } else if (fromDate == "") { result.fault = new FaultTO("Missing fromDate"); } else if (toDate == "") { result.fault = new FaultTO("Missing toDate"); } if (result.fault != null) { return(result); } try { NoteApi api = new NoteApi(); IndexedHashtable t = api.getNotes(_mySession.ConnectionSet, fromDate, toDate, nNotes); result = new TaggedNoteArrays(t); } catch (Exception e) { result.fault = new FaultTO(e); } return(result); }
public TaggedNoteArrays getDischargeSummaries(String fromDate, String toDate, int nNotes) { TaggedNoteArrays result = new TaggedNoteArrays(); string msg = MdwsUtils.isAuthorizedConnection(_mySession); if (msg != "OK") { result.fault = new FaultTO(msg); } else if (fromDate == "") { result.fault = new FaultTO("Missing fromDate"); } else if (toDate == "") { result.fault = new FaultTO("Missing toDate"); } if (result.fault != null) { return(result); } try { NoteApi api = new NoteApi(); IndexedHashtable t = api.getDischargeSummaries(_mySession.ConnectionSet, fromDate, toDate, nNotes); result = new TaggedNoteArrays(t); } catch (Exception e) { result.fault = new FaultTO(e); } return(result); }
public TextTO getNoteEncounterString(string sitecode, string noteId) { TextTO result = new TextTO(); string msg = MdwsUtils.isAuthorizedConnection(mySession, sitecode); if (msg != "OK") { result.fault = new FaultTO(msg); } else if (noteId == "") { result.fault = new FaultTO("Missing noteId"); } if (result.fault != null) { return(result); } if (sitecode == null) { sitecode = mySession.ConnectionSet.BaseSiteId; } try { AbstractConnection cxn = mySession.ConnectionSet.getConnection(sitecode); NoteApi api = new NoteApi(); result.text = api.getNoteEncounterString(cxn, noteId); } catch (Exception e) { result.fault = new FaultTO(e.Message); } return(result); }
public TextTO getNote(string siteId, string noteId) { TextTO result = new TextTO(); string msg = MdwsUtils.isAuthorizedConnection(_mySession, siteId); if (msg != "OK") { result.fault = new FaultTO(msg); } else if (siteId == "") { result.fault = new FaultTO("Missing siteId"); } else if (noteId == "") { result.fault = new FaultTO("Missing noteId"); } if (result.fault != null) { return(result); } try { NoteApi api = new NoteApi(); string s = api.getNoteText(_mySession.ConnectionSet.getConnection(siteId), noteId); result = new TextTO(s); } catch (Exception e) { result.fault = new FaultTO(e); } return(result); }
public TextTO signNote(string sitecode, string noteId, string userId, string esig) { TextTO result = new TextTO(); string msg = MdwsUtils.isAuthorizedConnection(_mySession, sitecode); if (msg != "OK") { result.fault = new FaultTO(msg); } else if (noteId == "") { result.fault = new FaultTO("Missing noteId"); } else if (esig == "") { result.fault = new FaultTO("Missing esig"); } if (userId == "") { if (_mySession.User.Uid == "") { result.fault = new FaultTO("Missing userId"); } else { userId = _mySession.User.Uid; } } if (result.fault != null) { return(result); } if (sitecode == null) { sitecode = _mySession.ConnectionSet.BaseSiteId; } try { AbstractConnection cxn = _mySession.ConnectionSet.getConnection(sitecode); NoteApi api = new NoteApi(); string s = api.signNote(cxn, noteId, userId, esig); if (s != "OK") { result.fault = new FaultTO(s); } else { result = new TextTO(s); } } catch (Exception e) { result.fault = new FaultTO(e.Message); } return(result); }
public void NoteApiUsesKVStoreToStoreNotes() { var kvStore = new Mock <IKeyValueStore>(); var noteApi = new NoteApi(kvStore.Object); noteApi.AddNote("user-id", "this is a note"); kvStore.Verify(x => x.Set("notes:user-id", "[{\"Id\":\"1\",\"Text\":\"this is a note\"}]")); kvStore.Verify(x => x.Set("notes:user-id:next", "2")); }
public void UsesKVStoreToDeleteNotes() { var kvStore = new Mock <IKeyValueStore>(); var noteApi = new NoteApi(kvStore.Object); kvStore.Setup(x => x.Get("notes:user-id")).Returns("[{\"Id\":\"1\",\"Text\":\"this is a note\"},{\"Id\":\"2\",\"Text\":\"this is another note\"}]"); kvStore.Setup(x => x.Get("notes:user-id:next")).Returns("3"); noteApi.RemoveNote("user-id", "1"); kvStore.Verify(x => x.Set("notes:user-id", "[{\"Id\":\"2\",\"Text\":\"this is another note\"}]")); }
public void NoteApiUsesKVStoreToListNotes() { var kvStore = new Mock <IKeyValueStore>(); var noteApi = new NoteApi(kvStore.Object); kvStore.Setup(x => x.Get("notes:user-id")).Returns("[{\"Id\":\"1\",\"Text\":\"this is a note\"},{\"Id\":\"2\",\"Text\":\"this is another note\"}]"); kvStore.Setup(x => x.Get("notes:user-id:next")).Returns("3"); var notes = noteApi.GetNotes("user-id"); CollectionAssert.AreEqual(new[] { new Note("1", "this is a note"), new Note("2", "this is another note") }, notes); }
private async void SaveNote(object obj) { IsReadOnly = true; IsSaveButtonVisible = Visibility.Hidden; IsEditButtonVisible = Visibility.Visible; AuthenticationToken authToken = new AuthenticationToken(ConnectionApi.HttpClient); token = await authToken.PostAuthRecordAsync(_authenticationRecord); user = await methods.GetUserInfo(token, _authenticationRecord.Email); noteApi = new NoteApi(_authenticationRecord, user.Id); noteApi.UpdateNoteAsync(Note.Id, Note); OnPropertyChanged(nameof(IsSaveButtonVisible)); OnPropertyChanged(nameof(IsSaveButtonVisible)); OnPropertyChanged(nameof(IsReadOnly)); }
private void OnNoteDelete() { Console.WriteLine("输入ID"); int id = 0; if (int.TryParse(Console.ReadLine().Trim(), out id)) { if (NoteApi.NoteDelete(NotebookId, NotebookPass, id)) { Console.WriteLine("删除成功"); } else { Console.WriteLine("删除失败"); } } else { Console.WriteLine("输入失败"); } Console.ReadKey(); }
public async void GetAllNotes(bool showSingleNotes) { getToken(); LoggedUser = await methods.GetUserInfo(token, _authenticationRecord.Email); noteApi = new NoteApi(_authenticationRecord, LoggedUser.Id); try { IEnumerable <Note> tempNotes = await noteApi.GetAllNotesAsync(); IEnumerable <Note> tempSortedNotes = tempNotes.OrderByDescending <Note, DateTime>(o => o.CreateTimestamp).ToList(); Notes.Clear(); singleNotes.Clear(); foreach (var note in tempSortedNotes) { Notes.Add(note); singleNotes.Add(note); } foreach (var note in Notes) { note.CreateTimestamp = note.CreateTimestamp.ToLocalTime(); note.LastChangeTimestamp = note.LastChangeTimestamp.ToLocalTime(); if (showSingleNotes == true) { var window = new SingleNoteWindow(note); window.Show(); singleNoteWindows.Add(window); } } } catch (Exception e) { MessageBox.Show("An error has occured." + e.Message); return; } }
public TaggedNoteArrays getNotesForBhie(string pwd, string mpiPid, string fromDate, string toDate, string nNotes) { TaggedNoteArrays result = new TaggedNoteArrays(); if (pwd != "iBnOfs55iEZ,d") { result.fault = new FaultTO("Invalid application password"); } else if (String.IsNullOrEmpty(mpiPid)) { result.fault = new FaultTO("Missing mpiPid"); } else if (String.IsNullOrEmpty(fromDate)) { result.fault = new FaultTO("Missing fromDate"); } else if (String.IsNullOrEmpty(toDate)) { result.fault = new FaultTO("Missing toDate"); } if (result.fault != null) { return(result); } if (nNotes == "") { nNotes = "50"; } try { int maxNotes = Convert.ToInt16(nNotes); PatientLib patLib = new PatientLib(_mySession); TaggedTextArray sites = patLib.getPatientSitesByMpiPid(mpiPid); if (sites == null) { return(null); } if (sites.fault != null) { result.fault = sites.fault; return(result); } string sitelist = ""; for (int i = 0; i < sites.count; i++) { if ((string)sites.results[i].tag == "200") { continue; } if (sites.results[i].fault != null) { } else { sitelist += (string)sites.results[i].tag + ','; } } sitelist = sitelist.Substring(0, sitelist.Length - 1); AccountLib acctLib = new AccountLib(_mySession); sites = acctLib.visitSites("BHIE", sitelist, MdwsConstants.CPRS_CONTEXT); if (sites.fault != null) { result.fault = sites.fault; return(result); } PatientApi patApi = new PatientApi(); IndexedHashtable t = patApi.setLocalPids(_mySession.ConnectionSet, mpiPid); NoteApi api = new NoteApi(); IndexedHashtable tNotes = api.getNotes(_mySession.ConnectionSet, fromDate, toDate, maxNotes); IndexedHashtable tSumms = api.getDischargeSummaries(_mySession.ConnectionSet, fromDate, toDate, 50); result = new TaggedNoteArrays(mergeNotesAndDischargeSummaries(tNotes, tSumms)); } catch (Exception ex) { result.fault = new FaultTO(ex); } finally { if (_mySession.ConnectionSet != null) { _mySession.ConnectionSet.disconnectAll(); } } return(result); }
public NoteLib(MySession mySession) { this._mySession = mySession; this._api = new NoteApi(); }