Inheritance: AbstractTO
Ejemplo n.º 1
0
        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;
        }