Package uk.nhs.interoperability.payloads.exceptions

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


public class EndOfLifeCareDocumentParsingHelper {

  public static EndOfLifeCareISBFields getISBFields(ClinicalDocument document) {
    EndOfLifeCareISBFields fields = new EndOfLifeCareISBFields();
    ParsePayloadContentException parseExceptions = new ParsePayloadContentException();
   
    // Get overall document fields
    getDocumentFields(fields, document, parseExceptions);
   
    // Patient
    TemplateParsingHelper.getPatientFields(fields, document.getPatient(), parseExceptions);

    // Custodian (Organisation hosting the EPaCCS)
    if (document.getCustodianOrganisation() != null) {
      String className = ((Payload)(document.getCustodianOrganisation())).getClassName();
      if (className.equals("CustodianOrganizationUniversal")) {
        getCustodianFields(fields, (CustodianOrganizationUniversal)document.getCustodianOrganisation(), parseExceptions);
      }
    }

    // Loop through coded sections, extracting values
    List<CodedSections> codedSections = document.getCodedSections();
    for (CodedSections s : codedSections) {
      CodedSection codedSection = s.getCodedEntry();
      String className = ((Payload)codedSection).getClassName();
     
      // End of life care plan
      if (className.equals("EoLCarePlan")) {
        EoLCarePlan eolcp = (EoLCarePlan)codedSection;
        getEoLCPFields(fields, eolcp, parseExceptions);
      }
     
      // Advance decision to refuse treatment
      if (className.equals("AdvanceDecisionToRefuseTreatment")) {
        AdvanceDecisionToRefuseTreatment adrt = (AdvanceDecisionToRefuseTreatment)codedSection;
        getADRTFields(fields, adrt, parseExceptions);
      }
     
      // Anticipatory medicine box
      if (className.equals("AnticipatoryMedicineBoxIssueProcedure")) {
        AnticipatoryMedicineBoxIssueProcedure ambox = (AnticipatoryMedicineBoxIssueProcedure)codedSection;
        getAMBoxFields(fields, ambox, parseExceptions);
      }
     
      // DNACPR Decision
      if (className.equals("DNACPRDecisionbySeniorResponsibleClinician")) {
        DNACPRDecisionbySeniorResponsibleClinician dnacpr = (DNACPRDecisionbySeniorResponsibleClinician)codedSection;
        getDNACPRFields(fields, dnacpr, parseExceptions);
      }
     
      // Main informal carer awareness of prognosis
      if (className.equals("PrognosisAwareness")) {
        PrognosisAwareness aware = (PrognosisAwareness)codedSection;
        getPrognosisAwarenessFields(fields, aware, parseExceptions);
      }
     
      // Authority to Lasting Power of Attorney
      if (className.equals("AuthoritytoLastingPowerofAttorney")) {
        AuthoritytoLastingPowerofAttorney lpa = (AuthoritytoLastingPowerofAttorney)codedSection;
        getLPAFields(fields, lpa, parseExceptions);
      }
    }
   
    // Loop through text sections, extracting values
    List<TextSections> textSections = document.getTextSections();
    for (TextSections s : textSections) {
      TextSection section = s.getTextSection();
     
      // NOTE: Currently we unfortunately have to rely on the titles to find the right sections. This
      // will improve in a later release, which will have reliable identifiers for each text section to
      // allow us to extract the values more safely.
      if (section.getTitle().equals("Patient Choices")) {
        for (Section2 section2 : section.getSection2()) {
          if (section2.getTitle().equals("First preferred place of death")) {
            // ARGH - Can't parse this all back out to separate fields..
          }
          else if (section2.getTitle().equals("Second preferred place of death")) {
            // ARGH - Can't parse this all back out to separate fields..
          }
          else if (section2.getTitle().equals("Other Relevant Issues or Preferences about Provision of Care")) {
            fields.setOtherRelevantInformation(section2.getText());
          }
        }
      }
      else if (section.getTitle().equals("End of Life Care Observations")) {
        for (Section2 section2 : section.getSection2()) {
          if (section2.getTitle().equals("Primary EoLC Diagnosis")) {
            fields.setPrimaryEOLCDiagnosis(section2.getText());
          }
          else if (section2.getTitle().equals("Other EoLC Diagnosis")) {
            fields.setOtherRelevantDiagnoses(section2.getText());
          }
          else if (section2.getTitle().equals("Disabilities")) {
            fields.setPatientDisability(section2.getText());
          }
          else if (section2.getTitle().equals("Allergies and Adverse Reaction Summary")) {
            fields.setAllergiesAndAdverseReactions(section2.getText());
          }
        }
      }
      else if (section.getTitle().equals("EPaCCS Record Location")) {
        fields.setEPaCCSURL(section.getText());
      }
      else if (section.getTitle().equals("Advance Statements")) {
        fields.setAdvanceStatements(section.getText());
      }
    }
   
    if (parseExceptions.hasEntries()) {
      System.out.println("Errors: " + parseExceptions.toString());
    }
    return fields;
   
  }
View Full Code Here

TOP

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

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.