use of org.hl7.fhir.dstu2.model.ContactPoint in project org.hl7.fhir.core by hapifhir.
the class StructureMapUtilities method createProfile.
private PropertyWithType createProfile(StructureMap map, List<StructureDefinition> profiles, PropertyWithType prop, String sliceName, Base ctxt) throws FHIRException {
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);
// then we can easily assign this profile url for validation later when we actually transform
ctxt.setUserData("profile", profile.getUrl());
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(FHIRVersion.fromCode(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;
}
use of org.hl7.fhir.dstu2.model.ContactPoint in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireBuilder method processDataType.
private void processDataType(StructureDefinition profile, QuestionnaireItemComponent group, ElementDefinition element, String path, TypeRefComponent t, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> answerGroups, List<ElementDefinition> parents) throws FHIRException {
String tc = t.getWorkingCode();
if (tc.equals("code"))
addCodeQuestions(group, element, path, answerGroups);
else if (Utilities.existsInList(tc, "string", "id", "oid", "uuid", "markdown"))
addStringQuestions(group, element, path, answerGroups);
else if (Utilities.existsInList(tc, "uri", "url", "canonical"))
addUriQuestions(group, element, path, answerGroups);
else if (tc.equals("boolean"))
addBooleanQuestions(group, element, path, answerGroups);
else if (tc.equals("decimal"))
addDecimalQuestions(group, element, path, answerGroups);
else if (tc.equals("dateTime") || tc.equals("date"))
addDateTimeQuestions(group, element, path, answerGroups);
else if (tc.equals("instant"))
addInstantQuestions(group, element, path, answerGroups);
else if (tc.equals("time"))
addTimeQuestions(group, element, path, answerGroups);
else if (tc.equals("CodeableConcept"))
addCodeableConceptQuestions(group, element, path, answerGroups);
else if (tc.equals("Period"))
addPeriodQuestions(group, element, path, answerGroups);
else if (tc.equals("Ratio"))
addRatioQuestions(group, element, path, answerGroups);
else if (tc.equals("HumanName"))
addHumanNameQuestions(group, element, path, answerGroups);
else if (tc.equals("Address"))
addAddressQuestions(group, element, path, answerGroups);
else if (tc.equals("ContactPoint"))
addContactPointQuestions(group, element, path, answerGroups);
else if (tc.equals("Identifier"))
addIdentifierQuestions(group, element, path, answerGroups);
else if (tc.equals("integer") || tc.equals("positiveInt") || tc.equals("unsignedInt"))
addIntegerQuestions(group, element, path, answerGroups);
else if (tc.equals("Coding"))
addCodingQuestions(group, element, path, answerGroups);
else if (Utilities.existsInList(tc, "Quantity", "Count", "Age", "Duration", "Distance", "Money"))
addQuantityQuestions(group, element, path, answerGroups);
else if (tc.equals("Money"))
addMoneyQuestions(group, element, path, answerGroups);
else if (tc.equals("Reference"))
addReferenceQuestions(group, element, path, t.getTargetProfile(), answerGroups);
else if (tc.equals("Duration"))
addDurationQuestions(group, element, path, answerGroups);
else if (tc.equals("base64Binary"))
addBinaryQuestions(group, element, path, answerGroups);
else if (tc.equals("Attachment"))
addAttachmentQuestions(group, element, path, answerGroups);
else if (tc.equals("Age"))
addAgeQuestions(group, element, path, answerGroups);
else if (tc.equals("Range"))
addRangeQuestions(group, element, path, answerGroups);
else if (tc.equals("Timing"))
addTimingQuestions(group, element, path, answerGroups);
else if (tc.equals("Annotation"))
addAnnotationQuestions(group, element, path, answerGroups);
else if (tc.equals("SampledData"))
addSampledDataQuestions(group, element, path, answerGroups);
else if (tc.equals("Extension")) {
if (t.hasProfile())
addExtensionQuestions(profile, group, element, path, t.getProfile().get(0).getValue(), answerGroups, parents);
} else if (tc.equals("SampledData"))
addSampledDataQuestions(group, element, path, answerGroups);
else if (!tc.equals("Narrative") && !tc.equals("Resource") && !tc.equals("Meta") && !tc.equals("Signature")) {
StructureDefinition sd = context.fetchTypeDefinition(tc);
if (sd == null)
throw new NotImplementedException("Unhandled Data Type: " + tc + " on element " + element.getPath());
buildGroup(group, sd, sd.getSnapshot().getElementFirstRep(), parents, answerGroups);
}
}
use of org.hl7.fhir.dstu2.model.ContactPoint in project org.hl7.fhir.core by hapifhir.
the class ProfileDrivenRenderer method renderLeaf.
private void renderLeaf(ResourceWrapper res, BaseWrapper ew, ElementDefinition defn, XhtmlNode parent, XhtmlNode x, boolean title, boolean showCodeDetails, Map<String, String> displayHints, String path, int indent) throws FHIRException, UnsupportedEncodingException, IOException, EOperationOutcome {
if (ew == null)
return;
Base e = ew.getBase();
if (e instanceof StringType)
x.addText(((StringType) e).getValue());
else if (e instanceof CodeType)
x.addText(((CodeType) e).getValue());
else if (e instanceof IdType)
x.addText(((IdType) e).getValue());
else if (e instanceof Extension)
return;
else if (e instanceof InstantType)
x.addText(((InstantType) e).toHumanDisplay());
else if (e instanceof DateTimeType) {
renderDateTime(x, e);
} else if (e instanceof Base64BinaryType)
x.addText(new Base64().encodeAsString(((Base64BinaryType) e).getValue()));
else if (e instanceof org.hl7.fhir.r5.model.DateType) {
org.hl7.fhir.r5.model.DateType dt = ((org.hl7.fhir.r5.model.DateType) e);
renderDate(x, dt);
} else if (e instanceof Enumeration) {
Object ev = ((Enumeration<?>) e).getValue();
// todo: look up a display name if there is one
x.addText(ev == null ? "" : ev.toString());
} else if (e instanceof BooleanType) {
x.addText(((BooleanType) e).getValue().toString());
} else if (e instanceof CodeableConcept) {
renderCodeableConcept(x, (CodeableConcept) e, showCodeDetails);
} else if (e instanceof Coding) {
renderCoding(x, (Coding) e, showCodeDetails);
} else if (e instanceof CodeableReference) {
renderCodeableReference(x, (CodeableReference) e, showCodeDetails);
} else if (e instanceof Annotation) {
renderAnnotation(x, (Annotation) e);
} else if (e instanceof Identifier) {
renderIdentifier(x, (Identifier) e);
} else if (e instanceof org.hl7.fhir.r5.model.IntegerType) {
if (((org.hl7.fhir.r5.model.IntegerType) e).hasValue()) {
x.addText(Integer.toString(((org.hl7.fhir.r5.model.IntegerType) e).getValue()));
} else {
x.addText("??");
}
} else if (e instanceof org.hl7.fhir.r5.model.Integer64Type) {
if (((org.hl7.fhir.r5.model.Integer64Type) e).hasValue()) {
x.addText(Long.toString(((org.hl7.fhir.r5.model.Integer64Type) e).getValue()));
} else {
x.addText("??");
}
} else if (e instanceof org.hl7.fhir.r5.model.DecimalType) {
x.addText(((org.hl7.fhir.r5.model.DecimalType) e).getValue().toString());
} else if (e instanceof HumanName) {
renderHumanName(x, (HumanName) e);
} else if (e instanceof SampledData) {
renderSampledData(x, (SampledData) e);
} else if (e instanceof Address) {
renderAddress(x, (Address) e);
} else if (e instanceof ContactPoint) {
renderContactPoint(x, (ContactPoint) e);
} else if (e instanceof Expression) {
renderExpression(x, (Expression) e);
} else if (e instanceof Money) {
renderMoney(x, (Money) e);
} else if (e instanceof ContactDetail) {
ContactDetail cd = (ContactDetail) e;
if (cd.hasName()) {
x.tx(cd.getName() + ": ");
}
boolean first = true;
for (ContactPoint c : cd.getTelecom()) {
if (first)
first = false;
else
x.tx(",");
renderContactPoint(x, c);
}
} else if (e instanceof UriType) {
renderUri(x, (UriType) e, defn.getPath(), rcontext != null && rcontext.getResourceResource() != null ? rcontext.getResourceResource().getId() : null);
} else if (e instanceof Timing) {
renderTiming(x, (Timing) e);
} else if (e instanceof Range) {
renderRange(x, (Range) e);
} else if (e instanceof Quantity) {
renderQuantity(x, (Quantity) e, showCodeDetails);
} else if (e instanceof Ratio) {
renderQuantity(x, ((Ratio) e).getNumerator(), showCodeDetails);
x.tx("/");
renderQuantity(x, ((Ratio) e).getDenominator(), showCodeDetails);
} else if (e instanceof Period) {
Period p = (Period) e;
renderPeriod(x, p);
} else if (e instanceof Reference) {
Reference r = (Reference) e;
if (r.getReference() != null && r.getReference().contains("#")) {
if (containedIds.contains(r.getReference().substring(1))) {
x.ah(r.getReference()).tx("See " + r.getReference());
} else {
// in this case, we render the resource in line
ResourceWrapper rw = null;
for (ResourceWrapper t : res.getContained()) {
if (r.getReference().substring(1).equals(t.getId())) {
rw = t;
}
}
if (rw == null) {
renderReference(res, x, r);
} else {
x.an(rw.getId());
ResourceRenderer rr = RendererFactory.factory(rw, context.copy().setAddGeneratedNarrativeHeader(false));
rr.render(parent.blockquote(), rw);
}
}
} else {
renderReference(res, x, r);
}
} else if (e instanceof Resource) {
return;
} else if (e instanceof DataRequirement) {
DataRequirement p = (DataRequirement) e;
renderDataRequirement(x, p);
} else if (e instanceof PrimitiveType) {
x.tx(((PrimitiveType) e).primitiveValue());
} else if (e instanceof ElementDefinition) {
x.tx("todo-bundle");
} else if (e != null && !(e instanceof Attachment) && !(e instanceof Narrative) && !(e instanceof Meta)) {
throw new NotImplementedException("type " + e.getClass().getName() + " not handled - should not be here");
}
}
use of org.hl7.fhir.dstu2.model.ContactPoint in project org.hl7.fhir.core by hapifhir.
the class StructureMapUtilities method createProfile.
private PropertyWithType createProfile(StructureMap map, List<StructureDefinition> profiles, PropertyWithType prop, String sliceName, Base ctxt) throws FHIRException {
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 = "-" + 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);
// then we can easily assign this profile url for validation later when we actually transform
ctxt.setUserData("profile", profile.getUrl());
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(FHIRVersion.fromCode(Constants.VERSION));
profile.setKind(prop.getBaseProperty().getStructure().getKind());
profile.setAbstract(false);
ElementDefinition ed = profile.getDifferential().addElement();
ed.setPath(profile.getType());
prop.setProfileProperty(new Property(worker, ed, profile));
return prop;
}
use of org.hl7.fhir.dstu2.model.ContactPoint in project eCRNow by drajer-health.
the class CdaFhirUtilities method getTelecomXml.
public static String getTelecomXml(List<ContactPoint> tels, boolean onlyOne) {
StringBuilder telString = new StringBuilder(200);
if (tels != null && !tels.isEmpty()) {
for (ContactPoint tel : tels) {
if (tel.getSystem() != null && tel.getSystem() == ContactPoint.ContactPointSystem.PHONE && !StringUtils.isEmpty(tel.getValue())) {
logger.debug("Found Telecom Number for {}", tel.getSystem().getDisplay());
String use = (tel.getUse() == null) ? "" : CdaGeneratorConstants.getCodeForTelecomUse(tel.getUse().toCode());
telString.append(CdaGeneratorUtils.getXmlForTelecom(CdaGeneratorConstants.TEL_EL_NAME, tel.getValue(), use));
if (onlyOne)
break;
}
}
} else {
logger.debug("Did not find the Telecom ");
telString.append(CdaGeneratorUtils.getXmlForNFText(CdaGeneratorConstants.TEL_EL_NAME, CdaGeneratorConstants.NF_NI));
}
return telString.toString();
}
Aggregations