public IenResult SavePerson(string patientDfn, Person person)
        {
            // *** Performs operations to save the FOF ***

            IenResult result = new IenResult();

            if (this.broker != null)
            {
                // *** Create the command ***

                DsioSavePersonCommand command = new DsioSavePersonCommand(this.broker);

                // *** Get the linked person ***
                DsioLinkedPerson dsioFof = GetDsioPerson(patientDfn, person);

                // *** Add as argument ***
                command.AddCommandArguments(dsioFof);

                // *** Execute command ***
                RpcResponse response = command.Execute();

                // *** Set return values ***
                result.Success = (response.Status == RpcResponseStatus.Success);
                result.Message = response.InformationalMessage;

                if (result.Success)
                {
                    result.Ien = command.Ien;
                }
            }

            return(result);
        }
예제 #2
0
        private IenResult SaveDsioObservation(DsioObservation observation)
        {
            IenResult result = new IenResult();

            DsioSaveObservationCommand command = new DsioSaveObservationCommand(this.broker);

            // *** Add entry date if new ***
            if (string.IsNullOrWhiteSpace(observation.Ien))
            {
                observation.ExamDate = DateTime.Now.ToString(VistaDates.VistADateFormatFour);
            }

            command.AddCommandArguments(observation);

            RpcResponse response = command.Execute();

            result.Success = response.Status == RpcResponseStatus.Success;
            result.Message = response.InformationalMessage;

            if (result.Success)
            {
                result.Ien = command.Ien;
            }

            return(result);
        }
예제 #3
0
        public IenResult SaveSingletonObservation(Observation observation)
        {
            // *** Singleton observation: only one should exist, retrieve it and update if it does ***

            IenResult returnResult = new IenResult();

            // *** If we already have an ien, use it ***
            if (!string.IsNullOrWhiteSpace(observation.Ien))
            {
                returnResult = this.SaveObservation(observation);
            }
            else
            {
                ObservationListResult listResult = this.GetObservations(observation.PatientDfn, observation.PregnancyIen, observation.BabyIen, "", "", "", observation.Category, 0, 0);

                if (listResult.Success)
                {
                    if (listResult.Observations != null)
                    {
                        foreach (Observation tempObs in listResult.Observations)
                        {
                            if (tempObs.Code == observation.Code)
                            {
                                observation.Ien = tempObs.Ien;
                                break;
                            }
                        }
                    }
                }

                returnResult = this.SaveObservation(observation);
            }

            return(returnResult);
        }
        public IenResult SavePatientItem(PatientEducationItem item)
        {
            IenResult result = new IenResult();

            if (this.broker != null)
            {
                DsioEducationItem dsioEdItem = GetDsioItem(item);

                DsioPatientEducationItem dsioItem = new DsioPatientEducationItem(dsioEdItem);

                dsioItem.EducationItemIen = item.EducationItemIen;
                dsioItem.PatientDfn       = item.PatientDfn;

                dsioItem.CompletedOn = Util.GetFileManDateAndTime(item.CompletedOn);

                DsioSavePatientEducationCommand command = new DsioSavePatientEducationCommand(this.broker);

                command.AddCommandArguments(dsioItem);

                RpcResponse response = command.Execute();

                result.SetResult(response.Status == RpcResponseStatus.Success, response.InformationalMessage);

                if (result.Success)
                {
                    result.Ien = command.Ien;
                }
            }

            return(result);
        }
        public IenResult CreateNote(TiuNoteTitle noteTitle, string dfn, string noteText, string noteSubject, Dictionary <string, string> noteData, string pregIen)
        {
            IenResult returnResult = new IenResult();

            if (this.broker != null)
            {
                DsioCreateANoteCommand command = new DsioCreateANoteCommand(broker);

                //string noteTitleText = "MCC DASHBOARD NOTE";
                string noteTitleText = TiuNoteTitleInfo.TiuNoteTitleText[(int)noteTitle];
                command.AddCommandArguments(dfn, noteTitleText, noteText, noteSubject, noteData, pregIen);

                RpcResponse response = command.Execute();

                returnResult.Success = (response.Status == RpcResponseStatus.Success);
                returnResult.Message = response.InformationalMessage;

                if (response.InformationalMessage.Equals("Unable to assemble XWB broker message: Attempted to L-Pack a string longer than 999 characters.", StringComparison.CurrentCultureIgnoreCase))
                {
                    returnResult.Message = "Individual lines within a note must be less than 1000 characters.";
                }

                if (returnResult.Success)
                {
                    returnResult.Ien = command.Ien;
                }
            }

            return(returnResult);
        }
        public IenResult SavePregnancy(PregnancyDetails pregnancy)
        {
            // *** Saves pregnancy data ***

            IenResult result = new IenResult();

            // *** Create the dsio pregnancy string data ***
            DsioPregnancy dsioPregnancy = CreateDsioPregnancy(pregnancy);

            // *** Create RPC command ***
            DsioSavePregDetailsCommand command = new DsioSavePregDetailsCommand(this.broker);

            // *** Add command arguments ***
            command.AddCommandArguments(dsioPregnancy, false);

            // *** Execute the command ***
            RpcResponse response = command.Execute();

            // *** Add response data to result ***
            result.SetResult(response.Status == RpcResponseStatus.Success, response.InformationalMessage);

            if (result.Success)
            {
                result.Ien = command.Ien;
            }

            return(result);
        }
        public static BrokerOperationResult CompleteEducationItem(IDashboardRepository repo, string patientDfn, string educationItemIen, string checklistItemIen)
        {
            BrokerOperationResult returnResult = new BrokerOperationResult();

            // *** Two-step process:
            // ***      (1) Create completed patient education item
            // ***      (2) Complete the checklist item

            PatientEducationItem patItem = new PatientEducationItem()
            {
                PatientDfn       = patientDfn,
                EducationItemIen = educationItemIen,
                CompletedOn      = DateTime.Now
            };

            IenResult saveResult = repo.Education.SavePatientItem(patItem);

            returnResult.SetResult(saveResult.Success, saveResult.Message);

            if (saveResult.Success)
            {
                PregnancyChecklistItemsResult result = repo.Checklist.GetPregnancyItems(patientDfn, "", checklistItemIen);

                returnResult.SetResult(result.Success, result.Message);

                if (result.Success)
                {
                    if (result.Items != null)
                    {
                        if (result.Items.Count > 0)
                        {
                            PregnancyChecklistItem checkItem = result.Items[0];

                            checkItem.CompletionStatus = DsioChecklistCompletionStatus.Complete;
                            checkItem.CompletionLink   = saveResult.Ien;

                            IenResult ienResult = repo.Checklist.SavePregnancyItem(checkItem);

                            returnResult.SetResult(ienResult.Success, ienResult.Message);

                            if (returnResult.Success)
                            {
                                returnResult = UpdateNextDates(repo, patientDfn, checkItem.PregnancyIen);

                                if (returnResult.Success)
                                {
                                    returnResult.Message = "Education item completed";
                                }
                            }
                        }
                    }
                }
            }

            return(returnResult);
        }
        public IenResult SaveItem(NonVACareItem item)
        {
            // *** Creates a new Non VA Care Item ***

            IenResult result = new IenResult();

            // *** Create the command ***
            DsioSaveExternalEntityCommand command = new DsioSaveExternalEntityCommand(broker);

            // *** Create the entity to save ***
            DsioNonVAItem dsioItem = new DsioNonVAItem();

            //dsioItem.OriginalEntityName = item.OriginalName;
            dsioItem.Ien                 = item.Ien;
            dsioItem.EntityName          = item.Name;
            dsioItem.Address.StreetLine1 = item.AddressLine1;
            dsioItem.Address.StreetLine2 = item.AddressLine2;
            dsioItem.Address.City        = item.City;
            dsioItem.Address.State       = item.State;
            dsioItem.Address.ZipCode     = item.ZipCode;
            dsioItem.TelephoneList.Add(new DsioTelephone()
            {
                Number = item.PhoneNumber, Usage = DsioTelephone.WorkPhoneUsage
            });
            dsioItem.TelephoneList.Add(new DsioTelephone()
            {
                Number = item.FaxNumber, Usage = DsioTelephone.FaxUsage
            });
            dsioItem.PrimaryContact = item.PrimaryContact;

            //dsioItem.Inactive = (item.Inactive) ? "YES" : "NO";
            dsioItem.Inactive = (item.Inactive) ? "1" : "0";
            //dsioItem.EntityType = (item.ItemType== NonVACareItemType.Provider) ? "PROVIDER" : "FACILITY";
            dsioItem.EntityType = (item.ItemType == NonVACareItemType.Provider) ? "P" : "F";

            // *** Add the arguments ***
            command.AddCommandArguments(dsioItem);

            // *** Execute the command ***
            RpcResponse response = command.Execute();

            // *** Gather results ***
            result.Success = (response.Status == RpcResponseStatus.Success);
            result.Message = response.InformationalMessage;

            if (result.Success)
            {
                result.Ien = command.Ien;
            }

            return(result);
        }
        public ActionResult AddEdit(ChecklistItemAddEdit model)
        {
            ActionResult returnResult;

            bool success = false;

            //if (model.Item.ItemType == DsioChecklistItemType.EducationItem)
            //    model.Item.Link = model.EducationItemLink;

            if (model.Item.IsValid())
            {
                model.SetDueVals();

                IenResult result = this.DashboardRepository.Checklist.SaveItem(model.Item);

                if (!result.Success)
                {
                    this.Error(result.Message);
                }
                else
                {
                    success = true;
                }
            }
            else
            {
                this.Error(model.Item.ValidationMessage);
            }

            if (success)
            {
                if (string.IsNullOrWhiteSpace(model.Item.Ien))
                {
                    this.Information("Checklist item created successfully");
                }
                else
                {
                    this.Information("Checklist item updated successfully");
                }

                returnResult = RedirectToAction("Index");
            }
            else
            {
                model.EducationItemSelection = this.DashboardRepository.Education.GetItemSelection();
                returnResult = View(model);
            }

            return(returnResult);
        }
        public EducationItemsResult LoadDefaults()
        {
            EducationItemsResult returnResult = new EducationItemsResult();

            bool ok = false;

            EducationItemsResult result = this.GetEducationItems("", "", EducationItemType.Unknown, 0, 0, EducationItemSort.Type);

            if (result.Success)
            {
                if (result.EducationItems == null)
                {
                    ok = true;
                }
                else if (result.EducationItems.Count == 0)
                {
                    ok = true;
                }
            }

            if (ok)
            {
                AntepartumEducationValueSet valueSet = new AntepartumEducationValueSet();

                foreach (ValueSetItem item in valueSet.Items)
                {
                    //    public enum CodingSystem {None, Loinc, SnomedCT}

                    CodingSystem[] translation = new CodingSystem[] { CodingSystem.None, CodingSystem.Loinc, CodingSystem.SnomedCT };

                    EducationItem edItem = new EducationItem();
                    edItem.Description  = item.ItemName;
                    edItem.Category     = item.Category;
                    edItem.Code         = item.Code;
                    edItem.CodingSystem = translation[(int)item.CodeSystem];
                    edItem.ItemType     = EducationItemType.DiscussionTopic;

                    IenResult saveResult = this.SaveEducationItem(edItem);

                    returnResult.SetResult(saveResult.Success, saveResult.Message);

                    if (!saveResult.Success)
                    {
                        break;
                    }
                }
            }

            return(returnResult);
        }
        public ActionResult Status(LactationStatus model)
        {
            ActionResult returnResult;

            bool okToContinue = false;

            if (model.NewStatus.HasValue)
            {
                IenResult wvrpcorResult = this.DashboardRepository.Observations.AddWvrpcorLactationObservation(model.Patient.Dfn, model.NewStatus.Value);
                if (!wvrpcorResult.Success)
                {
                    this.Error(wvrpcorResult.Message);
                }
                else
                {
                    IenResult result = this.DashboardRepository.Observations.AddLactationObservation(model.Patient.Dfn, model.NewStatus.Value);

                    if (!result.Success)
                    {
                        this.Error(result.Message);
                    }
                    else
                    {
                        this.Information("Lactation Status Updated");
                        okToContinue = true;
                    }
                }
            }
            else
            {
                this.Error("Please select a lactation status");
            }

            if (okToContinue)
            {
                returnResult = RedirectToAction("Summary", "Patient", new { dfn = model.Patient.Dfn });
            }
            else
            {
                this.CurrentPatientDfn = model.Patient.Dfn;
                model.Patient          = this.CurrentPatient;
                model.CurrentStatus    = model.CurrentStatus = (this.CurrentPatient.Lactating) ? "Lactating" : "Not Lactating";

                returnResult = View(model);
            }

            return(returnResult);
        }
        public ActionResult PatientSelect(PatientEducationSelect model)
        {
            ActionResult returnResult;

            List <string> ienList = model.GetSelectedIenList();

            bool ok = false;

            if (ienList != null)
            {
                foreach (string ien in ienList)
                {
                    PatientEducationItem patItem = new PatientEducationItem();

                    patItem.EducationItemIen = ien;
                    patItem.PatientDfn       = model.Patient.Dfn;
                    patItem.CompletedOn      = DateTime.Now;

                    IenResult ienResult = this.DashboardRepository.Education.SavePatientItem(patItem);

                    if (!ienResult.Success)
                    {
                        this.Error(ienResult.Message);
                        ok = false;
                        break;
                    }
                    else
                    {
                        ok = true;
                    }
                }
            }

            if (ok)
            {
                this.Information("Education Items Added Successfully");
                returnResult = RedirectToAction("PatientIndex", new { dfn = model.Patient.Dfn });
            }
            else
            {
                this.CurrentPatientDfn = model.Patient.Dfn;
                model.Patient          = this.CurrentPatient;
                returnResult           = View(model);
            }

            return(returnResult);
        }
예제 #13
0
        public IenResult SaveDocument(CdaDocumentData documentData)
        {
            // *** Save a document to vista ***

            IenResult result = new IenResult();

            // *** Strings for direction to be stored in VistA ***
            string[] ExchangeDirectionDescription = { "IN", "OUT" };

            if (this.broker != null)
            {
                // *** Create the command ***
                DsioSaveIheDocCommand command = new DsioSaveIheDocCommand(broker);

                // *** Add the arguments ***
                command.AddCommandArguments(
                    documentData.Ien,
                    documentData.Id,
                    documentData.PatientDfn,
                    ExchangeDirectionDescription[(int)documentData.ExchangeDirection],
                    documentData.CreationDateTime.ToString(VistaDates.VistADateFormatFour),
                    documentData.ImportDateTime.ToString(VistaDates.VistADateFormatFour),
                    CdaUtility.DocumentTypeAbbreviation[(int)documentData.DocumentType],
                    documentData.Title,
                    documentData.Sender,
                    documentData.IntendedRecipient,
                    documentData.DocumentContent);

                // *** Execute and get response ***
                RpcResponse response = command.Execute();

                // *** Add command response to result ***
                result.Success = (response.Status == RpcResponseStatus.Success);
                result.Message = response.InformationalMessage;

                if (result.Success)
                {
                    result.Ien = response.Data;
                }
            }

            return(result);
        }
예제 #14
0
        public IenResult SavePregnancyItem(PregnancyChecklistItem item)
        {
            IenResult result = new IenResult();

            if (this.broker != null)
            {
                DsioSaveMccPatChecklistCommand command = new DsioSaveMccPatChecklistCommand(broker);

                DsioChecklistItem dsioItem = GetDsioChecklistItem(item);

                DsioPatientChecklistItem patItem = new DsioPatientChecklistItem(dsioItem);

                patItem.PatientDfn   = item.PatientDfn;
                patItem.PregnancyIen = item.PregnancyIen;
                if (item.SpecificDueDate != DateTime.MinValue)
                {
                    patItem.SpecificDueDate = Util.GetFileManDate(item.SpecificDueDate);
                }
                patItem.CompletionStatus = item.CompletionStatus;
                patItem.CompleteDate     = Util.GetFileManDate(item.CompleteDate);
                patItem.CompletionLink   = item.CompletionLink;
                patItem.CompletedBy      = item.CompletedBy;
                patItem.Note             = item.StoredNote;
                patItem.InProgress       = (item.InProgress) ? "1" : "0";

                // *** These items not saved - generated internally ***
                //patItem.User = item.User;
                //patItem.ItemDate = Util.GetFileManDate(item.ItemDate);

                command.AddCommandArguments(patItem);

                RpcResponse response = command.Execute();

                result.SetResult(response.Status == RpcResponseStatus.Success, response.InformationalMessage);

                if (result.Success)
                {
                    result.Ien = command.Ien;
                }
            }

            return(result);
        }
예제 #15
0
        public IenResult AddWvrpcorLactationObservation(string patientDfn, bool currentlyLactating)
        {
            IenResult result = new IenResult();

            // *** Create RPC command ***
            WvrpcorSaveObservationCommand saveWvrpcorObservationCommand = new WvrpcorSaveObservationCommand(this.broker);

            // *** Add command arguments ***
            saveWvrpcorObservationCommand.AddCommandArguments(patientDfn, currentlyLactating);
            // *** Execute the command ***
            RpcResponse response = saveWvrpcorObservationCommand.Execute();

            result.Success = response.Status == RpcResponseStatus.Success;
            result.Message = response.InformationalMessage;

            if (result.Success)
            {
                result.Ien = saveWvrpcorObservationCommand.Ien;
            }

            return(result);
        }
        public IenResult SaveEducationItem(EducationItem item)
        {
            IenResult result = new IenResult();

            if (this.broker != null)
            {
                DsioSaveEducationItemCommand command = new DsioSaveEducationItemCommand(this.broker);

                DsioEducationItem dsioItem = GetDsioItem(item);

                command.AddCommandArguments(dsioItem);

                RpcResponse response = command.Execute();

                result.SetResult(response.Status == RpcResponseStatus.Success, response.InformationalMessage);

                if (result.Success)
                {
                    result.Ien = command.Ien;
                }
            }

            return(result);
        }
예제 #17
0
        public ActionResult AddEdit(PatientOutcomeAddEdit model)
        {
            ActionResult returnResult = null;

            // *** Make sure patient is current ***
            this.CurrentPatientDfn = model.Patient.Dfn;
            model.Patient          = this.CurrentPatient;

            bool ok = true;

            // *** Add pregnancy record if it does not exist ***
            if (string.IsNullOrWhiteSpace(model.PregnancyIen))
            {
                PregnancyDetails newDetails = new PregnancyDetails()
                {
                    PatientDfn = this.CurrentPatientDfn, RecordType = PregnancyRecordType.Historical
                };

                IenResult saveResult = this.DashboardRepository.Pregnancy.SavePregnancy(newDetails);

                if (saveResult.Success)
                {
                    model.PregnancyIen = saveResult.Ien;
                }
                else
                {
                    this.Error(saveResult.Message);
                }
            }

            if (!string.IsNullOrWhiteSpace(model.PregnancyIen))
            {
                string normalizedOutcomeDate = "";
                if (!string.IsNullOrWhiteSpace(model.OutcomeDetails.OutcomeDate))
                {
                    normalizedOutcomeDate = VistaDates.StandardizeDateFormat(model.OutcomeDetails.OutcomeDate);
                }

                // *** Update outcome observation ***
                List <Observation> outcomeList = ObservationsFactory.CreateOutcomeObservations
                                                 (
                    model.Patient.Dfn,
                    model.OutcomeDetails.OutcomeType,
                    normalizedOutcomeDate,
                    model.PregnancyIen
                                                 );

                BrokerOperationResult obsResult = this.DashboardRepository.Observations.SaveSingletonObservations(outcomeList);

                if (!obsResult.Success)
                {
                    this.Error(obsResult.Message);
                    ok = false;
                }

                if (ok)
                {
                    if (!string.IsNullOrWhiteSpace(normalizedOutcomeDate))
                    {
                        // *** Update pregnancy end date ***
                        PregnancyDetails preg = PregnancyUtilities.GetPregnancy(this.DashboardRepository, model.Patient.Dfn, model.PregnancyIen);

                        if (preg != null)
                        {
                            // *** Update date ***
                            preg.DisplayEndDate = normalizedOutcomeDate;

                            // *** Save updated pregnancy ***
                            BrokerOperationResult savePregResult = this.DashboardRepository.Pregnancy.SavePregnancy(preg);

                            // *** Check result ***
                            if (!savePregResult.Success)
                            {
                                this.Error(savePregResult.Message);
                                ok = false;
                            }
                        }
                    }
                }

                // *** Get observations from the model ***
                ObservationConstructable details = model.OutcomeDetails.SelectedDetails;

                if (details != null)
                {
                    List <Observation> obsList = details.GetObservations(model.Patient.Dfn, model.PregnancyIen, "");

                    if (obsList != null)
                    {
                        if (obsList.Count > 0)
                        {
                            // *** If we have any, save them ***
                            BrokerOperationResult result = this.DashboardRepository.Observations.SaveSingletonObservationsByCategory(obsList);

                            if (!result.Success)
                            {
                                this.Error(result.Message);
                                ok = false;
                            }
                        }
                    }
                }
            }

            if (ok)
            {
                returnResult = RedirectToAction("PregnancyView", "Pregnancy", new { dfn = model.Patient.Dfn, pregIen = model.PregnancyIen });
            }
            else
            {
                returnResult = View(model);
            }

            return(returnResult);
        }
        public ActionResult PregnancyAddEdit(PregnancyChecklistAddEdit model)
        {
            ActionResult result;

            bool ok = false;

            //if (model.Item.ItemType == DsioChecklistItemType.EducationItem)
            //    model.Item.Link = model.EducationItemLink;

            if (model.Item.IsValid())
            {
                model.SetDueVals();

                IenResult saveResult = this.DashboardRepository.Checklist.SavePregnancyItem(model.Item);

                if (!saveResult.Success)
                {
                    this.Error(saveResult.Message);
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(model.Item.Ien))
                    {
                        this.Information("Checklist item created successfully");
                    }
                    else
                    {
                        this.Information("Checklist item updated successfully");
                    }

                    // *** Update the next checklist date ***
                    BrokerOperationResult updResult = ChecklistUtility.UpdateNextDates(this.DashboardRepository, model.Patient.Dfn, model.Item.PregnancyIen);

                    if (!updResult.Success)
                    {
                        this.Error("Error updating next dates: " + updResult.Message);
                    }

                    ok = true;
                }
            }
            else
            {
                this.Error(model.Item.ValidationMessage);
            }

            if (ok)
            {
                result = RedirectToAction("PregnancyIndex", new { dfn = model.Patient.Dfn, pregIen = model.Item.PregnancyIen });
            }
            else
            {
                this.CurrentPatientDfn = model.Patient.Dfn;
                model.Patient          = this.CurrentPatient;

                model.EducationItemSelection = this.DashboardRepository.Education.GetItemSelection();

                result = View(model);
            }

            return(result);
        }
예제 #19
0
        public BrokerOperationResult AddDefaultPregnancyItems(string dfn, string pregIen)
        {
            BrokerOperationResult result = new BrokerOperationResult();

            ChecklistItemsResult getResult = this.GetItems("", 1, 1000);

            if (string.IsNullOrWhiteSpace(dfn))
            {
                result.Message = "The patient could not be identified";
            }
            else
            {
                if (string.IsNullOrWhiteSpace(pregIen))
                {
                    result.Message = "The pregnancy could not be identified";
                }
                else
                {
                    if (!getResult.Success)
                    {
                        result.SetResult(getResult.Success, getResult.Message);
                    }
                    else
                    {
                        if (getResult.Items != null)
                        {
                            if (getResult.Items.Count == 0)
                            {
                                result.SetResult(false, "There are no default checklist items to add");
                            }
                            else
                            {
                                foreach (ChecklistItem item in getResult.Items)
                                {
                                    PregnancyChecklistItem patItem = new PregnancyChecklistItem(item);

                                    patItem.PatientDfn       = dfn;
                                    patItem.PregnancyIen     = pregIen;
                                    patItem.CompletionStatus = DsioChecklistCompletionStatus.NotComplete;
                                    patItem.Ien = "";

                                    if (item.DueCalculationType == DsioChecklistCalculationType.Initial)
                                    {
                                        patItem.SpecificDueDate = DateTime.Now;
                                    }

                                    IenResult saveResult = this.SavePregnancyItem(patItem);

                                    if (!saveResult.Success)
                                    {
                                        result.SetResult(saveResult.Success, saveResult.Message);
                                        break;
                                    }
                                    else
                                    {
                                        result.SetResult(saveResult.Success, saveResult.Message);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(result);
        }