Package uk.nhs.interoperability.payloads.exceptions

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


   
    return template;
  }
 
  public static PatientUniversal createPatient(NonCodedCDACommonFields commonFields) throws MissingMandatoryFieldException {
    MissingMandatoryFieldException missingFields = new MissingMandatoryFieldException();
   
    // Null checks for mandatory fields
    if (commonFields.getPatientNHSNoIsTraced() == null) {
      missingFields.addMissingField("PatientNHSNoIsTraced", "The tracing status for the NHS number must be provided");
    }
    if (commonFields.getPatientNHSNo() == null) {
      missingFields.addMissingField("PatientNHSNo", "The patient's NHS number must be provided");
    }
    if (commonFields.getPatientAddress() == null) {
      missingFields.addMissingField("PatientAddress", "The patient's address must be provided");
    }
    if (commonFields.getPatientName() == null) {
      missingFields.addMissingField("PatientName", "The patient's name must be provided");
    }
    if (commonFields.getPatientGender() == null) {
      missingFields.addMissingField("PatientGender", "The patient's gender must be provided");
    }
    if (commonFields.getPatientBirthDate() == null) {
      missingFields.addMissingField("PatientBirthDate", "The patient's date of birth must be provided");
    }
    if (commonFields.getUsualGPODSCode() == null) {
      missingFields.addMissingField("UsualGPODSCode", "The usual GP's ODS Code must be provided");
    }
    if (commonFields.getUsualGPOrgName() == null) {
      missingFields.addMissingField("UsualGPOrgName", "The usual GP's organisation 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(NonCodedCDACommonFields commonFields) throws MissingMandatoryFieldException {
    MissingMandatoryFieldException missingFields = new MissingMandatoryFieldException();
   
    // Null checks for mandatory fields
    if (commonFields.getDocumentAuthorSDSID() == null) {
      missingFields.addMissingField("DocumentAuthorSDSID", "The SDS ID of the document author must be provided");
    }
    if (commonFields.getDocumentAuthorRole() == null) {
      missingFields.addMissingField("DocumentAuthorRole", "The job role of the document author must be provided");
    }
    if (commonFields.getDocumentAuthorName() == null) {
      missingFields.addMissingField("DocumentAuthorName", "The name of the document author must be provided");
    }
    if (commonFields.getDocumentAuthorOrganisationODSID() == null) {
      missingFields.addMissingField("DocumentAuthorOrganisationODSID", "The ID of the organisation the document author belongs to must be provided");
    }
    if (commonFields.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();
    
View Full Code Here

   
    return template;
  }
 
  public static PersonUniversal createDataEnterer(NonCodedCDACommonFields commonFields) throws MissingMandatoryFieldException {
    MissingMandatoryFieldException missingFields = new MissingMandatoryFieldException();
    // Null checks for mandatory fields
    if (commonFields.getDataEntererSDSID() == null) {
      missingFields.addMissingField("dataEntererSDSID", "The SDS ID of the data enterer must be provided");
    }
    if (commonFields.getDataEntererSDSRoleID() == null) {
      missingFields.addMissingField("dataEntererSDSRoleID", "The SDS Role ID of the data enterer must be provided");
    }
    if (commonFields.getDataEntererName() == null) {
      missingFields.addMissingField("dataEntererName", "The name of the data enterer must be provided");
    }
    if (missingFields.hasEntries()) {
      throw missingFields;
    }
   
    PersonUniversal template = new PersonUniversal();
    // SDS ID
View Full Code Here

public class EndOfLifeCareDocumentCreationCDGRSHelper {

  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

    // If no prognosis awareness has been given, exit
    if (isbFields.getMainInformalCarerAwareOfPrognosis() == null) {
      return null;
    }
   
    MissingMandatoryFieldException missingFields = new MissingMandatoryFieldException();
    // Null checks for mandatory fields
    // If we have a prognosis awareness for the main informal carer, we need to know who the main informal carer is (name)
    if (isbFields.getMainInformalCarerName() == null) {
      missingFields.addMissingField("MainInformalCarerName", "In order to indicate the main informal carer's awareness of the prognosis, you must also include the name of the main informal carer");
    }
    // We also need to know when the prognosis awareness was recorded
    if (isbFields.getPrognosisAwarenessRecordedDate() == null) {
      missingFields.addMissingField("PrognosisAwarenessRecordedDate", "In order to indicate the main informal carer's awareness of the prognosis, you must also include the date this awareness was recorded");
    }
   
    if (missingFields.hasEntries()) {
      throw missingFields;
    }
   
    PrognosisAwareness template = new PrognosisAwareness();
   
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.