Package uk.nhs.interoperability.payloads.childscreeningv2

Examples of uk.nhs.interoperability.payloads.childscreeningv2.CodedSections


import uk.nhs.interoperability.payloads.vocabularies.internal.TelecomUseType;

public class ChildScreeningDocumentCreationHelper {

  public static ClinicalDocument createDocument(ChildScreeningFields childScreeningFields) 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.setConfidentialityCode(x_BasicConfidentialityKind._N);
   
    // If no record effective date/time specified, assume the current date/time
    if (childScreeningFields.getDocumentCreationDate() == null) {
      template.setEffectiveTime(currentDateTime);
    } else {
      template.setEffectiveTime(childScreeningFields.getDocumentCreationDate());
    }
   
    // If no document set ID provided, generate a new one
    if (childScreeningFields.getDocumentSetId() != null) {
      template.setDocumentSetId(childScreeningFields.getDocumentSetId());
    } else {
      template.setDocumentSetId(CDAUUID.generateUUIDString());
    }
   
    // Version defaults to 1 unless set to a different integer value
    template.setDocumentVersionNumber(String.valueOf(childScreeningFields.getDocumentVersionNumber()));
   
   
    // Child Patient
    try {
      ChildPatientUniversal patient = createPatient(childScreeningFields);
      template.setChildPatient(patient);
    } catch (MissingMandatoryFieldException e) {
      missingFields.addMissingFields(e);
    }
   
    // Author
    if (childScreeningFields.getDocumentAuthoredTime() == null) {
      template.setTimeAuthored(currentDateTime);
    } else {
      template.setTimeAuthored(childScreeningFields.getDocumentAuthoredTime());
    }
   
    try {
      AuthorPersonUniversal author = createAuthor(childScreeningFields);
      template.setAuthor(author);
    } catch (MissingMandatoryFieldException e) {
      missingFields.addMissingFields(e);
    }
   
    // Custodian (Organisation hosting the EPaCCS)
    try {
      CustodianOrganizationUniversal custodian = createCustodian(childScreeningFields);
      template.setCustodianOrganisation(custodian);
    } catch (MissingMandatoryFieldException e) {
      missingFields.addMissingFields(e);
    }
   
    // Recipients
   
    // Having at least one recipient is mandatory
    if (childScreeningFields.getRecipients()==null) {
      missingFields.addMissingField("recipients", "At least one recipient must be provided");
    } else if (childScreeningFields.getRecipients().size()==0) {
      missingFields.addMissingField("recipients", "At least one recipient must be provided");
    } else {
      // Primary Recipients
      for (DocumentRecipient recipient : childScreeningFields.getRecipients()) {
        try {
          Recipient r = createRecipient(recipient);
          template.addPrimaryRecipients(
                new PrimaryRecipient().setRecipient(r));
        } catch (MissingMandatoryFieldException e) {
          missingFields.addMissingFields(e);
        }
      }
      // Copy Recipients
      if (childScreeningFields.getCopyRecipients() != null) {
        for (DocumentRecipient recipient : childScreeningFields.getCopyRecipients()) {
          try {
            Recipient r = createRecipient(recipient);
            template.addInformationOnlyRecipients(
                  new InformationOnlyRecipient().setRecipient(r));
          } catch (MissingMandatoryFieldException e) {
            missingFields.addMissingFields(e);
          }
        }
      }
    }
   
    // Consent
    if (childScreeningFields.getConsent() != null) {
      template.setAuthorizingConsent(new Consent()
                          .setConsentCode(childScreeningFields.getConsent())
                          .addID(new ConsentID(CDAUUID.generateUUIDString())));
    }

    // ==== Now create the coded sections ====
   
    // Blood Spot Screening
    try {
      BloodSpotScreening bloodspot = createBloodSpotScreening(childScreeningFields);
      if (bloodspot != null) {
        template.addCodedSections(new CodedSections(bloodspot));
      }
    } catch (MissingMandatoryFieldException e) {
      missingFields.addMissingFields(e);
    }
   
    // New Born Birth Details
    try {
      NewBornBirthDetails birthdetails = createBirthDetails(childScreeningFields);
      if (birthdetails != null) {
        template.addCodedSections(new CodedSections(birthdetails));
      }
    } catch (MissingMandatoryFieldException e) {
      missingFields.addMissingFields(e);
    }
   
    // Hearing Screening
    try {
      NewBornHearingScreening hearing = createHearingScreening(childScreeningFields);
      if (hearing != null) {
        template.addCodedSections(new CodedSections(hearing));
      }
    } catch (MissingMandatoryFieldException e) {
      missingFields.addMissingFields(e);
    }
   
    // Hearing Screening
    try {
      NewBornPhysicalExamination physical = createPhysicalExam(childScreeningFields);
      if (physical != null) {
        template.addCodedSections(new CodedSections(physical));
      }
    } catch (MissingMandatoryFieldException e) {
      missingFields.addMissingFields(e);
    }
   
    // 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());
   
    TextSection ts1 = createTextSection_Guardian(childScreeningFields);
    if (ts1 != null) template.addTextSections(new TextSections(ts1));
   
    TextSection ts2 = createTextSection_NewBornBirthDetails(childScreeningFields);
    if (ts2 != null) template.addTextSections(new TextSections(ts2));

   
   
    return template;
  }
View Full Code Here


   
    // Blood Spot Screening
    try {
      BloodSpotScreening bloodspot = createBloodSpotScreening(childScreeningFields);
      if (bloodspot != null) {
        template.addCodedSections(new CodedSections(bloodspot));
      }
    } catch (MissingMandatoryFieldException e) {
      missingFields.addMissingFields(e);
    }
   
    // New Born Birth Details
    try {
      NewBornBirthDetails birthdetails = createBirthDetails(childScreeningFields);
      if (birthdetails != null) {
        template.addCodedSections(new CodedSections(birthdetails));
      }
    } catch (MissingMandatoryFieldException e) {
      missingFields.addMissingFields(e);
    }
   
    // Hearing Screening
    try {
      NewBornHearingScreening hearing = createHearingScreening(childScreeningFields);
      if (hearing != null) {
        template.addCodedSections(new CodedSections(hearing));
      }
    } catch (MissingMandatoryFieldException e) {
      missingFields.addMissingFields(e);
    }
   
    // Hearing Screening
    try {
      NewBornPhysicalExamination physical = createPhysicalExam(childScreeningFields);
      if (physical != null) {
        template.addCodedSections(new CodedSections(physical));
      }
    } catch (MissingMandatoryFieldException e) {
      missingFields.addMissingFields(e);
    }
   
View Full Code Here

      if (childScreeningFields.getCopyRecipients() != null) {
        for (DocumentRecipient recipient : childScreeningFields.getCopyRecipients()) {
          try {
            Recipient r = createRecipient(recipient);
            template.addInformationOnlyRecipients(
                  new InformationOnlyRecipient().setRecipient(r));
          } catch (MissingMandatoryFieldException e) {
            missingFields.addMissingFields(e);
          }
        }
      }
View Full Code Here

      // Primary Recipients
      for (DocumentRecipient recipient : childScreeningFields.getRecipients()) {
        try {
          Recipient r = createRecipient(recipient);
          template.addPrimaryRecipients(
                new PrimaryRecipient().setRecipient(r));
        } catch (MissingMandatoryFieldException e) {
          missingFields.addMissingFields(e);
        }
      }
      // Copy Recipients
View Full Code Here

   
    // ==== Now create the text sections ====
    template.setMainDocumentSectionID(CDAUUID.generateUUIDString());
   
    TextSection ts1 = createTextSection_Guardian(childScreeningFields);
    if (ts1 != null) template.addTextSections(new TextSections(ts1));
   
    TextSection ts2 = createTextSection_NewBornBirthDetails(childScreeningFields);
    if (ts2 != null) template.addTextSections(new TextSections(ts2));

   
   
    return template;
  }
View Full Code Here

TOP

Related Classes of uk.nhs.interoperability.payloads.childscreeningv2.CodedSections

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.