use of org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN in project openmrs-module-fhir2 by openmrs.
the class MedicationReferenceTranslatorImplTest method toOpenmrsType_shouldThrowExceptionIfReferenceIsntForMedication.
@Test(expected = IllegalArgumentException.class)
public void toOpenmrsType_shouldThrowExceptionIfReferenceIsntForMedication() {
Reference reference = new Reference().setReference("Unknown" + "/" + MEDICATION_UUID).setType("Unknown");
medicationReferenceTranslator.toOpenmrsType(reference);
}
use of org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN in project openmrs-module-fhir2 by openmrs.
the class VisitReferenceTranslatorImplTest method toOpenmrsType_shouldThrowExceptionIfReferenceIsNotForEncounter.
@Test(expected = IllegalArgumentException.class)
public void toOpenmrsType_shouldThrowExceptionIfReferenceIsNotForEncounter() {
Reference reference = new Reference().setReference("Unknown" + "/" + VISIT_UUID).setType("Unknown");
visitReferenceTranslator.toOpenmrsType(reference);
}
use of org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN in project integration-adaptor-111 by nhsconnect.
the class RelatedPersonMapper method mapRelatedPerson.
public RelatedPerson mapRelatedPerson(POCDMT000002UK01Informant12 informant, Encounter encounter) {
if (!informant.isSetRelatedEntity()) {
return null;
}
POCDMT000002UK01RelatedEntity relatedEntity = informant.getRelatedEntity();
RelatedPerson relatedPerson = new RelatedPerson();
relatedPerson.setIdElement(resourceUtil.newRandomUuid());
relatedPerson.setActive(true).setPatient(encounter.getSubject()).setGender(UNKNOWN);
if (relatedEntity.isSetRelatedPerson()) {
relatedPerson.setName(getHumanNameFromITK(relatedEntity.getRelatedPerson()));
}
if (relatedEntity.sizeOfTelecomArray() > 0) {
relatedPerson.setTelecom(getTelecomFromITK(relatedEntity.getTelecomArray()));
}
if (relatedEntity.sizeOfAddrArray() > 0) {
relatedPerson.setAddress(getAddressesFromITK(relatedEntity.getAddrArray()));
}
if (relatedEntity.isSetEffectiveTime()) {
Period period = new Period();
if (relatedEntity.getEffectiveTime().isSetLow()) {
period.setStartElement(DateUtil.parse(relatedEntity.getEffectiveTime().getLow().getValue()));
}
if (relatedEntity.getEffectiveTime().isSetHigh()) {
period.setEndElement(DateUtil.parse(relatedEntity.getEffectiveTime().getHigh().getValue()));
}
relatedPerson.setPeriod(period);
}
relatedPerson.setPeriod(getPeriod(relatedEntity));
setRelationship(relatedEntity, relatedPerson);
markEmergencyContact(relatedEntity.getTelecomArray(), relatedPerson);
return relatedPerson;
}
use of org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN in project org.hl7.fhir.core by hapifhir.
the class ExpressionAdvisor50 method handleExtension.
public void handleExtension(@Nonnull String path, @Nonnull org.hl7.fhir.r5.model.Extension src, @Nonnull org.hl7.fhir.dstu2.model.Extension tgt) {
if (src.getValue() instanceof org.hl7.fhir.r5.model.Expression) {
StringType type = new StringType();
if (src.getValue() == null) {
throw new NullPointerException("null cannot be cast to non-null type org.hl7.fhir.r5.model.Expression");
} else {
type.setValueAsString(((Expression) src.getValue()).getExpression());
tgt.setValue(type);
if (src.hasUrlElement()) {
tgt.setUrlElement(Uri10_50.convertUri(src.getUrlElement()));
}
}
} else {
throw new FHIRException("Unknown extension type passed in to custom convertor method.");
}
}
use of org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN in project org.hl7.fhir.core by hapifhir.
the class ADLImporter method execute.
private void execute() throws Exception {
// load config
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
adlConfig = builder.parse(new FileInputStream(config)).getDocumentElement();
// load ADL
builder = factory.newDocumentBuilder();
adl = builder.parse(new FileInputStream(source)).getDocumentElement();
check("root", adl.getNamespaceURI(), "http://schemas.openehr.org/v1", "Wrong namespace for ADL XML");
check("root", adl.getNodeName(), "archetype", "Wrong XML for ADL XML");
check("root", XMLUtil.getNamedChild(adl, "adl_version").getTextContent(), "1.4", "unsupported ADL version");
String id = XMLUtil.getFirstChild(XMLUtil.getNamedChild(adl, "archetype_id")).getTextContent().split("\\.")[1];
// create structure definition
StructureDefinition sd = new StructureDefinition();
sd.setId(id);
// populate metadata
Element description = XMLUtil.getNamedChild(adl, "description");
Element details = XMLUtil.getNamedChild(description, "details");
sd.setDescription(XMLUtil.getNamedChild(details, "purpose").getTextContent());
sd.setCopyright(XMLUtil.getNamedChild(details, "copyright").getTextContent());
sd.setPurpose("Use:\r\n" + XMLUtil.getNamedChild(details, "use").getTextContent() + "\r\n\r\nMisuse:\r\n" + XMLUtil.getNamedChild(details, "misuse").getTextContent());
List<Element> set = new ArrayList<Element>();
XMLUtil.getNamedChildren(details, "keywords", set);
for (Element e : set) sd.addKeyword().setDisplay(e.getTextContent());
String status = XMLUtil.getNamedChild(description, "lifecycle_state").getTextContent();
if ("CommitteeDraft".equals(status) || "AuthorDraft".equals(status))
sd.setStatus(PublicationStatus.DRAFT);
else
throw new Exception("Unknown life cycle state " + XMLUtil.getNamedChild(description, "lifecycle_state").getTextContent());
// load texts from ontology
Element ontology = XMLUtil.getNamedChild(adl, "ontology");
Element term_definitions = XMLUtil.getNamedChild(ontology, "term_definitions");
set.clear();
XMLUtil.getNamedChildren(term_definitions, "items", set);
for (Element item : set) {
processTextItem(item);
}
// load data and protocol
Element definition = XMLUtil.getNamedChild(adl, "definition");
NodeTreeEntry root = new NodeTreeEntry();
root.setTypeName(XMLUtil.getNamedChild(definition, "rm_type_name").getTextContent());
root.setAtCode(XMLUtil.getNamedChild(definition, "node_id").getTextContent());
root.setName(generateToken(root.getAtCode(), true));
sd.setName(root.getName());
root.setCardinality(readCardinality("root", XMLUtil.getNamedChild(definition, "occurrences")));
set.clear();
XMLUtil.getNamedChildren(definition, "attributes", set);
for (Element item : set) {
// we're actually skipping this level - we don't care about data protocol etc.
// XMLUtil.getNamedChild(XMLUtil.getNamedChild(item, "children"), "attributes");
Element attributes = item;
loadChildren(root.getAtCode(), root, attributes);
}
dumpChildren("", root);
genElements(sd, root.getName(), root);
// save
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(dest), sd);
System.out.println("done. saved as " + dest);
}
Aggregations