public NoteResultTO writeNote( string sitecode, string titleIEN, string encounterString, string text, string authorDUZ, string cosignerDUZ, string consultIEN, string prfIEN) { NoteResultTO result = new NoteResultTO(); string msg = MdwsUtils.isAuthorizedConnection(_mySession, sitecode); if (msg != "OK") { result.fault = new FaultTO(msg); } else if (titleIEN == "") { result.fault = new FaultTO("Missing titleIEN"); } else if (encounterString == "") { result.fault = new FaultTO("Missing encounterString"); } else if (text == "") { result.fault = new FaultTO("No text!"); } Encounter encounter = null; try { encounter = getFromEncounterString(encounterString); } catch (Exception e) { result.fault = new FaultTO(e.Message); } if (result.fault != null) { return(result); } // If no author DUZ we assume author is user if (authorDUZ == "") { authorDUZ = _mySession.User.Uid; } if (sitecode == null) { sitecode = _mySession.ConnectionSet.BaseSiteId; } // Externalizing note writing business rules... //Note note = new Note(); //note.DocumentDefinitionId = titleIEN; //note.Author = new Author(authorDUZ, "", ""); //note.Timestamp = DateTime.Now.ToString("yyyyMMdd"); //note.ConsultId = consultIEN; //note.IsAddendum = false; //note.PrfId = prfIEN; //if (cosignerDUZ != "") //{ // note.Cosigner = new Author(cosignerDUZ, "", ""); //} //note.Text = text; try { AbstractConnection cxn = _mySession.ConnectionSet.getConnection(sitecode); NoteResult noteResult = _api.writeNote( cxn, titleIEN, encounter, text, authorDUZ, cosignerDUZ, consultIEN, prfIEN ); return(new NoteResultTO(noteResult)); } catch (Exception e) { result.fault = new FaultTO(e.Message); result.fault.stackTrace = e.StackTrace; } return(result); }
/// <summary> /// US:1952 US:1945 US:885 /// write a note to MDWS /// </summary> /// <param name="strPatientID"></param> /// <param name="strAuthorID"></param> /// <param name="strVisitLocationID"></param> /// <param name="strNoteTitleIEN"></param> /// <param name="strNoteText"></param> /// <returns></returns> public CStatus WriteNote( string strPatientID, string strAuthorID, string strESignature, string strVisitLocationID, string strNoteTitleIEN, string strNoteText) { //select the patient PatientTO toSelect = GetMDWSSOAPClient().select(strPatientID); // easy way to make sure we're using new value each test run -- yes //this will create a lot of notes... DateTime dtnow = DateTime.Now; string strVisitTimeStamp = dtnow.ToString("yyyyMMdd.HHmmss"); //encounter // create our encounter string // use "A" not a historical note, "H" if it was... string strEncounter = strVisitLocationID + ";" + strVisitTimeStamp + ";H"; string strCosigner = String.Empty; string strConsultIEN = String.Empty; string strPrfIEN = String.Empty; //before we start any note writing we need to verify the //esignature so that we dont have dangling notes if they //enter a bad esig one time TextTO toTxt = GetMDWSSOAPClient().isValidEsig(strESignature); if (toTxt.text == null || toTxt.text.ToUpper() != "TRUE") { return(new CStatus(false, k_STATUS_CODE.Failed, "Invalid Signature Code!")); } //write the note // //For preserving line breaks within a text block that is //being written to a note, replace the \r\n or \n characters //with a pipe (|). // NoteResultTO noteResult = GetMDWSSOAPClient().writeNote( strNoteTitleIEN, strEncounter, strNoteText.Replace("\r\n", "|"), strAuthorID, strCosigner, strConsultIEN, strPrfIEN); //check for error while writing note... if (noteResult == null || noteResult.fault != null) { return(new CMDWSStatus(noteResult.fault)); } //sign the note TextTO toSign = GetMDWSSOAPClient().signNote(noteResult.id, strAuthorID, strESignature); //check for sign error and return if (toSign.fault != null) { return(new CMDWSStatus(toSign.fault)); } //close the note TextTO closeNoteResult = GetMDWSSOAPClient().closeNote(noteResult.id, string.Empty); //check for close error and return if (closeNoteResult == null || closeNoteResult.fault != null) { return(new CMDWSStatus(closeNoteResult.fault)); } ///////////////////////////////////////////////////////////// //todo: remove this code later - test pulling back notes //////////////////////////////////////////////////////////// //select the patient /* PatientTO toP = GetMDWSSOAPClient().select(strPatientID); * * //todate is today * DateTime dtToDate = DateTime.Now; * string strToDate = CDataUtils.GetMilitaryDateAsString(dtToDate); * * //fromdate is today - lookback * int nLookBackDays = 9999; * DateTime dtFromDate = dtToDate.AddDays(-1 * nLookBackDays); * string strFromDate = CDataUtils.GetMilitaryDateAsString(dtFromDate); * * //get the notes * TaggedNoteArrays tnas = GetMDWSSOAPClient().getNotesWithText( strFromDate, * strToDate, * 0); * * string strNotes = String.Empty; * * if(tnas != null) * { * foreach (TaggedNoteArray tna in tnas.arrays) * { * if (tna.notes != null) * { * foreach (NoteTO note in tna.notes) * { * strNotes += String.Empty; * strNotes += note.timestamp; * strNotes += "\r\n"; * strNotes += note.text; * strNotes += "\r\n\r\n"; * } * } * } * } */ ////////////////////////////////////////////////////////////// //end pulling back notes ///////////////////////////////////////////////////////////// return(new CStatus()); }