Skip to content

Commit

Permalink
Fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
rkorytkowski committed Mar 12, 2014
1 parent 0fee185 commit e5de1e6
Showing 1 changed file with 31 additions and 26 deletions.
57 changes: 31 additions & 26 deletions api/src/main/java/org/openmrs/hl7/handler/ORUR01Handler.java
Expand Up @@ -161,8 +161,8 @@ public Message processMessage(Message message) throws ApplicationException {
}
catch (ClassCastException e) {
log.warn("Error casting " + message.getClass().getName() + " to ORU_R01", e);
throw new ApplicationException(Context.getMessageSourceService().getMessage("ORUR01.error.invalidMessageType ",new Object[]
{ message.getClass().getName()},null), e);
throw new ApplicationException(Context.getMessageSourceService().getMessage("ORUR01.error.invalidMessageType ",
new Object[] { message.getClass().getName() }, null), e);
}
catch (HL7Exception e) {
log.warn("Error while processing ORU_R01 message", e);
Expand Down Expand Up @@ -267,7 +267,8 @@ private Message processORU_R01(ORU_R01 oru) throws HL7Exception {
OBR obr = orderObs.getOBR();

if (!StringUtils.hasText(obr.getUniversalServiceIdentifier().getIdentifier().getValue())) {
throw new HL7Exception(Context.getMessageSourceService().getMessage( "ORUR01.errorInvalidOBR ",new Object[]{messageControlId},null));
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.errorInvalidOBR ",
new Object[] { messageControlId }, null));
}

// if we're not ignoring this obs group, create an
Expand Down Expand Up @@ -366,8 +367,9 @@ private Message processORU_R01(ORU_R01 oru) throws HL7Exception {
finally {
// Handle obs-level exceptions
if (errorInHL7Queue != null) {
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.improperlyFormattedOBX",
new Object[]{ PipeParser.encode(obx, new EncodingCharacters('|', "^~\\&"))},null),
throw new HL7Exception(Context.getMessageSourceService().getMessage(
"ORUR01.error.improperlyFormattedOBX",
new Object[] { PipeParser.encode(obx, new EncodingCharacters('|', "^~\\&")) }, null),
HL7Exception.DATA_TYPE_ERROR, errorInHL7Queue);
}
}
Expand Down Expand Up @@ -423,17 +425,17 @@ protected void processNK1(Patient patient, NK1 nk1) throws HL7Exception {
// guarantee we are working with our custom coding system
String relCodingSystem = nk1.getRelationship().getNameOfCodingSystem().getValue();
if (!relCodingSystem.equals(HL7Constants.HL7_LOCAL_RELATIONSHIP)) {
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.relationshipCoding",new Object[]
{relCodingSystem},null) );
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.relationshipCoding",
new Object[] { relCodingSystem }, null));
}

// get the relationship type identifier
String relIdentifier = nk1.getRelationship().getIdentifier().getValue();

// validate the format of the relationship identifier
if (!Pattern.matches("[0-9]+[AB]", relIdentifier)) {
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.relationshipType",new Object[]
{relIdentifier},null) );
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.relationshipType",
new Object[] { relIdentifier }, null));
}

// get the type ID
Expand All @@ -442,13 +444,15 @@ protected void processNK1(Patient patient, NK1 nk1) throws HL7Exception {
relTypeId = Integer.parseInt(relIdentifier.substring(0, relIdentifier.length() - 1));
}
catch (NumberFormatException e) {
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.relationshipType",new Object[]{relIdentifier},null) );
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.relationshipType",
new Object[] { relIdentifier }, null));
}

// find the relationship type
RelationshipType relType = Context.getPersonService().getRelationshipType(relTypeId);
if (relType == null) {
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.relationshipTypeNotFound",new Object[]{relTypeId},null) );
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.relationshipTypeNotFound",
new Object[] { relTypeId }, null));
}

// find the relative
Expand Down Expand Up @@ -693,9 +697,9 @@ private Obs parseObs(Encounter encounter, OBX obx, OBR obr, String uid) throws H
obs.setValueNumeric(Double.valueOf(value));
}
catch (NumberFormatException e) {
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.notnumericConcept",
new Object[]
{value,concept.getConceptId(),conceptName.getName(),uid},null),e);
throw new HL7Exception(Context.getMessageSourceService().getMessage(
"ORUR01.error.notnumericConcept",
new Object[] { value, concept.getConceptId(), conceptName.getName(), uid }, null), e);
}
} else if (concept.getDatatype().isCoded()) {
Concept answer = value.equals("1") ? Context.getConceptService().getTrueConcept() : Context
Expand All @@ -713,22 +717,21 @@ private Obs parseObs(Encounter encounter, OBX obx, OBR obr, String uid) throws H
}
//answer the boolean answer concept was't found
if (!isValidAnswer) {
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.invalidAnswer",new Object[]
{answer.toString(),uid},null));
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.invalidAnswer",
new Object[] { answer.toString(), uid }, null));
}
} else {
//throw this exception to make sure that the handler doesn't silently ignore bad hl7 message
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.CannotSetBoolean",new Object[]
{obs.getConcept().getConceptId()},null));
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.CannotSetBoolean",
new Object[] { obs.getConcept().getConceptId() }, null));
}
} else {
try {
obs.setValueNumeric(Double.valueOf(value));
}
catch (NumberFormatException e) {
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.notnumericConcept",
new Object[]
{value,concept.getConceptId(),conceptName.getName(),uid},null),e);
new Object[] { value, concept.getConceptId(), conceptName.getName(), uid }, null), e);
}
}
} else if ("CWE".equals(hl7Datatype)) {
Expand Down Expand Up @@ -764,8 +767,8 @@ private Obs parseObs(Encounter encounter, OBX obx, OBR obr, String uid) throws H
}
}
catch (NumberFormatException e) {
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.InvalidConceptId",new Object[]
{valueIdentifier,valueName},null));
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.InvalidConceptId",
new Object[] { valueIdentifier, valueName }, null));
}
}
if (log.isDebugEnabled()) {
Expand All @@ -783,7 +786,8 @@ private Obs parseObs(Encounter encounter, OBX obx, OBR obr, String uid) throws H
obs.setValueCodedName(getConceptName(value));
}
catch (NumberFormatException e) {
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.InvalidConceptId",new Object[]{valueIdentifier,valueName},null));
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.InvalidConceptId",
new Object[] { valueIdentifier, valueName }, null));
}
}
} else if ("DT".equals(hl7Datatype)) {
Expand Down Expand Up @@ -848,7 +852,8 @@ private Obs parseObs(Encounter encounter, OBX obx, OBR obr, String uid) throws H
// unsupported data type
// TODO: support RP (report), SN (structured numeric)
// do we need to support BIT just in case it slips thru?
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.UpsupportedObs" ,new Object[]{hl7Datatype},null));
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.UpsupportedObs",
new Object[] { hl7Datatype }, null));
}

return obs;
Expand Down Expand Up @@ -988,8 +993,8 @@ protected Concept getConcept(String hl7ConceptId, String codingSystem, String ui
return Context.getConceptService().getConcept(conceptId);
}
catch (NumberFormatException e) {
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.hl7ConceptId",new Object[]
{hl7ConceptId,uid},null));
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.hl7ConceptId",
new Object[] { hl7ConceptId, uid }, null));
}
} else {
// the concept is not local, look it up in our mapping
Expand Down

0 comments on commit e5de1e6

Please sign in to comment.