Index: org/openmrs/hl7/impl/HL7ServiceImpl.java =================================================================== --- org/openmrs/hl7/impl/HL7ServiceImpl.java (revision 13548) +++ org/openmrs/hl7/impl/HL7ServiceImpl.java (working copy) @@ -48,7 +48,6 @@ import org.openmrs.hl7.Hl7InArchivesMigrateThread; import org.openmrs.hl7.Hl7InArchivesMigrateThread.Status; import org.openmrs.hl7.db.HL7DAO; -import org.openmrs.util.FormConstants; import org.openmrs.util.OpenmrsConstants; import org.openmrs.util.OpenmrsUtil; import org.openmrs.validator.PatientIdentifierValidator; @@ -638,24 +637,24 @@ assigningAuthority); if (pit == null) { // there is no matching PatientIdentifierType - if (assigningAuthority.equals(FormConstants.HL7_AUTHORITY_UUID)) { + if (assigningAuthority.equals(HL7Constants.HL7_AUTHORITY_UUID)) { // the identifier is a UUID Person p = Context.getPersonService().getPersonByUuid(hl7PersonId); if (p != null) return p; log.warn("Can't find person for UUID '" + hl7PersonId + "'"); continue; // skip identifiers with unknown type - } else if (assigningAuthority.equals(FormConstants.HL7_AUTHORITY_LOCAL)) { + } else if (assigningAuthority.equals(HL7Constants.HL7_AUTHORITY_LOCAL)) { // the ID is internal (local) String idType = identifier.getIdentifierTypeCode().getValue(); try { - if (idType.equals(FormConstants.HL7_ID_PERSON)) { + if (idType.equals(HL7Constants.HL7_ID_PERSON)) { Integer pid = Integer.parseInt(hl7PersonId); // patient_id == person_id, so just look for the person Person p = Context.getPersonService().getPerson(pid); if (p != null) return p; - } else if (idType.equals(FormConstants.HL7_ID_PATIENT)) { + } else if (idType.equals(HL7Constants.HL7_ID_PATIENT)) { Integer pid = Integer.parseInt(hl7PersonId); // patient_id == person_id, so just look for the person Patient p = Context.getPatientService().getPatient(pid); Index: org/openmrs/hl7/HL7Constants.java =================================================================== --- org/openmrs/hl7/HL7Constants.java (revision 13548) +++ org/openmrs/hl7/HL7Constants.java (working copy) @@ -13,6 +13,8 @@ */ package org.openmrs.hl7; +import java.util.Hashtable; + /** * Constants used by the hl7 package */ @@ -64,7 +66,44 @@ public static final Integer HL7_STATUS_ERROR = 3; + public static final String HL7_TEXT = "ST"; + + public static final String HL7_CODED = "CE"; + + public static final String HL7_CODED_WITH_EXCEPTIONS = "CWE"; + + public static final String HL7_NUMERIC = "NM"; + + public static final String HL7_DATE = "DT"; + + public static final String HL7_TIME = "TM"; + + public static final String HL7_DATETIME = "TS"; + + public static final String HL7_BOOLEAN = "BIT"; + + public static final String HL7_AUTHORITY_UUID = "UUID"; + + public static final String HL7_AUTHORITY_LOCAL = "L"; + + public static final Object HL7_ID_PERSON = "PN"; + + public static final Object HL7_ID_PATIENT = "PI"; + + public static final Integer CLASS_DRUG = 3; + /** + * Used in hl7 sextuplets: 123^Primary name^99DCT^345^Chosen name^99NAM + */ + public static final String HL7_LOCAL_CONCEPT = "99DCT"; + + public static final String HL7_LOCAL_CONCEPT_NAME = "99NAM"; + + public static final String HL7_LOCAL_DRUG = "99RX"; + + public static final String HL7_LOCAL_RELATIONSHIP = "99REL"; + + /** * @since 1.5 */ public static final int HL7_STATUS_DELETED = 4; @@ -83,4 +122,17 @@ //the maximum number if archives to fetch per query to save on memory public static final int MIGRATION_MAX_BATCH_SIZE = 2000; + + // List of datatypes that do not require complex definitions + public static final Hashtable simpleDatatypes = new Hashtable(); + static { + simpleDatatypes.put(HL7_TEXT, "xs:string"); + simpleDatatypes.put(HL7_DATE, "xs:date"); + simpleDatatypes.put(HL7_TIME, "xs:time"); + simpleDatatypes.put(HL7_DATETIME, "xs:dateTime"); + + // We make a special boolean type with an extra attribute + // to get InfoPath to treat booleans properly + simpleDatatypes.put(HL7_BOOLEAN, "_infopath_boolean"); + } } Index: org/openmrs/hl7/handler/ORUR01Handler.java =================================================================== --- org/openmrs/hl7/handler/ORUR01Handler.java (revision 13548) +++ org/openmrs/hl7/handler/ORUR01Handler.java (working copy) @@ -42,9 +42,9 @@ import org.openmrs.RelationshipType; import org.openmrs.User; import org.openmrs.api.context.Context; +import org.openmrs.hl7.HL7Constants; import org.openmrs.hl7.HL7InQueueProcessor; import org.openmrs.hl7.HL7Service; -import org.openmrs.util.FormConstants; import org.openmrs.util.OpenmrsConstants; import org.openmrs.util.OpenmrsUtil; @@ -370,7 +370,7 @@ 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(FormConstants.HL7_LOCAL_RELATIONSHIP)) + if (!relCodingSystem.equals(HL7Constants.HL7_LOCAL_RELATIONSHIP)) throw new HL7Exception("Relationship coding system '" + relCodingSystem + "' unknown in NK1 segment."); // get the relationship type identifier @@ -649,7 +649,7 @@ try { Concept valueConcept = getConcept(value, uid); obs.setValueCoded(valueConcept); - if (FormConstants.HL7_LOCAL_DRUG.equals(value.getNameOfAlternateCodingSystem().getValue())) { + if (HL7Constants.HL7_LOCAL_DRUG.equals(value.getNameOfAlternateCodingSystem().getValue())) { Drug valueDrug = new Drug(); valueDrug.setDrugId(new Integer(value.getAlternateIdentifier().getValue())); obs.setValueDrug(valueDrug); @@ -764,7 +764,7 @@ */ private ConceptName getConceptName(ST altIdentifier, ID altCodingSystem) throws HL7Exception { if (altIdentifier != null) { - if (FormConstants.HL7_LOCAL_CONCEPT_NAME.equals(altCodingSystem.getValue())) { + if (HL7Constants.HL7_LOCAL_CONCEPT_NAME.equals(altCodingSystem.getValue())) { String hl7ConceptNameId = altIdentifier.getValue(); return getConceptName(hl7ConceptNameId); } @@ -856,7 +856,7 @@ * @should return a mapped Concept if given a valid mapping */ protected Concept getConcept(String hl7ConceptId, String codingSystem, String uid) throws HL7Exception { - if (FormConstants.HL7_LOCAL_CONCEPT.equals(codingSystem)) { + if (HL7Constants.HL7_LOCAL_CONCEPT.equals(codingSystem)) { // the concept is local try { Integer conceptId = new Integer(hl7ConceptId); Index: org/openmrs/util/FormConstants.java =================================================================== --- org/openmrs/util/FormConstants.java (revision 13548) +++ org/openmrs/util/FormConstants.java (working copy) @@ -15,6 +15,8 @@ import java.util.Hashtable; +import org.openmrs.hl7.HL7Constants; + /** * Constants relating to forms * @@ -36,44 +38,110 @@ public static final Integer FIELD_TYPE_SECTION = 5; - public static final String HL7_TEXT = "ST"; + /** + * @deprecated Moved the constant to HL7Constants class + */ + @Deprecated + public static final String HL7_TEXT = HL7Constants.HL7_TEXT; - public static final String HL7_CODED = "CE"; + /** + * @deprecated Moved the constant to HL7Constants class + */ + @Deprecated + public static final String HL7_CODED = HL7Constants.HL7_CODED; - public static final String HL7_CODED_WITH_EXCEPTIONS = "CWE"; + /** + * @deprecated Moved the constant to HL7Constants class + */ + @Deprecated + public static final String HL7_CODED_WITH_EXCEPTIONS = HL7Constants.HL7_CODED_WITH_EXCEPTIONS; - public static final String HL7_NUMERIC = "NM"; + /** + * @deprecated Moved the constant to HL7Constants class + */ + @Deprecated + public static final String HL7_NUMERIC = HL7Constants.HL7_NUMERIC; - public static final String HL7_DATE = "DT"; + /** + * @deprecated Moved the constant to HL7Constants class + */ + @Deprecated + public static final String HL7_DATE = HL7Constants.HL7_DATE; - public static final String HL7_TIME = "TM"; + /** + * @deprecated Moved the constant to HL7Constants class + */ + @Deprecated + public static final String HL7_TIME = HL7Constants.HL7_TIME; - public static final String HL7_DATETIME = "TS"; + /** + * @deprecated Moved the constant to HL7Constants class + */ + @Deprecated + public static final String HL7_DATETIME = HL7Constants.HL7_DATETIME; - public static final String HL7_BOOLEAN = "BIT"; + /** + * @deprecated Moved the constant to HL7Constants class + */ + @Deprecated + public static final String HL7_BOOLEAN = HL7Constants.HL7_BOOLEAN; - public static final String HL7_AUTHORITY_UUID = "UUID"; + /** + * @deprecated Moved the constant to HL7Constants class + */ + @Deprecated + public static final String HL7_AUTHORITY_UUID = HL7Constants.HL7_AUTHORITY_UUID; - public static final String HL7_AUTHORITY_LOCAL = "L"; + /** + * @deprecated Moved the constant to HL7Constants class + */ + @Deprecated + public static final String HL7_AUTHORITY_LOCAL = HL7Constants.HL7_AUTHORITY_LOCAL; - public static final Object HL7_ID_PERSON = "PN"; + /** + * @deprecated Moved the constant to HL7Constants class + */ + @Deprecated + public static final Object HL7_ID_PERSON = HL7Constants.HL7_ID_PERSON; - public static final Object HL7_ID_PATIENT = "PI"; + /** + * @deprecated Moved the constant to HL7Constants class + */ + @Deprecated + public static final Object HL7_ID_PATIENT = HL7Constants.HL7_ID_PATIENT; - public static final Integer CLASS_DRUG = 3; + @Deprecated + public static final Integer CLASS_DRUG = HL7Constants.CLASS_DRUG; /** * Used in hl7 sextuplets: 123^Primary name^99DCT^345^Chosen name^99NAM */ - public static final String HL7_LOCAL_CONCEPT = "99DCT"; + @Deprecated + public static final String HL7_LOCAL_CONCEPT = HL7Constants.HL7_LOCAL_CONCEPT; - public static final String HL7_LOCAL_CONCEPT_NAME = "99NAM"; + /** + * @deprecated Moved the constant to HL7Constants class + */ + @Deprecated + public static final String HL7_LOCAL_CONCEPT_NAME = HL7Constants.HL7_LOCAL_CONCEPT_NAME; - public static final String HL7_LOCAL_DRUG = "99RX"; - - public static final String HL7_LOCAL_RELATIONSHIP = "99REL"; + /** + * @deprecated Moved the constant to HL7Constants class + */ + @Deprecated + public static final String HL7_LOCAL_DRUG = HL7Constants.HL7_LOCAL_DRUG; - // List of datatypes that do not require complex definitions + /** + * @deprecated Moved the constant to HL7Constants class + */ + @Deprecated + public static final String HL7_LOCAL_RELATIONSHIP = HL7Constants.HL7_LOCAL_RELATIONSHIP; + + /** + * @deprecated Moved the constant to HL7Constants class, List of datatypes that do not require + * complex definitions + */ + @Deprecated public static final Hashtable simpleDatatypes = new Hashtable(); static { simpleDatatypes.put(HL7_TEXT, "xs:string"); Index: org/openmrs/util/FormUtil.java =================================================================== --- org/openmrs/util/FormUtil.java (revision 13548) +++ org/openmrs/util/FormUtil.java (working copy) @@ -29,6 +29,7 @@ import org.openmrs.Drug; import org.openmrs.Form; import org.openmrs.FormField; +import org.openmrs.hl7.HL7Constants; /** * OpenMRS utilities related to forms. @@ -215,7 +216,7 @@ * @return String representation of the given concept */ public static String conceptToString(Concept concept, ConceptName localizedName) { - return concept.getConceptId() + "^" + localizedName.getName() + "^" + FormConstants.HL7_LOCAL_CONCEPT; // + "^" + return concept.getConceptId() + "^" + localizedName.getName() + "^" + HL7Constants.HL7_LOCAL_CONCEPT; // + "^" // + localizedName.getConceptNameId() + "^" + localizedName.getName() + "^" + FormConstants.HL7_LOCAL_CONCEPT_NAME; } @@ -226,6 +227,6 @@ * @return String representation of the given drug */ public static String drugToString(Drug drug) { - return drug.getDrugId() + "^" + drug.getName() + "^" + FormConstants.HL7_LOCAL_DRUG; + return drug.getDrugId() + "^" + drug.getName() + "^" + HL7Constants.HL7_LOCAL_DRUG; } }