Search in sources :

Example 1 with NonAgentRole

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;
}
Also used : PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) NonAgentRole(uk.nhs.adaptors.scr.models.xml.NonAgentRole) FhirValidationException(uk.nhs.adaptors.scr.exceptions.FhirValidationException)

Aggregations

PractitionerRole (org.hl7.fhir.r4.model.PractitionerRole)1 FhirValidationException (uk.nhs.adaptors.scr.exceptions.FhirValidationException)1 NonAgentRole (uk.nhs.adaptors.scr.models.xml.NonAgentRole)1