documentRoot = (DocumentRoot) clinicalDocument.eContainer(); nodeToObject.put(document, documentRoot); objectToNode.put(documentRoot, document);
public static void testDS(String fileName) { new StringBuffer(); String path = "samples/"; ConsolPackage.eINSTANCE.eClass(); ValidationResult result = new ValidationResult(); try { ClinicalDocument clinicalDocument = CDAUtil.load((new FileInputStream(path + fileName + ".xml")), result); System.out.println(clinicalDocument); System.out.println(clinicalDocument.getAllSections().size()); for (Object j : clinicalDocument.getAllSections()) { System.out.println(j); } } catch (Exception e) { e.printStackTrace(); } }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ public static void setStructuredBody(ClinicalDocument clinicalDocument, StructuredBody structuredBody) { Component2 component = clinicalDocument.getComponent(); if (component == null) { component = CDAFactory.eINSTANCE.createComponent2(); clinicalDocument.setComponent(component); } component.setStructuredBody(structuredBody); }
doc.setTypeId(typeId); doc.setId(id); doc.getTemplateIds().add(templateId); doc.setCode(code); doc.setTitle(title); doc.setEffectiveTime(effectiveTime); doc.setConfidentialityCode(confidentialityCode); doc.getRecordTargets().add(recordTarget); doc.getAuthors().add(author);
private static XMLResource prepare(ClinicalDocument clinicalDocument, boolean defaults) { if (defaults) { handleDefaults(clinicalDocument); } XMLResource resource = (XMLResource) clinicalDocument.eResource(); if (resource == null) { resource = (XMLResource) createResourceSet().createResource(URI.createURI(CDAPackage.eNS_URI)); DocumentRoot root = CDAFactory.eINSTANCE.createDocumentRoot(); root.setClinicalDocument(clinicalDocument); root.getXMLNSPrefixMap().put("", CDAPackage.eNS_URI); root.getXSISchemaLocation().put(CDAPackage.eNS_URI, "CDA.xsd"); resource.getContents().add(root); } else { DocumentRoot root = (DocumentRoot) clinicalDocument.eContainer(); List<String> keys = new ArrayList<String>(); for (Map.Entry<String, String> entry : root.getXMLNSPrefixMap().entrySet()) { if (EPackage.Registry.INSTANCE.keySet().contains(entry.getValue())) { keys.add(entry.getKey()); } } for (String key : keys) { root.getXMLNSPrefixMap().removeKey(key); } root.getXMLNSPrefixMap().put("", CDAPackage.eNS_URI); } return resource; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ public static void addPatientRole(ClinicalDocument clinicalDocument, PatientRole patientRole) { RecordTarget recordTarget = CDAFactory.eINSTANCE.createRecordTarget(); recordTarget.setPatientRole(patientRole); clinicalDocument.getRecordTargets().add(recordTarget); }
public static List<Section> getAllSections(ClinicalDocument clinicalDocument) { List<Section> allSections = new ArrayList<Section>(); Component2 component2 = clinicalDocument.getComponent(); if (component2 != null) { StructuredBody structuredBody = component2.getStructuredBody(); if (structuredBody != null) { for (Component3 component3 : structuredBody.getComponents()) { Section section = component3.getSection(); if (section != null) { allSections.addAll(getSections(section)); } } } } return allSections; }
public static boolean validate(ClinicalDocument clinicalDocument, ValidationHandler handler, boolean defaults) { if (defaults) { handleDefaults(clinicalDocument); } if (clinicalDocument.eResource() != null) { // process diagnostics that were produced during EMF deserialization processDiagnostic(EcoreUtil.computeDiagnostic(clinicalDocument.eResource(), true), handler); } Diagnostic diagnostic = Diagnostician.INSTANCE.validate(clinicalDocument); if (handler != null) { processDiagnostic(diagnostic, handler); } return diagnostic.getSeverity() != Diagnostic.ERROR; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ public static void addPatient(ClinicalDocument clinicalDocument, Patient patient) { RecordTarget recordTarget = CDAFactory.eINSTANCE.createRecordTarget(); PatientRole patientRole = CDAFactory.eINSTANCE.createPatientRole(); recordTarget.setPatientRole(patientRole); patientRole.setPatient(patient); clinicalDocument.getRecordTargets().add(recordTarget); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ public static void addSection(ClinicalDocument clinicalDocument, Section section) { Component2 component2 = clinicalDocument.getComponent(); if (component2 == null) { component2 = CDAFactory.eINSTANCE.createComponent2(); clinicalDocument.setComponent(component2); } StructuredBody structuredBody = component2.getStructuredBody(); if (structuredBody == null) { structuredBody = CDAFactory.eINSTANCE.createStructuredBody(); component2.setStructuredBody(structuredBody); } Component3 component3 = CDAFactory.eINSTANCE.createComponent3(); component3.setSection(section); structuredBody.getComponents().add(component3); }