Skip to content

Commit

Permalink
Merge pull request #635 from nhsconnect/develop
Browse files Browse the repository at this point in the history
Mods
  • Loading branch information
ChristopherJamesMorris authored Jun 20, 2024
2 parents 08606c9 + cb3ef7b commit 4462d2e
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 136 deletions.
237 changes: 120 additions & 117 deletions modules/api/src/Service/InteractionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,128 +38,131 @@ public InteractionService(ILogger<InteractionService> logger, IConfigurationServ
{
try
{
var odsCodesInScope = routeReportRequest.ReportSource.DistinctBy(x => x.OdsCode).Select(x => x.OdsCode).ToList();
string? jsonData = null;
var interactions = new List<IDictionary<string, object>>();

if (routeReportRequest.ReportSource.OdsCode != null)
if (odsCodesInScope.Count > 0)
{
switch (typeof(T))
for (var i = 0; i < odsCodesInScope.Count; i++)
{
case Type type when type == typeof(AccessRecordStructuredReporting):

var accessRecordStructuredReporting = new AccessRecordStructuredReporting()
{
OdsCode = routeReportRequest.ReportSource.OdsCode,
SupplierName = routeReportRequest.ReportSource.SupplierName,
Hierarchy = routeReportRequest.ReportSource.OrganisationHierarchy,
DocumentsVersion = ActiveInactiveConstants.NOTAVAILABLE,
DocumentsInProfile = ActiveInactiveConstants.NOTAVAILABLE,
Profile = null,
ApiVersion = ActiveInactiveConstants.NOTAVAILABLE,

};

var accessRecordStructuredReportingData = await GetInteractionData(new InteractionDataRequest
{
OdsCode = routeReportRequest.ReportSource.OdsCode,
Interaction = routeReportRequest.Interaction[0],
Client = Clients.GPCONNECTCLIENT,
HostIdentifier = "https://fhir.nhs.uk",
HasId = true
});

if (accessRecordStructuredReportingData != null && accessRecordStructuredReportingData.NoIssues)
{
accessRecordStructuredReporting.Rest = accessRecordStructuredReportingData.Rest;
accessRecordStructuredReporting.Profile = accessRecordStructuredReportingData.Profile;
accessRecordStructuredReporting.ApiVersion = $"v{accessRecordStructuredReportingData.Version}";
}

var accessRecordStructuredReportingDataDocuments = await GetInteractionData(new InteractionDataRequest
{
OdsCode = routeReportRequest.ReportSource.OdsCode,
Interaction = routeReportRequest.Interaction[1],
Client = Clients.GPCONNECTCLIENT,
HostIdentifier = "https://fhir.nhs.uk",
HasId = true
});

if (accessRecordStructuredReportingDataDocuments != null && accessRecordStructuredReportingDataDocuments.NoIssues)
{
accessRecordStructuredReporting.DocumentsVersion = $"v{accessRecordStructuredReportingDataDocuments.Version}";
accessRecordStructuredReporting.DocumentsInProfile = accessRecordStructuredReportingDataDocuments.Rest?.Count(x => x.Resource.Any(y => y.Type == "Binary")) > 0 ? ActiveInactiveConstants.ACTIVE : ActiveInactiveConstants.INACTIVE;
}

var jsonStringARS = JsonConvert.SerializeObject(accessRecordStructuredReporting);
var jObjectARS = JObject.Parse(jsonStringARS);
var jDictObjARS = jObjectARS.Flatten();

interactions.Add(jDictObjARS);
break;

case Type type when type == typeof(AccessRecordHtmlReporting):

var accessRecordHtmlReporting = new AccessRecordHtmlReporting()
{
OdsCode = routeReportRequest.ReportSource.OdsCode,
SupplierName = routeReportRequest.ReportSource.SupplierName,
Hierarchy = routeReportRequest.ReportSource.OrganisationHierarchy,
ApiVersion = ActiveInactiveConstants.NOTAVAILABLE
};

var accessRecordHtmlReportingData = await GetReportingInteractionData(new InteractionDataRequest()
{
OdsCode = routeReportRequest.ReportSource.OdsCode,
Interaction = routeReportRequest.Interaction[0],
Client = Clients.GPCONNECTCLIENTLEGACY,
HostIdentifier = "http://fhir.nhs.net",
AuthenticationAudience = "https://authorize.fhir.nhs.net/token",
HasId = false
});

if (accessRecordHtmlReportingData != null && accessRecordHtmlReportingData.NoIssues)
{
accessRecordHtmlReporting.Rest = accessRecordHtmlReportingData.Rest;
accessRecordHtmlReporting.ApiVersion = $"v{accessRecordHtmlReportingData.Version}";
}

var jsonStringARH = JsonConvert.SerializeObject(accessRecordHtmlReporting);
var jObjectARH = JObject.Parse(jsonStringARH);
var jDictObjARH = jObjectARH.Flatten();

interactions.Add(jDictObjARH);
break;
case Type type when type == typeof(AppointmentManagementReporting):

var appointmentManagementReporting = new AppointmentManagementReporting()
{
OdsCode = routeReportRequest.ReportSource.OdsCode,
SupplierName = routeReportRequest.ReportSource.SupplierName,
Hierarchy = routeReportRequest.ReportSource.OrganisationHierarchy,
ApiVersion = ActiveInactiveConstants.NOTAVAILABLE
};

var appointmentManagementReportingData = await GetInteractionData(new InteractionDataRequest()
{
OdsCode = routeReportRequest.ReportSource.OdsCode,
Interaction = routeReportRequest.Interaction[0],
Client = Clients.GPCONNECTCLIENT,
HostIdentifier = "https://fhir.nhs.uk",
HasId = true
});

if (appointmentManagementReportingData != null && appointmentManagementReportingData.NoIssues)
{
appointmentManagementReporting.Rest = appointmentManagementReportingData.Rest;
appointmentManagementReporting.ApiVersion = $"v{appointmentManagementReportingData.Version}";
}

var jsonStringAM = JsonConvert.SerializeObject(appointmentManagementReporting);
var jObjectAM = JObject.Parse(jsonStringAM);
var jDictObjAM = jObjectAM.Flatten();

interactions.Add(jDictObjAM);
break;
switch (typeof(T))
{
case Type type when type == typeof(AccessRecordStructuredReporting):

var accessRecordStructuredReporting = new AccessRecordStructuredReporting()
{
OdsCode = odsCodesInScope[i],
SupplierName = routeReportRequest.ReportSource[i].SupplierName,
Hierarchy = routeReportRequest.ReportSource[i].OrganisationHierarchy,
DocumentsVersion = ActiveInactiveConstants.NOTAVAILABLE,
DocumentsInProfile = ActiveInactiveConstants.NOTAVAILABLE,
Profile = null,
ApiVersion = ActiveInactiveConstants.NOTAVAILABLE
};

var accessRecordStructuredReportingData = await GetInteractionData(new InteractionDataRequest
{
OdsCode = odsCodesInScope[i],
Interaction = routeReportRequest.Interaction[0],
Client = Clients.GPCONNECTCLIENT,
HostIdentifier = "https://fhir.nhs.uk",
HasId = true
});

if (accessRecordStructuredReportingData != null && accessRecordStructuredReportingData.NoIssues)
{
accessRecordStructuredReporting.Rest = accessRecordStructuredReportingData.Rest;
accessRecordStructuredReporting.Profile = accessRecordStructuredReportingData.Profile;
accessRecordStructuredReporting.ApiVersion = $"v{accessRecordStructuredReportingData.Version}";
}

var accessRecordStructuredReportingDataDocuments = await GetInteractionData(new InteractionDataRequest
{
OdsCode = odsCodesInScope[i],
Interaction = routeReportRequest.Interaction[1],
Client = Clients.GPCONNECTCLIENT,
HostIdentifier = "https://fhir.nhs.uk",
HasId = true
});

if (accessRecordStructuredReportingDataDocuments != null && accessRecordStructuredReportingDataDocuments.NoIssues)
{
accessRecordStructuredReporting.DocumentsVersion = $"v{accessRecordStructuredReportingDataDocuments.Version}";
accessRecordStructuredReporting.DocumentsInProfile = accessRecordStructuredReportingDataDocuments.Rest?.Count(x => x.Resource.Any(y => y.Type == "Binary")) > 0 ? ActiveInactiveConstants.ACTIVE : ActiveInactiveConstants.INACTIVE;
}

var jsonStringARS = JsonConvert.SerializeObject(accessRecordStructuredReporting);
var jObjectARS = JObject.Parse(jsonStringARS);
var jDictObjARS = jObjectARS.Flatten();

interactions.Add(jDictObjARS);
break;

case Type type when type == typeof(AccessRecordHtmlReporting):

var accessRecordHtmlReporting = new AccessRecordHtmlReporting()
{
OdsCode = odsCodesInScope[i],
SupplierName = routeReportRequest.ReportSource[i].SupplierName,
Hierarchy = routeReportRequest.ReportSource[i].OrganisationHierarchy,
ApiVersion = ActiveInactiveConstants.NOTAVAILABLE
};

var accessRecordHtmlReportingData = await GetReportingInteractionData(new InteractionDataRequest()
{
OdsCode = odsCodesInScope[i],
Interaction = routeReportRequest.Interaction[0],
Client = Clients.GPCONNECTCLIENTLEGACY,
HostIdentifier = "http://fhir.nhs.net",
AuthenticationAudience = "https://authorize.fhir.nhs.net/token",
HasId = false
});

if (accessRecordHtmlReportingData != null && accessRecordHtmlReportingData.NoIssues)
{
accessRecordHtmlReporting.Rest = accessRecordHtmlReportingData.Rest;
accessRecordHtmlReporting.ApiVersion = $"v{accessRecordHtmlReportingData.Version}";
}

var jsonStringARH = JsonConvert.SerializeObject(accessRecordHtmlReporting);
var jObjectARH = JObject.Parse(jsonStringARH);
var jDictObjARH = jObjectARH.Flatten();

interactions.Add(jDictObjARH);
break;
case Type type when type == typeof(AppointmentManagementReporting):

var appointmentManagementReporting = new AppointmentManagementReporting()
{
OdsCode = odsCodesInScope[i],
SupplierName = routeReportRequest.ReportSource[i].SupplierName,
Hierarchy = routeReportRequest.ReportSource[i].OrganisationHierarchy,
ApiVersion = ActiveInactiveConstants.NOTAVAILABLE
};

var appointmentManagementReportingData = await GetInteractionData(new InteractionDataRequest()
{
OdsCode = odsCodesInScope[i],
Interaction = routeReportRequest.Interaction[0],
Client = Clients.GPCONNECTCLIENT,
HostIdentifier = "https://fhir.nhs.uk",
HasId = true
});

if (appointmentManagementReportingData != null && appointmentManagementReportingData.NoIssues)
{
appointmentManagementReporting.Rest = appointmentManagementReportingData.Rest;
appointmentManagementReporting.ApiVersion = $"v{appointmentManagementReportingData.Version}";
}

var jsonStringAM = JsonConvert.SerializeObject(appointmentManagementReporting);
var jObjectAM = JObject.Parse(jsonStringAM);
var jDictObjAM = jObjectAM.Flatten();

interactions.Add(jDictObjAM);
break;
}
}
jsonData = JsonConvert.SerializeObject(interactions);
}
Expand Down
42 changes: 23 additions & 19 deletions modules/api/src/Service/WorkflowService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,36 @@ public WorkflowService(ILogger<WorkflowService> logger, IHttpClientFactory httpC
{
try
{
var odsCodesInScope = routeReportRequest.ReportSource.DistinctBy(x => x.OdsCode).Select(x => x.OdsCode).ToList();
string? jsonData = null;
var workflows = new List<IDictionary<string, object>>();

if (routeReportRequest.ReportSource.OdsCode != null)
if (odsCodesInScope.Count > 0)
{
var mailboxReporting = new MailboxReporting()
for (var i = 0; i < odsCodesInScope.Count; i++)
{
OdsCode = routeReportRequest.ReportSource.OdsCode,
SupplierName = routeReportRequest.ReportSource.SupplierName,
Hierarchy = routeReportRequest.ReportSource.OrganisationHierarchy
};
var mailboxReporting = new MailboxReporting()
{
OdsCode = odsCodesInScope[i],
SupplierName = routeReportRequest.ReportSource[i].SupplierName,
Hierarchy = routeReportRequest.ReportSource[i].OrganisationHierarchy
};

var workflowData = await GetWorkflowData(routeReportRequest.Workflow[0], routeReportRequest.ReportSource.OdsCode);
if (workflowData != null)
{
mailboxReporting.Status = workflowData.Status;
}
else
{
mailboxReporting.Status = ActiveInactiveConstants.NOTAVAILABLE;
}
var jsonStringSD = JsonConvert.SerializeObject(mailboxReporting);
var jObjectSD = JObject.Parse(jsonStringSD);
var jDictSD = jObjectSD.Flatten();
var workflowData = await GetWorkflowData(routeReportRequest.Workflow[0], odsCodesInScope[i]);
if (workflowData != null)
{
mailboxReporting.Status = workflowData.Status;
}
else
{
mailboxReporting.Status = ActiveInactiveConstants.NOTAVAILABLE;
}
var jsonStringSD = JsonConvert.SerializeObject(mailboxReporting);
var jObjectSD = JObject.Parse(jsonStringSD);
var jDictSD = jObjectSD.Flatten();

workflows.Add(jDictSD);
workflows.Add(jDictSD);
}
jsonData = JsonConvert.SerializeObject(workflows);
}
return jsonData;
Expand Down

0 comments on commit 4462d2e

Please sign in to comment.