public org.hl7.fhir.dstu3.model.Meta convertMeta(org.hl7.fhir.instance.model.Meta src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Meta tgt = new org.hl7.fhir.dstu3.model.Meta(); copyElement(src, tgt); tgt.setVersionId(src.getVersionId()); tgt.setLastUpdated(src.getLastUpdated()); for (org.hl7.fhir.instance.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); for (org.hl7.fhir.instance.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); for (org.hl7.fhir.instance.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); return tgt; }
public static org.hl7.fhir.dstu2016may.model.Meta convertMeta(org.hl7.fhir.dstu3.model.Meta src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2016may.model.Meta tgt = new org.hl7.fhir.dstu2016may.model.Meta(); copyElement(src, tgt); if (src.hasVersionId()) tgt.setVersionId(src.getVersionId()); if (src.hasLastUpdated()) tgt.setLastUpdated(src.getLastUpdated()); for (org.hl7.fhir.dstu3.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); for (org.hl7.fhir.dstu3.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); for (org.hl7.fhir.dstu3.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); return tgt; }
public org.hl7.fhir.instance.model.Meta convertMeta(org.hl7.fhir.dstu3.model.Meta src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.instance.model.Meta tgt = new org.hl7.fhir.instance.model.Meta(); copyElement(src, tgt); tgt.setVersionId(src.getVersionId()); tgt.setLastUpdated(src.getLastUpdated()); for (org.hl7.fhir.dstu3.model.UriType t : src.getProfile()) tgt.addProfile(t.getValue()); for (org.hl7.fhir.dstu3.model.Coding t : src.getSecurity()) tgt.addSecurity(convertCoding(t)); for (org.hl7.fhir.dstu3.model.Coding t : src.getTag()) tgt.addTag(convertCoding(t)); return tgt; }
private Meta toMeta(Collection<TagDefinition> tagDefinitions) { Meta retVal = new Meta(); for (TagDefinition next : tagDefinitions) { switch (next.getTagType()) { case PROFILE: retVal.addProfile(next.getCode()); break; case SECURITY_LABEL: retVal.addSecurity().setSystem(next.getSystem()).setCode(next.getCode()).setDisplay(next.getDisplay()); break; case TAG: retVal.addTag().setSystem(next.getSystem()).setCode(next.getCode()).setDisplay(next.getDisplay()); break; } } return retVal; }
@Override public Base setProperty(int hash, String name, Base value) throws FHIRException { switch (hash) { case -1407102957: // versionId this.versionId = castToId(value); // IdType return value; case 1649733957: // lastUpdated this.lastUpdated = castToInstant(value); // InstantType return value; case -309425751: // profile this.getProfile().add(castToUri(value)); // UriType return value; case 949122880: // security this.getSecurity().add(castToCoding(value)); // Coding return value; case 114586: // tag this.getTag().add(castToCoding(value)); // Coding return value; default: return super.setProperty(hash, name, value); } }
public static void main(String[] args) { Map<String, Object> map = new HashMap<String, Object>(); List<LogDTO> logs = new ArrayList<LogDTO>(); logs.add(new LogDTO(1, true)); logs.add(new LogDTO(2, false)); logs.add(new LogDTO(3, true)); map.put("logs", logs); map.put("meta", new Meta(33)); Gson gson = new GsonBuilder().create(); String json = gson.toJson(map); LogsDTO dto = gson.fromJson(json, LogsDTO.class); System.out.println(json); System.out.println(dto); }
@Override public Base makeProperty(int hash, String name) throws FHIRException { switch (hash) { case -1407102957: return getVersionIdElement(); case 1649733957: return getLastUpdatedElement(); case -309425751: return addProfileElement(); case 949122880: return addSecurity(); case 114586: return addTag(); default: return super.makeProperty(hash, name); } }
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; }
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/valueset-shareable-definition")) return vs; vs.getMeta().getProfile().add(new UriType("http://hl7.org/fhir/StructureDefinition/valueset-shareable-definition")); return vs; }
public void clientRead() { //START SNIPPET: clientReadTags IPatientClient client = FhirContext.forDstu2().newRestfulClient(IPatientClient.class, "http://foo/fhir"); Patient patient = client.readPatient(new IdType("1234")); // Access the tag list List<Coding> tagList = patient.getMeta().getTag(); for (Coding next : tagList) { // ..process the tags somehow.. } //END SNIPPET: clientReadTags //START SNIPPET: clientCreateTags Patient newPatient = new Patient(); // Populate the resource object newPatient.addIdentifier().setUse(IdentifierUse.OFFICIAL).setValue("123"); newPatient.addName().setFamily("Jones").addGiven("Frank"); // Populate some tags newPatient.getMeta().addTag("http://animals", "Dog", "Canine Patient"); // TODO: more realistic example newPatient.getMeta().addTag("http://personality", "Friendly", "Friendly"); // TODO: more realistic example // ...invoke the create method on the client... //END SNIPPET: clientCreateTags }
protected String addReference(DomainResource r, String title, String id) throws Exception { if (r.getText() == null) r.setText(new Narrative()); if (r.getText().getDiv() == null) { r.getText().setStatus(NarrativeStatus.GENERATED); new NarrativeGenerator("", "", context).generate(r); } r.setMeta(new Meta().setLastUpdatedElement(InstantType.now())); r.setId(id); feed.getEntry().add(new BundleEntryComponent().setResource(r)); return id; }
@Override public Base addChild(String name) throws FHIRException { if (name.equals("versionId")) { throw new FHIRException("Cannot call addChild on a primitive type Meta.versionId"); } else if (name.equals("lastUpdated")) { throw new FHIRException("Cannot call addChild on a primitive type Meta.lastUpdated"); } else if (name.equals("profile")) { throw new FHIRException("Cannot call addChild on a primitive type Meta.profile"); } else if (name.equals("security")) { return addSecurity(); } else if (name.equals("tag")) { return addTag(); } else return super.addChild(name); }
/** * @param object bundle * @return true if one of the {@link #profileUris} are present in the Bundle's meta.profile */ @Override public boolean test(Object object) { Bundle bundle = (Bundle) object; boolean result = bundle.getMeta().getProfile().stream() .map(UriType::getValueAsString) .anyMatch(profileUris::contains); return result; } }
/** * @return The first repetition of repeating field {@link #security}, creating it if it does not already exist */ public Coding getSecurityFirstRep() { if (getSecurity().isEmpty()) { addSecurity(); } return getSecurity().get(0); }
protected Bundle provideAndRegister() throws Exception { Bundle bundle = new Bundle().setType(Bundle.BundleType.TRANSACTION); bundle.getMeta().addProfile(Iti65Constants.ITI65_PROFILE); .withZone(DateTimeZone.UTC).toDate(); DocumentReference reference = new DocumentReference(); reference.getMeta().setLastUpdated(timestamp); .setContentType("text/plain") .setContent(documentContent); binary.getMeta().setLastUpdated(timestamp);
public Meta copy() { Meta dst = new Meta(); copyValues(dst); dst.versionId = versionId == null ? null : versionId.copy(); dst.lastUpdated = lastUpdated == null ? null : lastUpdated.copy(); if (profile != null) { dst.profile = new ArrayList<UriType>(); for (UriType i : profile) dst.profile.add(i.copy()); }; if (security != null) { dst.security = new ArrayList<Coding>(); for (Coding i : security) dst.security.add(i.copy()); }; if (tag != null) { dst.tag = new ArrayList<Coding>(); for (Coding i : tag) dst.tag.add(i.copy()); }; return dst; }
@Read() public Patient readPatient(@IdParam IdType theId) { Patient retVal = new Patient(); // ..populate demographics, contact, or anything else you usually would.. // Populate some tags retVal.getMeta().addTag("http://animals", "Dog", "Canine Patient"); // TODO: more realistic example retVal.getMeta().addTag("http://personality", "Friendly", "Friendly"); // TODO: more realistic example return retVal; } //END SNIPPET: readTags
@Create public MethodOutcome createPatientResource(@ResourceParam Patient thePatient) { // ..save the resouce.. IdType id = new IdType("123"); // the new databse primary key for this resource // Get the tag list List<Coding> tags = thePatient.getMeta().getTag(); for (Coding tag : tags) { // process/save each tag somehow } return new MethodOutcome(id); } //END SNIPPET: createTags
/** * Convenience method which adds a security tag * * @param theSystem The code system * @param theCode The code * @param theDisplay The display name * @return Returns a reference to <code>this</code> for easy chaining */ public Meta addSecurity(String theSystem, String theCode, String theDisplay) { addSecurity().setSystem(theSystem).setCode(theCode).setDisplay(theDisplay); return this; } /**
protected Bundle thisSucks() { Bundle bundle = new Bundle().setType(Bundle.BundleType.TRANSACTION); bundle.getMeta().addProfile("http://thissucks.com"); return bundle; }