protected void makeDocument() throws Exception { composition = (Composition) ResourceFactory.createResource("Composition"); addReference(composition, "Composition", makeUUIDReference()); Element title = cda.getChild(doc, "title"); composition.setTitle(title.getTextContent()); if (cda.getChild(doc, "setId") != null) { feed.setId(convert.makeURIfromII(cda.getChild(doc, "id"))); composition.setIdentifier(convert.makeIdentifierFromII(cda.getChild(doc, "setId"))); } else composition.setIdentifier(convert.makeIdentifierFromII(cda.getChild(doc, "id"))); // well, we fall back to id composition.setDateElement(convert.makeDateTimeFromTS(cda.getChild(doc, "effectiveTime"))); composition.setType(convert.makeCodeableConceptFromCD(cda.getChild(doc, "code"))); composition.setConfidentiality(convertConfidentiality(cda.getChild(doc, "confidentialityCode"))); if (cda.getChild(doc, "confidentialityCode") != null) composition.setLanguage(cda.getChild(doc, "confidentialityCode").getAttribute("value")); // todo - fix streaming for this Element ee = cda.getChild(doc, "componentOf"); if (ee != null) ee = cda.getChild(ee, "encompassingEncounter"); if (ee != null) { Encounter visit = new Encounter(); for (Element e : cda.getChildren(ee, "id")) visit.getIdentifier().add(convert.makeIdentifierFromII(e)); visit.setPeriod(convert.makePeriodFromIVL(cda.getChild(ee, "effectiveTime"))); composition.getEvent().add(new Composition.CompositionEventComponent()); composition.getEvent().get(0).getCode().add(convert.makeCodeableConceptFromCD(cda.getChild(ee, "code"))); composition.getEvent().get(0).setPeriod(visit.getPeriod()); composition.getEvent().get(0).getDetail().add(Factory.makeReference(addReference(visit, "Encounter", makeUUIDReference()))); } // main todo: fill out the narrative, but before we can do that, we have to convert everything else }
public Bundle convert(InputStream stream) throws Exception { cda = new CDAUtilities(stream); doc = cda.getElement(); cda.checkTemplateId(doc, "2.16.840.1.113883.10.20.22.1.1"); convert = new Convert(cda, ucumSvc, "Z"); // check it's a CDA/CCD feed = new Bundle(); feed.setMeta(new Meta().setLastUpdatedElement(InstantType.now())); feed.setId(makeUUIDReference()); feed.getMeta().getTag().add(new Coding()); // todo-bundle ("http://hl7.org/fhir/tag", "http://hl7.org/fhir/tag/document", "Document")); // process the header makeDocument(); composition.setSubject(Factory.makeReference(makeSubject())); for (Element e : cda.getChildren(doc, "author")) composition.getAuthor().add(Factory.makeReference(makeAuthor(e))); // todo: data enterer & informant goes in provenance composition.setCustodian(Factory.makeReference(makeOrganization( cda.getDescendent(doc, "custodian/assignedCustodian/representedCustodianOrganization"), "Custodian"))); // todo: informationRecipient for (Element e : cda.getChildren(doc, "legalAuthenticator")) composition.getAttester().add(makeAttester(e, CompositionAttestationMode.LEGAL, "Legal Authenticator")); for (Element e : cda.getChildren(doc, "authenticator")) composition.getAttester().add(makeAttester(e, CompositionAttestationMode.PROFESSIONAL, "Authenticator")); // process the contents // we do this by section - keep the original section order Element body = cda.getDescendent(doc, "component/structuredBody"); processComponentSections(composition.getSection(), body); return feed; }
/** * {@inheritDoc} */ @Override public Bundle createResource( final JCas jCas, final TOP nullified, final FhirPractitioner practitioner, final FhirNoteSpecs noteSpecs ) { final Bundle bundle = new Bundle(); final String noteTime = DATE_FORMAT.format( new Date() ); bundle.setId( FhirElementFactory.createId( jCas, CTAKES_BUNDLE_ID, noteTime ) ); // The bundle is a collection; created for ease of distribution. bundle.setType( Bundle.BundleType.COLLECTION ); return bundle; }
@Override public void addRootPropertiesToBundle(String theId, String theServerBase, String theLinkSelf, String theLinkPrev, String theLinkNext, Integer theTotalResults, BundleTypeEnum theBundleType, IPrimitiveType<Date> theLastUpdated) { ensureBundle(); myBase = theServerBase; if (myBundle.getIdElement().isEmpty()) { myBundle.setId(theId); } if (myBundle.getIdElement().isEmpty()) { myBundle.setId(UUID.randomUUID().toString()); } if (myBundle.getMeta().getLastUpdated() == null && theLastUpdated != null) { myBundle.getMeta().getLastUpdatedElement().setValueAsString(theLastUpdated.getValueAsString()); } if (!hasLink(Constants.LINK_SELF, myBundle) && isNotBlank(theLinkSelf)) { myBundle.addLink().setRelation(Constants.LINK_SELF).setUrl(theLinkSelf); } if (!hasLink(Constants.LINK_NEXT, myBundle) && isNotBlank(theLinkNext)) { myBundle.addLink().setRelation(Constants.LINK_NEXT).setUrl(theLinkNext); } if (!hasLink(Constants.LINK_PREVIOUS, myBundle) && isNotBlank(theLinkPrev)) { myBundle.addLink().setRelation(Constants.LINK_PREVIOUS).setUrl(theLinkPrev); } if (myBundle.getTypeElement().isEmpty() && theBundleType != null) { myBundle.getTypeElement().setValueAsString(theBundleType.getCode()); } if (myBundle.getTotalElement().isEmpty() && theTotalResults != null) { myBundle.getTotalElement().setValue(theTotalResults); } }
protected void makeDocument() throws Exception { composition = (Composition) ResourceFactory.createResource("Composition"); addReference(composition, "Composition", makeUUIDReference()); Element title = cda.getChild(doc, "title"); composition.setTitle(title.getTextContent()); if (cda.getChild(doc, "setId") != null) { feed.setId(convert.makeURIfromII(cda.getChild(doc, "id"))); composition.setIdentifier(convert.makeIdentifierFromII(cda.getChild(doc, "setId"))); } else composition.setIdentifier(convert.makeIdentifierFromII(cda.getChild(doc, "id"))); // well, we fall back to id composition.setDateElement(convert.makeDateTimeFromTS(cda.getChild(doc, "effectiveTime"))); composition.setType(convert.makeCodeableConceptFromCD(cda.getChild(doc, "code"))); composition.setConfidentiality(convertConfidentiality(cda.getChild(doc, "confidentialityCode"))); if (cda.getChild(doc, "confidentialityCode") != null) composition.setLanguage(cda.getChild(doc, "confidentialityCode").getAttribute("value")); // todo - fix streaming for this Element ee = cda.getChild(doc, "componentOf"); if (ee != null) ee = cda.getChild(ee, "encompassingEncounter"); if (ee != null) { Encounter visit = new Encounter(); for (Element e : cda.getChildren(ee, "id")) visit.getIdentifier().add(convert.makeIdentifierFromII(e)); visit.setPeriod(convert.makePeriodFromIVL(cda.getChild(ee, "effectiveTime"))); composition.getEvent().add(new Composition.CompositionEventComponent()); composition.getEvent().get(0).getCode().add(convert.makeCodeableConceptFromCD(cda.getChild(ee, "code"))); composition.getEvent().get(0).setPeriod(visit.getPeriod()); composition.getEvent().get(0).getDetail().add(Factory.makeReference(addReference(visit, "Encounter", makeUUIDReference()))); } // main todo: fill out the narrative, but before we can do that, we have to convert everything else }
public Bundle convert(InputStream stream) throws Exception { cda = new CDAUtilities(stream); doc = cda.getElement(); cda.checkTemplateId(doc, "2.16.840.1.113883.10.20.22.1.1"); convert = new Convert(cda, ucumSvc, "Z"); // check it's a CDA/CCD feed = new Bundle(); feed.setMeta(new Meta().setLastUpdatedElement(InstantType.now())); feed.setId(makeUUIDReference()); feed.getMeta().getTag().add(new Coding()); // todo-bundle ("http://hl7.org/fhir/tag", "http://hl7.org/fhir/tag/document", "Document")); // process the header makeDocument(); composition.setSubject(Factory.makeReference(makeSubject())); for (Element e : cda.getChildren(doc, "author")) composition.getAuthor().add(Factory.makeReference(makeAuthor(e))); // todo: data enterer & informant goes in provenance composition.setCustodian(Factory.makeReference(makeOrganization( cda.getDescendent(doc, "custodian/assignedCustodian/representedCustodianOrganization"), "Custodian"))); // todo: informationRecipient for (Element e : cda.getChildren(doc, "legalAuthenticator")) composition.getAttester().add(makeAttester(e, CompositionAttestationMode.LEGAL, "Legal Authenticator")); for (Element e : cda.getChildren(doc, "authenticator")) composition.getAttester().add(makeAttester(e, CompositionAttestationMode.PROFESSIONAL, "Authenticator")); // process the contents // we do this by section - keep the original section order Element body = cda.getDescendent(doc, "component/structuredBody"); processComponentSections(composition.getSection(), body); return feed; }
myBundle = new Bundle(); myBundle.setId(UUID.randomUUID().toString());