Class CDAR2Extractor

java.lang.Object
org.projecthusky.common.communication.CDAR2Extractor
Direct Known Subclasses:
CDAR2ExtractorAt

public class CDAR2Extractor extends Object
Extracts XDS Document Entry Metadata from generic CDA R2 document
Author:
Sarah Knoop
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    CDA R2 document object
  • Constructor Summary

    Constructors
    Constructor
    Description
    Loads CDA Document
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
    Checks to see if the list has at least one element.
    org.openehealth.ipf.commons.ihe.xds.core.metadata.DocumentEntry
    Entry point to invoke extraction process.
    org.openehealth.ipf.commons.ihe.xds.core.metadata.Person
    Extracts authorPerson from CDAR2 of type AssignedAuthor expected.
    List<org.openehealth.ipf.commons.ihe.xds.core.metadata.Author>
    Extracts the relevant authorInstitution, authorPerson, authorRole and authorSpeciality information from the author list in the CDA:
    ClinicalDocument/author/assignedAuthor/id and
    ClinicalDocument/author/assignedAuthor/assignedPerson/name
    org.openehealth.ipf.commons.ihe.xds.core.metadata.AvailabilityStatus
    CDA R2 document header does not contain information corresponding to availablity status metadata.
    org.openehealth.ipf.commons.ihe.xds.core.metadata.Code
    Extracts the relevant classCode information from the CDA: ClinicalDocument/code.
    org.openehealth.ipf.commons.ihe.xds.core.metadata.LocalizedString
    CDA R2 document header does not contain information corresponding to comments metadata.
    List<org.openehealth.ipf.commons.ihe.xds.core.metadata.Code>
    Extracts the relevant confidentialityCodes information from the CDA: ClinicalDocument/confidentialityCode.
    org.openehealth.ipf.commons.ihe.xds.core.metadata.Timestamp
    Extracts the relevant creationTime information from the CDA: ClinicalDocument/effectiveTime.
    DocumentEntry.entryUUID is an XDS specific attribute and outside the scope of any CDA R2 document.
    List<org.openehealth.ipf.commons.ihe.xds.core.metadata.Code>
    This extraction routine, at this point, does not attempt to extract event code metadata from a generic CDA R2 document.
    This extraction routine, at this point, does not attempt to extract extension metadata from a generic CDA R2 document.
    org.openehealth.ipf.commons.ihe.xds.core.metadata.Code
    DocumentEntry.formatCode is an XDS specific attribute and outside the scope of any CDA R2 document.
    DocumentEntry.hash is a comptuted value and outside the scope of any CDA R2 document.
    org.openehealth.ipf.commons.ihe.xds.core.metadata.Code
    Extracts the relevant healthcareFacilityTypeCode information from the CDA: ClinicalDocument/componentOf/encompassingEncounter/location/code.
    Extracts the relevant languageCode information from the CDA: ClinicalDocument/languageCode
    org.openehealth.ipf.commons.ihe.xds.core.metadata.Person
    Extracts the relevant legalAuthenticator information from the CDA: ClinicalDocument/legalAuthenticator/assignedEntity/id and ClinicalDocument/legalAuthenticator/assignedEntity/assignedPerson/name
    NOTES: 1.
    DocumentEntry.mimeType is an XDS specific attribute and outside the scope of any CDA R2 document.
    org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable
    DocumentEntry.parentDocument expresses the id and relationship of a parent document to this CDA document in the XDS Regisry.
    DocumentEntry.repositoryUniqueId is an XDS specific attribute and outside the scope of any CDA R2 document.
    org.openehealth.ipf.commons.ihe.xds.core.metadata.Timestamp
    Extracts the relevant serviceStartTime information from the CDA: ClinicalDocument/documentationOf/serviceEvent/effectiveTime This time is to be in UTC, but without the timezone offset or fractional seconds: [[[[[YYYY]MM]DD]HH]mm]ss].
    org.openehealth.ipf.commons.ihe.xds.core.metadata.Timestamp
    Extracts the relevant serviceStopTime information from the CDA: ClinicalDocument/documentationOf/serviceEvent/effectiveTime This time is to be in UTC, but without the timezone offset or fractional seconds: [[[[[YYYY]MM]DD]HH]mm]ss].
    DocumentEntry.size is a comptuted value and outside the scope of any CDA R2 document.
    org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable
    Extracts the relevant sourcePatientId information from the CDA: ClinicalDocument/recordTarget/patientRole/id
    NOTES: 1.
    org.openehealth.ipf.commons.ihe.xds.core.metadata.PatientInfo
    Extracts the relevant sourcePatientInfo information from the CDA: ClinicalDocument/recordTarget/patientRole
    NOTES: 1.
    org.openehealth.ipf.commons.ihe.xds.core.metadata.LocalizedString
    Extracts the relevant title, Implementation consistent with PCC TF-2 Medical Document Binding to XDS, XDM and XDR.
    org.openehealth.ipf.commons.ihe.xds.core.metadata.Code
    Extracts the relevant typeCode.
    Extracts the relevant uniqueId.
    DocumentEntry.URI is a comptuted value and outside the scope of any CDA R2 document.
    protected org.openehealth.ipf.commons.ihe.xds.core.metadata.Address
    map(AD addr)
    Maps CDA R2 AD datatype to the OHT model version of the HL7 v2.5 XAD data type NOTES: 1.
    protected org.openehealth.ipf.commons.ihe.xds.core.metadata.Code
    map(CD docCode)
    Maps from document code CD (or children CE, CS1) to a CodedMetadataType
    protected org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable
    map(II id)
    Maps CDA R2 II data type to components to the OHT model version of a HL7 v2.5 CX data type NOTES: 1.
    protected org.openehealth.ipf.commons.ihe.xds.core.metadata.Person
    map(II id, PN name)
    Maps CDA R2 II and PN datatypes to the OHT model version of the HL7 v2.5 XCN data type.
    protected org.openehealth.ipf.commons.ihe.xds.core.metadata.Organization
    map(ON name, II id)
    Maps CDA R2 II and ON datatypes to the OHT model version of the HL7 v2.5 XON data type.
    protected org.openehealth.ipf.commons.ihe.xds.core.metadata.XpnName
    map(PN name)
    Maps CDA R2 PN datatype to the OHT model version of the HL7 v2.5 XPN data type.
    protected org.openehealth.ipf.commons.ihe.xds.core.metadata.Telecom
    map(TEL tel)
    Maps CDA R2 TEL type to the OHT model version of the Hl7 v2.5 XTN data type.
    protected org.openehealth.ipf.commons.ihe.xds.core.metadata.XcnName
    mapXcn(PN name)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • CDAR2Extractor

      public CDAR2Extractor(POCDMT000040ClinicalDocument cda)
      Loads CDA Document
      Parameters:
      cda - the CDA R2 document to extract metadata from for the document entry metadata. Cannot be null.
  • Method Details

    • extract

      public org.openehealth.ipf.commons.ihe.xds.core.metadata.DocumentEntry extract() throws MetadataExtractionException
      Entry point to invoke extraction process.
      NOTES:
      • 1. Only the first ClinicalDocument/documentationOf instance will be considered for it's ServiceEvent time to fill values for serviceStartTime and serviceStopTime
      • 2. Only the first ClinicalDocument/recordTarget instance will be considered for sourcePatientId (for which only the first patientRole/id on it's list will be taken) and sourcePatientInfo .
      • 3. XDS metadata does not accept CX types that have more or fewer components than CX.1, CX.4.2,CX.4.3. Other corresponding componets will not be extracted.
      • 4. XDS metadata validation for 2007 Connectathon will not accept DTM types beyond precision of YYYYMMDDHHMMSS. Precision has been truncated on values that include fractional seconds or time zone corrections
      • 5. XDS metadata validation for 2007 Connectathon will not accept SourcePatientInfo beyond local patient ids, patient name, address, birthdate and gender. Other patient info in the CDA that corresponds to source patient info will not be extracted.
      Throws:
      MetadataExtractionException
    • extractAuthors

      public List<org.openehealth.ipf.commons.ihe.xds.core.metadata.Author> extractAuthors()
      Extracts the relevant authorInstitution, authorPerson, authorRole and authorSpeciality information from the author list in the CDA:
      ClinicalDocument/author/assignedAuthor/id and
      ClinicalDocument/author/assignedAuthor/assignedPerson/name
    • extractAvailabilityStatus

      public org.openehealth.ipf.commons.ihe.xds.core.metadata.AvailabilityStatus extractAvailabilityStatus()
      CDA R2 document header does not contain information corresponding to availablity status metadata.
      Returns:
      null
    • extractClassCode

      public org.openehealth.ipf.commons.ihe.xds.core.metadata.Code extractClassCode()
      Extracts the relevant classCode information from the CDA: ClinicalDocument/code. Implementation consistent with PCC TF-2 Medical Document Binding to XDS, XDM and XDR.
      Note: typeCode and classCode data sources are the same in the CDA
    • extractComments

      public org.openehealth.ipf.commons.ihe.xds.core.metadata.LocalizedString extractComments()
      CDA R2 document header does not contain information corresponding to comments metadata.
      Returns:
      null
    • extractConfidentialityCodes

      public List<org.openehealth.ipf.commons.ihe.xds.core.metadata.Code> extractConfidentialityCodes()
      Extracts the relevant confidentialityCodes information from the CDA: ClinicalDocument/confidentialityCode. Implementation consistent with PCC TF-2 Medical Document Binding to XDS, XDM and XDR.
    • extractCreationTime

      public org.openehealth.ipf.commons.ihe.xds.core.metadata.Timestamp extractCreationTime()
      Extracts the relevant creationTime information from the CDA: ClinicalDocument/effectiveTime. This time is to be in UTC, but without the timezone offset or fractional seconds: [[[[[YYYY]MM]DD]HH]mm]ss]. Thus, this time is assumed to be in GMT. So, if the timestamp in the corresponding CDA element contains the timezone offset, this method will convert the timestamp to GMT. If the timezone offset is ommitted, then the timestamp is assumed to be in GMT. Implementation consistent with PCC TF-2 Medical Document Binding to XDS, XDM and XDR.
    • extractEntryUUID

      public String extractEntryUUID()
      DocumentEntry.entryUUID is an XDS specific attribute and outside the scope of any CDA R2 document. Thus, it cannot be extracted.
      Returns:
      null
    • extractEventCodes

      public List<org.openehealth.ipf.commons.ihe.xds.core.metadata.Code> extractEventCodes()
      This extraction routine, at this point, does not attempt to extract event code metadata from a generic CDA R2 document.
      Returns:
      null
    • extractExtensions

      public Map<String,List<String>> extractExtensions()
      This extraction routine, at this point, does not attempt to extract extension metadata from a generic CDA R2 document.
      Returns:
      null
    • extractFormatCode

      public org.openehealth.ipf.commons.ihe.xds.core.metadata.Code extractFormatCode()
      DocumentEntry.formatCode is an XDS specific attribute and outside the scope of any CDA R2 document. Thus, it cannot be extracted.
      Returns:
      null
    • extractHash

      public String extractHash()
      DocumentEntry.hash is a comptuted value and outside the scope of any CDA R2 document. Thus, it cannot be extracted.
      Returns:
      null
    • extractHealthCareFacilityTypeCode

      public org.openehealth.ipf.commons.ihe.xds.core.metadata.Code extractHealthCareFacilityTypeCode()
      Extracts the relevant healthcareFacilityTypeCode information from the CDA: ClinicalDocument/componentOf/encompassingEncounter/location/code. Per the CDA specification this code, when present shall be consistent with ClinicalDocument/code. Thus, implementation consistent with PCC TF-2 Medical Document Binding to XDS, XDM and XDR.
      Note: healthcareFacilityTypeCode and practiceSettingCode data sources are the same in the CDA
    • extractLanguageCode

      public String extractLanguageCode()
      Extracts the relevant languageCode information from the CDA: ClinicalDocument/languageCode
    • extractLegalAuthenticator

      public org.openehealth.ipf.commons.ihe.xds.core.metadata.Person extractLegalAuthenticator()
      Extracts the relevant legalAuthenticator information from the CDA: ClinicalDocument/legalAuthenticator/assignedEntity/id and ClinicalDocument/legalAuthenticator/assignedEntity/assignedPerson/name
      NOTES:
      • 1. Only the first ClinicalDocument/legalAuthenticator/assignedEntity/id instance and first ClinicalDocument/legalAuthenticator/assignedEntity/assignedPerson/name instance will be considered for values for the legal authenticator XCN
      • 2. Implementation consistent with PCC TF-2 Medical Document Binding to XDS, XDM and XDR.
    • extractMimeType

      public String extractMimeType()
      DocumentEntry.mimeType is an XDS specific attribute and outside the scope of any CDA R2 document. Thus, it cannot be extracted.
      Returns:
      null
    • extractParentDocument

      public org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable extractParentDocument()
      DocumentEntry.parentDocument expresses the id and relationship of a parent document to this CDA document in the XDS Regisry. This is not necessairly the same parent document that is documented within the CDA. Thus, this information is not extracted.
      Returns:
      null
    • extractRepositoryUniqueId

      public String extractRepositoryUniqueId()
      DocumentEntry.repositoryUniqueId is an XDS specific attribute and outside the scope of any CDA R2 document. Thus, it cannot be extracted.
      Returns:
      null
    • extractServiceStartTime

      public org.openehealth.ipf.commons.ihe.xds.core.metadata.Timestamp extractServiceStartTime()
      Extracts the relevant serviceStartTime information from the CDA: ClinicalDocument/documentationOf/serviceEvent/effectiveTime This time is to be in UTC, but without the timezone offset or fractional seconds: [[[[[YYYY]MM]DD]HH]mm]ss]. Thus, this time is assumed to be in GMT. So, if the timestamp in the corresponding CDA element contains the timezone offset, this method will convert the timestamp to GMT. If the timezone offset is ommitted, then the timestamp is assumed to be in GMT. NOTES:
      • 1. Finds the minimum low time among ClinicalDocument/documentationOf/serviceEvent/effectiveTime instance will be for serviceStartTime.
      • 2. XDS metadata validation for 2007 Connectathon will not accept DTM types beyond precision of YYYYMMDDHHMMSS. Precision has been truncated on values that include fractional seconds or time zone corrections. Time is in UTC.
      • 3. Implementation consistent with PCC TF-2 Medical Document Binding to XDS, XDM and XDR.
    • extractServiceStopTime

      public org.openehealth.ipf.commons.ihe.xds.core.metadata.Timestamp extractServiceStopTime()
      Extracts the relevant serviceStopTime information from the CDA: ClinicalDocument/documentationOf/serviceEvent/effectiveTime This time is to be in UTC, but without the timezone offset or fractional seconds: [[[[[YYYY]MM]DD]HH]mm]ss]. Thus, this time is assumed to be in GMT. So, if the timestamp in the corresponding CDA element contains the timezone offset, this method will convert the timestamp to GMT. If the timezone offset is ommitted, then the timestamp is assumed to be in GMT.
      NOTES:
      • 1. Finds the maximum high time among ClinicalDocument/documentationOf/serviceEvent/effectiveTime instance will be for serviceStartTime.
      • 2. XDS metadata validation for 2007 Connectathon will not accept DTM types beyond precision of YYYYMMDDHHMMSS. Precision has been truncated on values that include fractional seconds or time zone corrections. Time is in UTC.
      • 3.Implementation consistent with PCC TF-2 Medical Document Binding to XDS, XDM and XDR.
    • extractSize

      public Long extractSize()
      DocumentEntry.size is a comptuted value and outside the scope of any CDA R2 document. Thus, it cannot be extracted.
      Returns:
      null
    • extractSourcePatientId

      public org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable extractSourcePatientId()
      Extracts the relevant sourcePatientId information from the CDA: ClinicalDocument/recordTarget/patientRole/id
      NOTES:
      • 1. Only the first ClinicalDocument/recordTarget instance will be considered for sourcePatientId (for which only the first patientRole/id on it's list will be taken) and sourcePatientInfo .
      • 2. XDS metadata does not accept CX types that have more or fewer components than CX.1, CX.4.2,CX.4.3. Other corresponding componets will not be extracted.
      • 3. Implementation consistent with PCC TF-2 Medical Document Binding to XDS, XDM and XDR.
    • extractSourcePatientInfo

      public org.openehealth.ipf.commons.ihe.xds.core.metadata.PatientInfo extractSourcePatientInfo()
      Extracts the relevant sourcePatientInfo information from the CDA: ClinicalDocument/recordTarget/patientRole
      NOTES:
      • 1. Only the first ClinicalDocument/recordTarget instance will be considered for sourcePatientId (for which only the first patientRole/id on it's list will be taken) and sourcePatientInfo .
      • 2. Extracts all id of the list of ids for PatientRole to PID-3 and the PatientRole/Patient/id
      • 3. XDS metadata does not accept CX types that have more or fewer components than CX.1, CX.4.2,CX.4.3. Other corresponding componets will not be extracted.
      • 4. XDS metadata validation for 2007 Connectathon will not accept SourcePatientInfo beyond local patient ids, patient name, address, birthdate and gender. Other patient info in the CDA that corresponds to source patient info will not be extracted.
      • 5.Only the first address will be considered for extraction, only the first subelements of the AD type will be considered for extraction.
      • 6. Implementation consistent with PCC TF-2 Medical Document Binding to XDS, XDM and XDR.
    • extractTitle

      public org.openehealth.ipf.commons.ihe.xds.core.metadata.LocalizedString extractTitle()
      Extracts the relevant title, Implementation consistent with PCC TF-2 Medical Document Binding to XDS, XDM and XDR. information from the CDA: ClinicalDocument/title
    • extractTypeCode

      public org.openehealth.ipf.commons.ihe.xds.core.metadata.Code extractTypeCode()
      Extracts the relevant typeCode. Implementation consistent with PCC TF-2 Medical Document Binding to XDS, XDM and XDR. information from the CDA: ClinicalDocument/code
      Note: typeCode and classCode data sources are the same in the CDA
    • extractUniqueId

      public String extractUniqueId()
      Extracts the relevant uniqueId. Implementation consistent with PCC TF-2 Medical Document Binding to XDS, XDM and XDR. information from the CDA: ClinicalDocument/id (format is id@root^id@extension)
    • extractURI

      public String extractURI()
      DocumentEntry.URI is a comptuted value and outside the scope of any CDA R2 document. Thus, it cannot be extracted.
      Returns:
      null
    • extractAuthorPerson

      public org.openehealth.ipf.commons.ihe.xds.core.metadata.Person extractAuthorPerson(POCDMT000040AssignedAuthor aAuth)
      Extracts authorPerson from CDAR2 of type AssignedAuthor expected.
      • NOTES:
      • 1. only the first id of the list of ids is extracted for XCN.1, XCN.9.1, XCN.9.2
      • 2. only the first person name of the assignedAuthor/assignedPerson name list (and first entries in the sub lists) are extracted and processed for XCN.2 to XCN.6
      • 3. Implementation consistent with PCC TF-2 Medical Document Binding to XDS, XDM and XDR
      Parameters:
      aAuth - ClinicalDocument/author/assignedAuthor/ object
      Returns:
      Returns null if author cannot be extracted
    • atLeastOne

      protected boolean atLeastOne(List<?> l)
      Checks to see if the list has at least one element.
      Parameters:
      l -
      Returns:
      false if l is null, if l.size() < 1 or if l.get(0) is null. Otherwise, return true.
    • map

      protected org.openehealth.ipf.commons.ihe.xds.core.metadata.Address map(AD addr)
      Maps CDA R2 AD datatype to the OHT model version of the HL7 v2.5 XAD data type
      • NOTES:
      • 1. only the first entries in the sub lists for address parts are extracted and processed for XAD.1.1, XAD.2 through XAD.6
      • 2. XAD.9 is not extracted at this point due to IHE restrictions on metadata, could be enabled in the future.
      Parameters:
      addr -
      Returns:
    • map

      protected org.openehealth.ipf.commons.ihe.xds.core.metadata.Code map(CD docCode)
      Maps from document code CD (or children CE, CS1) to a CodedMetadataType
      Parameters:
      docCode -
      Returns:
    • map

      protected org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable map(II id)
      Maps CDA R2 II data type to components to the OHT model version of a HL7 v2.5 CX data type
      • NOTES:
      • 1. Always sets CX.4.3 to "ISO"
      • 2. XDS metadata does not accept CX types that have more or fewer components than CX.1, CX.4.2,CX.4.3. Other corresponding componets will not be extracted. (ie. will not extract assigningAuthorityName attribute from II type)
      Parameters:
      id -
      Returns:
    • map

      protected org.openehealth.ipf.commons.ihe.xds.core.metadata.Person map(II id, PN name)
      Maps CDA R2 II and PN datatypes to the OHT model version of the HL7 v2.5 XCN data type. Implementation consistent with PCC TF-2 Medical Document Binding to XDS, XDM and XDR.
      Parameters:
      id -
      name -
      Returns:
    • map

      protected org.openehealth.ipf.commons.ihe.xds.core.metadata.Organization map(ON name, II id)
      Maps CDA R2 II and ON datatypes to the OHT model version of the HL7 v2.5 XON data type. Implementation consistent with PCC TF-2 Medical Document Binding to XDS, XDM and XDR, pending resolution to ITI CP 316.
      Parameters:
      id -
      name -
      Returns:
    • map

      protected org.openehealth.ipf.commons.ihe.xds.core.metadata.XpnName map(PN name)
      Maps CDA R2 PN datatype to the OHT model version of the HL7 v2.5 XPN data type.
      • NOTES:
      • 1. only the first entries in the sub lists for name parts are extracted and processed for XPN.1 to XPN.5
      Parameters:
      name -
      Returns:
    • mapXcn

      protected org.openehealth.ipf.commons.ihe.xds.core.metadata.XcnName mapXcn(PN name)
    • map

      protected org.openehealth.ipf.commons.ihe.xds.core.metadata.Telecom map(TEL tel)
      Maps CDA R2 TEL type to the OHT model version of the Hl7 v2.5 XTN data type.
      Parameters:
      tel -
      Returns: