org.hl7.fhir.r4.model.Meta Java Examples

The following examples show how to use org.hl7.fhir.r4.model.Meta. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoincToDEConvertor.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
public Bundle process(String sourceFile) throws FileNotFoundException, SAXException, IOException, ParserConfigurationException {
  this.definitions = sourceFile;
  log("Begin. Produce Loinc CDEs in "+dest+" from "+definitions);
  loadLoinc();
  log("LOINC loaded");

  now = DateTimeType.now();

  bundle = new Bundle();
  bundle.setType(BundleType.COLLECTION);
  bundle.setId("http://hl7.org/fhir/commondataelement/loinc");
  bundle.setMeta(new Meta().setLastUpdatedElement(InstantType.now()));

  processLoincCodes();
  return bundle;
}
 
Example #2
Source File: LoincToDEConvertor.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
public void process() throws FHIRFormatError, IOException, XmlPullParserException, SAXException, ParserConfigurationException {
	log("Begin. Produce Loinc CDEs in "+dest+" from "+definitions);
	loadLoinc();
	log("LOINC loaded");

	now = DateTimeType.now();

	bundle = new Bundle();
	bundle.setId("http://hl7.org/fhir/commondataelement/loinc");
   bundle.setMeta(new Meta().setLastUpdatedElement(InstantType.now()));

	processLoincCodes();
	if (dest != null) {
		log("Saving...");
		saveBundle();
	}
	log("Done");

}
 
Example #3
Source File: CodeSystemUtilities.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static CodeSystem makeShareable(CodeSystem cs) {
  if (!cs.hasMeta())
    cs.setMeta(new Meta());
  for (UriType t : cs.getMeta().getProfile()) 
    if (t.getValue().equals("http://hl7.org/fhir/StructureDefinition/shareablecodesystem"))
      return cs;
  cs.getMeta().getProfile().add(new CanonicalType("http://hl7.org/fhir/StructureDefinition/shareablecodesystem"));
  return cs;
}
 
Example #4
Source File: ValueSetUtilities.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static ValueSet makeShareable(ValueSet vs) {
  if (!vs.hasMeta())
    vs.setMeta(new Meta());
  for (UriType t : vs.getMeta().getProfile()) 
    if (t.getValue().equals("http://hl7.org/fhir/StructureDefinition/shareablevalueset"))
      return vs;
  vs.getMeta().getProfile().add(new CanonicalType("http://hl7.org/fhir/StructureDefinition/shareablevalueset"));
  return vs;
}
 
Example #5
Source File: MetaTest.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
@Test
public void testMetaSecurity() {
  Meta meta = new Meta();
  Coding coding = meta.addSecurity().setSystem(TEST_SYSTEM).setCode(TEST_CODE);
  Assertions.assertTrue(meta.hasSecurity());
  Assertions.assertNotNull(meta.getSecurity());
  Assertions.assertNotNull(meta.getSecurity(TEST_SYSTEM, TEST_CODE));
  Assertions.assertEquals(1, meta.getSecurity().size());
  Assertions.assertEquals(meta.getSecurity().get(0), meta.getSecurity(TEST_SYSTEM, TEST_CODE));
  Assertions.assertEquals(meta.getSecurityFirstRep(), meta.getSecurity(TEST_SYSTEM, TEST_CODE));
  Assertions.assertEquals(coding, meta.getSecurity(TEST_SYSTEM, TEST_CODE));
}
 
Example #6
Source File: ResourceUtilities.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
public static Meta meta(Resource resource) {
  if (!resource.hasMeta())
    resource.setMeta(new Meta());
  return resource.getMeta();
}
 
Example #7
Source File: IdentifiableDomainResourceAttributeMapper.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
default void mapMetaData(Identifiable source, DomainResource target) {
	Meta meta = new Meta();
	meta.setLastUpdated(new Date(source.getLastupdate()));
	target.setMeta(meta);
}
 
Example #8
Source File: FhirChCrlDocumentBundle.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private void createBundle(){
	try {
		Date now = new Date();
		
		this.bundle = new Bundle();
		bundle.setId("BundleFromPractitioner");
		bundle.setMeta(new Meta().setLastUpdated(now).setProfile(Collections.singletonList(
			new CanonicalType("http://fhir.ch/ig/ch-crl/StructureDefinition/ch-crl-bundle"))));
		bundle.setType(BundleType.DOCUMENT);
		
		BundleEntryComponent compositionEntry = bundle.addEntry();
		Composition composition = new Composition();
		compositionEntry.setResource(composition);
		composition.setId("CompFromPractitioner");
		composition.setMeta(new Meta().setLastUpdated(now)
			.setProfile(Collections.singletonList(new CanonicalType(
				"http://fhir.ch/ig/ch-crl/StructureDefinition/ch-crl-composition"))));
		composition.setStatus(CompositionStatus.FINAL);
		composition.setType(new CodeableConcept(
			new Coding("http://loinc.org", "72134-0", "Cancer event report")));
		composition.setDate(now);
		composition.setTitle("Report to the Cancer Registry");
		
		BundleEntryComponent subjectEntry = bundle.addEntry();
		IFhirTransformer<Patient, IPatient> patientTransformer =
			(IFhirTransformer<Patient, IPatient>) FhirTransformersHolder
				.getTransformerFor(Patient.class, IPatient.class);
		Patient subject = patientTransformer.getFhirObject(patient)
			.orElseThrow(() -> new IllegalStateException("Could not create subject"));
		subject.getExtension().clear();
		fixAhvIdentifier(subject);
		
		subjectEntry.setResource(subject);
		
		BundleEntryComponent practitionerEntry = bundle.addEntry();
		IFhirTransformer<Practitioner, IMandator> practitionerTransformer =
			(IFhirTransformer<Practitioner, IMandator>) FhirTransformersHolder
				.getTransformerFor(Practitioner.class, IMandator.class);
		Practitioner practitioner = practitionerTransformer.getFhirObject(author)
			.orElseThrow(() -> new IllegalStateException("Could not create autor"));
		practitioner.getExtension().clear();
		practitioner.getIdentifier().clear();
		practitionerEntry.setResource(practitioner);
		
		BundleEntryComponent documentReferenceEntry = bundle.addEntry();
		DocumentReference documentReference = new DocumentReference();
		documentReferenceEntry.setResource(documentReference);
		documentReference.setId(document.getId());
		DocumentReferenceContentComponent content = documentReference.addContent();
		content.setAttachment(new Attachment().setContentType("application/pdf")
			.setData(IOUtils.toByteArray(document.getContent())));
		
		composition.setSubject(new Reference(subject));
		composition.setAuthor(Collections.singletonList(new Reference(practitioner)));
		SectionComponent section = composition.addSection();
		section.addEntry(new Reference(documentReference));
	} catch (IOException e) {
		LoggerFactory.getLogger(getClass()).error("Error creating FHIR bundle", e);
		throw new IllegalStateException("Error creating FHIR bundle", e);
	}
}