Skip to content

Commit

Permalink
Merge pull request #2 from palladiumkenya/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
sosewe authored Sep 20, 2018
2 parents 28cd2df + cbc1f0b commit 9517e63
Show file tree
Hide file tree
Showing 6 changed files with 3,420 additions and 3,342 deletions.
4 changes: 2 additions & 2 deletions Application/Application.Presentation/GblIQCare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class GblIQCare
public GblIQCare()
{
AppVersion = "Ver 1.0.0.7 Kenya HMIS";
ReleaseDate = "22-Aug-2018";
ReleaseDate = "20-Sep-2018";
VersionName = "Kenya HMIS Ver 1.0.0.7";
DbVersion = "Ver 1.0.0.7 Kenya HMIS";
}
Expand All @@ -50,7 +50,7 @@ public GblIQCare()
#region "Application Parameters"
public static string AppVersion = "Ver 1.0.0.7 Kenya HMIS";
public static string DbVersion = "Ver 1.0.0.7 Kenya HMIS";
public static string ReleaseDate = "22-Aug-2018";
public static string ReleaseDate = "20-Sep-2018";
public static string VersionName = "Kenya HMIS Ver 1.0.0.7";
#endregion

Expand Down
2 changes: 1 addition & 1 deletion Scripts/1.0.0.7/10 Version.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ UPDATE AppAdmin
SET
AppVer='Ver 1.0.0.7 Kenya HMIS',
DBVer='Ver 1.0.0.7 Kenya HMIS',
RelDate='22-Aug-2018',
RelDate='20-Sep-2018',
VersionName='Ver 1.0.0.7 Kenya HMIS'
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ await encounterTestingService.AddReferral(identifiers[0].PersonId,
}

// update message as processed
await registerPersonService.UpdateAfyaMobileInbox(afyaMobileMessage.Id, afyaMobileId, true, DateTime.Now);
await registerPersonService.UpdateAfyaMobileInbox(afyaMobileMessage.Id, afyaMobileId, true, DateTime.Now, "success");
}
else
{
Expand Down Expand Up @@ -834,7 +834,7 @@ await encounterTestingService.AddReferral(identifiers[0].PersonId,
}

//update message has been processed
await registerPersonService.UpdateAfyaMobileInbox(afyaMobileMessage.Id, afyaMobileId, true, DateTime.Now);
await registerPersonService.UpdateAfyaMobileInbox(afyaMobileMessage.Id, afyaMobileId, true, DateTime.Now, "success");
}
}
}
Expand All @@ -848,7 +848,7 @@ await encounterTestingService.AddReferral(identifiers[0].PersonId,
Log.Error(e.Message);
Log.Error(e.InnerException.ToString());
// update message as processed
await registerPersonService.UpdateAfyaMobileInbox(afyaMobileMessage.Id, afyaMobileId, false, DateTime.Now, e.Message);
await registerPersonService.UpdateAfyaMobileInbox(afyaMobileMessage.Id, afyaMobileId, false, DateTime.Now, e.Message + " " + e.InnerException.ToString());
return Result<string>.Invalid(e.Message);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
using IQCare.HTS.Infrastructure;
using MediatR;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Serilog;

namespace IQCare.HTS.BusinessProcess.CommandHandlers
{
Expand All @@ -31,36 +33,35 @@ public async Task<Result<string>> Handle(SynchronizeFamilyCommand request, Cance
using (_htsUnitOfWork)
using (_unitOfWork)
{
try
{
string afyaMobileId = string.Empty;
string indexClientAfyaMobileId = string.Empty;
string afyaMobileId = string.Empty;
string indexClientAfyaMobileId = string.Empty;

RegisterPersonService registerPersonService = new RegisterPersonService(_unitOfWork);
EncounterTestingService encounterTestingService = new EncounterTestingService(_unitOfWork, _htsUnitOfWork);
RegisterPersonService registerPersonService = new RegisterPersonService(_unitOfWork);
EncounterTestingService encounterTestingService = new EncounterTestingService(_unitOfWork, _htsUnitOfWork);

var facilityId = request.MESSAGE_HEADER.SENDING_FACILITY;
var facilityId = request.MESSAGE_HEADER.SENDING_FACILITY;

for (int i = 0; i < request.FAMILY.Count; i++)
for (int i = 0; i < request.FAMILY.Count; i++)
{
for (int j = 0; j < request.FAMILY[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID.Count; j++)
{


for (int j = 0; j < request.FAMILY[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID.Count; j++)
if (request.FAMILY[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].IDENTIFIER_TYPE ==
"AFYA_MOBILE_ID")
{
if (request.FAMILY[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].IDENTIFIER_TYPE ==
"AFYA_MOBILE_ID")
{
afyaMobileId = request.FAMILY[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].ID;
}
afyaMobileId = request.FAMILY[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].ID;
}

if (request.FAMILY[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].IDENTIFIER_TYPE ==
"INDEX_CLIENT_AFYAMOBILE_ID")
{
indexClientAfyaMobileId =
request.FAMILY[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].ID;
}
if (request.FAMILY[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].IDENTIFIER_TYPE ==
"INDEX_CLIENT_AFYAMOBILE_ID")
{
indexClientAfyaMobileId =
request.FAMILY[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].ID;
}
}

var afyaMobileMessage = await registerPersonService.AddAfyaMobileInbox(DateTime.Now, indexClientAfyaMobileId, JsonConvert.SerializeObject(request), false);
try
{
string firstName = request.FAMILY[i].PATIENT_IDENTIFICATION.PATIENT_NAME.FIRST_NAME;
string middleName = request.FAMILY[i].PATIENT_IDENTIFICATION.PATIENT_NAME.MIDDLE_NAME;
string lastName = request.FAMILY[i].PATIENT_IDENTIFICATION.PATIENT_NAME.LAST_NAME;
Expand Down Expand Up @@ -102,8 +103,8 @@ public async Task<Result<string>> Handle(SynchronizeFamilyCommand request, Cance
}

/***
*Encounter
*/
*Encounter
*/
if (request.FAMILY[i].ENCOUNTER != null)
{
if (request.FAMILY[i].ENCOUNTER.FAMILY_SCREENING != null)
Expand Down Expand Up @@ -198,8 +199,8 @@ await encounterTestingService.AddPartnerScreening(partnetPersonIdentifiers[0].Pe


/***
*Encounter
*/
*Encounter
*/
if (request.FAMILY[i].ENCOUNTER != null)
{
if (request.FAMILY[i].ENCOUNTER.FAMILY_SCREENING != null)
Expand Down Expand Up @@ -262,7 +263,7 @@ await encounterTestingService.AddPartnerScreening(person.Id, indexClient.Id, pat
if (!string.IsNullOrWhiteSpace(request.FAMILY[i].ENCOUNTER.TRACING[j].REMINDER_DATE))
reminderDate = DateTime.ParseExact(request.FAMILY[i].ENCOUNTER.TRACING[j].REMINDER_DATE, "yyyyMMdd", null);
DateTime? tracingBookingDate = null;
if(!string.IsNullOrWhiteSpace(request.FAMILY[i].ENCOUNTER.TRACING[j].BOOKING_DATE))
if (!string.IsNullOrWhiteSpace(request.FAMILY[i].ENCOUNTER.TRACING[j].BOOKING_DATE))
tracingBookingDate = DateTime.ParseExact(request.FAMILY[i].ENCOUNTER.TRACING[j].BOOKING_DATE, "yyyyMMdd", null);
int consent = request.FAMILY[i].ENCOUNTER.TRACING[j].CONSENT;

Expand All @@ -272,13 +273,23 @@ await encounterTestingService.AddPartnerScreening(person.Id, indexClient.Id, pat
}
}
}

// update message as processed
await registerPersonService.UpdateAfyaMobileInbox(afyaMobileMessage.Id, indexClientAfyaMobileId, true, DateTime.Now, "success");
return Result<string>.Valid(afyaMobileId);
}
catch (Exception e)
{
Log.Error(e.Message);
Log.Error(e.InnerException.ToString());
// update message as processed
await registerPersonService.UpdateAfyaMobileInbox(afyaMobileMessage.Id, indexClientAfyaMobileId, false, DateTime.Now, e.Message + " " + e.InnerException.ToString());
return Result<string>.Invalid(e.Message);
}
return Result<string>.Valid(afyaMobileId);
}
catch (Exception e)
{
return Result<string>.Invalid(e.Message);
}

return Result<string>.Valid(afyaMobileId);

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using IQCare.HTS.Infrastructure;
using MediatR;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Serilog;

namespace IQCare.HTS.BusinessProcess.CommandHandlers
Expand All @@ -32,34 +33,35 @@ public async Task<Result<string>> Handle(SynchronizePartnersCommand request, Can
using (_htsUnitOfWork)
using (_unitOfWork)
{
try
{
string afyaMobileId = string.Empty;
string indexClientAfyaMobileId = string.Empty;
string afyaMobileId = string.Empty;
string indexClientAfyaMobileId = string.Empty;

RegisterPersonService registerPersonService = new RegisterPersonService(_unitOfWork);
EncounterTestingService encounterTestingService = new EncounterTestingService(_unitOfWork, _htsUnitOfWork);
RegisterPersonService registerPersonService = new RegisterPersonService(_unitOfWork);
EncounterTestingService encounterTestingService = new EncounterTestingService(_unitOfWork, _htsUnitOfWork);

var facilityId = request.MESSAGE_HEADER.SENDING_FACILITY;
for (int i = 0; i < request.PARTNERS.Count; i++)
{
var facilityId = request.MESSAGE_HEADER.SENDING_FACILITY;
for (int i = 0; i < request.PARTNERS.Count; i++)
{

for (int j = 0; j < request.PARTNERS[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID.Count; j++)
for (int j = 0; j < request.PARTNERS[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID.Count; j++)
{
if (request.PARTNERS[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].IDENTIFIER_TYPE ==
"AFYA_MOBILE_ID")
{
if (request.PARTNERS[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].IDENTIFIER_TYPE ==
"AFYA_MOBILE_ID")
{
afyaMobileId = request.PARTNERS[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].ID;
}
afyaMobileId = request.PARTNERS[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].ID;
}

if (request.PARTNERS[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].IDENTIFIER_TYPE ==
"INDEX_CLIENT_AFYAMOBILE_ID")
{
indexClientAfyaMobileId =
request.PARTNERS[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].ID;
}
if (request.PARTNERS[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].IDENTIFIER_TYPE ==
"INDEX_CLIENT_AFYAMOBILE_ID")
{
indexClientAfyaMobileId =
request.PARTNERS[i].PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID[j].ID;
}
}

var afyaMobileMessage = await registerPersonService.AddAfyaMobileInbox(DateTime.Now, indexClientAfyaMobileId, JsonConvert.SerializeObject(request), false);
try
{
string firstName = request.PARTNERS[i].PATIENT_IDENTIFICATION.PATIENT_NAME.FIRST_NAME;
string middleName = request.PARTNERS[i].PATIENT_IDENTIFICATION.PATIENT_NAME.MIDDLE_NAME;
string lastName = request.PARTNERS[i].PATIENT_IDENTIFICATION.PATIENT_NAME.LAST_NAME;
Expand All @@ -81,10 +83,10 @@ public async Task<Result<string>> Handle(SynchronizePartnersCommand request, Can
var partnetPersonIdentifiers = await registerPersonService.getPersonIdentifiers(afyaMobileId, 10);
if (partnetPersonIdentifiers.Count > 0)
{
await registerPersonService.UpdatePerson(partnetPersonIdentifiers[0].PersonId,firstName, middleName, lastName, sex, dateOfBirth);
await registerPersonService.UpdatePerson(partnetPersonIdentifiers[0].PersonId, firstName, middleName, lastName, sex, dateOfBirth);
//update maritalstatus id
await registerPersonService.UpdateMaritalStatus(partnetPersonIdentifiers[0].PersonId, maritalStatusId);
if(!string.IsNullOrWhiteSpace(mobileNumber))
if (!string.IsNullOrWhiteSpace(mobileNumber))
await registerPersonService.UpdatePersonContact(partnetPersonIdentifiers[0].PersonId, null, mobileNumber);
if (!string.IsNullOrWhiteSpace(landmark))
await registerPersonService.UpdatePersonLocation(partnetPersonIdentifiers[0].PersonId, landmark);
Expand All @@ -102,8 +104,8 @@ public async Task<Result<string>> Handle(SynchronizePartnersCommand request, Can
}

/***
*Encounter
*/
*Encounter
*/

if (request.PARTNERS[i].ENCOUNTER != null)
{
Expand Down Expand Up @@ -250,6 +252,9 @@ public async Task<Result<string>> Handle(SynchronizePartnersCommand request, Can
tracingDate, mode, outcome, providerId, null, consent, tracingBookingDate, null);
}
}

// update message as processed
await registerPersonService.UpdateAfyaMobileInbox(afyaMobileMessage.Id, indexClientAfyaMobileId, true, DateTime.Now, "success");
}
else
{
Expand All @@ -272,14 +277,14 @@ public async Task<Result<string>> Handle(SynchronizePartnersCommand request, Can
await registerPersonService.addPersonLocation(person.Id, 0, 0, 0, " ", landmark,
providerId);
}

//Add PersonRelationship
var personRelationship = await registerPersonService.addPersonRelationship(person.Id, indexClient.Id, relationshipType, providerId);


/***
*Encounter
*/
*Encounter
*/

if (request.PARTNERS[i].ENCOUNTER != null)
{
Expand Down Expand Up @@ -428,15 +433,23 @@ await registerPersonService.addPersonLocation(person.Id, 0, 0, 0, " ", landmark,
}
}
}

// update message as processed
await registerPersonService.UpdateAfyaMobileInbox(afyaMobileMessage.Id, indexClientAfyaMobileId, true, DateTime.Now, "success");
return Result<string>.Valid(afyaMobileId);
}
return Result<string>.Valid(afyaMobileId);
}
catch (Exception e)
{
Log.Error(e.Message);
Log.Error(e.InnerException.ToString());
return Result<string>.Invalid(e.Message);
catch (Exception e)
{
Log.Error(e.Message);
Log.Error(e.InnerException.ToString());
// update message as processed
await registerPersonService.UpdateAfyaMobileInbox(afyaMobileMessage.Id, indexClientAfyaMobileId, false, DateTime.Now, e.Message + " " + e.InnerException.ToString());
return Result<string>.Invalid(e.Message);
}

}

return Result<string>.Valid(afyaMobileId);
}
}
}
Expand Down
Loading

0 comments on commit 9517e63

Please sign in to comment.