use of uk.nhs.adaptors.scr.exceptions.FhirValidationException in project summary-care-record-api by NHSDigital.
the class AlertRequestValidator method checkSubtype.
private void checkSubtype(List<Coding> subtypes) {
if (subtypes.size() != 1) {
throw new FhirValidationException("Expecting exactly one 'subtype' element");
}
Coding subtype = subtypes.get(0);
if (!SUBTYPE_SYSTEM.equals(subtype.getSystem())) {
throw new FhirValidationException("Invalid or missing value in field 'subtype.system'. Supported value is: " + SUBTYPE_SYSTEM);
}
if (!SUBTYPE_CODES.contains(subtype.getCode())) {
throw new FhirValidationException("Invalid or missing value in field 'subtype.code'. Supported values are: " + SUBTYPE_CODES.stream().collect(joining(", ")));
}
checkNotEmpty(subtype.getDisplay(), "Missing value 'subtype.display'");
}
use of uk.nhs.adaptors.scr.exceptions.FhirValidationException in project summary-care-record-api by NHSDigital.
the class ParticipantAgentMapper method mapAuthor1.
public static Participant.Author1 mapAuthor1(Bundle bundle, EncounterParticipantComponent encounterParticipant) {
var author = new Participant.Author1();
author.setTime(formatDateToHl7(encounterParticipant.getPeriod().getStartElement()));
var practitionerRoleReference = encounterParticipant.getIndividual().getReference();
var practitionerRole = getResourceByReference(bundle, practitionerRoleReference, PractitionerRole.class).orElseThrow(() -> new FhirValidationException(String.format("Bundle is missing PractitionerRole %s that is linked to Encounter", practitionerRoleReference)));
if (StringUtils.isNotBlank(practitionerRole.getOrganization().getReference())) {
setAgentDevice(bundle, practitionerRole.getOrganization(), author);
} else if (StringUtils.isNotBlank(practitionerRole.getPractitioner().getReference())) {
setParticipantAgents(bundle, practitionerRole.getPractitioner(), author);
}
return author;
}
use of uk.nhs.adaptors.scr.exceptions.FhirValidationException in project summary-care-record-api by NHSDigital.
the class ParticipantAgentMapper method setDeviceCoding.
private static void setDeviceCoding(org.hl7.fhir.r4.model.Device fhirDevice, Device agentDevice1) {
CodeableConcept type = fhirDevice.getType();
Coding coding = type.getCodingFirstRep();
if (!type.isEmpty() && isNotEmpty(coding.getCode()) && isNotEmpty(coding.getDisplay())) {
agentDevice1.setCodeCode(coding.getCode());
agentDevice1.setCodeDisplayName(coding.getDisplay());
} else {
throw new FhirValidationException("Missing mandatory elements: Device.type");
}
}
use of uk.nhs.adaptors.scr.exceptions.FhirValidationException in project summary-care-record-api by NHSDigital.
the class ParticipantAgentMapper method setRelationship.
private static void setRelationship(RelatedPerson relatedPerson, NonAgentRole participantNonAgentRole) {
Coding relationshipCoding = relatedPerson.getRelationshipFirstRep().getCodingFirstRep();
if (!RELATIONSHIP_TYPE_SYSTEM.equals(relationshipCoding.getSystem())) {
throw new FhirValidationException("Unsupported RelatedPerson.relationship.coding.system: " + relationshipCoding.getSystem());
}
if (!relationshipCoding.hasCode()) {
throw new FhirValidationException("Missing RelatedPerson.relationship.coding.code element");
}
if (!relationshipCoding.hasDisplay()) {
throw new FhirValidationException("Missing RelatedPerson.relationship.coding.display element");
}
participantNonAgentRole.setCodeCode(relationshipCoding.getCode());
participantNonAgentRole.setCodeDisplayName(relationshipCoding.getDisplay());
}
use of uk.nhs.adaptors.scr.exceptions.FhirValidationException in project summary-care-record-api by NHSDigital.
the class PatientMapper method mapPatient.
public static void mapPatient(GpSummary gpSummary, Bundle bundle) throws FhirMappingException {
Patient patient = getDomainResource(bundle, Patient.class);
setPatientIds(gpSummary, patient);
var composition = getDomainResource(bundle, Composition.class);
if (!composition.hasSubject() || !patient.getId().contains(composition.getSubject().getReference())) {
throw new FhirValidationException("Composition.subject reference is missing or invalid");
}
}
Aggregations