use of uk.nhs.adaptors.scr.models.xml.NonAgentRole in project summary-care-record-api by NHSDigital.
the class ParticipantAgentMapper method mapInformant.
public static Participant.Informant mapInformant(Bundle bundle, EncounterParticipantComponent encounterParticipant) {
var informant = new Participant.Informant();
informant.setTime(formatDateToHl7(encounterParticipant.getPeriod().getStartElement()));
var participantType = encounterParticipant.getIndividual().getReference().split("/")[0];
if (PractitionerRole.class.getSimpleName().equals(participantType)) {
setParticipantAgents(bundle, encounterParticipant.getIndividual(), informant);
} else if (RelatedPerson.class.getSimpleName().equals(participantType)) {
var relatedPerson = getResourceByReference(bundle, encounterParticipant.getIndividual().getReference(), RelatedPerson.class).orElseThrow(() -> new FhirValidationException(String.format("Bundle is missing RelatedPerson %s that is linked to Encounter", encounterParticipant.getIndividual().getReference())));
var participantNonAgentRole = new NonAgentRole("participantNonAgentRole");
setRelationship(relatedPerson, participantNonAgentRole);
setRelatedPersonName(relatedPerson, participantNonAgentRole);
informant.setParticipantNonAgentRole(participantNonAgentRole);
} else {
throw new FhirValidationException(String.format("Invalid Encounter participant type %s", participantType));
}
return informant;
}
Aggregations