public List <PatientFamilyTesting> GetPatientFamilyList(int patientId) { List <PatientFamilyTesting> patientFamilyTestings = new List <PatientFamilyTesting>(); PatientFamilyTesting familyTesting = null; List <PersonRelationship> personRelationships = _personRelationshipManager.GetAllPersonRelationship(patientId); Utility utility = new Utility(); foreach (var relationship in personRelationships) { var hivTesting = _hivTestingManager.GetAll().OrderByDescending(y => y.Id).FirstOrDefault(n => n.PersonId == relationship.PersonId); PersonLookUp person = personLookUp.GetPersonById(relationship.PersonId); var linkage = linkageManager.GetPatientLinkage(relationship.PersonId).FirstOrDefault(); if (person != null) { familyTesting = new PatientFamilyTesting() { FirstName = (person.FirstName), MiddleName = (person.MiddleName), LastName = (person.LastName), Sex = person.Sex, DateOfBirth = person.DateOfBirth, DobPrecision = person.DobPrecision, PersonId = relationship.PersonId, RelationshipId = relationship.RelationshipTypeId, BaseLineHivStatusId = relationship.BaselineResult, BaselineHivStatusDate = relationship.BaselineDate, //HivTestingResultsId = hivTesting.TestingResult, //HivTestingResultsDate = hivTesting.TestingDate, //CccReferal = hivTesting.ReferredToCare, //CccReferaalNumber = linkage.CCCNumber, //LinkageDate = linkage.LinkageDate, PersonRelationshipId = relationship.Id //HivTestingId = hivTesting.Id }; if (hivTesting != null) { familyTesting.HivTestingResultsId = hivTesting.TestingResult; familyTesting.HivTestingResultsDate = hivTesting.TestingDate; familyTesting.CccReferal = hivTesting.ReferredToCare; familyTesting.HivTestingId = hivTesting.Id; } if (linkage != null) { familyTesting.CccReferaalNumber = linkage.CCCNumber; familyTesting.LinkageDate = linkage.LinkageDate; } patientFamilyTestings.Add(familyTesting); } } return(patientFamilyTestings); }
public string GetPatientEnrollmentDetails() { try { EnrollmentDetails enrollmentDetails = new EnrollmentDetails(); enrollmentDetails.IndentifiersList = new List <Identifier>(); PersonId = int.Parse(Session["PersonId"].ToString()); PatientLookupManager patientLookupManager = new PatientLookupManager(); PatientEntryPointManager entryPointManager = new PatientEntryPointManager(); PatientIdentifierManager identifierManager = new PatientIdentifierManager(); IdentifierManager ideManager = new IdentifierManager(); PersonLookUpManager personLookUp = new PersonLookUpManager(); PatientLookup patientList = patientLookupManager.GetPatientByPersonId(PersonId); if (patientList != null) { enrollmentDetails.DOB = String.Format("{0:dd-MMM-yyyy}", patientList.DateOfBirth); enrollmentDetails.DobPrecision = patientList.DobPrecision; if (enrollmentDetails.DOB == null) { PersonLookUp person = personLookUp.GetPersonById(PersonId); if (person.DateOfBirth != null) { enrollmentDetails.DOB = String.Format("{0:dd-MMM-yyyy}", person.DateOfBirth); enrollmentDetails.DobPrecision = person.DobPrecision == null?false:Convert.ToBoolean(person.DobPrecision); } } enrollmentDetails.NationalId = patientList.NationalId; enrollmentDetails.EnrollmentDate = String.Format("{0:dd-MMM-yyyy}", patientList.EnrollmentDate); var entryPoints = entryPointManager.GetPatientEntryPoints(patientList.Id); var identifiers = identifierManager.GetAllPatientEntityIdentifiers(patientList.Id); var dynamicFields = EnrollmentService.ServiceDynamicFields(1); if (entryPoints.Count > 0) { string Name = LookupLogic.GetLookupNameById(entryPoints[0].EntryPointId); if (Name == "Unknown") { enrollmentDetails.EntryPointIdUnknown = true; enrollmentDetails.EntryPointId = entryPoints[0].EntryPointId; } else { enrollmentDetails.EntryPointIdUnknown = false; enrollmentDetails.EntryPointId = entryPoints[0].EntryPointId; } } var dynamicObject = new ExpandoObject() as IDictionary <string, Object>; foreach (var field in dynamicFields) { foreach (var itemsEntityIdentifier in identifiers) { if (itemsEntityIdentifier.IdentifierTypeId == field.ID) { var code = field.Code; dynamicObject.Add(code, itemsEntityIdentifier.IdentifierValue); } } } //if (identifiers.Count > 0) //{ // enrollmentDetails.IndentifierId = identifiers[0].IdentifierTypeId; //} foreach (var dynamicItem in dynamicObject) { var key = dynamicItem.Key; var identifier = ideManager.GetIdentifierByCode(key); var dynIdentifier = new Identifier(); if (identifier.PrefixType != null) { string[] enrollmentParts = dynamicItem.Value.ToString().Split('-'); int parts = enrollmentParts.Length; if (parts > 1) { dynIdentifier.Code = key; dynIdentifier.PrefixType = enrollmentParts[0]; dynIdentifier.DataType = enrollmentParts[1]; //enrollmentDetails.EnrollmentValue = enrollmentParts[1]; //enrollmentDetails.Prefix = enrollmentParts[0]; //enrollmentDetails.Suffix = null; } else { dynIdentifier.Code = key; dynIdentifier.DataType = dynamicItem.Value.ToString(); //enrollmentDetails.EnrollmentValue = dynamicItem.Value.ToString(); } } else { dynIdentifier.Code = key; dynIdentifier.DataType = dynamicItem.Value.ToString(); } enrollmentDetails.IndentifiersList.Add(dynIdentifier); } //string[] enrollmentParts = patientList[0].EnrollmentNumber.Split('-'); //int parts = enrollmentParts.Length; //if (parts > 1) //{ // enrollmentDetails.EnrollmentValue = enrollmentParts[1]; // enrollmentDetails.Prefix = enrollmentParts[0]; // enrollmentDetails.Suffix = null; //} //else //{ // enrollmentDetails.EnrollmentValue = patientList[0].EnrollmentNumber; //} } else { PersonLookUp person = personLookUp.GetPersonById(PersonId); if (person.DateOfBirth != null) { enrollmentDetails.DOB = String.Format("{0:dd-MMM-yyyy}", person.DateOfBirth); enrollmentDetails.DobPrecision = person.DobPrecision == null ? false : Convert.ToBoolean(person.DobPrecision); } } return(new JavaScriptSerializer().Serialize(enrollmentDetails)); } catch (Exception e) { Console.WriteLine(e); throw; } }