Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/gradle/common/org.junit.jupiter-j…
Browse files Browse the repository at this point in the history
…unit-jupiter-api-5.11.0
  • Loading branch information
ole4ryb authored Aug 21, 2024
2 parents 50a3f3c + edf8870 commit ff24135
Show file tree
Hide file tree
Showing 73 changed files with 1,019 additions and 875 deletions.
2 changes: 1 addition & 1 deletion OPERATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ For more configuration see the [Attachment storage variables](#attachment-storag
## AWS daisy chaining example

The Adaptors team have their own AWS environment they use for deploying both the GP2GP and Patient Swtiching adaptors and MHS adaptor.
The infrastructure as code can be used as an example and is found inside the [integration-adaptors repository](https://github.com/nhsconnect/integration-adaptors/tree/develop/terraform/aws/components).
The infrastructure as code can be used as an example and is found inside the [integration-adaptors-deployment repository](https://github.com/NHSDigital/integration-adaptors-deployment/tree/main/aws/components).

## Environment variables

Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies {
api 'org.apache.commons:commons-lang3:3.15.0'
api 'org.apache.qpid:qpid-jms-client:2.5.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.3'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.0'

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ private boolean nackSentWithCode(String code) {

requests.sort(Comparator.comparing(Request::getLoggedDate).reversed());

var mostRecentRequest = requests.get(0);
var mostRecentRequest = requests.getFirst();

return mostRecentRequest.getHeaders().getInteractionId().equals(ACK_INTERACTION_ID)
&& mostRecentRequest.getBody()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void When_AddReferences_With_ObservationAsProblem_Expect_CodeAddedToCondi

conditionMapper.addReferences(buildBundleWithNamedStatementObservation(), conditions, ehrExtract);

var code = conditions.get(0).getCode().getCodingFirstRep();
var code = conditions.getFirst().getCode().getCodingFirstRep();

assertEquals(OBSERVATION_CONCEPT_DESCRIPTION, code.getDisplay());
assertEquals(OBSERVATION_CONCEPT_ID, code.getCode());
Expand All @@ -92,7 +92,7 @@ public void When_AddReferences_With_AllergyIntoleranceAsProblem_Expect_CodeAdded

conditionMapper.addReferences(buildBundleWithNamedStatementAllergy(), conditions, ehrExtract);

var code = conditions.get(0).getCode().getCoding().get(1);
var code = conditions.getFirst().getCode().getCoding().get(1);

assertEquals(ALLERGY_CONCEPT_DESCRIPTION, code.getDisplay());
assertEquals(ALLERGY_CONCEPT_ID, code.getCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public void When_MappingBundle_With_RepresentedOrganisation_Expect_OrganisationM
assertThat(practitioners.size()).isOne();
assertThat(practitionerRoles.size()).isOne();

var organisationId = organisations.get(0).getId();
var practitionerId = practitioners.get(0).getId();
var practitionerRole = practitionerRoles.get(0);
var organisationId = organisations.getFirst().getId();
var practitionerId = practitioners.getFirst().getId();
var practitionerRole = practitionerRoles.getFirst();

assertThat(practitionerRole.getPractitioner().getReferenceElement().getIdPart()).isEqualTo(practitionerId);
assertThat(practitionerRole.getOrganization().getReferenceElement().getIdPart()).isEqualTo(organisationId);
Expand All @@ -74,9 +74,9 @@ public void When_MappingBundle_With_DuplicateRepresentedOrganisations_Expect_Dup
assertThat(practitioners.size()).isEqualTo(2);
assertThat(practitionerRoles.size()).isEqualTo(2);

var organisationId = organisations.get(0).getId();
var organisationId = organisations.getFirst().getId();

assertThat(practitionerRoles.get(0).getOrganization().getReferenceElement().getIdPart())
assertThat(practitionerRoles.getFirst().getOrganization().getReferenceElement().getIdPart())
.isEqualTo(organisationId);

assertThat(practitionerRoles.get(1).getOrganization().getReferenceElement().getIdPart())
Expand All @@ -98,10 +98,10 @@ public void When_MappingBundle_With_Documents_Expect_OrganisationAdded() throws
assertThat(practitionerRoles.size()).isZero();
assertThat(documentReferences.size()).isOne();

var organisationId = organisations.get(0)
var organisationId = organisations.getFirst()
.getId();

var custodianId = documentReferences.get(0)
var custodianId = documentReferences.getFirst()
.getCustodian()
.getResource()
.getIdElement()
Expand Down Expand Up @@ -142,21 +142,21 @@ public void When_MappingBundle_With_DocumentsAndMatchingRepresentedOrganisation_
assertThat(practitionerRoles.size()).isOne();
assertThat(documentReferences.size()).isOne();

var organisationId = organisations.get(0)
var organisationId = organisations.getFirst()
.getId();

var custodianId = documentReferences.get(0)
var custodianId = documentReferences.getFirst()
.getCustodian()
.getResource()
.getIdElement()
.getIdPart();

assertThat(custodianId).isEqualTo(organisationId);

assertThat(practitionerRoles.get(0).getOrganization().getReferenceElement().getIdPart())
assertThat(practitionerRoles.getFirst().getOrganization().getReferenceElement().getIdPart())
.isEqualTo(organisationId);
assertThat(practitionerRoles.get(0).getPractitioner().getReferenceElement().getIdPart())
.isEqualTo(practitioners.get(0).getId());
assertThat(practitionerRoles.getFirst().getPractitioner().getReferenceElement().getIdPart())
.isEqualTo(practitioners.getFirst().getId());
}

@SneakyThrows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private void mapAgent(RCCTMT120101UK01Agent agent, List<DomainResource> agentRes
var agentPerson = agent.getAgentPerson();
var agentOrganization = agent.getAgentOrganization();
var representedOrganization = agent.getRepresentedOrganization();
var resourceId = agent.getId().get(0).getRoot();
var resourceId = agent.getId().getFirst().getRoot();
var gpNumber = agent.getId().size() > 1 ? agent.getId().get(1).getExtension() : "";

if (agentPerson != null && representedOrganization != null) {
Expand Down Expand Up @@ -198,15 +198,15 @@ private Organization addOrganisationAddressAndTelecomIfPresent(RCCTMT120101UK01O

private ContactPoint getOrganizationTelecom(List<TEL> telecomList) {
if (!telecomList.isEmpty()) {
return TelecomUtil.mapTelecom(telecomList.get(0));
return TelecomUtil.mapTelecom(telecomList.getFirst());
}

return null;
}

private Address getOrganizationAddress(List<AD> addressList) {
if (!addressList.isEmpty()) {
return AddressUtil.mapAddress(addressList.get(0));
return AddressUtil.mapAddress(addressList.getFirst());
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private Observation mapObservation(RCMRMT030101UKEhrComposition ehrComposition,
RCMRMT030101UKCompoundStatement compoundStatement, Patient patient, List<Encounter> encounters,
String practiseCode) {
var observationStatements = getObservationStatementsFromCompoundStatement(compoundStatement);
var id = compoundStatement.getId().get(0);
var id = compoundStatement.getId().getFirst();

Observation observation = new Observation()
.addIdentifier(buildIdentifier(id.getRoot(), practiseCode))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public List<Condition> mapResources(RCMRMT030101UKEhrExtract ehrExtract, Patient
}

private Condition getCondition(Patient patient, List<Encounter> encounters, RCMRMT030101UKEhrComposition composition,
RCMRMT030101UKLinkSet linkSet, String practiseCode) {
RCMRMT030101UKLinkSet linkSet, String practiceCode) {

String id = linkSet.getId().getRoot();

Expand All @@ -117,11 +117,7 @@ private Condition getCondition(Patient patient, List<Encounter> encounters, RCMR
composition.getConfidentialityCode()
);

Condition condition = (Condition) new Condition()
.addIdentifier(buildIdentifier(id, practiseCode))
.addCategory(generateCategory())
.setId(id)
.setMeta(meta);
Condition condition = initializeCondition(id, practiceCode, meta);

buildClinicalStatus(linkSet.getCode()).ifPresentOrElse(
condition::setClinicalStatus,
Expand All @@ -130,9 +126,9 @@ private Condition getCondition(Patient patient, List<Encounter> encounters, RCMR
condition.addNote(new Annotation(new StringType(DEFAULT_CLINICAL_STATUS)));
});

condition.setSubject(new Reference(patient));
condition.setSubject(new Reference(patient))
.addExtension(buildProblemSignificance(linkSet.getCode()));

condition.addExtension(buildProblemSignificance(linkSet.getCode()));
generateAnnotationToMinor(linkSet.getCode()).ifPresent(condition::addNote);

buildContext(composition, encounters).ifPresent(condition::setContext);
Expand All @@ -152,6 +148,14 @@ private Condition getCondition(Patient patient, List<Encounter> encounters, RCMR
return condition;
}

private Condition initializeCondition(String id, String practiceCode, Meta meta) {
return (Condition) new Condition()
.addIdentifier(buildIdentifier(id, practiceCode))
.addCategory(generateCategory())
.setId(id)
.setMeta(meta);
}

public void addHierarchyReferencesToConditions(List<Condition> conditions, RCMRMT030101UKEhrExtract ehrExtract) {
var allLinkSets = getCompositionsContainingLinkSets(ehrExtract).stream()
.flatMap(ehrComposition -> ehrComposition.getComponent().stream())
Expand Down Expand Up @@ -291,7 +295,7 @@ private Optional<Extension> buildActualProblem(Bundle bundle, RCMRMT030101UKStat
}

private boolean hasMajorCode(CD linkSetCode) {
return hasCode(linkSetCode) && MAJOR_CODE.equals(linkSetCode.getQualifier().get(0).getName().getCode());
return hasCode(linkSetCode) && MAJOR_CODE.equals(linkSetCode.getQualifier().getFirst().getName().getCode());
}

private Extension buildConditionReferenceExtension(String id, String heirarchyType) {
Expand Down Expand Up @@ -398,7 +402,7 @@ private Map<String, String> getMedicationStatementIdMapping(List<RCMRMT030101UKM

medicationStatements.forEach(medicationStatement -> {
var medicationStatementId = medicationStatement.getId().getRoot();
var moodCode = medicationStatement.getMoodCode().get(0);
var moodCode = medicationStatement.getMoodCode().getFirst();

switch (moodCode) {
case MEDICATION_MOOD_ORDER -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private String getConsultationId(String id) {

private String getConsultationTitle(List<CodeableConcept> codeableConceptList) {
if (!CollectionUtils.isEmpty(codeableConceptList)) {
var codeableConcept = codeableConceptList.get(0);
var codeableConcept = codeableConceptList.getFirst();
if (codeableConcept.hasText()) {
return codeableConcept.getText();
} else if (codeableConcept.getCodingFirstRep().hasDisplay()) {
Expand Down Expand Up @@ -110,7 +110,7 @@ public ListResource mapToTopic(ListResource consultation, RCMRMT030101UKCompound
}

private String getTopicId(RCMRMT030101UKCompoundStatement compoundStatement) {
return compoundStatement != null ? compoundStatement.getId().get(0).getRoot() : idGenerator.generateUuid();
return compoundStatement != null ? compoundStatement.getId().getFirst().getRoot() : idGenerator.generateUuid();
}

public ListResource mapToCategory(ListResource topic, RCMRMT030101UKCompoundStatement compoundStatement) {
Expand All @@ -127,7 +127,7 @@ public ListResource mapToCategory(ListResource topic, RCMRMT030101UKCompoundStat
.setOrderedBy(CodeableConceptUtils.createCodeableConcept(LIST_ORDERED_BY_CODE, LIST_ORDERED_BY_SYSTEM,
LIST_ORDERED_BY_DISPLAY, null))
.setMeta(generateMeta(LIST_META_PROFILE))
.setId(compoundStatement.getId().get(0).getRoot());
.setId(compoundStatement.getId().getFirst().getRoot());

return category;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private DocumentReference mapDocumentReference(RCMRMT030101UKNarrativeStatement

// document references actually use the narrative statement id rather than the referenceDocument root id in EMIS data
// if EMIS is incorrect, replace the id below with the following...
// narrativeStatement.getReference().get(0).getReferredToExternalDocument().getId().getRoot()
// narrativeStatement.getReference().getFirst().getReferredToExternalDocument().getId().getRoot()
var id = narrativeStatement.getId().getRoot();

documentReference.addIdentifier(buildIdentifier(id, organization.getIdentifierFirstRep().getValue()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ private static boolean areSameObservationStatements(RCMRMT030101UKObservationSta
}

private static RCMRMT030101UKAnnotation getPertinentAnnotation(RCMRMT030101UKObservationStatement linkedObservationStatement) {
return linkedObservationStatement.getPertinentInformation().get(0).getPertinentAnnotation();
return linkedObservationStatement.getPertinentInformation().getFirst().getPertinentAnnotation();
}

private static boolean hasSinglePertinentInformation(RCMRMT030101UKObservationStatement observation) {
return observation.getPertinentInformation().size() == 1
&& observation.getPertinentInformation().get(0).getSequenceNumber().getValue().intValueExact() == 1;
&& observation.getPertinentInformation().getFirst().getSequenceNumber().getValue().intValueExact() == 1;
}

private static boolean doesTruncatedAnnotationMatchOtherAnnotation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private List<RCMRMT030101UKCompoundStatement> getCategoryCompoundStatements(RCMR
}

private boolean hasValidCategoryCompoundStatement(RCMRMT030101UKCompoundStatement compoundStatement) {
return compoundStatement != null && CATEGORY_CLASS_CODE.equals(compoundStatement.getClassCode().get(0));
return compoundStatement != null && CATEGORY_CLASS_CODE.equals(compoundStatement.getClassCode().getFirst());
}

private List<RCMRMT030101UKEhrComposition> getEncounterEhrCompositions(RCMRMT030101UKEhrExtract ehrExtract) {
Expand Down Expand Up @@ -278,24 +278,31 @@ private List<RCMRMT030101UKCompoundStatement> getTopicCompoundStatements(RCMRMT0
}

private boolean hasValidTopicCompoundStatement(RCMRMT030101UKCompoundStatement compoundStatement) {
return compoundStatement != null && TOPIC_CLASS_CODE.equals(compoundStatement.getClassCode().get(0));
return compoundStatement != null && TOPIC_CLASS_CODE.equals(compoundStatement.getClassCode().getFirst());
}

private Encounter mapToEncounter(
RCMRMT030101UKEhrComposition ehrComposition,
Patient patient,
String practiseCode,
List<Location> entryLocations
) {
var id = ehrComposition.getId().getRoot();
RCMRMT030101UKEhrComposition ehrComposition,
Patient patient,
String practiseCode,
List<Location> entryLocations) {

var encounter = new Encounter();
var id = ehrComposition.getId().getRoot();

final Meta meta = confidentialityService.createMetaAndAddSecurityIfConfidentialityCodesPresent(
ENCOUNTER_META_PROFILE,
ehrComposition.getConfidentialityCode()
);

var encounter = initializeEncounter(ehrComposition, patient, practiseCode, id, meta);
setEncounterLocation(encounter, ehrComposition, entryLocations);

return encounter;
}

private Encounter initializeEncounter(RCMRMT030101UKEhrComposition ehrComposition, Patient patient,
String practiseCode, String id, Meta meta) {
var encounter = new Encounter();
encounter
.setParticipant(getParticipants(ehrComposition.getAuthor(), ehrComposition.getParticipant2()))
.setStatus(EncounterStatus.FINISHED)
Expand All @@ -305,9 +312,6 @@ private Encounter mapToEncounter(
.addIdentifier(buildIdentifier(id, practiseCode))
.setMeta(meta)
.setId(id);

setEncounterLocation(encounter, ehrComposition, entryLocations);

return encounter;
}

Expand Down
Loading

0 comments on commit ff24135

Please sign in to comment.