Java Code Examples for org.hl7.fhir.dstu3.model.StructureDefinition#setId()

The following examples show how to use org.hl7.fhir.dstu3.model.StructureDefinition#setId() . 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: ISO21090Importer.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void generateType(DataType dt) throws Exception {
  StructureDefinition sd = new StructureDefinition();
  sd.setId(dt.name);
  sd.setUrl("http://hl7.org/fhir/iso21090/StructureDefinition/"+sd.getId());
  sd.setName(dt.name+" data type");
  sd.setStatus(PublicationStatus.ACTIVE);
  sd.setExperimental(false);
  sd.setPublisher("HL7 / ISO");
  sd.setDate(new Date());
  sd.setDescription(dt.doco);
  sd.setKind(StructureDefinitionKind.LOGICAL);
  sd.setAbstract(Utilities.existsInList(dt.name, "HXIT", "QTY"));
  sd.setType("Element");
  if (dt.parent == null)
    sd.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/Element");
  else
    sd.setBaseDefinition("http://hl7.org/fhir/iso21090/StructureDefinition/"+dt.parent);
  sd.setDerivation(TypeDerivationRule.SPECIALIZATION);
  ElementDefinition ed = sd.getDifferential().addElement();
  ed.setPath(dt.name);
  produceProperties(sd.getDifferential().getElement(), dt.name, dt.properties, true, false);
  produceProperties(sd.getDifferential().getElement(), dt.name, dt.properties, false, false);
  ed = sd.getSnapshot().addElement();
  ed.setPath(dt.name);
  if (dt.parent != null)
    addParentProperties(sd.getSnapshot().getElement(), dt.name, dt.parent, true, true);
  produceProperties(sd.getSnapshot().getElement(), dt.name, dt.properties, true, true);
  if (dt.parent != null)
    addParentProperties(sd.getSnapshot().getElement(), dt.name, dt.parent, false, true);
  produceProperties(sd.getSnapshot().getElement(), dt.name, dt.properties, false, true);
  ed.getBase().setPath(ed.getPath()).setMin(ed.getMin()).setMax(ed.getMax());
  new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream("c:\\temp\\iso21090\\StructureDefinition-"+dt.name+".xml"), sd);    
}
 
Example 2
Source File: StructureMapUtilities.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private PropertyWithType createProfile(StructureMap map, List<StructureDefinition> profiles, PropertyWithType prop, String sliceName, Base ctxt) throws DefinitionException {
  if (prop.getBaseProperty().getDefinition().getPath().contains(".")) 
    throw new DefinitionException("Unable to process entry point");

  String type = prop.getBaseProperty().getDefinition().getPath();
  String suffix = "";
  if (ids.containsKey(type)) {
    int id = ids.get(type);
    id++;
    ids.put(type, id);
    suffix = "-"+Integer.toString(id);
  } else
    ids.put(type, 0);
  
  StructureDefinition profile = new StructureDefinition();
  profiles.add(profile);
  profile.setDerivation(TypeDerivationRule.CONSTRAINT);
  profile.setType(type);
  profile.setBaseDefinition(prop.getBaseProperty().getStructure().getUrl());
  profile.setName("Profile for "+profile.getType()+" for "+sliceName);
  profile.setUrl(map.getUrl().replace("StructureMap", "StructureDefinition")+"-"+profile.getType()+suffix);
  ctxt.setUserData("profile", profile.getUrl()); // then we can easily assign this profile url for validation later when we actually transform
  profile.setId(map.getId()+"-"+profile.getType()+suffix);
  profile.setStatus(map.getStatus());
  profile.setExperimental(map.getExperimental());
  profile.setDescription("Generated automatically from the mapping by the Java Reference Implementation");
  for (ContactDetail c : map.getContact()) {
    ContactDetail p = profile.addContact();
    p.setName(c.getName());
    for (ContactPoint cc : c.getTelecom()) 
      p.addTelecom(cc);
  }
  profile.setDate(map.getDate());
  profile.setCopyright(map.getCopyright());
  profile.setFhirVersion(Constants.VERSION);
  profile.setKind(prop.getBaseProperty().getStructure().getKind());
  profile.setAbstract(false);
  ElementDefinition ed = profile.getDifferential().addElement();
  ed.setPath(profile.getType());
  prop.profileProperty = new Property(worker, ed, profile);
  return prop;
}
 
Example 3
Source File: StructureDefinitionEntityToFHIRStructureDefinitionTransformer.java    From careconnect-reference-implementation with Apache License 2.0 3 votes vote down vote up
public StructureDefinition transform(final StructureDefinitionEntity structureDefinitionEntity, FhirContext ctx) {
    final StructureDefinition structureDefinition = (StructureDefinition) ctx.newJsonParser().parseResource(structureDefinitionEntity.getResource());

    structureDefinition.setId(structureDefinitionEntity.getId().toString());

    return structureDefinition;

}