public static DNACPRDecisionbySeniorResponsibleClinician createDNACPR(EndOfLifeCareISBFields isbFields) throws MissingMandatoryFieldException {
// If no DNACPR Decision included, skip this
if (isbFields.getDNACPR() == null) {
return null;
}
MissingMandatoryFieldException missingFields = new MissingMandatoryFieldException();
// Null checks for mandatory fields
// If we have a DNACPR Decision, we also need a senior responsible clinician name
if (isbFields.getSeniorResponsibleClinicianName() == null) {
missingFields.addMissingField("SeniorResponsibleClinicianName", "If a DNACPR decision is included, the senior responsible clinician name is also required");
}
// We also need the senior responsible clinician org id
if (isbFields.getSeniorResponsibleClinicianORGID() == null) {
missingFields.addMissingField("SeniorResponsibleClinicianORGID", "If a DNACPR decision is included, the senior responsible clinician's organisation (ODS) ID is also required");
}
// We also need the senior responsible clinician org name
if (isbFields.getSeniorResponsibleClinicianORGName() == null) {
missingFields.addMissingField("SeniorResponsibleClinicianORGName", "If a DNACPR decision is included, the senior responsible clinician's organisation name is also required");
}
// We also need the date of the decision
if (isbFields.getDNACPRDate() == null) {
missingFields.addMissingField("DNACPRDate", "If a DNACPR decision is included, the date the decision was made is also required");
}
// We also need the date the decision was recorded
if (isbFields.getDNACPRCreatedDate() == null) {
missingFields.addMissingField("DNACPRCreatedDate", "If a DNACPR decision is included, the date the decision was originally recorded is also required");
}
if (missingFields.hasEntries()) {
throw missingFields;
}
DNACPRDecisionbySeniorResponsibleClinician template = new DNACPRDecisionbySeniorResponsibleClinician();