Package uk.nhs.interoperability.payloads.exceptions

Examples of uk.nhs.interoperability.payloads.exceptions.MissingMandatoryFieldException


    }

    AdvanceDecisionToRefuseTreatment template = new AdvanceDecisionToRefuseTreatment();
    template.setID(CDAUUID.generateUUIDString());
   
    MissingMandatoryFieldException missingFields = new MissingMandatoryFieldException();
    // Null checks for mandatory fields
    // If we have an ADRT, we need an effective time
    if (isbFields.getADRTRecordedDate() == null) {
      missingFields.addMissingField("ADRTRecordedDate", "If an ADRT is provided, the date this was recorded is also required");
    }
    // We also need to know where the ADRT documents are held
    if (isbFields.getADRTDocumentLocation() == null) {
      missingFields.addMissingField("ADRTDocumentLocation", "If an ADRT is provided, the location of the ADRT documentation is also required");
    }
   
    if (missingFields.hasEntries()) {
      throw missingFields;
    }
   
    // Time recorded
    template.setEffectiveTime(isbFields.getADRTRecordedDate());
View Full Code Here


  public static AnticipatoryMedicineBoxIssueProcedure createAMBox(EndOfLifeCareISBFields isbFields) throws MissingMandatoryFieldException {
    // If no anticipatory medication issued, skip this
    if (!isbFields.isAnticipatoryMedicinesIssued()) {
      return null;
    }
    MissingMandatoryFieldException missingFields = new MissingMandatoryFieldException();
    // Null checks for mandatory fields
    // If we have an anticipatory medicine box, we need a time issued
    if (isbFields.getAnticipatoryMedicinesDateIssued() == null) {
      missingFields.addMissingField("AnticipatoryMedicinesDateIssued", "If an anticipatory medicine box has been issued, the date it was issued is required");
    }
    // We also need to know where the ADRT documents are held
    if (isbFields.getAnticipatoryMedicinesLocation() == null) {
      missingFields.addMissingField("AnticipatoryMedicinesLocation", "If an anticipatory medicine box has been issued, the location of the box is required");
    }
    if (missingFields.hasEntries()) {
      throw missingFields;
    }
   
    AnticipatoryMedicineBoxIssueProcedure template = new AnticipatoryMedicineBoxIssueProcedure();
    template.setID(CDAUUID.generateUUIDString());
View Full Code Here

  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();
View Full Code Here

  public static AuthoritytoLastingPowerofAttorney createLPA(EndOfLifeCareISBFields isbFields) throws MissingMandatoryFieldException {
    // If no DNACPR Decision included, skip this
    if (isbFields.getLPAAuthority() == null) {
      return null;
    }
    MissingMandatoryFieldException missingFields = new MissingMandatoryFieldException();
    // Null checks for mandatory fields
    // If we have an LPA authority we also need a name for the LPA
    if (isbFields.getLPAName() == null) {
      missingFields.addMissingField("LPAName", "If an LPA authority is included, the name of the LPA is also required");
    }
    if (isbFields.getLPADate() == null) {
      missingFields.addMissingField("LPADate", "If an LPA authority is included, the date the LPA was granted is also required");
    }
    if (missingFields.hasEntries()) {
      throw missingFields;
    }
   
    AuthoritytoLastingPowerofAttorney template = new AuthoritytoLastingPowerofAttorney();
    template.setID(CDAUUID.generateUUIDString());
View Full Code Here

public class EndOfLifeCareDocumentCreationHelper {

  public static ClinicalDocument createDocument(EndOfLifeCareISBFields isbFields) throws MissingMandatoryFieldException {
    ClinicalDocument template = new ClinicalDocument();
    MissingMandatoryFieldException missingFields = new MissingMandatoryFieldException();
    DateValue currentDateTime = new DateValue(new Date(), DatePrecision.Minutes);
   
    // ==== We will assume some things and set them accordingly ====
    template.setDocumentId(CDAUUID.generateUUIDString());
    template.setDocumentTitle("End of Life Care Coordination Summary");
    template.setConfidentialityCode(x_BasicConfidentialityKind._N);
   
    // If no record effective date/time specified, assume the current date/time
    if (isbFields.getDocumentCreationDate() == null) {
      template.setEffectiveTime(currentDateTime);
    } else {
      template.setEffectiveTime(isbFields.getDocumentCreationDate());
    }
   
    // If no document set ID provided, generate a new one
    if (isbFields.getDocumentSetId() != null) {
      template.setDocumentSetId(isbFields.getDocumentSetId());
    } else {
      template.setDocumentSetId(CDAUUID.generateUUIDString());
    }
   
    // Version defaults to 1 unless set to a different integer value
    template.setDocumentVersionNumber(String.valueOf(isbFields.getDocumentVersionNumber()));
   
    // Patient
    try {
      PatientUniversal patient = createPatient(isbFields);
      template.setPatient(patient);
    } catch (MissingMandatoryFieldException e) {
      missingFields.addMissingFields(e);
    }
   
    // Author
    if (isbFields.getDocumentAuthoredTime() == null) {
      template.setTimeAuthored(currentDateTime);
    } else {
      template.setTimeAuthored(isbFields.getDocumentAuthoredTime());
    }
   
    try {
      AuthorPersonUniversal author = createAuthor(isbFields);
      template.setAuthor(author);
    } catch (MissingMandatoryFieldException e) {
      missingFields.addMissingFields(e);
    }
   
    // Custodian (Organisation hosting the EPaCCS)
    try {
      CustodianOrganizationUniversal custodian = createCustodian(isbFields);
      template.setCustodianOrganisation(custodian);
    } catch (MissingMandatoryFieldException e) {
      missingFields.addMissingFields(e);
    }
   
    // Recipients - this is not part of the core ISB data set, and may not be
    // relevant depending on how the EPaCCS works (e.g. send document on-demand), so
    // we won't do anything with recipients in this helper. These can easily be added
    // to the document afterwards by calling the relevant methods.

    // ==== Now create the coded sections ====
    EoLCarePlan carePlan;
    AdvanceDecisionToRefuseTreatment adrt;
    AnticipatoryMedicineBoxIssueProcedure ambox;
    DNACPRDecisionbySeniorResponsibleClinician dnacpr;
    PrognosisAwareness prognosis;
    AuthoritytoLastingPowerofAttorney lpa;
   
    // End of Life Care Plan
    try {
      carePlan = createEoLCarePlan(isbFields);
      template.addCodedSections(new CodedSections(carePlan));
    } catch (MissingMandatoryFieldException e) {
      missingFields.addMissingFields(e);
    }

    // Advance decision to refuse treatment
    try {
      adrt = createADRT(isbFields);
      if (adrt != null) {
        template.addCodedSections(new CodedSections(adrt));
      }
    } catch (MissingMandatoryFieldException e) {
      missingFields.addMissingFields(e);
    }

    // Anticipatory medicine box
    try {
      ambox = createAMBox(isbFields);
      if (ambox != null) {
        template.addCodedSections(new CodedSections(ambox));
      }
    } catch (MissingMandatoryFieldException e) {
      missingFields.addMissingFields(e);
    }
   
    // DNACPR Decision
    try {
      dnacpr = createDNACPR(isbFields);
      if (dnacpr != null) {
        template.addCodedSections(new CodedSections(dnacpr));
      }
    } catch (MissingMandatoryFieldException e) {
      missingFields.addMissingFields(e);
    }
   
    // Main informal carer awareness of prognosis
    try {
      prognosis = createPrognosisAwareness(isbFields);
      if (prognosis != null) {
        template.addCodedSections(new CodedSections(prognosis));
      }
    } catch (MissingMandatoryFieldException e) {
      missingFields.addMissingFields(e);
    }
   
    // Authority to Lasting Power of Attorney
    try {
      lpa = createLPA(isbFields);
      if (lpa != null) {
        template.addCodedSections(new CodedSections(lpa));
      }
    } catch (MissingMandatoryFieldException e) {
      missingFields.addMissingFields(e);
    }
   
    // Additional mandatory field checks for text sections
    if (isbFields.getPrimaryEOLCDiagnosis() == null) {
      missingFields.addMissingField("PrimaryEOLCDiagnosis", "A primary EOLC Diagnosis must be provided");
    }

    // We have done all the checks on mandatory fields, so if there are any
    // errors, throw them up to the caller
    if (missingFields.hasEntries()) {
      throw missingFields;
    }
   
    // ==== Now create the text sections ====
    template.setMainDocumentSectionID(CDAUUID.generateUUIDString());
View Full Code Here

   
    return template;
  }
 
  public static PatientUniversal createPatient(EndOfLifeCareISBFields isbFields) throws MissingMandatoryFieldException {
    MissingMandatoryFieldException missingFields = new MissingMandatoryFieldException();
   
    // Null checks for mandatory fields
    if (isbFields.getPatientNHSNoIsTraced() == null) {
      missingFields.addMissingField("PatientNHSNoIsTraced", "The tracing status for the NHS number must be provided");
    }
    if (isbFields.getPatientNHSNo() == null) {
      missingFields.addMissingField("PatientNHSNo", "The patient's NHS number must be provided");
    }
    if (isbFields.getPatientAddress() == null) {
      missingFields.addMissingField("PatientAddress", "The patient's address must be provided");
    }
    if (isbFields.getPatientName() == null) {
      missingFields.addMissingField("PatientName", "The patient's name must be provided");
    }
    if (isbFields.getPatientGender() == null) {
      missingFields.addMissingField("PatientGender", "The patient's gender must be provided");
    }
    if (isbFields.getPatientBirthDate() == null) {
      missingFields.addMissingField("PatientBirthDate", "The patient's date of birth must be provided");
    }
    if (isbFields.getUsualGPODSCode() == null) {
      missingFields.addMissingField("UsualGPODSCode", "The usual GP's ODS Code must be provided");
    }
    if (isbFields.getUsualGPOrgName() == null) {
      missingFields.addMissingField("UsualGPOrgName", "The usual GP's organisation name must be provided");
    }
    if (isbFields.getUsualGPName() == null) {
      missingFields.addMissingField("UsualGPName", "The usual GP's name must be provided");
    }
    if (missingFields.hasEntries()) {
      throw missingFields;
    }
   
    PatientUniversal template = new PatientUniversal();
    // NHS Number and trace status
View Full Code Here

   
    return template;
  }
 
  public static AuthorPersonUniversal createAuthor(EndOfLifeCareISBFields isbFields) throws MissingMandatoryFieldException {
    MissingMandatoryFieldException missingFields = new MissingMandatoryFieldException();
   
    // Null checks for mandatory fields
    if (isbFields.getDocumentAuthorSDSID() == null) {
      missingFields.addMissingField("DocumentAuthorSDSID", "The SDS ID of the document author must be provided");
    }
    if (isbFields.getDocumentAuthorRole() == null) {
      missingFields.addMissingField("DocumentAuthorRole", "The job role of the document author must be provided");
    }
    if (isbFields.getDocumentAuthorName() == null) {
      missingFields.addMissingField("DocumentAuthorName", "The name of the document author must be provided");
    }
    if (isbFields.getDocumentAuthorOrganisationODSID() == null) {
      missingFields.addMissingField("DocumentAuthorOrganisationODSID", "The ID of the organisation the document author belongs to must be provided");
    }
    if (isbFields.getDocumentAuthorOrganisationName() == null) {
      missingFields.addMissingField("DocumentAuthorOrganisationName", "The name of the organisation the document author belongs to must be provided");
    }
    if (missingFields.hasEntries()) {
      throw missingFields;
    }
   
    AuthorPersonUniversal template = new AuthorPersonUniversal();
     // Author SID ID
View Full Code Here

   
    return template;
  }
 
  public static CustodianOrganizationUniversal createCustodian(EndOfLifeCareISBFields isbFields) throws MissingMandatoryFieldException {
    MissingMandatoryFieldException missingFields = new MissingMandatoryFieldException();
    // Null checks for mandatory fields
    if (isbFields.getEPACCSOrganisationODSID() == null) {
      missingFields.addMissingField("EPACCSOrganisationODSID", "The ODS ID of the organisation hosting the EOL record must be provided");
    }
    if (isbFields.getEPACCSOrganisation() == null) {
      missingFields.addMissingField("EPACCSOrganisation", "The name of the organisation hosting the EOL record must be provided");
    }
    if (missingFields.hasEntries()) {
      throw missingFields;
    }
   
    CustodianOrganizationUniversal template = new CustodianOrganizationUniversal();
   
View Full Code Here

   
    return template;
  }
 
  public static EoLCarePlan createEoLCarePlan(EndOfLifeCareISBFields isbFields) throws MissingMandatoryFieldException {
    MissingMandatoryFieldException missingFields = new MissingMandatoryFieldException();
    EoLCarePlan template = new EoLCarePlan();
   
    // Null checks for mandatory fields
    if (isbFields.getEpaccsRecordCreationDate() == null) {
      missingFields.addMissingField("EpaccsRecordCreationDate", "The creation date of the EPaCCS record must be provided");
    }
    // This may be an error in the DMS, so may not be mandatory in a later release
    if (isbFields.getEolcTool() == null) {
      missingFields.addMissingField("EolcTool", "The EOLC tool that is in use must be provided (e.g. LCP, PPC, GSF)");
    }
   
    // If any of the original EPaCCS author fields exist, check the mandatory author fields also exist
    boolean time = (isbFields.getEpaccsRecordAuthoredDate() != null);
    boolean add = (isbFields.getEpaccsRecordAuthorAddress() != null);
    boolean role = (isbFields.getEpaccsRecordAuthorRole() != null);
    boolean id = (isbFields.getEpaccsRecordAuthorSDSID() != null);
    boolean tel = (isbFields.getEpaccsRecordAuthorTelephone() != null);
    boolean name = (isbFields.getEpaccsRecordAuthorName() != null);
    boolean orgid = (isbFields.getEpaccsRecordAuthorOrganisationODSID() != null);
    boolean org = (isbFields.getEpaccsRecordAuthorOrganisationName() != null);
    boolean originalEPaCCSAuthorProvided = (time || add || role || id || tel || name || orgid || org);
    if (originalEPaCCSAuthorProvided) {
      if (!time) {
        missingFields.addMissingField("EpaccsRecordAuthoredDate", "If specifying the original EPaCCS author, the original authoring date must be provided");
      }
      if (!id) {
        missingFields.addMissingField("EpaccsRecordAuthorSDSID", "If specifying the original EPaCCS author, the original author's SDS ID must be provided");
      }
      if (!name) {
        missingFields.addMissingField("EpaccsRecordAuthorName", "If specifying the original EPaCCS author, the original author's name must be provided");
      }
      if (!orgid) {
        missingFields.addMissingField("EpaccsRecordAuthorOrganisationODSID", "If specifying the original EPaCCS author, the original author's organisation ODS ID must be provided");
      }
      if (!org) {
        missingFields.addMissingField("EpaccsRecordAuthorOrganisationName", "If specifying the original EPaCCS author, the original author's organisation name must be provided");
      }
    }
   
    // If any of the EPaCCS last amending author fields exist, check the mandatory author fields also exist
    boolean latime = (isbFields.getEpaccsRecordUpdatedDate() != null);
    boolean laadd = (isbFields.getEpaccsRecordUpdateAuthorAddress() != null);
    boolean larole = (isbFields.getEpaccsRecordUpdateAuthorRole() != null);
    boolean laid = (isbFields.getEpaccsRecordUpdateAuthorSDSID() != null);
    boolean latel = (isbFields.getEpaccsRecordUpdateAuthorTelephone() != null);
    boolean laname = (isbFields.getEpaccsRecordUpdateAuthorName() != null);
    boolean laorgid = (isbFields.getEpaccsRecordUpdateAuthorOrganisationODSID() != null);
    boolean laorg = (isbFields.getEpaccsRecordUpdateAuthorOrganisationName() != null);
    boolean laEPaCCSAuthorProvided = (latime || laadd || larole || laid || latel || laname || laorgid || laorg);
    if (laEPaCCSAuthorProvided) {
      if (!latime) {
        missingFields.addMissingField("EpaccsRecordUpdatedDate", "If specifying the last updating EPaCCS author, the last updated date must be provided");
      }
      if (!laid) {
        missingFields.addMissingField("EpaccsRecordUpdateAuthorSDSID", "If specifying the last updating EPaCCS author, the last updating author's SDS ID must be provided");
      }
      if (!laname) {
        missingFields.addMissingField("EpaccsRecordUpdateAuthorName", "If specifying the last updating EPaCCS author, the last updating author's name must be provided");
      }
      if (!laorgid) {
        missingFields.addMissingField("EpaccsRecordUpdateAuthorOrganisationODSID", "If specifying the last updating EPaCCS author, the last updating author's organisation ODS ID must be provided");
      }
      if (!laorg) {
        missingFields.addMissingField("EpaccsRecordUpdateAuthorOrganisationName", "If specifying the last updating EPaCCS author, the last updating author's organisation name must be provided");
      }
    }

    // Related persons - call this first so we can collate any other missing mandatory fields
    try {
      template.addPatientRelationships(new EOLPatientRelationships(createRelatedPersons(isbFields)));
    } catch (MissingMandatoryFieldException e) {
      missingFields.addMissingFields(e);
    }
     
    if (missingFields.hasEntries()) {
      throw missingFields;
    }

    // ================== Now set the values ==================
   
View Full Code Here

   * @param isbFields Fields to set in document
   * @return PatientRelationships
   * @throws MissingMandatoryFieldException Thrown if mandatory fields have not been provided, contains a list of missing fields.
   */
  public static PatientRelationships createRelatedPersons(EndOfLifeCareISBFields isbFields) throws MissingMandatoryFieldException {
    MissingMandatoryFieldException missingFields = new MissingMandatoryFieldException();
    // Null checks for mandatory fields
    // Check any formal carers provided at least have names
     List<EndOfLifeCareDocumentFormalCarer> carerlist = isbFields.getFormalCarers();
     if (carerlist != null) {
       for (EndOfLifeCareDocumentFormalCarer carerentry : carerlist) {
         if (carerentry.getName() == null) {
           missingFields.addMissingField("FormalCarers", "If specifying a formal carer, the name of the carer must be provided");
         }
       }
     }
   
    if (missingFields.hasEntries()) {
      throw missingFields;
   
   
    PatientRelationships template = new PatientRelationships();
   
View Full Code Here

TOP

Related Classes of uk.nhs.interoperability.payloads.exceptions.MissingMandatoryFieldException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.