public string Save(PatientRegistrationDTO registration) { try { LookupLogic lookupLogic = new LookupLogic(); PatientLookupManager patientLookup = new PatientLookupManager(); PatientLookup patient = new PatientLookup(); PatientRegistrationValidation registrationValidation = new PatientRegistrationValidation(); //Validate DTO string results = registrationValidation.ValidateDTO(registration); if (!String.IsNullOrWhiteSpace(results)) { throw new Exception(results); } int interopUserId = InteropUser.UserId; //Get FacilityId int facilityId = Convert.ToInt32(registration.MESSAGE_HEADER.SENDING_FACILITY); //Get Gender string gender = registration.PATIENT_IDENTIFICATION.SEX == "F" ? "Female" : "Male"; //IQCare Sex int sex = lookupLogic.GetItemIdByGroupAndItemName("Gender", gender)[0].ItemId; //Assume this is a new patient int patientType = lookupLogic.GetItemIdByGroupAndItemName("PatientType", registration.PATIENT_VISIT.PATIENT_TYPE)[0].ItemId; //Get Enrollment Id Type int visitType = lookupLogic.GetItemIdByGroupAndItemName("VisitType", "Enrollment")[0].ItemId; //Get DOB DateTime DOB = DateTime.ParseExact(registration.PATIENT_IDENTIFICATION.DATE_OF_BIRTH, "yyyyMMdd", null); bool DOB_Precision = true; switch (registration.PATIENT_IDENTIFICATION.DATE_OF_BIRTH_PRECISION) { case "ESTIMATED": DOB_Precision = false; break; case "EXACT": DOB_Precision = true; break; default: DOB_Precision = true; break; } //Get Enrollment Date DateTime dateOfEnrollment = DateTime.ParseExact(registration.PATIENT_VISIT.HIV_CARE_ENROLLMENT_DATE, "yyyyMMdd", null); //Get Patient Names string firstName = registration.PATIENT_IDENTIFICATION.PATIENT_NAME.FIRST_NAME; string middleName = registration.PATIENT_IDENTIFICATION.PATIENT_NAME.MIDDLE_NAME; string lastName = registration.PATIENT_IDENTIFICATION.PATIENT_NAME.LAST_NAME; //Get gods number string godsNumber = registration.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID.ID; //get marital status string maritalStatusString = String.Empty; int maritalStatusId = 0; switch (registration.PATIENT_IDENTIFICATION.MARITAL_STATUS) { case "S": maritalStatusString = "Single"; break; case "W": maritalStatusString = "Widowed"; break; case "D": maritalStatusString = "Divorced"; break; case "MP": maritalStatusString = "Married Polygamous"; break; case "C": maritalStatusString = "Cohabiting"; break; case "MM": maritalStatusString = "Married Monogamous"; break; default: maritalStatusString = "Unknown"; break; } maritalStatusId = lookupLogic.GetItemIdByGroupAndItemName("MaritalStatus", maritalStatusString)[0].ItemId; //Get patient Address string village = String.Empty; string ward = String.Empty; string sub_county = String.Empty; string county = String.Empty; string nearestLandMark = String.Empty; string postalAdress = String.Empty; string phoneNumber = String.Empty; string deathDate = String.Empty; var patient_address = registration.PATIENT_IDENTIFICATION.PATIENT_ADDRESS; if (patient_address != null) { var physicalAddress = registration.PATIENT_IDENTIFICATION.PATIENT_ADDRESS.PHYSICAL_ADDRESS; if (physicalAddress != null) { village = registration.PATIENT_IDENTIFICATION.PATIENT_ADDRESS.PHYSICAL_ADDRESS.VILLAGE; ward = registration.PATIENT_IDENTIFICATION.PATIENT_ADDRESS.PHYSICAL_ADDRESS.WARD; sub_county = registration.PATIENT_IDENTIFICATION.PATIENT_ADDRESS.PHYSICAL_ADDRESS.SUB_COUNTY; county = registration.PATIENT_IDENTIFICATION.PATIENT_ADDRESS.PHYSICAL_ADDRESS.COUNTY; nearestLandMark = registration.PATIENT_IDENTIFICATION.PATIENT_ADDRESS.PHYSICAL_ADDRESS.NEAREST_LANDMARK; } postalAdress = registration.PATIENT_IDENTIFICATION.PATIENT_ADDRESS.POSTAL_ADDRESS; } //Lookup Ward, sub_county_county int wardId = 0; int subCountyId = 0; int countyId = 0; var countyDetails = lookupLogic.GetCountyDetailsByWardName(ward); if (countyDetails != null) { wardId = countyDetails.WardId; subCountyId = countyDetails.SubcountyId; countyId = countyDetails.CountyId; } //Get Phone Number phoneNumber = registration.PATIENT_IDENTIFICATION.PHONE_NUMBER; deathDate = registration.PATIENT_IDENTIFICATION.DEATH_DATE; DateTime?DateOfDeath = null; if (!string.IsNullOrWhiteSpace(deathDate)) { DateOfDeath = DateTime.ParseExact(deathDate, "yyyyMMdd", null); } //GET NEXT OF KIN var nextOfKin = registration.NEXT_OF_KIN; //Get CCCNumber and NationalId string nationalId = String.Empty; string cccNumber = String.Empty; int entryPointId = 0; var lookupEntryPoints = lookupLogic.GetItemIdByGroupAndItemName("Entrypoint", registration.PATIENT_VISIT.PATIENT_SOURCE); if (lookupEntryPoints.Count > 0) { entryPointId = lookupEntryPoints[0].ItemId; } else { entryPointId = lookupLogic.GetItemIdByGroupAndDisplayName("Entrypoint", "Other")[0].ItemId; } foreach (var internalpatientid in registration.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID) { if (internalpatientid.IDENTIFIER_TYPE == "NATIONAL_ID" && internalpatientid.ASSIGNING_AUTHORITY == "GOK") { nationalId = internalpatientid.ID; } if (internalpatientid.IDENTIFIER_TYPE == "CCC_NUMBER" && internalpatientid.ASSIGNING_AUTHORITY == "CCC") { cccNumber = internalpatientid.ID; } } if (!String.IsNullOrWhiteSpace(cccNumber)) { patient = patientLookup.GetPatientByCccNumber(cccNumber); if (patient == null) { msg = ProcessPatient.Add(firstName, middleName, lastName, sex, interopUserId, DOB, DOB_Precision, facilityId, patientType, nationalId, visitType, dateOfEnrollment, cccNumber, entryPointId, godsNumber, maritalStatusId, village, wardId, subCountyId, countyId, nearestLandMark, postalAdress, phoneNumber, DateOfDeath, nextOfKin); } else { msg = ProcessPatient.Update(firstName, middleName, lastName, sex, patient.PersonId, patient.Id, patient.ptn_pk, DOB, DOB_Precision, nationalId, facilityId, entryPointId, dateOfEnrollment, cccNumber, patient, godsNumber, maritalStatusId, village, wardId, subCountyId, countyId, nearestLandMark, postalAdress, phoneNumber, DateOfDeath, nextOfKin, interopUserId); } } } catch (Exception ex) { throw new Exception(ex.Message); } return(msg); }
public async Task <Result <string> > Handle(AfyaMobileSynchronizeClientsCommand request, CancellationToken cancellationToken) { string afyaMobileId = String.Empty; using (var trans = _unitOfWork.Context.Database.BeginTransaction()) { RegisterPersonService registerPersonService = new RegisterPersonService(_unitOfWork); LookupLogic lookupLogic = new LookupLogic(_unitOfWork); PersonOccupationService pocc = new PersonOccupationService(_unitOfWork); EducationLevelService educationLevelService = new EducationLevelService(_unitOfWork); for (int i = 0; i < request.CLIENTS.Count; i++) { for (int j = 0; j < request.CLIENTS[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID.Count; j++) { if (request.CLIENTS[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].IDENTIFIER_TYPE == "AFYA_MOBILE_ID" && request.CLIENTS[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].ASSIGNING_AUTHORITY == "AFYAMOBILE") { afyaMobileId = request.CLIENTS[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].ID; } } } var afyaMobileMessage = await registerPersonService.AddAfyaMobileInbox(DateTime.Now, request.MESSAGE_HEADER.MESSAGE_TYPE, afyaMobileId, JsonConvert.SerializeObject(request), false); try { var facilityId = request.MESSAGE_HEADER.SENDING_FACILITY; for (int i = 0; i < request.CLIENTS.Count; i++) { string firstName = request.CLIENTS[i].PATIENT_IDENTIFICATION.PATIENT_NAME.FIRST_NAME; string middleName = string.IsNullOrWhiteSpace(request.CLIENTS[i].PATIENT_IDENTIFICATION.PATIENT_NAME.MIDDLE_NAME) ? "" : request.CLIENTS[i].PATIENT_IDENTIFICATION.PATIENT_NAME.MIDDLE_NAME; string lastName = request.CLIENTS[i].PATIENT_IDENTIFICATION.PATIENT_NAME.LAST_NAME; string nickName = (request.CLIENTS[i].PATIENT_IDENTIFICATION.PATIENT_NAME.NICK_NAME == null) ? "" : request.CLIENTS[i].PATIENT_IDENTIFICATION.PATIENT_NAME.NICK_NAME.ToString(); int sex = request.CLIENTS[i].PATIENT_IDENTIFICATION.SEX; //Try to parse dateOfBirth DateTime dateOfBirth = DateTime.Now; try { dateOfBirth = DateTime.ParseExact(request.CLIENTS[i].PATIENT_IDENTIFICATION.DATE_OF_BIRTH, "yyyyMMdd", null); } catch (Exception e) { Log.Error($"Could not parse DateOfBirth: {request.CLIENTS[i].PATIENT_IDENTIFICATION.DATE_OF_BIRTH} as a valid date. Incorrect format, date should be in the following format yyyyMMdd"); throw new Exception($"Could not parse DateOfBirth: {request.CLIENTS[i].PATIENT_IDENTIFICATION.DATE_OF_BIRTH} as a valid date. Incorrect format, date should be in the following format yyyyMMdd"); } string dobPrecision = request.CLIENTS[i].PATIENT_IDENTIFICATION.DATE_OF_BIRTH_PRECISION; //Try to parse DateOfEnrollment DateTime dateEnrollment = DateTime.Now; try { dateEnrollment = DateTime.ParseExact(request.CLIENTS[i].PATIENT_IDENTIFICATION.REGISTRATION_DATE, "yyyyMMdd", null); } catch (Exception e) { Log.Error($"Could not parse DateOfEnrollment: {request.CLIENTS[i].PATIENT_IDENTIFICATION.REGISTRATION_DATE} as a valid date: Incorrect format, date should be in the following format yyyyMMdd"); throw new Exception($"Could not parse DateOfEnrollment: {request.CLIENTS[i].PATIENT_IDENTIFICATION.REGISTRATION_DATE} as a valid date: Incorrect format, date should be in the following format yyyyMMdd"); } int maritalStatusId = request.CLIENTS[i].PATIENT_IDENTIFICATION.MARITAL_STATUS; string landmark = request.CLIENTS[i].PATIENT_IDENTIFICATION.PATIENT_ADDRESS.PHYSICAL_ADDRESS .LANDMARK; int ward = request.CLIENTS[i].PATIENT_IDENTIFICATION.PATIENT_ADDRESS.PHYSICAL_ADDRESS.WARD; int county = request.CLIENTS[i].PATIENT_IDENTIFICATION.PATIENT_ADDRESS.PHYSICAL_ADDRESS.COUNTY; int subcounty = request.CLIENTS[i].PATIENT_IDENTIFICATION.PATIENT_ADDRESS.PHYSICAL_ADDRESS.SUB_COUNTY; string educationlevel = (request.CLIENTS[i].PATIENT_IDENTIFICATION.EDUCATIONLEVEL == null) ? "" : request.CLIENTS[i].PATIENT_IDENTIFICATION.EDUCATIONLEVEL.ToString(); string educationoutcome = (request.CLIENTS[i].PATIENT_IDENTIFICATION.EDUCATIONOUTCOME == null) ? "" : request.CLIENTS[i].PATIENT_IDENTIFICATION.EDUCATIONOUTCOME.ToString(); string occupation = (request.CLIENTS[i].PATIENT_IDENTIFICATION.OCCUPATION == null) ? "" : request.CLIENTS[i].PATIENT_IDENTIFICATION.OCCUPATION.ToString(); string physicalAddress = request.CLIENTS[i].PATIENT_IDENTIFICATION.PATIENT_ADDRESS.POSTAL_ADDRESS; string mobileNumber = request.CLIENTS[i].PATIENT_IDENTIFICATION.PHONE_NUMBER; string enrollmentNo = string.Empty; int userId = request.CLIENTS[i].PATIENT_IDENTIFICATION.USER_ID; string maritalStatusName = String.Empty; string gender = String.Empty; var maritalStatusList = await lookupLogic.GetLookupNameByGroupNameItemId(maritalStatusId, "HTSMaritalStatus"); var genderList = await lookupLogic.GetLookupNameByGroupNameItemId(sex, "Gender"); if (maritalStatusList.Count > 0) { maritalStatusName = maritalStatusList[0].ItemName; } if (genderList.Count > 0) { gender = genderList[0].ItemName; } for (int j = 0; j < request.CLIENTS[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID.Count; j++) { if (request.CLIENTS[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].ASSIGNING_AUTHORITY == "HTS" && request.CLIENTS[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].IDENTIFIER_TYPE == "HTS_SERIAL") { enrollmentNo = request.CLIENTS[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].ID; } if (request.CLIENTS[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].IDENTIFIER_TYPE == "AFYA_MOBILE_ID" && request.CLIENTS[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].ASSIGNING_AUTHORITY == "AFYAMOBILE") { afyaMobileId = request.CLIENTS[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].ID; } } Facility clientFacility = await _unitOfWork.Repository <Facility>().Get(x => x.PosID == facilityId).FirstOrDefaultAsync(); if (clientFacility == null) { clientFacility = await _unitOfWork.Repository <Facility>().Get(x => x.DeleteFlag == 0).FirstOrDefaultAsync(); } //check if person already exists var identifiers = await registerPersonService.getPersonIdentifiers(afyaMobileId, 10); if (identifiers.Count > 0) { var registeredPerson = await registerPersonService.GetPerson(identifiers[0].PersonId); if (registeredPerson != null) { var updatedPerson = await registerPersonService.UpdatePerson(identifiers[0].PersonId, firstName, middleName, lastName, sex, dateOfBirth, clientFacility.FacilityID, registrationDate : dateEnrollment, NickName : nickName); } else { var person = await registerPersonService.RegisterPerson(firstName, middleName, lastName, sex, userId, clientFacility.FacilityID, dateOfBirth, nickName : nickName); } var patient = await registerPersonService.GetPatientByPersonId(identifiers[0].PersonId); if (patient != null) { var updatedPatient = await registerPersonService.UpdatePatient(patient.Id, dateOfBirth, facilityId); } else { //Add Person to mst_patient var mstResult = await registerPersonService.InsertIntoBlueCard(firstName, lastName, middleName, dateEnrollment, " ", 283, maritalStatusName, physicalAddress, mobileNumber, gender, dobPrecision, dateOfBirth, userId, facilityId); if (mstResult.Count > 0) { patient = await registerPersonService.AddPatient(identifiers[0].PersonId, userId, facilityId); // Person is enrolled state var enrollmentAppState = await registerPersonService.AddAppStateStore(identifiers[0].PersonId, patient.Id, 7, null, null); // Enroll patient var patientIdentifier = await registerPersonService.EnrollPatient(enrollmentNo, patient.Id, 2, userId, dateEnrollment); //Add PersonIdentifiers var personIdentifier = await registerPersonService.addPersonIdentifiers(identifiers[0].PersonId, 10, afyaMobileId, userId); } } var updatedPersonPopulations = await registerPersonService.UpdatePersonPopulation(identifiers[0].PersonId, request.CLIENTS[i].PATIENT_IDENTIFICATION.KEY_POP, userId); //Location if (!string.IsNullOrWhiteSpace(landmark) || (county > 0) || (subcounty > 0) || (ward > 0)) { var updatedLocation = await registerPersonService.UpdatePersonLocation(identifiers[0].PersonId, landmark, ward, county, subcounty, userId); } if (!string.IsNullOrWhiteSpace(educationlevel)) { var personeducation = await educationLevelService.UpdatePersonEducation(identifiers[0].PersonId, educationlevel, educationoutcome, userId); } if (!string.IsNullOrWhiteSpace(occupation)) { var personoccupation = await pocc.Update(identifiers[0].PersonId, occupation, userId); } if (!string.IsNullOrWhiteSpace(mobileNumber) || !string.IsNullOrWhiteSpace(physicalAddress)) { //add Person Contact var personContact = await registerPersonService.UpdatePersonContact(identifiers[0].PersonId, physicalAddress, mobileNumber); } // update message as processed await registerPersonService.UpdateAfyaMobileInbox(afyaMobileMessage.Id, afyaMobileId, true, DateTime.Now, "success", true); } else { // Add Person var person = await registerPersonService.RegisterPerson(firstName, middleName, lastName, sex, userId, clientFacility.FacilityID, dateOfBirth, nickName : nickName); //Add Person to mst_patient var mstResult = await registerPersonService.InsertIntoBlueCard(firstName, lastName, middleName, dateEnrollment, " ", 283, maritalStatusName, physicalAddress, mobileNumber, gender, dobPrecision, dateOfBirth, userId, facilityId); if (mstResult.Count > 0) { //Add PersonIdentifiers var personIdentifier = await registerPersonService.addPersonIdentifiers(person.Id, 10, afyaMobileId, userId); // Add Patient var patient = await registerPersonService.AddPatient(person.Id, userId, mstResult[0].Ptn_Pk, facilityId); // Person is enrolled state var enrollmentAppState = await registerPersonService.AddAppStateStore(person.Id, patient.Id, 7, null, null); // Enroll patient var patientIdentifier = await registerPersonService.EnrollPatient(enrollmentNo, patient.Id, 2, userId, dateEnrollment); // Add Marital Status var maritalStatus = await registerPersonService.AddMaritalStatus(person.Id, maritalStatusId, userId); // Add Person Key pop var population = await registerPersonService.addPersonPopulation(person.Id, request.CLIENTS[i].PATIENT_IDENTIFICATION.KEY_POP, userId); // Add Person Location if (!string.IsNullOrWhiteSpace(landmark) || (county > 0) || (subcounty > 0) || (ward > 0)) { var personLocation = await registerPersonService.UpdatePersonLocation(person.Id, landmark, ward, county, subcounty, userId); } if (!string.IsNullOrWhiteSpace(educationlevel)) { var personeducation = await educationLevelService.UpdatePersonEducation(person.Id, educationlevel, educationoutcome, userId); } if (!string.IsNullOrWhiteSpace(occupation)) { var personoccupation = await pocc.Update(person.Id, occupation, userId); } if (!string.IsNullOrWhiteSpace(mobileNumber) || !string.IsNullOrWhiteSpace(physicalAddress)) { //add Person Contact var personContact = await registerPersonService.addPersonContact(person.Id, physicalAddress, mobileNumber, string.Empty, string.Empty, userId); } //update message has been processed await registerPersonService.UpdateAfyaMobileInbox(afyaMobileMessage.Id, afyaMobileId, true, DateTime.Now, $"Successfully synchronized demographics for afyamobileid: {afyaMobileId}", true); } } } //update message has been processed await registerPersonService.UpdateAfyaMobileInbox(afyaMobileMessage.Id, afyaMobileId, true, DateTime.Now, $"Successfully synchronized demographics for afyamobileid: {afyaMobileId}", true); trans.Commit(); return(Result <string> .Valid($"Successfully synchronized demographics for afyamobileid: {afyaMobileId}")); } catch (Exception ex) { trans.Rollback(); Log.Error($"Error syncronizing afyamobileid: {afyaMobileId}. Exception Message: {ex.Message}, Inner Exception {ex.InnerException}"); return(Result <string> .Invalid($"Failed to synchronize clientId: {afyaMobileId} " + ex.Message + " " + ex.InnerException)); } } }
public void getScoreCTRLs() { LookupLogic lookUp = new LookupLogic(); List <LookupItemView> questionsList = lookUp.getQuestions("CRAFFTScoreQuestions"); int i = 0; foreach (var value in questionsList) { i = i + 1; screenTypeId = value.MasterId; PHCRAFFTAlcoholScreening.Controls.Add(new LiteralControl("<div class='row'>")); PHCRAFFTAlcoholScreening.Controls.Add(new LiteralControl("<div class='col-md-10 text-left'>")); PHCRAFFTAlcoholScreening.Controls.Add(new LiteralControl("<label>" + i + ". " + value.ItemDisplayName + "" + "</label>")); PHCRAFFTAlcoholScreening.Controls.Add(new LiteralControl("</div>")); PHCRAFFTAlcoholScreening.Controls.Add(new LiteralControl("<div class='col-md-2 text-right'>")); rbList = new RadioButtonList(); rbList.ID = "crafft" + value.ItemId.ToString(); rbList.RepeatColumns = 4; rbList.ClientIDMode = System.Web.UI.ClientIDMode.Static; rbList.CssClass = "crafftrbList"; lookUp.populateRBL(rbList, "GeneralYesNo"); PHCRAFFTAlcoholScreening.Controls.Add(rbList); PHCRAFFTAlcoholScreening.Controls.Add(new LiteralControl("</div>")); PHCRAFFTAlcoholScreening.Controls.Add(new LiteralControl("</div>")); var lastItem = questionsList.Last(); if (!value.Equals(lastItem)) { PHCRAFFTAlcoholScreening.Controls.Add(new LiteralControl("<hr />")); } } //var SHL = new SocialHistoryLogic(); //LookupLogic lookUp = new LookupLogic(); //List<LookupItemView> questionsList = lookUp.getQuestions("CRAFFTScoreQuestions"); //foreach (var value in questionsList) //{ // screenTypeId = value.MasterId; // PHCRAFFTAlcoholScreening.Controls.Add(new LiteralControl("<div class='col-md-4 text-left'>")); // PHCRAFFTAlcoholScreening.Controls.Add(new LiteralControl("<label><span class='text-primary'>" + value.ItemDisplayName + "" + "</span></label>")); // PHCRAFFTAlcoholScreening.Controls.Add(new LiteralControl("<div class=''>")); // RadioButtonList rbList = new RadioButtonList(); // rbList.ID = "crafft" + value.ItemId.ToString(); // rbList.RepeatColumns = 1; // rbList.ClientIDMode = System.Web.UI.ClientIDMode.Static; // rbList.CssClass = "crafftrbList"; // lookUp.populateRBL(rbList, value.ItemName); // PHCRAFFTAlcoholScreening.Controls.Add(rbList); // PHCRAFFTAlcoholScreening.Controls.Add(new LiteralControl("</div>")); // PHCRAFFTAlcoholScreening.Controls.Add(new LiteralControl("</div>")); //} PHCRAFFTScore.Controls.Add(new LiteralControl("<div class='input-group'>")); PHCRAFFTScore.Controls.Add(new LiteralControl("<span class='input-group-addon'>CRAFFT SCORE</span>")); tbCrafftScore = new TextBox(); tbCrafftScore.CssClass = "form-control input-sm"; tbCrafftScore.ClientIDMode = System.Web.UI.ClientIDMode.Static; tbCrafftScore.ID = "crafft" + LookupLogic.GetLookupItemId("AlcoholScore"); tbCrafftScore.Enabled = false; PHCRAFFTScore.Controls.Add(tbCrafftScore); PHCRAFFTScore.Controls.Add(new LiteralControl("<span class='input-group-addon'>/ 6</span>")); PHCRAFFTScore.Controls.Add(new LiteralControl("</div>")); //RISK PHCrafftRisk.Controls.Add(new LiteralControl("<div class='input-group'>")); PHCrafftRisk.Controls.Add(new LiteralControl("<span class='input-group-addon'>Risk</span>")); tbCrafftRisk = new TextBox(); tbCrafftRisk.CssClass = "form-control input-sm"; tbCrafftRisk.ClientIDMode = System.Web.UI.ClientIDMode.Static; tbCrafftRisk.ID = "crafft" + LookupLogic.GetLookupItemId("AlcoholRiskLevel"); tbCrafftRisk.Enabled = false; PHCrafftRisk.Controls.Add(tbCrafftRisk); PHCrafftRisk.Controls.Add(new LiteralControl("</div>")); }
public void populateMMAS() { LookupLogic lookUp = new LookupLogic(); List <LookupItemView> questionsList = lookUp.getQuestions("Session4MMAS4"); LookupItemView[] questionArray = questionsList.ToArray(); int i = 0; foreach (var value in questionArray) { i = i + 1; screenTypeId = value.MasterId; string radioItems = ""; List <LookupItemView> itemList = lookUp.getQuestions(value.ItemName); if (itemList.Any()) { foreach (var items in itemList) { radioItems = items.ItemName; } } PHMMAS4.Controls.Add(new LiteralControl("<div class='row' id='" + value.ItemName + "'>")); if (radioItems != "") { PHMMAS4.Controls.Add(new LiteralControl("<div class='col-md-8 text-left'>")); PHMMAS4.Controls.Add(new LiteralControl("<label>" + i + ". " + value.ItemDisplayName + "" + "</label>")); PHMMAS4.Controls.Add(new LiteralControl("</div>")); PHMMAS4.Controls.Add(new LiteralControl("<div class='col-md-4 text-right'>")); rbList = new RadioButtonList(); rbList.ID = "session4rb" + value.ItemId.ToString(); rbList.RepeatColumns = 2; rbList.ClientIDMode = System.Web.UI.ClientIDMode.Static; rbList.CssClass = "mmrbList"; lookUp.populateRBL(rbList, radioItems); PHMMAS4.Controls.Add(rbList); PHMMAS4.Controls.Add(new LiteralControl("</div>")); } PHMMAS4.Controls.Add(new LiteralControl("</div>")); var lastItem = questionsList.Last(); if (!value.Equals(lastItem)) { PHMMAS4.Controls.Add(new LiteralControl("<hr />")); } } List <LookupItemView> mmas8QuestionsList = lookUp.getQuestions("Session4MMAS8"); LookupItemView[] mmas8QuestionArray = mmas8QuestionsList.ToArray(); foreach (var value in mmas8QuestionArray) { i = i + 1; var lastItem = mmas8QuestionArray.Last(); screenTypeId = value.MasterId; string radioItems = ""; List <LookupItemView> itemList = lookUp.getQuestions(value.ItemName); if (itemList.Any()) { foreach (var items in itemList) { radioItems = items.ItemName; } } PHMMAS8.Controls.Add(new LiteralControl("<div class='row' id='" + value.ItemName + "'>")); if (radioItems != "") { if (value.Equals(lastItem)) { PHMMAS8.Controls.Add(new LiteralControl("<div class='col-md-4 text-left'>")); PHMMAS8.Controls.Add(new LiteralControl("<label>" + i + ". " + value.ItemDisplayName + "" + "</label>")); PHMMAS8.Controls.Add(new LiteralControl("</div>")); PHMMAS8.Controls.Add(new LiteralControl("<div class='col-md-8 text-right'>")); rbList = new RadioButtonList(); rbList.ID = "session4rb" + value.ItemId.ToString(); rbList.RepeatColumns = 5; rbList.ClientIDMode = System.Web.UI.ClientIDMode.Static; rbList.CssClass = "mmrbList"; lookUp.populateRBL(rbList, radioItems); PHMMAS8.Controls.Add(rbList); PHMMAS8.Controls.Add(new LiteralControl("</div>")); } else { PHMMAS8.Controls.Add(new LiteralControl("<div class='col-md-8 text-left'>")); PHMMAS8.Controls.Add(new LiteralControl("<label>" + i + ". " + value.ItemDisplayName + "" + "</label>")); PHMMAS8.Controls.Add(new LiteralControl("</div>")); PHMMAS8.Controls.Add(new LiteralControl("<div class='col-md-4 text-right'>")); rbList = new RadioButtonList(); rbList.ID = "session4rb" + value.ItemId.ToString(); rbList.RepeatColumns = 2; rbList.ClientIDMode = System.Web.UI.ClientIDMode.Static; rbList.CssClass = "mmrbList"; lookUp.populateRBL(rbList, radioItems); PHMMAS8.Controls.Add(rbList); PHMMAS8.Controls.Add(new LiteralControl("</div>")); } } PHMMAS8.Controls.Add(new LiteralControl("</div>")); if (!value.Equals(lastItem)) { PHMMAS8.Controls.Add(new LiteralControl("<hr />")); } } }
protected void populateNotesRadio(string screeningType, PlaceHolder typePlaceHolder) { LookupLogic lookUp = new LookupLogic(); //LookupItemView[] questionsList = lookUp.getQuestions("SessionReferralsNetworks").ToArray(); //int i = 0; //if (Cache[screeningType] == null) //{ // List<LookupItemView> questionsCacheList = lookUp.getQuestions(screeningType); // HttpRuntime.Cache.Insert(screeningType, questionsCacheList, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.Zero); //} int i = 0; //List<LookupItemView> questionsList = (List<LookupItemView>)Cache[screeningType]; List <LookupItemView> questionsList = lookUp.getQuestions(screeningType); foreach (var value in questionsList) { i = i + 1; screenTypeId = value.MasterId; string radioItems = ""; int notesValue = 0; List <LookupItemView> itemList = lookUp.getQuestions(value.ItemName); if (itemList.Any()) { foreach (var items in itemList) { if (items.ItemName == "Notes") { notesValue = items.ItemId; } else { radioItems = items.ItemName; } } } typePlaceHolder.Controls.Add(new LiteralControl("<div class='row' id='" + value.ItemName + "'>")); //Rdaios start if (radioItems != "") { typePlaceHolder.Controls.Add(new LiteralControl("<div class='col-md-8 text-left'>")); typePlaceHolder.Controls.Add(new LiteralControl("<label>" + i + ". " + value.ItemDisplayName + "" + "</label>")); typePlaceHolder.Controls.Add(new LiteralControl("</div>")); typePlaceHolder.Controls.Add(new LiteralControl("<div class='col-md-4 text-right'>")); rbList = new RadioButtonList(); rbList.ID = "session1rb" + value.ItemId.ToString(); rbList.RepeatColumns = 2; rbList.ClientIDMode = System.Web.UI.ClientIDMode.Static; rbList.CssClass = "mmrbList"; lookUp.populateRBL(rbList, radioItems); typePlaceHolder.Controls.Add(rbList); typePlaceHolder.Controls.Add(new LiteralControl("</div>")); } else { typePlaceHolder.Controls.Add(new LiteralControl("<div class='col-md-12 text-left'>")); typePlaceHolder.Controls.Add(new LiteralControl("<label>" + i + ". " + value.ItemDisplayName + "" + radioItems + "</label>")); typePlaceHolder.Controls.Add(new LiteralControl("</div>")); } //Radios end //notes start if (notesValue > 0) { if (radioItems == "GeneralYesNo") { typePlaceHolder.Controls.Add(new LiteralControl("<div class='col-md-12 text-left session1notessection'>")); } else { typePlaceHolder.Controls.Add(new LiteralControl("<div class='col-md-12 text-left'>")); } NotesId = value.ItemId; notesTb = new TextBox(); notesTb.TextMode = TextBoxMode.MultiLine; notesTb.CssClass = "form-control input-sm"; notesTb.ClientIDMode = System.Web.UI.ClientIDMode.Static; notesTb.ID = "session1tb" + value.ItemId.ToString(); notesTb.Rows = 3; typePlaceHolder.Controls.Add(notesTb); typePlaceHolder.Controls.Add(new LiteralControl("</div>")); } //notes end typePlaceHolder.Controls.Add(new LiteralControl("</div>")); var lastItem = questionsList.Last(); if (!value.Equals(lastItem)) { typePlaceHolder.Controls.Add(new LiteralControl("<hr />")); } } }
protected void Page_Load(object sender, EventArgs e) { age = Convert.ToInt32(HttpContext.Current.Session["Age"]); PatientId = Convert.ToInt32(HttpContext.Current.Session["PatientPK"]); PatientMasterVisitId = Convert.ToInt32(Request.QueryString["visitId"] != null ? Request.QueryString["visitId"] : HttpContext.Current.Session["PatientMasterVisitId"]); if (Request.QueryString["visitId"] != null) { Session["ExistingRecordPatientMasterVisitID"] = Request.QueryString["visitId"].ToString(); PatientEncounterExists = Convert.ToInt32(Request.QueryString["visitId"].ToString()); } else { Session["ExistingRecordPatientMasterVisitID"] = "0"; ///////Check if visit is scheduled if (PEL.isVisitScheduled(HttpContext.Current.Session["PatientPK"].ToString()) > 0) { vsYes.Checked = true; } else { vsNo.Checked = true; } } // Get Gender PatientLookup genderId = _patientLookupmanager.GetGenderID(Convert.ToInt32(HttpContext.Current.Session["PatientPK"])); if (genderId != null) { genderID = genderId.Sex; } LookupItemView genderType = _lookupItemManager.GetPatientGender(genderID); gender = genderType.ItemName; ILookupManager mgr = (ILookupManager)ObjectFactory.CreateInstance("BusinessProcess.CCC.BLookupManager, BusinessProcess.CCC"); List <LookupItemView> statuses = mgr.GetLookItemByGroup("AppointmentStatus"); if (statuses != null && statuses.Count > 0) { status.Items.Add(new ListItem("select", "0")); foreach (var k in statuses) { status.Items.Add(new ListItem(k.ItemDisplayName, k.ItemId.ToString())); } status.SelectedIndex = 1; status.Enabled = false; } List <LookupItemView> whoStage = mgr.GetLookItemByGroup("WHOStage"); if (whoStage != null && whoStage.Count > 0) { WHOStage.Items.Add(new ListItem("select", "")); foreach (var k in whoStage) { WHOStage.Items.Add(new ListItem(k.ItemName, k.ItemId.ToString())); } } List <LookupItemView> areas = mgr.GetLookItemByGroup("ServiceArea"); if (areas != null && areas.Count > 0) { ServiceArea.Items.Add(new ListItem("select", "0")); foreach (var k in areas) { ServiceArea.Items.Add(new ListItem(k.ItemDisplayName, k.ItemId.ToString())); } } List <LookupItemView> reasons = mgr.GetLookItemByGroup("AppointmentReason"); if (reasons != null && reasons.Count > 0) { Reason.Items.Add(new ListItem("select", "0")); foreach (var k in reasons) { Reason.Items.Add(new ListItem(k.ItemDisplayName, k.ItemId.ToString())); } } List <LookupItemView> care = mgr.GetLookItemByGroup("DifferentiatedCare"); if (care != null && care.Count > 0) { DifferentiatedCare.Items.Add(new ListItem("select", "0")); foreach (var k in care) { DifferentiatedCare.Items.Add(new ListItem(k.ItemDisplayName, k.ItemId.ToString())); } } if (!IsPostBack) { LookupLogic lookUp = new LookupLogic(); lookUp.populateDDL(tbscreeningstatus, "TBStatus"); lookUp.populateDDL(nutritionscreeningstatus, "NutritionStatus"); lookUp.populateDDL(AdverseEventAction, "AdverseEventsActions"); lookUp.populateDDL(ddlAdverseEventSeverity, "ADRSeverity"); lookUp.populateDDL(ddlVisitBy, "VisitBy"); lookUp.populateDDL(ChronicIllnessName, "ChronicIllness"); lookUp.populateDDL(ddlVaccine, "Vaccinations"); lookUp.populateDDL(ddlVaccineStage, "VaccinationStages"); lookUp.populateDDL(ddlExaminationType, "ReviewOfSystems"); //lookUp.populateDDL(ddlExamination, "PhysicalExamination"); lookUp.populateCBL(cblGeneralExamination, "GeneralExamination"); lookUp.populateCBL(cblPHDP, "PHDP"); lookUp.populateDDL(arvAdherance, "ARVAdherence"); lookUp.populateDDL(ctxAdherance, "CTXAdherence"); lookUp.populateDDL(ddlAllergySeverity, "ADRSeverity"); lookUp.populateDDL(stabilityStatus, "StabilityAssessment"); //lookUp.populateDDL(WHOStage, "WHOStage"); var patientVitals = new PatientVitalsManager(); PatientVital patientTriage = patientVitals.GetByPatientId(Convert.ToInt32(Session["PatientPK"].ToString())); if (patientTriage != null) { Weight = patientTriage.Weight.ToString(); txtWeight.Text = Weight; txtHeight.Text = patientTriage.Height.ToString(); txtBMI.Text = patientTriage.BMI.ToString(); txtBMIZ.Text = patientTriage.BMIZ.ToString(); } //if (Convert.ToInt32(Session["PatientMasterVisitId"]) > 0) loadPatientEncounter(); } }
public static string Update(string firstName, string middleName, string lastName, int personSex, int personId, int patientId, int?ptn_pk, DateTime dateOfBirth, bool DOB_Precision, string nationalId, int facilityId, int entryPointId, DateTime enrollmentDate, string cccNumber, PatientLookup patient, string godsNumber, int matStatusId, string village, int wardId, int subCountyId, int countyId, string nearestLandMark, string postalAdress, string phoneNumber, DateTime?deathDate, List <NEXTOFKIN> nextofkin, int userId) { try { //todo: fetch assigning facility from the message string assigning_Facility = ""; PersonManager personManager = new PersonManager(); var patientManager = new PatientManager(); var patientEntryPointManager = new PatientEntryPointManager(); var patientIdentifierManager = new PatientIdentifierManager(); var patientEnrollmentManager = new PatientEnrollmentManager(); var personIdentifierManager = new PersonIdentifierManager(); PersonMaritalStatusManager personMaritalStatusManager = new PersonMaritalStatusManager(); PersonLocationManager locationManager = new PersonLocationManager(); PersonContactManager contactManager = new PersonContactManager(); var personContactLookUp = new PersonContactLookUpManager(); var patientTreatmentlookupManager = new PatientTreatmentSupporterLookupManager(); var treatmentSupporterManager = new PatientTreatmentSupporterManager(); personManager.UpdatePerson(firstName, middleName, lastName, personSex, userId, patient.PersonId, dateOfBirth, DOB_Precision); if (!string.IsNullOrWhiteSpace(godsNumber)) { IdentifierManager identifierManager = new IdentifierManager(); Identifier identifier = identifierManager.GetIdentifierByCode("GODS_NUMBER"); var personIdentifiers = personIdentifierManager.GetPersonIdentifiers(personId, identifier.Id); if (personIdentifiers.Count == 0) { personIdentifierManager.AddPersonIdentifier(personId, identifier.Id, godsNumber, userId, assigning_Facility); } } if (matStatusId > 0) { var currentMaritalStatus = personMaritalStatusManager.GetCurrentPatientMaritalStatus(personId); if (currentMaritalStatus != null) { currentMaritalStatus.MaritalStatusId = matStatusId; personMaritalStatusManager.UpdatePatientMaritalStatus(currentMaritalStatus); } else { personMaritalStatusManager.AddPatientMaritalStatus(personId, matStatusId, userId); } } if (wardId > 0 && subCountyId > 0 && countyId > 0) { var currentLocation = locationManager.GetCurrentPersonLocation(personId); if (currentLocation.Count > 0) { currentLocation[0].DeleteFlag = true; locationManager.UpdatePersonLocation(currentLocation[0]); } locationManager.AddPersonLocation(personId, countyId, subCountyId, wardId, village, "", "", nearestLandMark, nearestLandMark, userId); } if (postalAdress != null || phoneNumber != null) { var contacts = personContactLookUp.GetPersonContactByPersonId(personId); if (contacts.Count > 0) { PersonContact perContact = new PersonContact(); perContact.Id = contacts[0].Id; perContact.PersonId = contacts[0].PersonId; perContact.PhysicalAddress = (postalAdress); perContact.MobileNumber = (phoneNumber); perContact.AlternativeNumber = ""; perContact.EmailAddress = ""; contactManager.UpdatePatientContact(perContact); } else { contactManager.AddPersonContact(personId, postalAdress, phoneNumber, "", "", userId); } } if (nextofkin.Count > 0) { foreach (var kin in nextofkin) { if (kin.CONTACT_ROLE == "T") { //Get Gender string gender = kin.SEX == "F" ? "Female" : "Male"; //IQCare Sex LookupLogic lookupLogic = new LookupLogic(); int sex = lookupLogic.GetItemIdByGroupAndItemName("Gender", gender)[0].ItemId; var listPatientTreatmentSupporter = patientTreatmentlookupManager.GetAllPatientTreatmentSupporter(personId); if (listPatientTreatmentSupporter.Count > 0) { personManager.UpdatePerson(kin.NOK_NAME.FIRST_NAME, kin.NOK_NAME.MIDDLE_NAME, kin.NOK_NAME.LAST_NAME, sex, userId, listPatientTreatmentSupporter[0].SupporterId); if (listPatientTreatmentSupporter[0].SupporterId > 0) { var treatmentSupporter = patientTreatmentlookupManager.GetAllPatientTreatmentSupporter(personId); if (treatmentSupporter.Count > 0) { PatientTreatmentSupporter supporter = new PatientTreatmentSupporter() { Id = treatmentSupporter[0].Id, PersonId = personId, SupporterId = listPatientTreatmentSupporter[0].SupporterId, MobileContact = kin.PHONE_NUMBER, CreatedBy = treatmentSupporter[0].CreatedBy, DeleteFlag = treatmentSupporter[0].DeleteFlag }; treatmentSupporterManager.UpdatePatientTreatmentSupporter(supporter); } } } else { int supporterId = personManager.AddPersonTreatmentSupporterUiLogic(kin.NOK_NAME.FIRST_NAME, kin.NOK_NAME.MIDDLE_NAME, kin.NOK_NAME.LAST_NAME, sex, userId); if (supporterId > 0) { treatmentSupporterManager.AddPatientTreatmentSupporter(personId, supporterId, kin.PHONE_NUMBER, userId); } } } } } List <PatientLookup> patientLookups = new List <PatientLookup>(); patientLookups.Add(patient); var entity = patientLookups.ConvertAll(x => new PatientEntity { Id = x.Id, Active = x.Active, DateOfBirth = x.DateOfBirth, ptn_pk = x.ptn_pk, PatientType = x.PatientType, PatientIndex = x.PatientIndex, NationalId = x.NationalId, FacilityId = x.FacilityId }); var patientAuditData = AuditDataUtility.AuditDataUtility.Serializer(entity); PatientEntity updatePatient = new PatientEntity(); updatePatient.ptn_pk = ptn_pk; updatePatient.DateOfBirth = dateOfBirth; updatePatient.DobPrecision = DOB_Precision; updatePatient.NationalId = nationalId; updatePatient.FacilityId = facilityId; updatePatient.AuditData = patientAuditData; patientManager.UpdatePatient(updatePatient, patientId); List <PatientEntryPoint> entryPoints = patientEntryPointManager.GetPatientEntryPoints(patient.Id, 1); if (entryPoints.Count > 0) { string entryPointAuditData = null; entryPointAuditData = AuditDataUtility.AuditDataUtility.Serializer(entryPoints); entryPoints[0].EntryPointId = entryPointId; entryPoints[0].AuditData = entryPointAuditData; patientEntryPointManager.UpdatePatientEntryPoint(entryPoints[0]); } else { patientEntryPointManager.addPatientEntryPoint(patientId, entryPointId, userId); } var identifiersByPatientId = patientIdentifierManager.GetPatientEntityIdentifiersByPatientId(patientId, 1); if (identifiersByPatientId.Count > 0) { foreach (var entityIdentifier in identifiersByPatientId) { int enrollmentId = entityIdentifier.PatientEnrollmentId; PatientEntityEnrollment entityEnrollment = patientEnrollmentManager.GetPatientEntityEnrollment(enrollmentId); List <PatientEntityEnrollment> listEnrollment = new List <PatientEntityEnrollment>(); listEnrollment.Add(entityEnrollment); var enrollmentAuditData = AuditDataUtility.AuditDataUtility.Serializer(listEnrollment); entityEnrollment.EnrollmentDate = enrollmentDate; entityEnrollment.AuditData = enrollmentAuditData; patientEnrollmentManager.updatePatientEnrollment(entityEnrollment); var entityIdentifierAuditData = AuditDataUtility.AuditDataUtility.Serializer(identifiersByPatientId); entityIdentifier.IdentifierValue = cccNumber; entityIdentifier.AuditData = entityIdentifierAuditData; patientIdentifierManager.UpdatePatientIdentifier(entityIdentifier, facilityId, false); if (deathDate.HasValue) { PatientMasterVisitManager masterVisitManager = new PatientMasterVisitManager(); PatientCareEndingManager careEndingManager = new PatientCareEndingManager(); LookupLogic lookupLogic = new LookupLogic(); int itemId = lookupLogic.GetItemIdByGroupAndItemName("CareEnded", "Death")[0].ItemId; int patientMasterVisitId = masterVisitManager.GetLastPatientVisit(patientId).Id; careEndingManager.AddPatientCareEndingDeath(patientId, patientMasterVisitId, enrollmentId, itemId, deathDate.Value, deathDate.Value, ""); PatientEntityEnrollment entityEnrollmentCareEnded = patientEnrollmentManager.GetPatientEntityEnrollment(enrollmentId); entityEnrollmentCareEnded.CareEnded = true; patientEnrollmentManager.updatePatientEnrollment(entityEnrollmentCareEnded); } } } else { var assigningFacility = cccNumber.Substring(0, 5); int patientEnrollmentId = patientEnrollmentManager.addPatientEnrollment(patientId, enrollmentDate.ToString(), userId); int patientEntryPointId = patientEntryPointManager.addPatientEntryPoint(patientId, entryPointId, userId); int patientIdentifierId = patientIdentifierManager.addPatientIdentifier(patientId, patientEnrollmentId, 1, cccNumber, facilityId, assigningFacility, false); if (deathDate.HasValue) { PatientMasterVisitManager masterVisitManager = new PatientMasterVisitManager(); PatientCareEndingManager careEndingManager = new PatientCareEndingManager(); LookupLogic lookupLogic = new LookupLogic(); int itemId = lookupLogic.GetItemIdByGroupAndItemName("CareEnded", "Death")[0].ItemId; int patientMasterVisitId = masterVisitManager.GetLastPatientVisit(patientId).Id; careEndingManager.AddPatientCareEndingDeath(patientId, patientMasterVisitId, patientEnrollmentId, itemId, deathDate.Value, deathDate.Value, ""); PatientEntityEnrollment entityEnrollmentCareEnded = patientEnrollmentManager.GetPatientEntityEnrollment(patientEnrollmentId); entityEnrollmentCareEnded.CareEnded = true; patientEnrollmentManager.updatePatientEnrollment(entityEnrollmentCareEnded); } } return("Successfully updated patient"); } catch (Exception e) { throw new Exception(e.Message); } }
public async Task <Result <AddEnrollPatientResponse> > Handle(EnrollPatientCommand request, CancellationToken cancellationToken) { try { String sDate = DateTime.Now.ToString(); DateTime datevalue = Convert.ToDateTime(sDate); var patientMasterVisitManager = new PatientMasterVisitManager(); var patientEnrollmentManager = new PatientEnrollmentManager(); var personLookUp = new PersonLookUpManager(); var patientEntryPointManager = new PatientEntryPointManager(); var patientLookUpManager = new PatientLookupManager(); var patientManager = new PatientManager(); var patientIdentifierManager = new PatientIdentifierManager(); var personContactLookUpManager = new PersonContactLookupManager(); var lookupLogic = new LookupLogic(); var personContacts = new List <PersonContactLookUp>(); var identifiersObjects = request.identifiersList; List <PatientLookup> isPersonEnrolled = await Task.Run(() => patientLookUpManager.GetPatientByPersonId(request.PersonId)); string dobPrecision = String.IsNullOrEmpty(request.DobPrecision) ? "false" : "true"; foreach (var item in identifiersObjects) { var identifiers = await Task.Run(() => patientIdentifierManager.CheckIfIdentifierNumberIsUsed(item.Value, Convert.ToInt32(item.Key))); if (identifiers.Count > 0) { foreach (var items in identifiers) { if (isPersonEnrolled.Count > 0) { if (items.PatientId == isPersonEnrolled[0].Id) { } else { var exception = new Exception("No: " + item.Value + " already exists"); msg = exception.Message.ToString(); throw exception; } } else { var exception = new Exception("No: " + item.Value + " already exists"); msg = exception.Message.ToString(); throw exception; } } } } if (isPersonEnrolled.Count == 0) { List <PatientRegistrationLookup> patientsByPersonId = await Task.Run(() => patientManager.GetPatientIdByPersonId(request.PersonId)); var patientIndex = datevalue.Year.ToString() + '-' + request.PersonId; PatientEntity patient = new PatientEntity(); if (patientsByPersonId.Count > 0) { patient.FacilityId = request.facilityId; patient.DateOfBirth = DateTime.Parse(request.DateofBirth); patient.NationalId = request.nationalId; patient.ptn_pk = patientsByPersonId[0].ptn_pk > 0 ? patientsByPersonId[0].ptn_pk : 0; patientManager.UpdatePatient(patient, patientsByPersonId[0].Id); patientId = patientsByPersonId[0].Id; } else { patient.PersonId = request.PersonId; patient.ptn_pk = 0; patient.FacilityId = request.facilityId; patient.PatientType = request.PatientType; patient.PatientIndex = patientIndex; patient.DateOfBirth = DateTime.Parse(request.DateofBirth); patient.NationalId = (request.nationalId); patient.Active = true; patient.CreatedBy = request.UserId; patient.CreateDate = DateTime.Now; patient.DeleteFlag = false; patient.DobPrecision = bool.Parse(dobPrecision); patientId = patientManager.AddPatient(patient); } if (patientId > 0) { var visitTypes = await Task.Run(() => lookupLogic.GetItemIdByGroupAndItemName("VisitType", "Enrollment")); var visitType = 0; if (visitTypes.Count > 0) { visitType = visitTypes[0].ItemId; } //Add enrollment visit patientMasterVisitId = patientMasterVisitManager.AddPatientMasterVisit(patientId, request.UserId, visitType); //Enroll Patient to service patientEnrollmentId = patientEnrollmentManager.addPatientEnrollment(patientId, request.EnrollmentDate, request.UserId); //Add enrollment entry point patientEntryPointId = patientEntryPointManager.addPatientEntryPoint(patientId, request.EntryPointId, request.UserId); if (patientMasterVisitId > 0) { foreach (var item in identifiersObjects) { patientIdentifierId = await Task.Run(() => patientIdentifierManager.addPatientIdentifier(patientId, patientEnrollmentId, Convert.ToInt32(item.Key), item.Value, request.facilityId)); //Get User Details to be used in BLUE CARD } msg = "Succefully enrolled patient."; } } { var patientLookManager = new PatientLookupManager(); List <PatientLookup> patientlook = await Task.Run(() => patientLookManager.GetPatientByPersonId(request.PersonId)); if (patientlook.Count > 0) { int ptn_pk = patientlook[0].Id; List <PatientEntity> listPatient = new List <PatientEntity>(); var entity = await Task.Run(() => patientlook.ConvertAll(x => new PatientEntity { Id = x.Id, Active = x.Active, DateOfBirth = x.DateOfBirth, ptn_pk = x.ptn_pk, PatientType = x.PatientType, PatientIndex = x.PatientIndex, NationalId = x.NationalId, FacilityId = x.FacilityId })); var patientAuditData = await Task.Run(() => AuditDataUtility.Serializer(entity)); PatientEntity updatePatient = new PatientEntity(); updatePatient.ptn_pk = patientlook[0].ptn_pk; updatePatient.DateOfBirth = patientlook[0].DateOfBirth; updatePatient.NationalId = request.nationalId; updatePatient.FacilityId = patientlook[0].FacilityId; //listPatient.Add(entity); updatePatient.AuditData = patientAuditData; //var enrollmentAuditData = AuditDataUtility.Serializer(patient); await Task.Run(() => patientManager.UpdatePatient(updatePatient, patientlook[0].Id)); int patientMasterVisitId = await Task.Run(() => patientMasterVisitManager.PatientMasterVisitCheckin(patientlook[0].Id, request.UserId)); int PatientMasterVisitId = patientMasterVisitId; List <PatientEntryPoint> entryPoints = await Task.Run(() => patientEntryPointManager.GetPatientEntryPoints(patientlook[0].Id)); if (entryPoints.Count > 0) { var entryPointAuditData = await Task.Run(() => AuditDataUtility.Serializer(entryPoints)); entryPoints[0].EntryPointId = request.EntryPointId; entryPoints[0].AuditData = entryPointAuditData; await Task.Run(() => patientEntryPointManager.UpdatePatientEntryPoint(entryPoints[0])); } foreach (var item in identifiersObjects) { var identifiersByPatientId = await Task.Run(() => patientIdentifierManager .GetPatientEntityIdentifiersByPatientId(patientlook[0].Id, Convert.ToInt32(item.Key))); if (identifiersByPatientId.Count > 0) { foreach (var entityIdentifier in identifiersByPatientId) { int enrollmentId = entityIdentifier.PatientEnrollmentId; PatientEntityEnrollment entityEnrollment = await Task.Run(() => patientEnrollmentManager.GetPatientEntityEnrollment(enrollmentId)); List <PatientEntityEnrollment> listEnrollment = new List <PatientEntityEnrollment>(); await Task.Run(() => listEnrollment.Add(entityEnrollment)); var enrollmentAuditData = await Task.Run(() => AuditDataUtility.Serializer(listEnrollment)); entityEnrollment.EnrollmentDate = DateTime.Parse(request.EnrollmentDate); entityEnrollment.AuditData = enrollmentAuditData; patientEnrollmentManager.updatePatientEnrollment(entityEnrollment); var entityIdentifierAuditData = AuditDataUtility.Serializer(identifiersByPatientId); entityIdentifier.IdentifierValue = item.Value; entityIdentifier.AuditData = entityIdentifierAuditData; patientIdentifierManager.UpdatePatientIdentifier(entityIdentifier, request.facilityId); } } else { patientEnrollmentId = await Task.Run(() => patientEnrollmentManager.addPatientEnrollment(patientlook[0].Id, request.EnrollmentDate, request.UserId)); patientEntryPointId = await Task.Run(() => patientEntryPointManager.addPatientEntryPoint(patientlook[0].Id, request.EntryPointId, request.UserId)); patientIdentifierId = await Task.Run(() => patientIdentifierManager.addPatientIdentifier(patientlook[0].Id, patientEnrollmentId, Convert.ToInt32(item.Key), item.Value, request.facilityId)); } } } } } return(Result <AddEnrollPatientResponse> .Valid(new AddEnrollPatientResponse() { IdentifierValue = Convert.ToString(patientEnrollmentId), IdentifierId = patientIdentifierId, PatientId = patientId, Message = msg } )); } catch (Exception ex) { return(Result <AddEnrollPatientResponse> .Invalid(ex.Message)); } }
public string GetLookupPendingLabsList() { string jsonObject = LookupLogic.GetLookupPendingLabsListJson(patientId); return(jsonObject); }
public static string Update(PatientAppointSchedulingDTO appointmentScheduling) { try { //todo: fetch assigning facility from the message string assigning_Facility = ""; PatientAppointmentManager manager = new PatientAppointmentManager(); PatientLookupManager patientLookup = new PatientLookupManager(); LookupLogic lookupLogic = new LookupLogic(); PatientMasterVisitManager masterVisitManager = new PatientMasterVisitManager(); var personIdentifierManager = new PersonIdentifierManager(); var interopPlacerValuesManager = new InteropPlacerValuesManager(); PatientLookup patient = new PatientLookup(); string cccNumber = String.Empty; string appointmentReason = String.Empty; string appointmentStatus = String.Empty; string appointmentType = String.Empty; int interopUserId = InteropUser.UserId; foreach (var item in appointmentScheduling.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID) { if (item.IDENTIFIER_TYPE == "CCC_NUMBER" && item.ASSIGNING_AUTHORITY == "CCC") { cccNumber = item.ID; } } string godsNumber = appointmentScheduling.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID.ID; if (!String.IsNullOrWhiteSpace(cccNumber)) { patient = patientLookup.GetPatientByCccNumber(cccNumber); if (patient != null) { if (!string.IsNullOrWhiteSpace(godsNumber)) { IdentifierManager identifierManager = new IdentifierManager(); Identifier identifier = identifierManager.GetIdentifierByCode("GODS_NUMBER"); var personIdentifiers = personIdentifierManager.GetPersonIdentifiers(patient.PersonId, identifier.Id); if (personIdentifiers.Count == 0) { personIdentifierManager.AddPersonIdentifier(patient.PersonId, identifier.Id, godsNumber, interopUserId, assigning_Facility); } } int patientMasterVisitId = masterVisitManager.GetLastPatientVisit(patient.Id).Id; int serviceAreaId = lookupLogic.GetItemIdByGroupAndItemName("ServiceArea", "MoH 257 GREENCARD")[0].ItemId; foreach (var appointment in appointmentScheduling.APPOINTMENT_INFORMATION) { switch (appointment.APPOINTMENT_REASON) { case "PHARMACY_REFILL": appointmentReason = "Pharmacy Refill"; break; case "TREATMENT_PREP": appointmentReason = "Treatment Preparation"; break; case "LAB_TEST": appointmentReason = "Lab Tests"; break; case "FOLLOWUP": appointmentReason = "Follow Up"; break; default: appointmentReason = "Follow Up"; break; } switch (appointment.APPOINTMENT_STATUS) { case "HONORED": appointmentStatus = "Met"; break; case "MISSED": appointmentStatus = "Missed"; break; case "PENDING": appointmentStatus = "Pending"; break; case "CANCELLED": appointmentStatus = "CareEnded"; break; default: appointmentStatus = "Pending"; break; } switch (appointment.APPOINTMENT_TYPE) { case "CLINICAL": appointmentType = "Standard Care"; break; case "PHARMACY": appointmentType = "Express Care"; break; case "INVESTIGATION": appointmentType = "Express Care"; break; default: appointmentType = "Standard Care"; break; } var reasons = lookupLogic.GetItemIdByGroupAndItemName("AppointmentReason", appointmentReason); int reasonId = 0; if (reasons == null || reasons.Count > 0) { throw new Exception($"No matching reasons in the databases {appointmentReason}"); } reasonId = reasons[0].ItemId; int statusId = 0; var status = lookupLogic.GetItemIdByGroupAndItemName("AppointmentStatus", appointmentStatus); if (status == null || status.Count > 0) { throw new Exception($"No matching appointmentstatus in the databases {appointmentStatus}"); } statusId = status[0].ItemId; int differentiatedCareId = 0; var diffCare = lookupLogic.GetItemIdByGroupAndItemName("DifferentiatedCare", appointmentType); if (diffCare == null || diffCare.Count > 0) { throw new Exception($"No matching differentiated care option in the databases {appointmentType}"); } differentiatedCareId = diffCare[0].ItemId; InteropPlacerTypeManager interopPlacerTypeManager = new InteropPlacerTypeManager(); int interopPlacerTypeId = interopPlacerTypeManager.GetInteropPlacerTypeByName(appointment.PLACER_APPOINTMENT_NUMBER.ENTITY).Id; var interopPlacerValues = interopPlacerValuesManager.GetInteropPlacerValues(interopPlacerTypeId, 3, Convert.ToInt32(appointment.PLACER_APPOINTMENT_NUMBER.NUMBER)); if (interopPlacerValues != null) { PatientAppointment patientAppointment = manager.GetPatientAppointment(interopPlacerValues.EntityId); patientAppointment.AppointmentDate = DateTime.ParseExact(appointment.APPOINTMENT_DATE, "yyyyMMdd", null); patientAppointment.Description = appointment.APPOINTMENT_NOTE; patientAppointment.DifferentiatedCareId = differentiatedCareId; patientAppointment.ReasonId = reasonId; patientAppointment.ServiceAreaId = serviceAreaId; patientAppointment.StatusId = statusId; manager.UpdatePatientAppointments(patientAppointment); } else { PatientAppointment patientAppointment = new PatientAppointment() { PatientId = patient.Id, PatientMasterVisitId = patientMasterVisitId, AppointmentDate = DateTime.ParseExact(appointment.APPOINTMENT_DATE, "yyyyMMdd", null), Description = appointment.APPOINTMENT_NOTE, DifferentiatedCareId = differentiatedCareId, ReasonId = reasonId, ServiceAreaId = serviceAreaId, StatusId = statusId, CreatedBy = interopUserId, CreateDate = DateTime.Now }; int appointmentId = manager.AddPatientAppointments(patientAppointment); InteropPlacerValues placerValues = new InteropPlacerValues() { IdentifierType = 3, EntityId = appointmentId, InteropPlacerTypeId = interopPlacerTypeId, PlacerValue = Convert.ToInt32(appointment.PLACER_APPOINTMENT_NUMBER.NUMBER) }; interopPlacerValuesManager.AddInteropPlacerValue(placerValues); } } } } } catch (Exception e) { throw new Exception(e.Message); } return(String.Empty); }
protected void populateQuestions() { LookupLogic lookUp = new LookupLogic(); List <LookupItemView> questionsList = lookUp.getQuestions("ClinicalEvaluation");// ("PsychosocialCircumstances"); int i = 0; foreach (var value in questionsList) { i = i + 1; evaluationId = value.MasterId; string radioItems = ""; int notesValue = 0; List <LookupItemView> itemList = lookUp.getQuestions(value.ItemName); if (itemList.Any()) { foreach (var items in itemList) { if (items.ItemName == "Notes") { notesValue = items.ItemId; } else { radioItems = items.ItemName; } } } QuestionsPlaceholder.Controls.Add(new LiteralControl("<div class='row' id='" + value.ItemName + "'>")); //Rdaios start if (radioItems != "") { QuestionsPlaceholder.Controls.Add(new LiteralControl("<div class='col-md-12 text-left'>")); QuestionsPlaceholder.Controls.Add(new LiteralControl("<label>" + i + ". " + value.ItemDisplayName + "" + "</label>")); QuestionsPlaceholder.Controls.Add(new LiteralControl("</div>")); QuestionsPlaceholder.Controls.Add(new LiteralControl("<div class='col-md-12 text-right'>")); rbList = new RadioButtonList(); rbList.ID = value.ItemId.ToString(); rbList.RepeatColumns = 4; rbList.ClientIDMode = System.Web.UI.ClientIDMode.Static; rbList.CssClass = "rbList"; lookUp.populateRBL(rbList, radioItems); QuestionsPlaceholder.Controls.Add(rbList); QuestionsPlaceholder.Controls.Add(new LiteralControl("</div>")); } else { QuestionsPlaceholder.Controls.Add(new LiteralControl("<div class='col-md-12 text-left'>")); QuestionsPlaceholder.Controls.Add(new LiteralControl("<label>" + i + ". " + value.ItemDisplayName + "" + radioItems + "</label>")); QuestionsPlaceholder.Controls.Add(new LiteralControl("</div>")); } //Radios end //notes start if (notesValue > 0) { if (radioItems == "GeneralYesNo") { QuestionsPlaceholder.Controls.Add(new LiteralControl("<div class='col-md-12 text-left notessection'>")); } else { QuestionsPlaceholder.Controls.Add(new LiteralControl("<div class='col-md-12 text-left'>")); } NotesId = value.ItemId; notesTb = new TextBox(); notesTb.TextMode = TextBoxMode.MultiLine; notesTb.CssClass = "form-control input-sm"; notesTb.ClientIDMode = System.Web.UI.ClientIDMode.Static; notesTb.ID = "notes" + value.ItemId.ToString(); notesTb.Rows = 3; QuestionsPlaceholder.Controls.Add(notesTb); QuestionsPlaceholder.Controls.Add(new LiteralControl("</div>")); } //notes end QuestionsPlaceholder.Controls.Add(new LiteralControl("</div>")); var lastItem = questionsList.Last(); if (!value.Equals(lastItem)) { QuestionsPlaceholder.Controls.Add(new LiteralControl("<hr />")); } } }
protected void Page_Load(object sender, EventArgs e) { var patientTransfer = new PatientTransferInmanager(); var patientDiagnosis = new PatientHivDiagnosisManager(); var patientEntryPoint = new PatientEntryPointManager(); PatientLookupManager patientLookup = new PatientLookupManager(); Session["TechnicalAreaId"] = 203; var objTransfer = patientTransfer.GetPatientTransferIns(PatientId); var objDiagnosis = patientDiagnosis.GetPatientHivDiagnosisList(PatientId); var objEntryPoint = patientEntryPoint.GetPatientEntryPoints(Convert.ToInt32(Session["PatientPK"])); var patientDetailSummary = patientLookup.GetPatientDetailSummary(Convert.ToInt32(Session["PatientPK"])); if (patientDetailSummary != null) { this.ptnPk = patientDetailSummary.ptn_pk.HasValue ? patientDetailSummary.ptn_pk.Value : 0; } if (objTransfer.Count > 0) { foreach (var item in objTransfer) { lblTransferinDate.Text = "<h6>" + item.TransferInDate.ToString("dd-MMM-yyyy") + "</h6>"; lblTreatmentStartDate.Text = "<h6>" + item.TreatmentStartDate.ToString("dd-MMM-yyyy") + "</h6>";; //lblTIRegimen.Text = "<h6>" + LookupLogic.GetLookupNameById(Convert.ToInt32(item.CurrentTreatment)).ToString() + "</h6>"; ; lblFacilityFrom.Text = "<h6>" + item.FacilityFrom.ToString() + "</h6>";; } } else { lblTransferinDate.Text = "N/A"; lblTreatmentStartDate.Text = "N/A"; lblTIRegimen.Text = "N/A"; lblFacilityFrom.Text = "N/A"; } if (objDiagnosis.Count > 0) { foreach (var item in objDiagnosis) { if (item.HivDiagnosisDate.HasValue) { DateTime HivDiagnosisDate = item.HivDiagnosisDate.Value; lblDateOfHivDiagnosis.Text = HivDiagnosisDate.ToString("dd-MMM-yyyy"); } else { lblDateOfHivDiagnosis.Text = "Not Taken"; } if (item.EnrollmentDate.HasValue) { lblDateOfEnrollment.Text = item.EnrollmentDate.Value.ToString("dd-MMM-yyyy"); } else { lblDateOfEnrollment.Text = "Not Taken"; } // lblWhoStage.Text = LookupLogic.GetLookupNameById(item.EnrollmentWhoStage).ToString(); //lblDateOfHivDiagnosis.Text = item.HivDiagnosisDate.ToString("dd-MMM-yyyy"); lblARTInitiationDate.Text = Convert.ToString(item.ArtInitiationDate); } } else { lblDateOfHivDiagnosis.Text = "Not Taken"; lblDateOfEnrollment.Text = "Not Taken"; lblWhoStage.Text = "Not Taken"; lblARTInitiationDate.Text = "Not Taken"; } if (objEntryPoint.Count > 0) { foreach (var item in objEntryPoint) { lblEntryPoint.Text = LookupLogic.GetLookupNameById(item.EntryPointId); } } else { lblEntryPoint.Text = "missing"; } if (!IsPostBack) { ILookupManager mgr = (ILookupManager) ObjectFactory.CreateInstance("BusinessProcess.CCC.BLookupManager, BusinessProcess.CCC"); List <LookupItemView> keyPopulationList = mgr.GetLookItemByGroup("PopulationType"); if (keyPopulationList != null && keyPopulationList.Count > 0) { bioPatientPopulation.Items.Add(new ListItem("select", "0")); foreach (var item in keyPopulationList) { bioPatientPopulation.Items.Add(new ListItem(item.ItemDisplayName, item.ItemId.ToString())); } } List <LookupCounty> ct = mgr.GetLookupCounties(); if (ct != null && ct.Count > 0) { smrCounty.Items.Add(new ListItem("select", "0")); foreach (var item in ct) { smrCounty.Items.Add(new ListItem(item.CountyName, item.CountyId.ToString())); } } List <LookupItemView> vw = mgr.GetGenderOptions(); if (vw != null && vw.Count > 0) { trtGender.Items.Add(new ListItem("select", "0")); foreach (var item in vw) { trtGender.Items.Add(new ListItem(item.ItemName, item.ItemId.ToString())); } } if (vw != null && vw.Count > 0) { Gender.Items.Add(new ListItem("select", "0")); foreach (var item in vw) { Gender.Items.Add(new ListItem(item.ItemName, item.ItemId.ToString())); } } List <LookupItemView> keyPopList = mgr.GetLookItemByGroup("KeyPopulation"); if (keyPopList != null && keyPopList.Count > 0) { var patientLookUp = new PatientLookupManager(); int sex = patientLookUp.GetPatientSexId(Convert.ToInt32(Session["PatientPK"])); string gender = LookupLogic.GetLookupNameById(sex); //bioPatientKeyPopulation.Items.Add(new ListItem("select", "0")); foreach (var item in keyPopList) { if (gender == "Female" && item.DisplayName == "Men having Sex with Men") { } else if (gender == "Male" && item.DisplayName == "Female Sex Worker") { } else { bioPatientKeyPopulation.Items.Add(new ListItem(item.ItemDisplayName, item.ItemId.ToString())); } } } // Get Patient Regimen Map: IPatientTreatmentTrackerManager patientTreatmentTrackerManager = (IPatientTreatmentTrackerManager)ObjectFactory.CreateInstance("BusinessProcess.CCC.Lookup.BPatientTreatmentTrackerManager, BusinessProcess.CCC"); var curentRegimen = patientTreatmentTrackerManager.GetCurrentPatientRegimen(PatientId); if (curentRegimen != null) { if (curentRegimen.RegimenId > 0) { //lblCurrentRegimen.Text = "<span class='label label-success'>" + curentRegimen.Regimen.ToString() + " started on : " + Convert.ToDateTime(curentRegimen.DispensedByDate).ToString("dd-MMM-yyyy") + "</span>"; lblCurrentRegimen.Text = "<span class='label label-success'>" + curentRegimen.Regimen.ToString() + " | " + Convert.ToDateTime(curentRegimen.DispensedByDate).ToString("dd-MMM-yyyy") + "</span>"; } else { lblCurrentRegimen.Text = "<span class='label label-danger'>Patient NOT on ARVs</span>"; } } else { lblCurrentRegimen.Text = "<span class='label label-danger'>Patient NOT on ARVs</span>"; } //Get Adherance Status ILookupManager patientAdheLookupManager = (ILookupManager)ObjectFactory.CreateInstance("BusinessProcess.CCC.BLookupManager, BusinessProcess.CCC"); var adherenceList = LookupLogic.GetLookItemByGroup("ARVAdherence"); int adherenceType = 34; if (adherenceList.Count > 0) { adherenceType = adherenceList[0].MasterId; } var adheranceStatus = patientAdheLookupManager.GetPatientAdherence(PatientId, adherenceType); if (adheranceStatus != null) { string adheranceString = LookupLogic.GetLookupNameById(adheranceStatus.Score); switch (adheranceString) { case "Poor": lblAdheranceStatus.Text = "<span class='label label-danger'> Poor [Offer Adherence Interventions]</span>"; break; case "Good": lblAdheranceStatus.Text = "<span class='label label-success'> Good </span>"; break; case "Fair": lblAdheranceStatus.Text = "<span class='label label-warning'> Fair [Consider Adherence Intervetion]</span>"; break; } } else { lblAdheranceStatus.Text = "<span class='label label-danger'>Adherance Assessment Not Done</span>"; } /*update Treatment Initiation for New Patients */ if (PatientType == "New") { var patientTreatmentManager = new PatientTreatmentTrackerManager(); var ptnTreatmentInitiation = patientTreatmentManager.GetCurrentPatientRegimen(PatientId); var ptnTreatmentBaseline = patientTreatmentManager.GetPatientbaselineRegimenLookup(PatientId); if (ptnTreatmentInitiation != null) { if (ptnTreatmentBaseline != null) { if (ptnTreatmentBaseline.DispensedByDate.HasValue) { DateTime DispensedByDate = (DateTime)ptnTreatmentBaseline.DispensedByDate; lblFirstline.Text = DispensedByDate.ToString("dd-MMM-yyyy"); lblcohort.Text = DispensedByDate.ToString("MMM") + "-" + DispensedByDate.Year; } lblRegimenName.Text = ptnTreatmentInitiation.Regimen.ToString(); //lblCurrentRegimen.Text = "<span class='label label-success'>" + ptnTreatmentBaseline.Regimen.ToString() + "</span>"; lblARTInitiationDate.Text = ptnTreatmentBaseline.CreateDate.ToString("dd-MMM-yyyy"); // lblRegimenName.Text = ptnTreatmentInitiation.Regimen.ToString(); //lblCurrentRegimen.Text = "<span class='label label-success'>" + ptnTreatmentBaseline.Regimen.ToString() + "</span>"; //lblARTInitiationDate.Text = ptnTreatmentBaseline.CreateDate.ToString("dd-MMM-yyyy"); } } else { lblDateOfARTInitiation.Text = "<span class='label'> Not dispensed</span>"; lblcohort.Text = "<span class='label label-danger'>N/A</span>"; // lblCurrentRegimen.Text = "<span class='label label-danger'>PATIENT NOT ON ARVs</span>"; } } // viral Load Alerts //PatientLabTracker vltestId = _lookupData.GetPatientLabTestId(PatientId); //check patient has vl lab PatientLabTracker lastVL = _lookupData.GetPatientLastVL(PatientId); //if (lastVL != null) //{ // labTestId = lastVL.LabTestId; //} if (lastVL != null) { //var labOrder = _lookupData.GetPatientCurrentviralLoadInfo(PatientId); //get vl lab details for patient //if (lastVL != null) //{ //foreach (var item in _lookupData.GetPatientVlById(labOrder.Id)) //{ // vlValue = item.ResultValues; //} // vlValue = Convert.ToDecimal(_lookupData.GetPatientVL(LabOrder.Id)); if (PatientType == "New") { //lblbaselineVL.Text = Convert.ToString(vlValue); DateTime x = Convert.ToDateTime(lastVL.SampleDate); lblBlDate.Text = x.ToString("dd-MMM-yyyy"); } else { lblbaselineVL.Text = "<span class='label label-danger'>Not Taken</span>"; lblBlDate.Text = "<span class='label label-danger'>N/A</span>"; } if (lastVL.Results != null) { switch (lastVL.Results.ToLower().Trim()) { case "pending": var pendingDueDate = Convert.ToDateTime(lastVL.SampleDate); DateTime sampleDate = Convert.ToDateTime(lastVL.SampleDate.ToString()); if ((DateTime.Today.Subtract(sampleDate).Days > 30)) { lblVL.Text = "<span class='label label-danger' > Overdue | Ordered On: " + ((DateTime)lastVL.SampleDate).ToString("dd-MMM-yyyy") + "</span>"; lblvlDueDate.Text = "<span class='label label-success'> " + pendingDueDate.AddMonths(6).ToString("dd-MMM-yyy") + " </span>"; } else if ((lastVL.Results == "Pending") && (DateTime.Today.Subtract(sampleDate).Days < 30)) { lblVL.Text = "<span class='label label-warning'> Pending | Ordered On: " + ((DateTime)lastVL.SampleDate).ToString("dd-MMM-yyyy") + "</span>"; lblvlDueDate.Text = "<span class='label label-success'> " + pendingDueDate.AddMonths(6).ToString("dd-MMM-yyy") + " </span>"; } else { lblVL.Text = "<span class='label label-warning'>" + lastVL.Results + "| Date: " + ((DateTime)lastVL.SampleDate).ToString("dd-MMM-yyyy") + "</span>"; lblbaselineVL.Text = "<span class='label label-warning'>" + lastVL.Results + "| Date: " + ((DateTime)lastVL.SampleDate).ToString("dd-MMM-yyyy") + "</span>"; } break; case "complete": case "completed": if (lastVL.ResultValues >= 1000) { lblVL.Text = "<span class='label label-danger'>" + lastVL.ResultValues + " copies/ml (" + Convert.ToDateTime(lastVL.SampleDate).ToString("dd-MMM-yyyy") + ")</span>"; lblvlDueDate.Text = "<span class='label label-success' > " + ((DateTime)lastVL.SampleDate).AddMonths(3).ToString("dd-MMM-yyyy") + "</span>"; } else if (lastVL.ResultValues <= 50) { lblVL.Text = "<span class='label label-success'> Undetectable VL (" + Convert.ToDateTime(lastVL.SampleDate).ToString("dd-MMM-yyyy") + ")</span>"; lblvlDueDate.Text = "<span class='label label-success' > " + ((DateTime)lastVL.SampleDate).AddMonths(12).ToString("dd-MMM-yyyy") + "</span>"; } else { lblVL.Text = "<span class='label label-success' > Complete | Results : " + lastVL.ResultValues + " copies/ml</span>"; lblvlDueDate.Text = "<span class='label label-success' > " + ((DateTime)lastVL.SampleDate).AddMonths(12).ToString("dd-MMM-yyyy") + "</span>"; } break; default: var patientEnrollment = new PatientEnrollmentManager(); var enrolDate = patientEnrollment.GetPatientEnrollmentDate(PatientId); var treatmentTrackerManager = new PatientTreatmentTrackerManager(); var patientBaseline = treatmentTrackerManager.GetPatientbaselineRegimenLookup(PatientId); DateTime today = DateTime.Today; // TimeSpan difference = today.Date - enrolDate.Date; TimeSpan difference = today.Date - patientBaseline.CreateDate; int days = (int)difference.TotalDays; if (patientBaseline != null) { if (patientBaseline.RegimenId > 0) { if (days < 180) { lblvlDueDate.Text = "<span class='label label-success'>" + patientBaseline.CreateDate.AddMonths(6).ToString("dd-MMM-yyyy") + "</span>"; lblVL.Text = "<span class='label label-success fa fa-exclamation'><strong> VL Not Requested </strong></span>"; } else { lblVL.Text = "<span class='label label-danger'> Not Done </span>"; lblvlDueDate.Text = "<span class='label label-danger'><strong> Overdue Since | " + patientBaseline.CreateDate.AddMonths(6).ToString("dd-MMM-yyyy") + " </strong></span>"; } } else { lblVL.Text = "<span class='label label-danger'> Not Available </span>"; lblvlDueDate.Text = "<span class='label label-danger'><strong> unknown </strong></span>"; } } else { lblVL.Text = "<span class='label label-danger'> Not Done </span>"; lblvlDueDate.Text = "<span class='label label-danger'><strong> Overdue Since | " + patientBaseline.CreateDate.AddMonths(6).ToString("dd-MMM-yyyy") + " </strong></span>"; } break; } } else { //var patientEnrollment = new PatientEnrollmentManager(); //var enrolDate = patientEnrollment.GetPatientEnrollmentDate(PatientId); var treatmentTrackerManager = new PatientTreatmentTrackerManager(); var patientBaseline = treatmentTrackerManager.GetPatientbaselineRegimenLookup(PatientId); if (patientBaseline != null) { if (patientBaseline.RegimenId > 0) { DateTime today = DateTime.Today; //TimeSpan difference = today.Date - enrolDate.Date; TimeSpan difference = today.Date - patientBaseline.CreateDate; int days = (int)difference.TotalDays; if (days < 180) { lblvlDueDate.Text = "<span class='label label-success'>" + patientBaseline.CreateDate.AddMonths(6).ToString("dd-MMM-yyyy") + "</span>"; lblVL.Text = "<span class='label label-success fa fa-exclamation'><strong> VL Not Requested </strong></span>"; } else { lblVL.Text = "<span class='label label-danger'> Not Done </span>"; lblvlDueDate.Text = "<span class='label label-danger'><strong> Overdue Since | " + patientBaseline.CreateDate.AddMonths(6).ToString("dd-MMM-yyyy") + " </strong></span>"; } } else { lblVL.Text = "<span class='label label-danger'> Not Done</span>"; lblvlDueDate.Text = "<span class='label label-danger'><strong> unknown </strong></span>"; } } else { lblVL.Text = "<span class='label label-danger'> Not Done </span>"; lblvlDueDate.Text = "<span class='label label-danger'><strong> unknown </strong></span>"; } } //} } else { //var patientEnrollment = new PatientEnrollmentManager(); //var enrolDate = patientEnrollment.GetPatientEnrollmentDate(PatientId); var treatmentTrackerManager = new PatientTreatmentTrackerManager(); var patientBaseline = treatmentTrackerManager.GetPatientbaselineRegimenLookup(PatientId); DateTime today = DateTime.Today; //TimeSpan difference = today.Date - enrolDate.Date; TimeSpan difference = today.Date - patientBaseline.CreateDate; if (patientBaseline != null) { if (patientBaseline.RegimenId > 0) { int days = (int)difference.TotalDays; if (days < 180) { lblvlDueDate.Text = "<span class='label label-success'>" + patientBaseline.CreateDate.AddMonths(6).ToString("dd-MMM-yyyy") + "</span>"; lblVL.Text = "<span class='label label-success fa fa-exclamation'><strong> VL Not Requested </strong></span>"; } else { lblVL.Text = "<span class='label label-danger'> Not Available </span>"; lblvlDueDate.Text = "<span class='label label-danger'><strong> Overdue </strong></span>"; } } else { lblVL.Text = "<span class='label label-danger'> Not Done </span>"; lblvlDueDate.Text = "<span class='label label-danger'><strong> unknown </strong></span>"; } } else { lblVL.Text = "<span class='label label-danger'> Not Done </span>"; lblvlDueDate.Text = "<span class='label label-danger'><strong> unknown </strong></span>"; } } PharmacyHistoryDrugSubstitutionsManager pharmacyHistoryDrug = new PharmacyHistoryDrugSubstitutionsManager(); var pharmacyDrugsSubstitutionsSwitchesData = pharmacyHistoryDrug.GetPharmacyDrugsSubstitutionsSwitchesData(this.ptnPk); if (pharmacyDrugsSubstitutionsSwitchesData.Count > 0) { for (int p = 0; p < pharmacyDrugsSubstitutionsSwitchesData.Count; p++) { HtmlTableRow tableRow = new HtmlTableRow(); HtmlTableCell idcell = new HtmlTableCell(); idcell.InnerHtml = (p + 1).ToString(); tableRow.Controls.Add(idcell); HtmlTableCell cell = new HtmlTableCell(); cell.InnerHtml = pharmacyDrugsSubstitutionsSwitchesData[p].regimentype; tableRow.Controls.Add(cell); HtmlTableCell cell2 = new HtmlTableCell(); cell2.InnerHtml = pharmacyDrugsSubstitutionsSwitchesData[p].DispensedByDate.HasValue ? pharmacyDrugsSubstitutionsSwitchesData[p].DispensedByDate.Value.ToString("dd-MMM-yyyy") : "not dispensed"; tableRow.Controls.Add(cell2); tblPharmacyHistory.Rows.Add(tableRow); } } } }
private void getScreeningYesNo(int PatientId) { var PSM = new PatientScreeningManager(); List <PatientScreening> screeningList = PSM.GetPatientScreening(PatientId); if (screeningList != null) { foreach (var value in screeningList) { RadioButtonList rbl = (RadioButtonList)PHSocialHistory.FindControl(value.ScreeningCategoryId.ToString()); if (rbl != null) { rbl.SelectedValue = value.ScreeningValueId.ToString(); } } } var PCN = new PatientClinicalNotesLogic(); List <PatientClinicalNotes> socialNotesList = PCN.getPatientClinicalNotesById(PatientId, Convert.ToInt32(LookupLogic.GetLookupItemId("SocialNotes"))); if (socialNotesList.Any()) { foreach (var value in socialNotesList) { TextBox ntb = (TextBox)PHSocialHistoryNotes.FindControl(value.NotesCategoryId.ToString()); if (ntb != null) { ntb.Text = value.ClinicalNotes; } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { age = Convert.ToInt32(HttpContext.Current.Session["Age"]); LookupLogic lookUp = new LookupLogic(); lookUp.populateRBL(BVCoInfection, "GeneralYesNo"); /**BVCoInfection.CssClass = "BVCoInfectioninput";**/ foreach (ListItem item in BVCoInfection.Items) { item.Attributes.Add("class", "BVCoInfectioninput"); } ILookupManager mgr = (ILookupManager)ObjectFactory.CreateInstance("BusinessProcess.CCC.BLookupManager, BusinessProcess.CCC"); IPatientVitals patientVitals = (IPatientVitals)ObjectFactory.CreateInstance("BusinessProcess.CCC.BPatientVitals, BusinessProcess.CCC"); List <LookupCounty> ct = mgr.GetLookupCounties(); if (ct != null && ct.Count > 0) { TransferFromCounty.Items.Add(new ListItem("select", "0")); foreach (var item in ct) { TransferFromCounty.Items.Add(new ListItem(item.CountyName, item.CountyId.ToString())); } } //who stage WHOStage List <LookupItemView> ms = mgr.GetLookItemByGroup("WHOStage"); if (ms != null && ms.Count > 0) { WHOStageAtEnrollment.Items.Add(new ListItem("select", "0")); bwhoStage.Items.Add(new ListItem("select", "0")); foreach (var k in ms) { WHOStageAtEnrollment.Items.Add(new ListItem(k.ItemName, k.ItemId.ToString())); bwhoStage.Items.Add(new ListItem(k.ItemName, k.ItemId.ToString())); } } //History of ART Use List <LookupItemView> lk = mgr.GetLookItemByGroup("HistoryARTUse"); if (lk != null && lk.Count > 0) { RegimenPurpose.Items.Add(new ListItem("select", "0")); foreach (var k in lk) { RegimenPurpose.Items.Add(new ListItem(k.DisplayName, k.ItemId.ToString())); } } /* Regimen classification*/ List <LookupItemView> lookupItem; if (Age > 15) { lookupItem = mgr.GetLookItemByGroup("RegimenClassificationAdult"); } else { lookupItem = mgr.GetLookItemByGroup("RegimenClassificationPaeds"); } //List<LookupItemView> lookupItem = mgr.GetLookItemByGroup("RegimenClassification"); if (lookupItem != null && lookupItem.Count > 0) { regimenCategory.Items.Add(new ListItem("select", "0")); InitiationRegimen.Items.Add(new ListItem("select", "0")); foreach (var k in lookupItem) { regimenCategory.Items.Add(new ListItem(k.ItemDisplayName, k.ItemId.ToString())); InitiationRegimen.Items.Add(new ListItem(k.ItemDisplayName, k.ItemId.ToString())); } } /* Get patientBaseline Vitals */ var ptnVitals = patientVitals.GetPatientVitalsBaseline(PatientId); if (ptnVitals != null) { BaselineWeight.Text = Convert.ToString(ptnVitals.Weight); BaselineMUAC.Text = Convert.ToString(ptnVitals.Muac); BaselineHeight.Text = Convert.ToString(ptnVitals.Height); BaselineBMI.Text = Convert.ToString(ptnVitals.BMI); } var facilityListManager = new FacilityListManager(); var result = facilityListManager.GetFacilitiesList(); if (result != null && result.Count > 0) { TransferFromFacility.Items.Add(new ListItem("", "")); foreach (var facility in result) { TransferFromFacility.Items.Add(new ListItem(facility.Name, facility.MFLCode)); } } ARTUseHistory.Items.Add(new ListItem("select", "")); ARTUseHistory.Items.Add(new ListItem("Yes", "1")); ARTUseHistory.Items.Add(new ListItem("No", "0")); } }
public ArrayList LoadImmunization() { LookupLogic ll = new LookupLogic(); ArrayList rows = new ArrayList(); var vaccineLogic = new PatientVaccinationManager(); List <PatientVaccination> list = new List <PatientVaccination>(); list = vaccineLogic.GetPatientVaccinations(Convert.ToInt32(Session["PatientPK"])); if (list.Count > 0) { foreach (var items in list) { string PeriodId; string Vaccine; string VaccineDate; //List<LookupItemView> lookupList = ll.GetItemIdByGroupAndItemName("ImmunizationPeriod", LookupLogic.GetLookupNameById(Convert.ToInt32(items.PeriodId)).ToString()); if (!String.IsNullOrEmpty(items.PeriodId.ToString())) { PeriodId = LookupLogic.GetLookupNameById(Convert.ToInt32(items.PeriodId)).ToString(); } else { PeriodId = ""; } if (!String.IsNullOrEmpty(items.Vaccine.ToString())) { if (items.Vaccine > 0) { Vaccine = LookupLogic.GetLookupNameById(Convert.ToInt32(items.Vaccine)).ToString(); } else { Vaccine = ""; } } else { Vaccine = ""; } if (items.VaccineDate != null) { VaccineDate = Convert.ToDateTime(items.VaccineDate).ToString("dd-MMM-yyyy").ToString(); } else { VaccineDate = ""; } if (items.VaccineStage != null) { VaccineStage = items.VaccineStage.ToString(); } //if (lookupList.Any()) //{ string[] i = new string[6] { items.Id.ToString(), PeriodId, Vaccine, VaccineStage, VaccineDate, //LookupLogic.GetLookupNameById(Convert.ToInt32(items.PeriodId)).ToString() //, LookupLogic.GetLookupNameById(Convert.ToInt32(items.Vaccine)).ToString() //, Convert.ToDateTime(items.VaccineDate).ToString("dd-MMM-yyyy"), "<button type='button' class='btnDelete btn btn-danger fa fa-minus-circle btn-fill' > Remove</button>" }; rows.Add(i); //} } } return(rows); }
public string ExtruderPendingLabsList() { string jsonObject = LookupLogic.LookupExtruderPendingLabs(patientId); return(jsonObject); }
public ArrayList LoadMilestones() { ArrayList rows = new ArrayList(); var MilestonesLogic = new NeonatalHistoryLogic(); List <PatientMilestone> list = new List <PatientMilestone>(); list = MilestonesLogic.getPatientMilestones(Convert.ToInt32(Session["PatientPK"])); if (list.Any()) { foreach (var items in list) { string milestoneAssessed = LookupLogic.GetLookupNameById(items.TypeAssessedId).ToString(); if (items.DateAssessed.HasValue) { DateAssessed = items.DateAssessed.Value.ToString("dd-MMM-yyyy"); } else { DateAssessed = ""; } if (items.AchievedId != null) { if (items.AchievedId == true) { valueAchieved = "Yes"; } else if (items.AchievedId == false) { valueAchieved = "No"; } else { valueAchieved = ""; } } else { valueAchieved = ""; } string[] i = new string[7] { items.Id.ToString(), LookupLogic.GetLookupNameById(items.TypeAssessedId).ToString(), DateAssessed, valueAchieved, LookupLogic.GetLookupNameById(items.StatusId).ToString(), items.Comment.ToString(), "<button type='button' class='btnDelete btn btn-danger fa fa-minus-circle btn-fill' > Remove</button>" }; rows.Add(i); } } return(rows); }
public string GetPendingvlTests() { string jsonObject = LookupLogic.GetPendingvlTestsJson(patientId); return(jsonObject); }
public string Process(DtoDrugDispensed drugDispensed) { try { LookupLogic facilityLookup = new LookupLogic(); string receivingFacilityMflCode = drugDispensed.MESSAGE_HEADER.RECEIVING_FACILITY; string sendingFacilityMflCode = drugDispensed.MESSAGE_HEADER.SENDING_FACILITY; int interopUserId = InteropUser.UserId; if (string.IsNullOrEmpty(receivingFacilityMflCode)) { Msg = "The receiving facility mfl code is missing"; return(Msg); } if (string.IsNullOrEmpty(sendingFacilityMflCode)) { Msg = "The sending facility mfl code is missing"; return(Msg); } if (receivingFacilityMflCode != sendingFacilityMflCode) { return(Msg = "The sending facility is not the same as the receiving facility!"); } //check if facility exists LookupFacility recieverfacility = facilityLookup.GetFacility(receivingFacilityMflCode); // LookupFacility senderfacility = facilityLookup.GetFacility(sendingFacilityMflCode); if (recieverfacility == null) { return(Msg = $"The facility {receivingFacilityMflCode} does not exist"); } //if (senderfacility == null) //{ // return Msg = $"The facility {sendingFacilityMflCode} does not exist"; //} //if (recieverfacility.FacilityID != senderfacility.FacilityID) //{ // return Msg = "The sending facility is not the same as the receiving facility!"; //} //check if it is the right facility LookupFacility thisFacility = facilityLookup.GetFacility(); if (thisFacility == null) { return(Msg = "Facility not found"); } if (recieverfacility.FacilityID != thisFacility.FacilityID) { return(Msg = $"This message belongs to {receivingFacilityMflCode}, not this facility {thisFacility.MFLCode}!"); } var patientLookup = new PatientLookupManager(); //check patient var identifier = drugDispensed.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID.FirstOrDefault(n => n.IDENTIFIER_TYPE == "CCC_NUMBER"); if (identifier == null) { return(Msg = "Message does not contain a CCC number!"); } var patient = patientLookup.GetPatientByCccNumber(identifier.ID); if (patient == null) { return(Msg = "Patient could not be found!"); } //check pharmacy order exists int orderId = Convert.ToInt32(drugDispensed.COMMON_ORDER_DETAILS.PLACER_ORDER_NUMBER.NUMBER); int drugCount = 0; var pharmacyOrder = _pharmacyOrderManager.GetPharmacyOrder(orderId); if (pharmacyOrder == null) { return(Msg = "Pharmacy Order could not be found!"); } var orderedDrugs = _pharmacyDispenseManager.GetByPharmacyOrderId(pharmacyOrder.ptn_pharmacy_pk); if (orderedDrugs != null) { var newDispensedDrugs = orderedDrugs; foreach (var drug in newDispensedDrugs) { //todo refactor to use drug codes and possibly drug ids to be included in the message var drugFind = _drugManager.GetDrug(drug.Drug_Pk); string drugname = drugFind.DrugName; PHARMACY_DISPENSE messageDispensed = null; messageDispensed = drugDispensed.PHARMACY_DISPENSE.FirstOrDefault(x => drugname.Contains(x.ACTUAL_DRUGS)); if (messageDispensed != null) { drug.DispensedQuantity = messageDispensed.QUANTITY_DISPENSED; //todo get frequencyId //drug.FrequencyID = messageDispensed.FREQUENCY; drug.PatientInstructions = messageDispensed.DISPENSING_NOTES; //todo get strength ids //drug.StrengthID = messageDispensed.STRENGTH; drug.Duration = messageDispensed.DURATION; drug.UpdateDate = DateTime.Now; drug.UserID = interopUserId; //drug.SingleDose = Convert.ToDecimal(Regex.Replace(messageDispensed.DOSAGE, @"^[A-Za-z]+", "")); try { _pharmacyDispenseManager.UpdatePatientPharmacyDispense(drug); drugCount++; } catch (Exception e) { Console.WriteLine(e); return(Msg = "error " + e.Message); } } } } else { PatientPharmacyDispense newlyDispensedDrugs = new PatientPharmacyDispense(); foreach (var drug in drugDispensed.PHARMACY_DISPENSE) { string drugNameQuery = "%" + drug.ACTUAL_DRUGS + "%"; var drugFind = _drugManager.GetDrugsByName(drugNameQuery).FirstOrDefault(); newlyDispensedDrugs.Drug_Pk = drugFind.Drug_pk; newlyDispensedDrugs.DispensedQuantity = drug.QUANTITY_DISPENSED; newlyDispensedDrugs.Duration = drug.DURATION; //todo get frequencyId //newlyDispensedDrugs.FrequencyID = drug.FREQUENCY; //newlyDispensedDrugs.SingleDose = Convert.ToDecimal(Regex.Replace(drug.DOSAGE, @"^[A-Za-z]+", "")); //todo get strength ids //newlyDispensedDrugs.StrengthID = drug.STRENGTH; newlyDispensedDrugs.PatientInstructions = drug.DISPENSING_NOTES; newlyDispensedDrugs.Prophylaxis = 0; } foreach (var order in drugDispensed.PHARMACY_ENCODED_ORDER) { newlyDispensedDrugs.OrderedQuantity = Convert.ToInt32(order.QUANTITY_PRESCRIBED); newlyDispensedDrugs.PatientInstructions = order.PRESCRIPTION_NOTES; try { _pharmacyDispenseManager.AddPatientPharmacyDispense(newlyDispensedDrugs); drugCount++; } catch (Exception e) { Console.WriteLine(e); return(Msg = "error " + e.Message); } } } if (drugCount > 0) { var updatedPharmacyOrder = pharmacyOrder; var orderingPhysician = drugDispensed.COMMON_ORDER_DETAILS.ORDERING_PHYSICIAN; updatedPharmacyOrder.OrderedByName = orderingPhysician.PREFIX + " " + orderingPhysician.FIRST_NAME + " " + orderingPhysician.LAST_NAME; //todo harmonise users updatedPharmacyOrder.DispensedBy = interopUserId; updatedPharmacyOrder.DispensedByDate = drugDispensed.MESSAGE_HEADER.MESSAGE_DATETIME; updatedPharmacyOrder.OrderStatus = 2; if (string.IsNullOrEmpty(updatedPharmacyOrder.PharmacyNotes)) { updatedPharmacyOrder.PharmacyNotes = "Dispensed from IL"; } else { updatedPharmacyOrder.PharmacyNotes += " Dispensed from IL"; } // string str = updatedPharmacyOrder.PharmacyNotes; //if (str != null) //{ // str += " Dispensed from IL"; //} //updatedPharmacyOrder.PharmacyNotes = str; try { _pharmacyOrderManager.UpdatePharmacyOrder(updatedPharmacyOrder); } catch (Exception e) { Console.WriteLine(e); return(Msg = "error " + e.Message); } Msg = "Success"; } else { Msg = "Unable to match the drugs in the dispense message with the drug in the order"; } } catch (Exception e) { Console.WriteLine(e); Msg = "error " + e.Message; } return(Msg); }
public void displayQuestions() { LookupLogic lookUp = new LookupLogic(); List <LookupItemView> lasttwoweeksqlist = lookUp.getQuestions("DepressionScreeningQuestions"); foreach (var value in lasttwoweeksqlist) { screenTypeId = value.MasterId; depressionId = value.MasterId; PlaceHolder2.Controls.Add(new LiteralControl("<div class='col-md-6 text-left'>")); PlaceHolder2.Controls.Add(new LiteralControl("<div class='row'>")); PlaceHolder2.Controls.Add(new LiteralControl("<div class='col-md-8 text-left'>")); PlaceHolder2.Controls.Add(new LiteralControl("<label>" + value.ItemDisplayName + "" + "</label>")); PlaceHolder2.Controls.Add(new LiteralControl("</div>")); PlaceHolder2.Controls.Add(new LiteralControl("<div class='col-md-4 text-right'>")); rbList = new RadioButtonList(); rbList.ID = "uds" + value.ItemId.ToString(); rbList.RepeatColumns = 4; rbList.ClientIDMode = System.Web.UI.ClientIDMode.Static; rbList.CssClass = "rbList"; lookUp.populateRBL(rbList, "GeneralYesNo"); PlaceHolder2.Controls.Add(rbList); PlaceHolder2.Controls.Add(new LiteralControl("</div>")); PlaceHolder2.Controls.Add(new LiteralControl("</div>")); PlaceHolder2.Controls.Add(new LiteralControl("</div>")); } List <LookupItemView> ph9qlist = lookUp.getQuestions("PHQ9Questions"); foreach (var value in ph9qlist) { PlaceHolder1.Controls.Add(new LiteralControl("<div class='row'>")); PlaceHolder1.Controls.Add(new LiteralControl("<div class='col-md-5 text-left'>")); PlaceHolder1.Controls.Add(new LiteralControl("<label>" + value.ItemDisplayName + "" + "</label>")); PlaceHolder1.Controls.Add(new LiteralControl("</div>")); PlaceHolder1.Controls.Add(new LiteralControl("<div class='col-md-7 text-right'>")); rbList = new RadioButtonList(); rbList.ID = "uds" + value.ItemId.ToString(); rbList.RepeatColumns = 4; rbList.ClientIDMode = System.Web.UI.ClientIDMode.Static; rbList.CssClass = "rbList"; lookUp.populateRBL(rbList, "DepressionFrequency"); PlaceHolder1.Controls.Add(rbList); PlaceHolder1.Controls.Add(new LiteralControl("</div>")); PlaceHolder1.Controls.Add(new LiteralControl("</div>")); PlaceHolder1.Controls.Add(new LiteralControl("<hr />")); } //Depression Total PHDepressionTotal.Controls.Add(new LiteralControl("<div class='input-group'>")); PHDepressionTotal.Controls.Add(new LiteralControl("<span class='input-group-addon'>Total</span>")); depressionTotalTb = new TextBox(); depressionTotalTb.CssClass = "form-control input-sm"; depressionTotalTb.ClientIDMode = System.Web.UI.ClientIDMode.Static; depressionTotalTb.ID = "uds" + LookupLogic.GetLookupItemId("DepressionTotal"); depressionTotalTb.Enabled = false; PHDepressionTotal.Controls.Add(depressionTotalTb); PHDepressionTotal.Controls.Add(new LiteralControl("<span class='input-group-addon'>/ 30</span>")); PHDepressionTotal.Controls.Add(new LiteralControl("</div>")); //Depression Severity PHDepressionSeverity.Controls.Add(new LiteralControl("<div class='input-group'>")); PHDepressionSeverity.Controls.Add(new LiteralControl("<span class='input-group-addon'>Depression Severity</span>")); depressionSeverityTb = new TextBox(); depressionSeverityTb.CssClass = "form-control input-sm"; depressionSeverityTb.ClientIDMode = System.Web.UI.ClientIDMode.Static; depressionSeverityTb.ID = "uds" + LookupLogic.GetLookupItemId("DepressionSeverity"); depressionSeverityTb.Enabled = false; PHDepressionSeverity.Controls.Add(depressionSeverityTb); PHDepressionSeverity.Controls.Add(new LiteralControl("</div>")); //Reccommended Management PHRecommendedManagement.Controls.Add(new LiteralControl("<div class='input-group'>")); PHRecommendedManagement.Controls.Add(new LiteralControl("<span class='input-group-addon'>Reccommended Management</span>")); depressionReccommendationTb = new TextBox(); depressionReccommendationTb.CssClass = "form-control input-sm"; depressionReccommendationTb.ClientIDMode = System.Web.UI.ClientIDMode.Static; depressionReccommendationTb.ID = "uds" + LookupLogic.GetLookupItemId("ReccommendedManagement"); depressionReccommendationTb.Enabled = false; PHRecommendedManagement.Controls.Add(depressionReccommendationTb); PHRecommendedManagement.Controls.Add(new LiteralControl("</div>")); }
public static string Add(string firstName, string middleName, string lastName, int sex, int userId, DateTime dob, bool dobPrecision, int facilityId, int patientType, string nationalId, int visitType, DateTime dateOfEnrollment, string cccNumber, int entryPointId, string godsNumber, int matStatusId, string village, int wardId, int subCountyId, int countyId, string nearestLandMark, string postalAdress, string phoneNumber, DateTime?deathDate, List <NEXTOFKIN> nextofkin) { try { PersonManager personManager = new PersonManager(); PatientManager patientManager = new PatientManager(); PatientMasterVisitManager patientMasterVisitManager = new PatientMasterVisitManager(); PatientEnrollmentManager patientEnrollmentManager = new PatientEnrollmentManager(); PatientEntryPointManager patientEntryPointManager = new PatientEntryPointManager(); PersonLookUpManager personLookUp = new PersonLookUpManager(); PersonContactLookUpManager personContactLookUpManager = new PersonContactLookUpManager(); MstPatientLogic mstPatientLogic = new MstPatientLogic(); PatientIdentifierManager patientIdentifierManager = new PatientIdentifierManager(); PersonMaritalStatusManager personMaritalStatusManager = new PersonMaritalStatusManager(); PersonLocationManager locationManager = new PersonLocationManager(); PersonContactManager contactManager = new PersonContactManager(); var treatmentSupporterManager = new PatientTreatmentSupporterManager(); var personIdentifierManager = new PersonIdentifierManager(); //todo: fetch assigning facility from the message string assigning_Facility = ""; var personContacts = new List <PersonContactLookUp>(); int ptn_Pk = 0; //Start Saving int personId = personManager.AddPersonUiLogic(firstName, middleName, lastName, sex, userId, dob, dobPrecision); if (matStatusId > 0) { personMaritalStatusManager.AddPatientMaritalStatus(personId, matStatusId, userId); } if (wardId > 0 && subCountyId > 0 && countyId > 0) { locationManager.AddPersonLocation(personId, countyId, subCountyId, wardId, village, "", "", nearestLandMark, nearestLandMark, userId); } if (postalAdress != null || phoneNumber != null) { contactManager.AddPersonContact(personId, postalAdress, phoneNumber, "", "", userId); } String sDate = DateTime.Now.ToString(); DateTime datevalue = Convert.ToDateTime(sDate); var patientIndex = datevalue.Year.ToString() + '-' + personId; if (!string.IsNullOrWhiteSpace(godsNumber)) { IdentifierManager identifierManager = new IdentifierManager(); Identifier identifier = identifierManager.GetIdentifierByCode("GODS_NUMBER"); var personIdentifiers = personIdentifierManager.GetPersonIdentifiers(personId, identifier.Id); if (personIdentifiers.Count == 0) { personIdentifierManager.AddPersonIdentifier(personId, identifier.Id, godsNumber, userId, assigning_Facility); } } if (nextofkin.Count > 0) { foreach (var kin in nextofkin) { if (kin.CONTACT_ROLE == "T") { //Get Gender string gender = kin.SEX == "F" ? "Female" : "Male"; //IQCare Sex LookupLogic lookupLogic = new LookupLogic(); int sexT = lookupLogic.GetItemIdByGroupAndItemName("Gender", gender)[0].ItemId; int supporterId = personManager.AddPersonTreatmentSupporterUiLogic(kin.NOK_NAME.FIRST_NAME, kin.NOK_NAME.MIDDLE_NAME, kin.NOK_NAME.LAST_NAME, sexT, 1); if (supporterId > 0) { treatmentSupporterManager.AddPatientTreatmentSupporter(personId, supporterId, kin.PHONE_NUMBER, userId); } } } } PatientEntity patientEntity = new PatientEntity(); patientEntity.PersonId = personId; patientEntity.ptn_pk = 0; patientEntity.FacilityId = facilityId; patientEntity.PatientType = patientType; patientEntity.PatientIndex = patientIndex; patientEntity.DateOfBirth = dob; patientEntity.NationalId = (nationalId); patientEntity.Active = true; patientEntity.CreatedBy = 1; patientEntity.CreateDate = DateTime.Now; patientEntity.DeleteFlag = false; patientEntity.DobPrecision = dobPrecision; int patientId = patientManager.AddPatient(patientEntity); //Add enrollment visit int patientMasterVisitId = patientMasterVisitManager.AddPatientMasterVisit(patientId, userId, visitType); //Enroll Patient to service int patientEnrollmentId = patientEnrollmentManager.addPatientEnrollment(patientId, dateOfEnrollment.ToString(), userId); //Add enrollment entry point int patientEntryPointId = patientEntryPointManager.addPatientEntryPoint(patientId, entryPointId, userId); if (deathDate.HasValue) { PatientCareEndingManager careEndingManager = new PatientCareEndingManager(); LookupLogic lookupLogic = new LookupLogic(); int itemId = lookupLogic.GetItemIdByGroupAndItemName("CareEnded", "Death")[0].ItemId; careEndingManager.AddPatientCareEndingDeath(patientId, patientMasterVisitId, patientEnrollmentId, itemId, deathDate.Value, deathDate.Value, ""); PatientEntityEnrollment entityEnrollment = patientEnrollmentManager.GetPatientEntityEnrollment(patientEnrollmentId); entityEnrollment.CareEnded = true; patientEnrollmentManager.updatePatientEnrollment(entityEnrollment); } //Get User Details to be used in BLUE CARD var patient_person_details = personLookUp.GetPersonById(personId); var greencardlookup = new PersonGreenCardLookupManager(); var greencardptnpk = greencardlookup.GetPtnPkByPersonId(personId); if (patient_person_details != null) { var maritalStatus = new PersonMaritalStatusManager().GetCurrentPatientMaritalStatus(personId); personContacts = personContactLookUpManager.GetPersonContactByPersonId(personId); var address = ""; var phone = ""; if (personContacts.Count > 0) { address = personContacts[0].PhysicalAddress; phone = personContacts[0].MobileNumber; } var MaritalStatusId = 0; if (maritalStatus != null) { MaritalStatusId = maritalStatus.MaritalStatusId; } var sexBluecard = 0; var enrollmentBlueCardId = ""; if (LookupLogic.GetLookupNameById(patient_person_details.Sex) == "Male") { sexBluecard = 16; } else if (LookupLogic.GetLookupNameById(patient_person_details.Sex) == "Female") { sexBluecard = 17; } enrollmentBlueCardId = cccNumber; if (greencardptnpk.Count == 0) { ptn_Pk = mstPatientLogic.InsertMstPatient((patient_person_details.FirstName), (patient_person_details.LastName), (patient_person_details.MiddleName), facilityId, enrollmentBlueCardId, entryPointId, dateOfEnrollment, sexBluecard, dob, 1, MaritalStatusId, address, phone, 1, facilityId.ToString(), 203, dateOfEnrollment, DateTime.Now); patientEntity.ptn_pk = ptn_Pk; patientManager.UpdatePatient(patientEntity, patientId); } else { ptn_Pk = greencardptnpk[0].Ptn_Pk; patientEntity.ptn_pk = greencardptnpk[0].Ptn_Pk; patientManager.UpdatePatient(patientEntity, patientId); } } if (patientMasterVisitId > 0) { var assigningFacility = cccNumber.Substring(0, 5); int patientIdentifierId = patientIdentifierManager.addPatientIdentifier(patientId, patientEnrollmentId, 1, cccNumber, facilityId, assigningFacility, false); if (greencardptnpk.Count == 0) { mstPatientLogic.AddOrdVisit(ptn_Pk, facilityId, DateTime.Now, 110, userId, DateTime.Now, 203); } } return("successfully saved"); } catch (Exception e) { throw new Exception(e.Message); } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["visitId"] != null) { Session["ExistingRecordPatientMasterVisitID"] = Request.QueryString["visitId"].ToString(); } else { Session["ExistingRecordPatientMasterVisitID"] = "0"; } if (Session["DosageFrequency"] != null) { DosageFrequency = Convert.ToInt32(Session["DosageFrequency"]); } PatientVitalsManager pvm = new PatientVitalsManager(); PatientVital patientvital = pvm.GetPatientVitals(PatientId); if (patientvital != null) { patientweight = patientvital.Weight.ToString(); } else { patientweight = ""; } if (!IsPostBack) { if (Session["SCMModule"] != null) { PMSCM = Session["SCMModule"].ToString(); } if (Session["SCMSamePointDispense"] != null) { PMSCMSAmePointDispense = Session["SCMSamePointDispense"].ToString(); } LookupLogic lookUp = new LookupLogic(); PatientTreatmentTrackerManager treatmentTrackerManager = new PatientTreatmentTrackerManager(); StartTreatment = treatmentTrackerManager.HasPatientTreatmentStarted(Convert.ToInt32(Session["PatientPK"].ToString())); int patientType = Convert.ToInt32(Session["PatientType"].ToString()); patType = LookupLogic.GetLookupNameById(patientType).ToLower(); if (patType == "transit") { StartTreatment = true; } //lookUp.populateDDL(ddlTreatmentProgram, "TreatmentProgram"); lookUp.populateDDL(ddlPeriodTaken, "PeriodDrugsTaken"); lookUp.populateDDL(ddlTreatmentPlan, "TreatmentPlan"); if (Convert.ToInt32(Session["Age"]) > 14) { lookUp.populateDDL(regimenLine, "RegimenClassificationAdult", "RegimenClassificationPaeds"); } else { lookUp.populateDDL(regimenLine, "RegimenClassificationPaeds"); } lookUp.getPharmacyDrugFrequency(ddlFreq); PatientEncounterLogic pel = new PatientEncounterLogic(); pel.getPharmacyTreatmentProgram(ddlTreatmentProgram); LoadExistingData(); var patientEnrollment = new PatientEnrollmentManager(); var enrolDate = patientEnrollment.GetPatientEnrollmentDate(Convert.ToInt32(Session["PatientPK"])); enrolmentDate = enrolDate.Date.ToString(); } }
protected void populateReferrals() { LookupLogic lookUp = new LookupLogic(); List <LookupItemView> questionsList = lookUp.getQuestions("Session4ReferralsNetworks"); int i = 0; foreach (var value in questionsList) { i = i + 1; screenTypeId = value.MasterId; string radioItems = ""; int notesValue = 0; List <LookupItemView> itemList = lookUp.getQuestions(value.ItemName); LookupItemView[] itemArray = itemList.ToArray(); if (itemArray.Any()) { foreach (var items in itemArray) { if (items.ItemName == "Notes") { notesValue = items.ItemId; } else { radioItems = items.ItemName; } } } PHReferralsandNetworks.Controls.Add(new LiteralControl("<div class='row' id='" + value.ItemName + "'>")); //Rdaios start if (radioItems != "") { PHReferralsandNetworks.Controls.Add(new LiteralControl("<div class='col-md-8 text-left'>")); PHReferralsandNetworks.Controls.Add(new LiteralControl("<label>" + i + ". " + value.ItemDisplayName + "" + "</label>")); PHReferralsandNetworks.Controls.Add(new LiteralControl("</div>")); PHReferralsandNetworks.Controls.Add(new LiteralControl("<div class='col-md-4 text-right'>")); rbList = new RadioButtonList(); rbList.ID = "session4rb" + value.ItemId.ToString(); rbList.RepeatColumns = 2; rbList.ClientIDMode = System.Web.UI.ClientIDMode.Static; rbList.CssClass = "mmrbList"; lookUp.populateRBL(rbList, radioItems); PHReferralsandNetworks.Controls.Add(rbList); PHReferralsandNetworks.Controls.Add(new LiteralControl("</div>")); } else { PHReferralsandNetworks.Controls.Add(new LiteralControl("<div class='col-md-12 text-left'>")); PHReferralsandNetworks.Controls.Add(new LiteralControl("<label>" + i + ". " + value.ItemDisplayName + "" + radioItems + "</label>")); PHReferralsandNetworks.Controls.Add(new LiteralControl("</div>")); } //Radios end //notes start if (notesValue > 0) { if (radioItems == "GeneralYesNo") { PHReferralsandNetworks.Controls.Add(new LiteralControl("<div class='col-md-12 text-left notessection'>")); } else { PHReferralsandNetworks.Controls.Add(new LiteralControl("<div class='col-md-12 text-left'>")); } NotesId = value.ItemId; notesTb = new TextBox(); notesTb.TextMode = TextBoxMode.MultiLine; notesTb.CssClass = "form-control input-sm"; notesTb.ClientIDMode = System.Web.UI.ClientIDMode.Static; notesTb.ID = "session4tb" + value.ItemId.ToString(); notesTb.Rows = 3; PHReferralsandNetworks.Controls.Add(notesTb); PHReferralsandNetworks.Controls.Add(new LiteralControl("</div>")); } //notes end PHReferralsandNetworks.Controls.Add(new LiteralControl("</div>")); var lastItem = questionsList.Last(); if (!value.Equals(lastItem)) { PHReferralsandNetworks.Controls.Add(new LiteralControl("<hr />")); } } }
//[ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string GetPatientSearchx(List <Data> dataPayLoad) { String output = null; int filteredRecords = 0; int totalCount = 0; var jsonData = new List <PatientLookup>(); try { string patientId = ""; string firstName = null; string middleName = null; string lastName = null; string isEnrolled = null; PatientLookupManager patientLookup = new PatientLookupManager(); patientId = dataPayLoad.FirstOrDefault(x => x.name == "patientId").value; firstName = Convert.ToString(dataPayLoad.FirstOrDefault(x => x.name == "firstName").value); middleName = Convert.ToString(dataPayLoad.FirstOrDefault(x => x.name == "middleName").value); lastName = Convert.ToString(dataPayLoad.FirstOrDefault(x => x.name == "lastName").value); isEnrolled = Convert.ToString(dataPayLoad.FirstOrDefault(x => x.name == "isEnrolled").value); //patientId = patientId != "" ? patientId : 0; if (patientId != "" || !string.IsNullOrWhiteSpace(firstName) || !string.IsNullOrWhiteSpace(middleName) || !string.IsNullOrWhiteSpace(lastName)) { jsonData = patientLookup.GetPatientSearchListPayload(patientId, isEnrolled, firstName, middleName, lastName); } else { jsonData = patientLookup.GetPatientSearchListPayload(isEnrolled); } if (jsonData.Count > 0) { var sEcho = Convert.ToInt32(dataPayLoad.FirstOrDefault(x => x.name == "sEcho").value); var displayLength = Convert.ToInt32(dataPayLoad.FirstOrDefault(x => x.name == "iDisplayLength").value); var displayStart = Convert.ToInt32(dataPayLoad.FirstOrDefault(x => x.name == "iDisplayStart").value); // var dateOfBirth = Convert.ToDateTime(dataPayLoad.FirstOrDefault(x => x.name == "DateOfBirth").value); // var gender = Convert.ToInt32(dataPayLoad.FirstOrDefault(x => x.name == "gender").value); var facility = Convert.ToInt32(dataPayLoad.FirstOrDefault(x => x.name == "facility").value); var sortCol = Convert.ToInt32(dataPayLoad.FirstOrDefault(x => x.name == "iSortCol_0").value); string sortDir = dataPayLoad.FirstOrDefault(x => x.name == "sSortDir_0").value; string searchString = dataPayLoad.FirstOrDefault(x => x.name == "sSearch").value; //if (!string.IsNullOrWhiteSpace(patientId)) //{ // //jsonData = jsonData.Where(x => x.EnrollmentNumber == patientId).ToList(); // jsonData = jsonData.Where(x => x.EnrollmentNumber.Contains(patientId)).ToList(); //} //if (!string.IsNullOrWhiteSpace(firstName)) //{ // jsonData = // jsonData.Where(x => x.FirstName.ToLower().Contains(firstName.ToLower())) // .ToList(); //} //if (!string.IsNullOrWhiteSpace(lastName)) //{ // jsonData = // jsonData.Where(x => x.LastName.ToLower().Contains(lastName.ToLower())) // .ToList(); //} //if (!string.IsNullOrWhiteSpace(middleName)) //{ // jsonData = // jsonData.Where(x => x.MiddleName.ToLower().Contains(middleName.ToLower())) // .ToList(); //} /*-- order columns based on payload received -- */ switch (sortCol) { case 0: jsonData = (sortDir == "desc") ? jsonData = jsonData.OrderByDescending(x => x.Id).ToList() : jsonData.OrderBy(x => x.Id).ToList(); break; case 1: jsonData = (sortDir == "desc") ? jsonData = jsonData.OrderByDescending(x => x.EnrollmentNumber).ToList() : jsonData.OrderBy(x => x.EnrollmentNumber).ToList(); break; case 2: jsonData = (sortDir == "desc") ? jsonData = jsonData.OrderByDescending(x => x.FirstName).ToList() : jsonData.OrderBy(x => x.FirstName).ToList(); break; case 3: jsonData = (sortDir == "desc") ? jsonData = jsonData.OrderByDescending(x => x.MiddleName).ToList() : jsonData.OrderBy(x => x.MiddleName).ToList(); break; case 4: jsonData = (sortDir == "desc") ? jsonData.OrderBy(x => x.LastName).ToList() : jsonData = jsonData.OrderByDescending(x => x.LastName).ToList(); break; case 5: jsonData = (sortDir == "desc") ? jsonData.OrderBy(x => x.DateOfBirth).ToList() : jsonData = jsonData.OrderByDescending(x => x.DateOfBirth).ToList(); break; case 6: jsonData = (sortDir == "desc") ? jsonData.OrderBy(x => LookupLogic.GetLookupNameById(x.Sex)).ToList() : jsonData = jsonData.OrderByDescending(x => LookupLogic.GetLookupNameById(x.Sex)).ToList(); break; case 7: jsonData = (sortDir == "desc") ? jsonData = jsonData.OrderByDescending(x => x.EnrollmentDate).ToList() : jsonData.OrderBy(x => x.EnrollmentDate).ToList(); break; case 8: break; } /*-- implement search -- */ if (searchString.Length > 0 || !string.IsNullOrWhiteSpace(searchString)) { jsonData = jsonData.Where(x => x.EnrollmentNumber.Equals(searchString) || x.FirstName .ToLower() .Contains(searchString.ToLower()) || x.MiddleName .ToLower() .Contains(searchString.ToLower()) || x.LastName .ToLower() .Contains(searchString.ToLower()) || LookupLogic.GetLookupNameById(x.Sex) .Contains(searchString.ToLower()) || x.EnrollmentNumber.Contains(searchString.ToString()) || x.MobileNumber.Contains(searchString) ) .ToList(); filteredRecords = jsonData.Count(); } else { filteredRecords = jsonData.Count(); } /*---- Perform paging based on request */ // var skip = (displayLength * displayStart); // var ableToSkip = skip < displayLength; //string patientStatus; totalCount = jsonData.Count(); jsonData = jsonData.Skip(displayStart).Take(displayLength).ToList(); var json = new { draw = sEcho, recordsTotal = totalCount, recordsFiltered = filteredRecords, // recordsFiltered =(filteredRecords>0)?filteredRecords: jsonData.Count(), data = jsonData.Select(x => new string[] { //(isEnrolled=="notEnrolledClients")? x.PersonId.ToString(): x.Id.ToString(), (isEnrolled == "notEnrolledClients")? "0": x.Id.ToString(), x.EnrollmentNumber.ToString(), x.FirstName, x.MiddleName, x.LastName, x.DateOfBirth.ToString("dd-MMM-yyyy"), LookupLogic.GetLookupNameById(x.Sex), //x.RegistrationDate.ToString("dd-MMM-yyyy"), (isEnrolled == "notEnrolledClients")? Convert.ToDateTime(x.RegistrationDate).ToString("dd-MMM-yyyy") : x.EnrollmentDate.ToString("dd-MMM-yyyy"), x.PatientStatus.ToString(), x.PersonId.ToString() //,utility.Decrypt(x.MobileNumber) }) }; //output = JsonConvert.SerializeObject(json); string tooutput = new JavaScriptSerializer().Serialize(json); output = tooutput; } } catch (Exception e) { //Dispose(); output = e.Message; } finally { Dispose(); } string newoutput = output; return(newoutput); }
private void populateMMAS() { LookupLogic lookUp = new LookupLogic(); //LookupItemView[] questionsArray = lookUp.getQuestions("MMAS4").ToArray(); //LookupItemView[] questionsArray; ////string jsondata = new JavaScriptSerializer().Serialize(questionsList); ////string path = Server.MapPath("~/CCC/Data/"); ////System.IO.File.WriteAllText(path + "output.json", jsondata); //string path = Server.MapPath("~/CCC/Data/output.json"); int i = 0; //using (StreamReader r = new StreamReader(path)) //{ // string json = r.ReadToEnd(); // JavaScriptSerializer ser = new JavaScriptSerializer(); // questionsArray = ser.Deserialize<LookupItemView[]>(json); // //List<Item> items = JsonConvert.DeserializeObject<List<Item>>(json); //} //if (Cache["MMAS4"] == null) //{ // List<LookupItemView> questionsCacheList = lookUp.getQuestions("MMAS4"); // HttpRuntime.Cache.Insert("MMAS4", questionsCacheList, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.Zero); //} //LookupItemView[] questionsArray = (LookupItemView[])Cache["MMAS4"]; List <LookupItemView> questionsList = lookUp.getQuestions("MMAS4").ToList(); // foreach (var value in (List<LookupItemView>)Cache["MMAS4"]) foreach (var value in questionsList) { i = i + 1; screenTypeId = value.MasterId; string radioItems = ""; LookupItemView[] itemList = lookUp.getQuestions(value.ItemName).ToArray(); if (itemList.Any()) { foreach (var items in itemList) { radioItems = items.ItemName; } } PHMMAS4.Controls.Add(new LiteralControl("<div class='row' id='" + value.ItemName + "'>")); if (radioItems != "") { PHMMAS4.Controls.Add(new LiteralControl("<div class='col-md-8 text-left'>")); PHMMAS4.Controls.Add(new LiteralControl("<label>" + i + ". " + value.ItemDisplayName + "" + "</label>")); PHMMAS4.Controls.Add(new LiteralControl("</div>")); PHMMAS4.Controls.Add(new LiteralControl("<div class='col-md-4 text-right'>")); rbList = new RadioButtonList(); rbList.ID = "session1rb" + value.ItemId.ToString(); rbList.RepeatColumns = 2; rbList.ClientIDMode = System.Web.UI.ClientIDMode.Static; rbList.CssClass = "mmrbList"; lookUp.populateRBL(rbList, radioItems); PHMMAS4.Controls.Add(rbList); PHMMAS4.Controls.Add(new LiteralControl("</div>")); } PHMMAS4.Controls.Add(new LiteralControl("</div>")); //var lastItem = questionsArray.Last(); //if (!value.Equals(lastItem)) //{ PHMMAS4.Controls.Add(new LiteralControl("<hr />")); //} } //if (Cache["MMAS8"] == null) //{ // List<LookupItemView> questionsCacheList = lookUp.getQuestions("MMAS8"); // HttpRuntime.Cache.Insert("MMAS8", questionsCacheList, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.Zero); //} //LookupItemView[] mmas8QuestionsList = lookUp.getQuestions("MMAS8").ToArray(); List <LookupItemView> questionsCacheList = lookUp.getQuestions("MMAS8"); //List<LookupItemView> mmas8QuestionsList = (List<LookupItemView>)Cache["MMAS8"]; List <LookupItemView> mmas8QuestionsList = questionsCacheList; foreach (var value in mmas8QuestionsList) { i = i + 1; var lastItem = mmas8QuestionsList.Last(); screenTypeId = value.MasterId; string radioItems = ""; LookupItemView[] itemList = lookUp.getQuestions(value.ItemName).ToArray(); if (itemList.Any()) { foreach (var items in itemList) { radioItems = items.ItemName; } } PHMMAS8.Controls.Add(new LiteralControl("<div class='row' id='" + value.ItemName + "'>")); if (radioItems != "") { if (value.Equals(lastItem)) { PHMMAS8.Controls.Add(new LiteralControl("<div class='col-md-4 text-left'>")); PHMMAS8.Controls.Add(new LiteralControl("<label>" + i + ". " + value.ItemDisplayName + "" + "</label>")); PHMMAS8.Controls.Add(new LiteralControl("</div>")); PHMMAS8.Controls.Add(new LiteralControl("<div class='col-md-8 text-right'>")); rbList = new RadioButtonList(); rbList.ID = "session1rb" + value.ItemId.ToString(); rbList.RepeatColumns = 5; rbList.ClientIDMode = System.Web.UI.ClientIDMode.Static; rbList.CssClass = "mmrbList"; lookUp.populateRBL(rbList, radioItems); PHMMAS8.Controls.Add(rbList); PHMMAS8.Controls.Add(new LiteralControl("</div>")); } else { PHMMAS8.Controls.Add(new LiteralControl("<div class='col-md-8 text-left'>")); PHMMAS8.Controls.Add(new LiteralControl("<label>" + i + ". " + value.ItemDisplayName + "" + "</label>")); PHMMAS8.Controls.Add(new LiteralControl("</div>")); PHMMAS8.Controls.Add(new LiteralControl("<div class='col-md-4 text-right'>")); rbList = new RadioButtonList(); rbList.ID = "session1rb" + value.ItemId.ToString(); rbList.RepeatColumns = 2; rbList.ClientIDMode = System.Web.UI.ClientIDMode.Static; rbList.CssClass = "mmrbList"; lookUp.populateRBL(rbList, radioItems); PHMMAS8.Controls.Add(rbList); PHMMAS8.Controls.Add(new LiteralControl("</div>")); } } PHMMAS8.Controls.Add(new LiteralControl("</div>")); if (!value.Equals(lastItem)) { PHMMAS8.Controls.Add(new LiteralControl("<hr />")); } } }
public string GetPatientFamilyMembers(string firstName, string middleName, string lastName, string sex) { List <PatientLookup> patientLookups = new List <PatientLookup>(); IEnumerable <object> newresults = Enumerable.Empty <object>(); try { LookupLogic logic = new LookupLogic(); int intSex = 0; if (!System.String.IsNullOrEmpty(sex)) { var items = logic.GetItemIdByGroupAndItemName("Gender", sex); if (items.Count > 0) { intSex = items[0].ItemId; } } int patientId = int.Parse(Session["PatientPK"].ToString()); PatientLookupManager patientLookup = new PatientLookupManager(); PersonRelationshipManager relationManager = new PersonRelationshipManager(); patientLookups = patientLookup.GetPatientListByParams(patientId, firstName, middleName, lastName, intSex); newresults = patientLookups.Select(x => new Dictionary <string, string>() { { "Id", x.Id.ToString() }, { "EnrollmentNumber", x.EnrollmentNumber.ToString() }, { "FirstName", x.FirstName }, { "MiddleName", x.MiddleName }, { "LastName", x.LastName }, { "DateOfBirth", x.DateOfBirth.ToString() }, { "Sex", LookupLogic.GetLookupNameById(x.Sex) }, { "EnrollmentDate", x.EnrollmentDate.ToString() }, { "PatientStatus", x.PatientStatus }, { "PersonId", x.PersonId.ToString() }, { "LinkedToPatient", relationManager.PersonLinkedToPatient(x.PersonId, patientId).ToString() } }); } catch (Exception e) { Console.WriteLine(e); throw; } //return JsonConvert.SerializeObject(newresults); return(new JavaScriptSerializer().Serialize(newresults)); }
public void getNotesData(int PatientId) { var PCN = new PatientClinicalNotesLogic(); List <PatientClinicalNotes> socialNotesList = PCN.getPatientClinicalNotesByCategoryVisitId(PatientId, Convert.ToInt32(LookupLogic.GetLookupItemId("SocialNotes")), PmVisitId); //.getPatientClinicalNotesById(PatientId, Convert.ToInt32(LookupLogic.GetLookupItemId("SocialNotes"))); if (socialNotesList.Any()) { foreach (var value in socialNotesList) { TextBox ntb = (TextBox)PHCRAFFTNotes.FindControl("crafft" + value.NotesCategoryId.ToString()); if (ntb != null) { ntb.Text = value.ClinicalNotes; } } } }
protected void ddlCounsellingType_SelectedIndexChanged(object sender, EventArgs e) { LookupLogic lookUp = new LookupLogic(); lookUp.populateDDL(ddlCounsellingTopic, "ProgressionRX"); }
// Utility _utility = new Utility(); //readonly ILookupManager _lookupManager = (ILookupManager)ObjectFactory.CreateInstance("BusinessProcess.CCC.BLookupManager, BusinessProcess.CCC"); protected void Page_Load(object sender, EventArgs e) { var myDate = DateTime.Now.Year; var myDateMonth = DateTime.Now.Month; int patientId = Convert.ToInt32(HttpContext.Current.Session["PatientPK"]); //if (patientId== 0 && Request.QueryString["patient"] != null) //{ // patientId = Convert.ToInt32(Request.QueryString["patient"]); // Session["PatientPK"] = patientId; //} DateTime DoB; //IPatientLookupmanager patientLookupmanager = (IPatientLookupmanager)ObjectFactory.CreateInstance("BusinessProcess.CCC.BPatientLookupManager, BusinessProcess.CCC"); //List<PatientLookup> patientLookups = patientLookupmanager.GetPatientDetailsLookup(patientId); PatientLookupManager pMgr = new PatientLookupManager(); PatientLookup thisPatient = pMgr.GetPatientDetailSummary(patientId); if (null != thisPatient) { DoB = Convert.ToDateTime(thisPatient.DateOfBirth); Session["DateOfBirth"] = thisPatient.DateOfBirth.ToString("dd-MMM-yyyy"); lblLastName.Text = "<strong><h2><i>" + (thisPatient.LastName) + "</i></h2></strong>"; if (thisPatient.Active) { lblStatus.Text = "<i class=fa fa-user-o text-success' aria-hidden='true'></i><strong class='label label-info fa-1x'>Patient Active</strong>"; } else { lblStatus.Text = "<i class=fa fa-user-o text-danger' aria-hidden='true'></i><strong> Inactive</strong>"; } // string femaleIcon= "<i class='fa fa-female' aria-hidden='true'></i>"; //string maleIcon = "<i class='fa fa-male' aria-hidden='true'></i>"; //if (x.Sex == 62) //{ // lblGender.Text= femaleIcon + "<strong><i>"+_lookupManager.GetLookupNameFromId(x.Sex)+ "</i></strong>"; // Session["Gender"] = _lookupManager.GetLookupNameFromId(x.Sex).ToLower(); //} //if (x.Sex==61) //{ // lblGender.Text = maleIcon + "<strong><i>" + _lookupManager.GetLookupNameFromId(x.Sex) + "</i></strong>"; // Session["Gender"] = _lookupManager.GetLookupNameFromId(x.Sex).ToLower(); //} Session["Gender"] = lblGender.Text = LookupLogic.GetLookupNameById(thisPatient.Sex); lblOtherNames.Text = "<strong><h2><i>" + (thisPatient.FirstName) + ' ' + (thisPatient.MiddleName) + "</i></h2></strong>"; var age = PatientManager.CalculateYourAge(DoB); //lblAge.Text ="<strong><i>"+ Convert.ToString(myDate - DoB.Year)+" Years " + Convert.ToString(myDateMonth-DoB.Month) + " Months </i></strong>"; lblAge.Text = "<strong><i>" + age + "</i></strong>"; Session["Age"] = Convert.ToString(myDate - DoB.Year); lblCCCReg.Text = thisPatient.EnrollmentNumber; lblEnrollmentDate.Text = "Enrollment Date :" + thisPatient.EnrollmentDate.ToString("dd-MMM-yyyy"); } }
//int _userId = Convert.ToInt32(HttpContext.Current.Session["AppUserId"]); //int _facilityId = Convert.ToInt32(HttpContext.Current.Session["AppLocationId"]); public string Save(ViralLoadResultsDto viralLoadResults) { LabOrderEntity labOrder = null; List <LabDetailsEntity> labDetails = null; var results = viralLoadResults.ViralLoadResult; if (results != null) { try { var patientLookup = new PatientLookupManager(); var labOrderManager = new PatientLabOrderManager(); var patientCcc = viralLoadResults.PatientIdentification.INTERNAL_PATIENT_ID.FirstOrDefault(n => n.IdentifierType == "CCC_NUMBER").IdentifierValue; var patient = patientLookup.GetPatientByCccNumber(patientCcc); string receivingFacilityMFLCode = viralLoadResults.MesssageHeader.ReceivingFacility; LookupLogic flm = new LookupLogic(); LookupFacility thisFacility = flm.GetFacility(receivingFacilityMFLCode); int interopUserId = InteropUser.UserId; if (thisFacility == null) { Msg = $"The facility {receivingFacilityMFLCode} does not exist"; throw new Exception(Msg); } if (patient == null) { Msg = $"Patient {patientCcc} does not exist "; throw new Exception(Msg); } if (results.Count(r => string.IsNullOrWhiteSpace(r.VlResult.Trim())) > 0) { Msg = $"Viral load message has no results indicated "; throw new Exception(Msg); } int invalidResult = 0; foreach (var result in results) { if (result.VlResult.Contains("LDL")) { } else if (Regex.Split(result.VlResult, @"[^0-9\.]+").Length > 0) { } else { invalidResult++; } } if (invalidResult > 0) { Msg = $"Viral load message has invalid results indicated "; throw new Exception(Msg); } if (patient != null && thisFacility != null) { //todo brian check labOrder = labOrderManager.GetPatientLabOrdersByDate((int)patient.ptn_pk, results.FirstOrDefault().DateSampleCollected).DefaultIfEmpty(null).FirstOrDefault(); DateTime sampleCollectionDate = results.FirstOrDefault().DateSampleCollected; if (labOrder == null) { var patientMasterVisitManager = new PatientMasterVisitManager(); //var visitType = flm.GetItemIdByGroupAndItemName("VisitType", "Enrollment")[0] // .ItemId; int patientMasterVisitId = patientMasterVisitManager.AddPatientMasterVisit(patient.Id, interopUserId, 316); var listOfTestsOrdered = new List <ListLabOrder>(); var order = new ListLabOrder() { FacilityId = Convert.ToInt32(viralLoadResults.MesssageHeader.ReceivingFacility), LabName = "Viral Load",// results.FirstOrDefault().LabTestedIn, LabNameId = 3, LabNotes = results.FirstOrDefault().Regimen + " " + results.FirstOrDefault().SampleType, LabOrderDate = sampleCollectionDate, LabOrderId = 0, OrderReason = "", Results = results.FirstOrDefault().VlResult, VisitId = patientMasterVisitId, ResultDate = viralLoadResults.MesssageHeader.MessageDatetime }; listOfTestsOrdered.Add(order); var jss = new JavaScriptSerializer(); string patientLabOrder = jss.Serialize(listOfTestsOrdered); //include userid and facility ID int orderId = labOrderManager.savePatientLabOrder(patient.Id, (int)patient.ptn_pk, interopUserId, thisFacility.FacilityID, 203, patientMasterVisitId, sampleCollectionDate.ToString(), "IL lab order", patientLabOrder, "Complete"); labOrder = labOrderManager.GetLabOrdersById(orderId); labDetails = labOrderManager.GetLabTestsOrderedById(labOrder.Id); } else { labDetails = labOrderManager.GetLabTestsOrderedById(labOrder.Id); } if (labOrder != null) { bool isUndetectable = false; string resultText = ""; decimal?resultValue = null; foreach (var result in results) { if (result.VlResult.Contains("LDL")) { isUndetectable = true; resultText = result.VlResult; } else { var resultString = result.VlResult.Replace("copies/ml", ""); string[] numbers = Regex.Split(resultString, @"[^0-9\.]+"); //bool isSuccess = decimal.TryParse(resultString, out decimalValue); //if (isSuccess) resultValue = decimalValue; for (int i = 0; i < numbers.Length; i++) { if (Regex.IsMatch(numbers[i], @"^\d+$")) { resultValue = Convert.ToDecimal(numbers[i]); break; } } } if (labOrder != null) { var labResults = new LabResultsEntity() { //todo remove hard coding LabOrderId = labOrder.Id, LabOrderTestId = labDetails.FirstOrDefault().Id, ParameterId = 3, LabTestId = 3, ResultText = resultText, ResultValue = resultValue, ResultUnit = "copies/ml", ResultUnitId = 129, Undetectable = isUndetectable, StatusDate = result.DateSampleTested, HasResult = true }; labOrderManager.AddPatientLabResults(labResults); labOrder.OrderStatus = "Complete"; labOrderManager.savePatientLabOrder(labOrder); } } Msg = "Success"; } } else { Msg = "Patient does not exist"; return(Msg); } } catch (Exception e) { Msg = "error " + e.Message; throw e; } } else { Msg = "Message does not contain results"; throw new Exception(Msg); } return(Msg); }