Java Code Examples for ca.uhn.hl7v2.model.Segment

The following are top voted examples for showing how to use ca.uhn.hl7v2.model.Segment. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: OSCAR-ConCert   File: TDISHandler.java   Source Code and License 6 votes vote down vote up
public String getOBXIdentifier(int i, int j) {

		try {

			Terser t = new Terser(msg);
			Segment obxSeg = ((ca.uhn.hl7v2.model.v25.segment.OBX) ((ArrayList) obrSegMap.get(obrSegKeySet.get(i)))
					.get(j));
			String ident = getString(Terser.get(obxSeg, 3, 0, 1, 1));
			String subIdent = Terser.get(obxSeg, 3, 0, 1, 2);

			if (subIdent != null)
				ident = ident + "&" + subIdent;

			//logger.info("returning obx identifier: " + ident);
			return (ident);
		} catch (Exception e) {
			logger.error("error returning obx identifier", e);

		}
		return "";
	}
 
Example 2
Project: OSCAR-ConCert   File: PFHTHandler.java   Source Code and License 6 votes vote down vote up
public String getOBXIdentifier(int i, int j){

	        try{

	            Segment obxSeg = ((obrSegMap.get(obrSegKeySet.get(i))).get(j));
	            String ident = getString(Terser.get(obxSeg, 3, 0, 1, 1 ));
	            String subIdent = Terser.get(obxSeg, 3, 0, 1, 2);

	            if (subIdent != null)
	                ident = ident+"&"+subIdent;

	            logger.info("returning obx identifier: "+ident);
	            return(ident);
	        }catch(Exception e){
	            logger.error("error returning obx identifier", e);
	            return("");
	        }
	    }
 
Example 3
Project: OSCAR-ConCert   File: BioTestHandler.java   Source Code and License 6 votes vote down vote up
public String getOBXIdentifier(int i, int j){

        try{

            Segment obxSeg = (( obrSegMap.get(obrSegKeySet.get(i))).get(j));
            String ident = getString(Terser.get(obxSeg, 3, 0, 1, 1 ));
            String subIdent = Terser.get(obxSeg, 3, 0, 1, 2);

            if (subIdent != null)
                ident = ident+"&"+subIdent;

            logger.info("returning obx identifier: "+ident);
            return(ident);
        }catch(Exception e){
            logger.error("error returning obx identifier", e);
            return("");
        }
    }
 
Example 4
Project: OSCAR-ConCert   File: DefaultGenericHandler.java   Source Code and License 6 votes vote down vote up
public String getOBRName(int i){

        String obrName;
        i++;
        try{
            if (i == 1){

                obrName = getString(terser.get("/.OBR-4-2"));
                if (obrName.equals(""))
                    obrName = getString(terser.get("/.OBR-4-1"));

            }else{
                Segment obrSeg = (Segment) terser.getFinder().getRoot().get("OBR"+i);
                obrName = getString(Terser.get(obrSeg,4,0,2,1));
                if (obrName.equals(""))
                    obrName = getString(Terser.get(obrSeg,4,0,1,1));

            }

            return(obrName);

        }catch(Exception e){
            return("");
        }
    }
 
Example 5
Project: OSCAR-ConCert   File: DefaultGenericHandler.java   Source Code and License 6 votes vote down vote up
public String getOBRComment(int i, int j){

        try{
            String[] segments = terser.getFinder().getRoot().getNames();
            int k = getNTELocation(i, -1);

            Structure[] nteSegs = terser.getFinder().getRoot().getAll(segments[k]);
            Segment nteSeg = (Segment) nteSegs[j];
            return(getString(Terser.get(nteSeg,3,0,1,1)));

        }catch(Exception e){
            logger.error("Could not retrieve OBX comments", e);

            return("");
        }
    }
 
Example 6
Project: OSCAR-ConCert   File: IHAHandler.java   Source Code and License 6 votes vote down vote up
@Override
public String getOBRName(int i){
    
    String obrName,sendApp;
    i++;
    try{
    	sendApp=getSendingApplication();
    	if(sendApp.startsWith("IHA")) sendApp = sendApp.substring(3);
        if (i == 1){
            obrName = getString(terser.get("/.OBR-4-2"));  //Universal Service ID
            if (obrName.equals(""))
                obrName = getString(terser.get("/.OBR-4-1"));
        }else{
            Segment obrSeg = (Segment) terser.getFinder().getRoot().get("OBR"+i);
            obrName = getString(Terser.get(obrSeg,4,0,2,1));
            if (obrName.equals(""))
                obrName = getString(Terser.get(obrSeg,4,0,1,1));
        }
        
        return(obrName);
        
    }catch(Exception e){
        return("");
    }
}
 
Example 7
Project: OSCAR-ConCert   File: IHAHandler.java   Source Code and License 6 votes vote down vote up
@Override
public String getOBRComment(int i, int j){
    
    try{
        String[] segments = terser.getFinder().getRoot().getNames();
        int k = getNTELocation(i, -1);
        
        Structure[] nteSegs = terser.getFinder().getRoot().getAll(segments[k]);
        Segment nteSeg = (Segment) nteSegs[j];
        return(getString(Terser.get(nteSeg,3,0,1,1)));
        
    }catch(Exception e){
        logger.error("Could not retrieve OBX comments", e);
        
        return("");
    }
}
 
Example 8
Project: OSCAR-ConCert   File: IHAHandler.java   Source Code and License 6 votes vote down vote up
@Override
public String getTimeStamp(int i, int j){
    String timeStamp;
    i++;
    try{
        if (i == 1){
            timeStamp = formatDateTime(getString(terser.get("/.OBR-7-1")));
        }else{
            Segment obrSeg = (Segment) terser.getFinder().getRoot().get("OBR"+i);
            timeStamp = formatDateTime(getString(Terser.get(obrSeg,7,0,1,1)));
        }
        return(timeStamp);
    }catch(Exception e){
        return("");
    }
}
 
Example 9
Project: OSCAR-ConCert   File: IHAHandler.java   Source Code and License 6 votes vote down vote up
@Override
public String getOBXComment(int i, int j, int nteNum){
    
    
    try{
        
        String[] segments = terser.getFinder().getRoot().getNames();
        int k = getNTELocation(i, j);
        Structure[] nteSegs = terser.getFinder().getRoot().getAll(segments[k]);
        Segment nteSeg = (Segment) nteSegs[nteNum];
        return(getString(Terser.get(nteSeg,3,0,1,1)));
        
    }catch(Exception e){
        logger.error("Could not retrieve OBX comments", e);
        
        return("");
    }
}
 
Example 10
Project: OSCAR-ConCert   File: TRUENORTHHandler.java   Source Code and License 6 votes vote down vote up
public String getOBXIdentifier(int i, int j){

        try{ // no value for TRUENORTH
            Segment obxSeg = (( obrSegMap.get(obrSegKeySet.get(i))).get(j));
            String ident = getString(Terser.get(obxSeg, 3, 0, 1, 1 ));
            String subIdent = Terser.get(obxSeg, 3, 0, 1, 2);

            if (subIdent != null)
                ident = ident+"&"+subIdent;

            logger.debug("returning obx identifier: "+ident);
            return(ident);
        }catch(Exception e){
            logger.error("error returning obx identifier", e);
            return("");
        }
    }
 
Example 11
Project: OSCAR-ConCert   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
private void parseERRSegment() throws HL7Exception {
	Segment err = terser.getSegment("/.ERR");
	errors = new ArrayList<OLISError>();
	String segment, sequence, field, identifier, text;
	int rep = -1;
	while ((identifier = Terser.get(err, 1, ++rep, 4, 1)) != null) {
		if (identifier.trim().equals("320")) {
			reportBlocked = true;
		}
		segment = Terser.get(err, 1, rep, 1, 1);
		sequence = Terser.get(err, 1, rep, 1, 2);
		field = Terser.get(err, 1, rep, 1, 3);
		text = Terser.get(err, 1, rep, 4, 2);
		errors.add(new OLISError(segment, sequence, field, identifier, text));
	}
}
 
Example 12
Project: OSCAR-ConCert   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
private void mapOBXSortKey(int obr) {
	HashMap<String, Integer> obxMap = null;
	int k;
	String tempKey;
	obxMap = new HashMap<String, Integer>();
	for (int i = 0; i < getOBXCount(obr); i++) {

		try {
			k = getZBXLocation(obr, i);
			String[] segments = terser.getFinder().getRoot().getNames();
			if (!segments[k].startsWith("ZBX")) {
				continue;
			}
			Structure[] zbxSegs = terser.getFinder().getRoot().getAll(segments[k]);
			Segment zbxSeg = (Segment) zbxSegs[0];
			tempKey = getString(Terser.get(zbxSeg, 2, 0, 1, 1));
			obxMap.put(tempKey.equals("") ? String.valueOf(i) : tempKey, i);

		} catch (Exception e) {
			MiscUtils.getLogger().error("OLIS HL7 Error", e);
		}
	}
	obxSortMap.put(obr, obxMap);
}
 
Example 13
Project: OSCAR-ConCert   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
public String getCollectorsComment(int i) {
	String comment;
	i++;
	try {
		if (i == 1) {
			comment = getString(terser.get("/.OBR-39-2"));
		} else {
			Segment obrSeg = (Segment) terser.getFinder().getRoot().get("OBR" + i);
			comment = getString(Terser.get(obrSeg, 39, 0, 2, 1));
		}
		return comment;

	} catch (Exception e) {
		return ("");
	}

}
 
Example 14
Project: OSCAR-ConCert   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
public String getCollectorsCommentSourceOrganization(int i) {
	String ident;
	String id;
	i++;
	try {
		if (i == 1) {
			id = getString(terser.get("/.ZBR-3-6-2"));
			ident = getString(terser.get("/.ZBR-3-1"));

		} else {
			Segment zbrSeg = (Segment) terser.getFinder().getRoot().get("ZBR" + i);
			ident = getString(Terser.get(zbrSeg, 3, 0, 1, 1));
			id = getString(Terser.get(zbrSeg, 3, 0, 6, 2));
		}
		if (id != null && id.trim().length() > 0) {
			id = id.substring(id.indexOf(":") + 1);
		}
		return ident + " (" + id + ")";

	} catch (Exception e) {
		return ("");
	}

}
 
Example 15
Project: OSCAR-ConCert   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
@Override
public String getOBRName(int i) {

	String obrName;
	i++;
	try {
		if (i == 1) {

			obrName = getString(terser.get("/.OBR-4-2"));
			if (obrName.equals("")) obrName = getString(terser.get("/.OBR-4-1"));

		} else {
			Segment obrSeg = (Segment) terser.getFinder().getRoot().get("OBR" + i);
			obrName = getString(Terser.get(obrSeg, 4, 0, 2, 1));
			if (obrName.equals("")) obrName = getString(Terser.get(obrSeg, 4, 0, 1, 1));

		}

		return (obrName);

	} catch (Exception e) {
		return ("");
	}
}
 
Example 16
Project: OSCAR-ConCert   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
@Override
public String getTimeStamp(int i, int j) {
	String timeStamp;
	i++;
	try {
		if (i == 1) {
			timeStamp = formatDateTime(getString(terser.get("/.OBR-7-1")));
		} else {
			Segment obrSeg = (Segment) terser.getFinder().getRoot().get("OBR" + i);
			timeStamp = formatDateTime(getString(Terser.get(obrSeg, 7, 0, 1, 1)));
		}
		return (timeStamp);
	} catch (Exception e) {
		return ("");
	}
}
 
Example 17
Project: OSCAR-ConCert   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
@Override
public String getOBRComment(int i, int j) {

	try {
		String[] segments = terser.getFinder().getRoot().getNames();
		int k = getNTELocation(i, -1);
		if (j > 0) {
			k = indexOfNextNTE(segments, k + 1, j);
		}
		Structure[] nteSegs = terser.getFinder().getRoot().getAll(segments[k]);
		Segment nteSeg = (Segment) nteSegs[0];
		return formatString(getString(Terser.get(nteSeg, 3, 0, 1, 1)));

	} catch (Exception e) {
		logger.error("Could not retrieve OBR comments", e);

		return ("");
	}
}
 
Example 18
Project: OSCAR-ConCert   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
public String getOBRSourceOrganization(int i, int j) {
	try {
		String[] segments = terser.getFinder().getRoot().getNames();
		int k = getNTELocation(i, -1);
		if (j > 0) {
			k = indexOfNextNTE(segments, k + 1, j);
		}
		k++;
		Structure[] ZNTSegs = terser.getFinder().getRoot().getAll(segments[k]);
		Segment ZNTSeg = (Segment) ZNTSegs[0];
		String key = Terser.get(ZNTSeg, 1, 0, 2, 1);
		if (key == null || key.indexOf(":") == -1) {
			return "";
		}
		String ident = key.substring(0, key.indexOf(":"));
		ident = getOrganizationType(ident);
		key = key.substring(key.indexOf(":") + 1);
		return sourceOrganizations.get(key) + " (" + ident + " " + key + ")";

	} catch (Exception e) {
		logger.error("Could not retrieve OBX comment ZNT", e);

		return ("");
	}
}
 
Example 19
Project: OSCAR-ConCert   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
public String getReportComment(int j) {

		try {
			String[] segments = terser.getFinder().getRoot().getNames();
			int k = getNTELocation(-1, -1);
			if (j > 0) {
				k = indexOfNextNTE(segments, k + 1, j);
			}
			Structure[] nteSegs = terser.getFinder().getRoot().getAll(segments[k]);
			Segment nteSeg = (Segment) nteSegs[0];
			return formatString(getString(Terser.get(nteSeg, 3, 0, 1, 1)));

		} catch (Exception e) {
			logger.error("Could not retrieve OBR comments", e);

			return ("");
		}
	}
 
Example 20
Project: OSCAR-ConCert   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
public String getReportSourceOrganization(int j) {
	try {
		String[] segments = terser.getFinder().getRoot().getNames();
		int k = getNTELocation(-1, -1);
		if (j > 0) {
			k = indexOfNextNTE(segments, k + 1, j);
		}
		k++;
		Structure[] ZNTSegs = terser.getFinder().getRoot().getAll(segments[k]);
		Segment ZNTSeg = (Segment) ZNTSegs[0];
		String key = Terser.get(ZNTSeg, 1, 0, 2, 1);
		if (key == null || key.indexOf(":") == -1) {
			return "";
		}
		String ident = key.substring(0, key.indexOf(":"));
		ident = getOrganizationType(ident);
		key = key.substring(key.indexOf(":") + 1);
		return String.format("%s (%s %s)", sourceOrganizations.get(key), ident, key);
	} catch (Exception e) {
		logger.error("Could not retrieve OBX comment ZNT", e);

		return ("");
	}
}
 
Example 21
Project: OSCAR-ConCert   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
@Override
public String getOBXComment(int i, int j, int nteNum) {
	try {
		String[] segments = terser.getFinder().getRoot().getNames();
		int k = getNTELocation(i, j);
		if (nteNum > 0) {
			k = indexOfNextNTE(segments, k, nteNum + 1);
		}
		Structure[] nteSegs = terser.getFinder().getRoot().getAll(segments[k]);
		Segment nteSeg = (Segment) nteSegs[0];
		return formatString(getString(Terser.get(nteSeg, 3, 0, 1, 1))).replace(" ", "&nbsp;");

	} catch (Exception e) {
		logger.error("Could not retrieve OBX comments", e);

		return ("");
	}
}
 
Example 22
Project: OSCAR-ConCert   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
public String getOBXSourceOrganization(int i, int j, int nteNum) {
	try {
		String[] segments = terser.getFinder().getRoot().getNames();
		int k = getNTELocation(i, j);
		if (nteNum > 0) {
			k = indexOfNextNTE(segments, k, nteNum + 1);
		}
		k++;
		Structure[] ZNTSegs = terser.getFinder().getRoot().getAll(segments[k]);
		Segment ZNTSeg = (Segment) ZNTSegs[0];
		String key = Terser.get(ZNTSeg, 1, 0, 2, 1);
		if (key == null || key.indexOf(":") == -1) {
			return "";
		}
		String ident = key.substring(0, key.indexOf(":"));
		ident = getOrganizationType(ident);
		key = key.substring(key.indexOf(":") + 1);
		return String.format("%s (%s %s)", sourceOrganizations.get(key), ident, key);

	} catch (Exception e) {
		logger.error("Could not retrieve OBX comment ZNT", e);

		return ("");
	}
}
 
Example 23
Project: product-ei   File: SampleApp.java   Source Code and License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Message processMessage(Message theIn) throws ApplicationException, HL7Exception {

    String encodedMessage = new PipeParser().encode(theIn);
    System.out.println("Received message:\n" + encodedMessage + "\n\n");

    // Now we need to generate a message to return. This will generally be an ACK message.
    Segment msh = (Segment) theIn.get("MSH");
    Message retVal;
    try {
        // This method takes in the MSH segment of an incoming message, and generates an
        // appropriate ACK
        retVal = DefaultApplication.makeACK(msh);
    } catch (IOException e) {
        throw new HL7Exception(e);
    }

    return retVal;
}
 
Example 24
Project: oscar-old   File: GDMLHandler.java   Source Code and License 6 votes vote down vote up
public String getOBXIdentifier(int i, int j){

        try{

            Terser t = new Terser(msg);
            Segment obxSeg = (( obrSegMap.get(obrSegKeySet.get(i))).get(j));
            String ident = getString(Terser.get(obxSeg, 3, 0, 1, 1 ));
            String subIdent = Terser.get(obxSeg, 3, 0, 1, 2);

            if (subIdent != null)
                ident = ident+"&"+subIdent;

            logger.info("returning obx identifier: "+ident);
            return(ident);
        }catch(Exception e){
            logger.error("error returning obx identifier", e);
            return("");
        }
    }
 
Example 25
Project: oscar-old   File: TDISHandler.java   Source Code and License 6 votes vote down vote up
public String getOBXIdentifier(int i, int j) {

		try {

			Terser t = new Terser(msg);
			Segment obxSeg = ((ca.uhn.hl7v2.model.v25.segment.OBX) ((ArrayList) obrSegMap.get(obrSegKeySet.get(i)))
					.get(j));
			String ident = getString(Terser.get(obxSeg, 3, 0, 1, 1));
			String subIdent = Terser.get(obxSeg, 3, 0, 1, 2);

			if (subIdent != null)
				ident = ident + "&" + subIdent;

			//logger.info("returning obx identifier: " + ident);
			return (ident);
		} catch (Exception e) {
			logger.error("error returning obx identifier", e);

		}
		return "";
	}
 
Example 26
Project: oscar-old   File: PFHTHandler.java   Source Code and License 6 votes vote down vote up
public String getOBXIdentifier(int i, int j){

	        try{

	            Segment obxSeg = ((obrSegMap.get(obrSegKeySet.get(i))).get(j));
	            String ident = getString(Terser.get(obxSeg, 3, 0, 1, 1 ));
	            String subIdent = Terser.get(obxSeg, 3, 0, 1, 2);

	            if (subIdent != null)
	                ident = ident+"&"+subIdent;

	            logger.info("returning obx identifier: "+ident);
	            return(ident);
	        }catch(Exception e){
	            logger.error("error returning obx identifier", e);
	            return("");
	        }
	    }
 
Example 27
Project: oscar-old   File: HRSRHHandler.java   Source Code and License 6 votes vote down vote up
public String getObservationHeader(int i, int j)
{
  String header = "";
  try {
    header = getString(((OBR)this.obrSegKeySet.get(i)).getUniversalServiceIdentifier().getText().getValue());

    if ((this.msg.getMSH().getSendingApplication().getNamespaceID().getValue().equals("ITS")) && (header.equals(""))) {
      header = getString(Terser.get((Segment)this.obrSegKeySet.get(i), 21, 0, 2, 1)).equals("") ? "Health Records" : getString(Terser.get((Segment)this.obrSegKeySet.get(i), 21, 0, 2, 1));
    }
  }
  catch (Exception e)
  {
    this.logger.error("Exception getting header", e);
  }

  return header;
}
 
Example 28
Project: oscar-old   File: HRSRHHandler.java   Source Code and License 6 votes vote down vote up
public String getOBXIdentifier(int i, int j)
{
  try
  {
    Segment obxSeg = (Segment)((ArrayList)this.obrSegMap.get(this.obrSegKeySet.get(i))).get(j);
    String ident = getString(Terser.get(obxSeg, 3, 0, 1, 1));
    String subIdent = Terser.get(obxSeg, 3, 0, 1, 2);

    if (subIdent != null) {
      ident = new StringBuilder().append(ident).append("&").append(subIdent).toString();
    }
    this.logger.info(new StringBuilder().append("returning obx identifier: ").append(ident).toString());
    return ident;
  } catch (Exception e) {
    this.logger.error("error returning obx identifier", e);
  }return "";
}
 
Example 29
Project: oscar-old   File: DefaultGenericHandler.java   Source Code and License 6 votes vote down vote up
public String getOBRName(int i){

        String obrName;
        i++;
        try{
            if (i == 1){

                obrName = getString(terser.get("/.OBR-4-2"));
                if (obrName.equals(""))
                    obrName = getString(terser.get("/.OBR-4-1"));

            }else{
                Segment obrSeg = (Segment) terser.getFinder().getRoot().get("OBR"+i);
                obrName = getString(Terser.get(obrSeg,4,0,2,1));
                if (obrName.equals(""))
                    obrName = getString(Terser.get(obrSeg,4,0,1,1));

            }

            return(obrName);

        }catch(Exception e){
            return("");
        }
    }
 
Example 30
Project: oscar-old   File: DefaultGenericHandler.java   Source Code and License 6 votes vote down vote up
public String getOBRComment(int i, int j){

        try{
            String[] segments = terser.getFinder().getRoot().getNames();
            int k = getNTELocation(i, -1);

            Structure[] nteSegs = terser.getFinder().getRoot().getAll(segments[k]);
            Segment nteSeg = (Segment) nteSegs[j];
            return(getString(Terser.get(nteSeg,3,0,1,1)));

        }catch(Exception e){
            logger.error("Could not retrieve OBX comments", e);

            return("");
        }
    }
 
Example 31
Project: oscar-old   File: IHAHandler.java   Source Code and License 6 votes vote down vote up
@Override
public String getOBRName(int i){
    
    String obrName,sendApp;
    i++;
    try{
    	sendApp=getSendingApplication();
    	if(sendApp.startsWith("IHA")) sendApp = sendApp.substring(3);
        if (i == 1){
            obrName = getString(terser.get("/.OBR-4-2"));  //Universal Service ID
            if (obrName.equals(""))
                obrName = getString(terser.get("/.OBR-4-1"));
        }else{
            Segment obrSeg = (Segment) terser.getFinder().getRoot().get("OBR"+i);
            obrName = getString(Terser.get(obrSeg,4,0,2,1));
            if (obrName.equals(""))
                obrName = getString(Terser.get(obrSeg,4,0,1,1));
        }
        
        return(obrName);
        
    }catch(Exception e){
        return("");
    }
}
 
Example 32
Project: oscar-old   File: IHAHandler.java   Source Code and License 6 votes vote down vote up
@Override
public String getOBRComment(int i, int j){
    
    try{
        String[] segments = terser.getFinder().getRoot().getNames();
        int k = getNTELocation(i, -1);
        
        Structure[] nteSegs = terser.getFinder().getRoot().getAll(segments[k]);
        Segment nteSeg = (Segment) nteSegs[j];
        return(getString(Terser.get(nteSeg,3,0,1,1)));
        
    }catch(Exception e){
        logger.error("Could not retrieve OBX comments", e);
        
        return("");
    }
}
 
Example 33
Project: oscar-old   File: IHAHandler.java   Source Code and License 6 votes vote down vote up
@Override
public String getTimeStamp(int i, int j){
    String timeStamp;
    i++;
    try{
        if (i == 1){
            timeStamp = formatDateTime(getString(terser.get("/.OBR-7-1")));
        }else{
            Segment obrSeg = (Segment) terser.getFinder().getRoot().get("OBR"+i);
            timeStamp = formatDateTime(getString(Terser.get(obrSeg,7,0,1,1)));
        }
        return(timeStamp);
    }catch(Exception e){
        return("");
    }
}
 
Example 34
Project: oscar-old   File: IHAHandler.java   Source Code and License 6 votes vote down vote up
@Override
public String getOBXComment(int i, int j, int nteNum){
    
    
    try{
        
        String[] segments = terser.getFinder().getRoot().getNames();
        int k = getNTELocation(i, j);
        Structure[] nteSegs = terser.getFinder().getRoot().getAll(segments[k]);
        Segment nteSeg = (Segment) nteSegs[nteNum];
        return(getString(Terser.get(nteSeg,3,0,1,1)));
        
    }catch(Exception e){
        logger.error("Could not retrieve OBX comments", e);
        
        return("");
    }
}
 
Example 35
Project: oscar-old   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
private void parseERRSegment() throws HL7Exception {
	Segment err = terser.getSegment("/.ERR");
	errors = new ArrayList<OLISError>();
	String segment, sequence, field, identifier, text;
	int rep = -1;
	while ((identifier = Terser.get(err, 1, ++rep, 4, 1)) != null) {
		if (identifier.trim().equals("320")) {
			reportBlocked = true;
		}
		segment = Terser.get(err, 1, rep, 1, 1);
		sequence = Terser.get(err, 1, rep, 1, 2);
		field = Terser.get(err, 1, rep, 1, 3);
		text = Terser.get(err, 1, rep, 4, 2);
		errors.add(new OLISError(segment, sequence, field, identifier, text));
	}
}
 
Example 36
Project: oscar-old   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
private void mapOBXSortKey(int obr) {
	HashMap<String, Integer> obxMap = null;
	int k;
	String tempKey;
	obxMap = new HashMap<String, Integer>();
	for (int i = 0; i < getOBXCount(obr); i++) {

		try {
			k = getZBXLocation(obr, i);
			String[] segments = terser.getFinder().getRoot().getNames();
			if (!segments[k].startsWith("ZBX")) {
				continue;
			}
			Structure[] zbxSegs = terser.getFinder().getRoot().getAll(segments[k]);
			Segment zbxSeg = (Segment) zbxSegs[0];
			tempKey = getString(Terser.get(zbxSeg, 2, 0, 1, 1));
			obxMap.put(tempKey.equals("") ? String.valueOf(i) : tempKey, i);

		} catch (Exception e) {
			MiscUtils.getLogger().error("OLIS HL7 Error", e);
		}
	}
	obxSortMap.put(obr, obxMap);
}
 
Example 37
Project: oscar-old   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
public String getCollectorsComment(int i) {
	String comment;
	i++;
	try {
		if (i == 1) {
			comment = getString(terser.get("/.OBR-39-2"));
		} else {
			Segment obrSeg = (Segment) terser.getFinder().getRoot().get("OBR" + i);
			comment = getString(Terser.get(obrSeg, 39, 0, 2, 1));
		}
		return comment;

	} catch (Exception e) {
		return ("");
	}

}
 
Example 38
Project: oscar-old   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
public String getCollectorsCommentSourceOrganization(int i) {
	String ident;
	String id;
	i++;
	try {
		if (i == 1) {
			id = getString(terser.get("/.ZBR-3-6-2"));
			ident = getString(terser.get("/.ZBR-3-1"));

		} else {
			Segment zbrSeg = (Segment) terser.getFinder().getRoot().get("ZBR" + i);
			ident = getString(Terser.get(zbrSeg, 3, 0, 1, 1));
			id = getString(Terser.get(zbrSeg, 3, 0, 6, 2));
		}
		if (id != null && id.trim().length() > 0) {
			id = id.substring(id.indexOf(":") + 1);
		}
		return ident + " (" + id + ")";

	} catch (Exception e) {
		return ("");
	}

}
 
Example 39
Project: oscar-old   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
@Override
public String getOBRName(int i) {

	String obrName;
	i++;
	try {
		if (i == 1) {

			obrName = getString(terser.get("/.OBR-4-2"));
			if (obrName.equals("")) obrName = getString(terser.get("/.OBR-4-1"));

		} else {
			Segment obrSeg = (Segment) terser.getFinder().getRoot().get("OBR" + i);
			obrName = getString(Terser.get(obrSeg, 4, 0, 2, 1));
			if (obrName.equals("")) obrName = getString(Terser.get(obrSeg, 4, 0, 1, 1));

		}

		return (obrName);

	} catch (Exception e) {
		return ("");
	}
}
 
Example 40
Project: oscar-old   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
@Override
public String getTimeStamp(int i, int j) {
	String timeStamp;
	i++;
	try {
		if (i == 1) {
			timeStamp = formatDateTime(getString(terser.get("/.OBR-7-1")));
		} else {
			Segment obrSeg = (Segment) terser.getFinder().getRoot().get("OBR" + i);
			timeStamp = formatDateTime(getString(Terser.get(obrSeg, 7, 0, 1, 1)));
		}
		return (timeStamp);
	} catch (Exception e) {
		return ("");
	}
}
 
Example 41
Project: oscar-old   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
@Override
public String getOBRComment(int i, int j) {

	try {
		String[] segments = terser.getFinder().getRoot().getNames();
		int k = getNTELocation(i, -1);
		if (j > 0) {
			k = indexOfNextNTE(segments, k + 1, j);
		}
		Structure[] nteSegs = terser.getFinder().getRoot().getAll(segments[k]);
		Segment nteSeg = (Segment) nteSegs[0];
		return formatString(getString(Terser.get(nteSeg, 3, 0, 1, 1)));

	} catch (Exception e) {
		logger.error("Could not retrieve OBR comments", e);

		return ("");
	}
}
 
Example 42
Project: oscar-old   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
public String getOBRSourceOrganization(int i, int j) {
	try {
		String[] segments = terser.getFinder().getRoot().getNames();
		int k = getNTELocation(i, -1);
		if (j > 0) {
			k = indexOfNextNTE(segments, k + 1, j);
		}
		k++;
		Structure[] ZNTSegs = terser.getFinder().getRoot().getAll(segments[k]);
		Segment ZNTSeg = (Segment) ZNTSegs[0];
		String key = Terser.get(ZNTSeg, 1, 0, 2, 1);
		if (key == null || key.indexOf(":") == -1) {
			return "";
		}
		String ident = key.substring(0, key.indexOf(":"));
		ident = getOrganizationType(ident);
		key = key.substring(key.indexOf(":") + 1);
		return sourceOrganizations.get(key) + " (" + ident + " " + key + ")";

	} catch (Exception e) {
		logger.error("Could not retrieve OBX comment ZNT", e);

		return ("");
	}
}
 
Example 43
Project: oscar-old   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
public String getReportComment(int j) {

		try {
			String[] segments = terser.getFinder().getRoot().getNames();
			int k = getNTELocation(-1, -1);
			if (j > 0) {
				k = indexOfNextNTE(segments, k + 1, j);
			}
			Structure[] nteSegs = terser.getFinder().getRoot().getAll(segments[k]);
			Segment nteSeg = (Segment) nteSegs[0];
			return formatString(getString(Terser.get(nteSeg, 3, 0, 1, 1)));

		} catch (Exception e) {
			logger.error("Could not retrieve OBR comments", e);

			return ("");
		}
	}
 
Example 44
Project: oscar-old   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
public String getReportSourceOrganization(int j) {
	try {
		String[] segments = terser.getFinder().getRoot().getNames();
		int k = getNTELocation(-1, -1);
		if (j > 0) {
			k = indexOfNextNTE(segments, k + 1, j);
		}
		k++;
		Structure[] ZNTSegs = terser.getFinder().getRoot().getAll(segments[k]);
		Segment ZNTSeg = (Segment) ZNTSegs[0];
		String key = Terser.get(ZNTSeg, 1, 0, 2, 1);
		if (key == null || key.indexOf(":") == -1) {
			return "";
		}
		String ident = key.substring(0, key.indexOf(":"));
		ident = getOrganizationType(ident);
		key = key.substring(key.indexOf(":") + 1);
		return String.format("%s (%s %s)", sourceOrganizations.get(key), ident, key);
	} catch (Exception e) {
		logger.error("Could not retrieve OBX comment ZNT", e);

		return ("");
	}
}
 
Example 45
Project: oscar-old   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
@Override
public String getOBXComment(int i, int j, int nteNum) {
	try {
		String[] segments = terser.getFinder().getRoot().getNames();
		int k = getNTELocation(i, j);
		if (nteNum > 0) {
			k = indexOfNextNTE(segments, k, nteNum + 1);
		}
		Structure[] nteSegs = terser.getFinder().getRoot().getAll(segments[k]);
		Segment nteSeg = (Segment) nteSegs[0];
		return formatString(getString(Terser.get(nteSeg, 3, 0, 1, 1))).replace(" ", "&nbsp;");

	} catch (Exception e) {
		logger.error("Could not retrieve OBX comments", e);

		return ("");
	}
}
 
Example 46
Project: oscar-old   File: OLISHL7Handler.java   Source Code and License 6 votes vote down vote up
public String getOBXSourceOrganization(int i, int j, int nteNum) {
	try {
		String[] segments = terser.getFinder().getRoot().getNames();
		int k = getNTELocation(i, j);
		if (nteNum > 0) {
			k = indexOfNextNTE(segments, k, nteNum + 1);
		}
		k++;
		Structure[] ZNTSegs = terser.getFinder().getRoot().getAll(segments[k]);
		Segment ZNTSeg = (Segment) ZNTSegs[0];
		String key = Terser.get(ZNTSeg, 1, 0, 2, 1);
		if (key == null || key.indexOf(":") == -1) {
			return "";
		}
		String ident = key.substring(0, key.indexOf(":"));
		ident = getOrganizationType(ident);
		key = key.substring(key.indexOf(":") + 1);
		return String.format("%s (%s %s)", sourceOrganizations.get(key), ident, key);

	} catch (Exception e) {
		logger.error("Could not retrieve OBX comment ZNT", e);

		return ("");
	}
}
 
Example 47
Project: rassyeyanie   File: SymA13PimsA11.java   Source Code and License 6 votes vote down vote up
public
    void
    dispatchProcessFixture(@Header(HL7AdditionalConstants.HL7_SOURCE_MESSAGE) ADT_A01 from,
                           @Body ADT_A01 to)
        throws HL7Exception
{
    
    this.changeMessageEventType(to, "A11");
    
    this.tranformPid(to.getPID());
    
    Segment zrf = this.promoteZrfSegment(from);
    
    this.transformZrf(zrf, to.getPV1());
    this.transform(to.getPV1(), zrf);
    
    to.addNonstandardSegment("ZRF");
    Segment toZrf = (Segment) to.insertRepetition("ZRF", 0);
    DeepCopy.copy(zrf, toZrf);
}
 
Example 48
Project: rassyeyanie   File: SymA13PimsA11.java   Source Code and License 6 votes vote down vote up
private Segment promoteZrfSegment(ADT_A01 message)
    throws HL7Exception
{
    
    int countPr1 = message.getPROCEDUREReps();
    if (countPr1 > 0)
    {
        ADT_A01_PROCEDURE lastProcedure =
            message.getPROCEDURE(countPr1 - 1);
        
        lastProcedure.addNonstandardSegment("ZRF");
        Segment zrf = (Segment) lastProcedure.get("ZRF");
        
        return zrf;
    }
    else
    {
        return (Segment) message.get("ZRF");
    }
}
 
Example 49
Project: rassyeyanie   File: SymA13PimsA13.java   Source Code and License 6 votes vote down vote up
private Segment promoteZrfSegment(ADT_A01 message)
    throws HL7Exception
{
    
    int countPr1 = message.getPROCEDUREReps();
    if (countPr1 > 0)
    {
        ADT_A01_PROCEDURE lastProcedure =
            message.getPROCEDURE(countPr1 - 1);
        
        Segment zrf = (Segment) lastProcedure.get("ZRF");
        
        return zrf;
    }
    else
    {
        return (Segment) message.get("ZRF");
    }
}
 
Example 50
Project: rassyeyanie   File: SymA13PimsA12.java   Source Code and License 6 votes vote down vote up
public
    void
    dispatchProcessFixture(@Header(HL7AdditionalConstants.HL7_SOURCE_MESSAGE) ADT_A01 from,
                           @Body ADT_A01 to)
        throws HL7Exception
{
    
    this.changeMessageEventType(to, "A12");
    
    this.tranformPid(to.getPID());
    
    Segment zrf = this.promoteZrfSegment(from);
    
    this.transformZrf(zrf, to.getPV1());
    this.transform(to.getPV1(), zrf);
    
    to.addNonstandardSegment("ZRF");
    Segment toZrf = (Segment) to.insertRepetition("ZRF", 0);
    DeepCopy.copy(zrf, toZrf);
}
 
Example 51
Project: rassyeyanie   File: SymA13PimsA12.java   Source Code and License 6 votes vote down vote up
private Segment promoteZrfSegment(ADT_A01 message)
    throws HL7Exception
{
    
    int countPr1 = message.getPROCEDUREReps();
    if (countPr1 > 0)
    {
        ADT_A01_PROCEDURE lastProcedure =
            message.getPROCEDURE(countPr1 - 1);
        
        lastProcedure.addNonstandardSegment("ZRF");
        Segment zrf = (Segment) lastProcedure.get("ZRF");
        
        return zrf;
    }
    else
    {
        return (Segment) message.get("ZRF");
    }
}
 
Example 52
Project: OSCAR-ConCert   File: GDMLHandler.java   Source Code and License 5 votes vote down vote up
public String getOBXIdentifier(int i, int j){

        try{

            Segment obxSeg = (( obrSegMap.get(obrSegKeySet.get(i))).get(j));
            String ident = getString(getComponent(obxSeg, 3, 0, 1));

            logger.info("returning obx identifier: "+ident);
            return(ident);
        }catch(Exception e){
            logger.error("error returning obx identifier", e);
            return("");
        }
    }
 
Example 53
Project: OSCAR-ConCert   File: GDMLHandler.java   Source Code and License 5 votes vote down vote up
private String getComponent(Segment seg, int i, int j, int k) throws HL7Exception{
	//track "&" in field and process accordingly, & = sub-component separator in HL7
	String field = Terser.get(seg, i, j, k, 1);
	
	if (field!=null){
        int subIndex = 2;
    	String nextSub = Terser.get(seg, i, j, k, subIndex);
    	
    	while(nextSub != null){
    		field += "&" + getString(nextSub);
    		nextSub = Terser.get(seg, i, j, k, ++subIndex);
    	}
	}
	return field;
}
 
Example 54
Project: OSCAR-ConCert   File: CLSHandler.java   Source Code and License 5 votes vote down vote up
public String getOBXIdentifier(int i, int j) {
	try {
		Segment obxSeg = msg.getRESPONSE().getORDER_OBSERVATION(i).getOBSERVATION(j).getOBX();
		String subIdent = Terser.get(obxSeg, 3, 0, 1, 2);
		if (subIdent != null) { //HACK: for gdml labs generated with SubmitLabByFormAction
			return getString(msg.getRESPONSE().getORDER_OBSERVATION(i).getOBSERVATION(j).getOBX().getObservationIdentifier().getIdentifier().getValue()) + "&" + subIdent;
		}
		return (getString(msg.getRESPONSE().getORDER_OBSERVATION(i).getOBSERVATION(j).getOBX().getObservationIdentifier().getIdentifier().getValue()));
	} catch (Exception e) {
		return ("");
	}
}
 
Example 55
Project: OSCAR-ConCert   File: CMLHandler.java   Source Code and License 5 votes vote down vote up
public String getOBXIdentifier(int i, int j){
    try{
		Segment obxSeg = msg.getRESPONSE().getORDER_OBSERVATION(i).getOBSERVATION(j).getOBX();
		String subIdent = Terser.get(obxSeg, 3, 0, 1, 2) ;
		if(subIdent != null){ //HACK: for gdml labs generated with SubmitLabByFormAction
			return getString(msg.getRESPONSE().getORDER_OBSERVATION(i).getOBSERVATION(j).getOBX().getObservationIdentifier().getIdentifier().getValue())+"&"+subIdent;
		}
        return(getString(msg.getRESPONSE().getORDER_OBSERVATION(i).getOBSERVATION(j).getOBX().getObservationIdentifier().getIdentifier().getValue()));
    }catch(Exception e){
        return("");
    }
}
 
Example 56
Project: OSCAR-ConCert   File: SpireHandler.java   Source Code and License 5 votes vote down vote up
public String getOBXIdentifier(int i, int j){
    try{
		Segment obxSeg = msg.getRESPONSE().getORDER_OBSERVATION(i).getOBSERVATION(j).getOBX();	
		String subIdent = Terser.get(obxSeg, 3, 0, 1, 2) ;
		if(subIdent != null){ //HACK: for gdml labs generated with SubmitLabByFormAction
			return getString(msg.getRESPONSE().getORDER_OBSERVATION(i).getOBSERVATION(j).getOBX().getObservationIdentifier().getIdentifier().getValue())+"&"+subIdent;
		}
        return(getString(msg.getRESPONSE().getORDER_OBSERVATION(i).getOBSERVATION(j).getOBX().getObservationIdentifier().getIdentifier().getValue()));
    }catch(Exception e){
        return("");
    }
}
 
Example 57
Project: OSCAR-ConCert   File: DefaultGenericHandler.java   Source Code and License 5 votes vote down vote up
public String getTimeStamp(int i, int j){
    String timeStamp;
    i++;
    try{
        if (i == 1){
            timeStamp = formatDateTime(getString(terser.get("/.OBR-7-1")));
        }else{
            Segment obrSeg = (Segment) terser.getFinder().getRoot().get("OBR"+i);
            timeStamp = formatDateTime(getString(Terser.get(obrSeg,7,0,1,1)));
        }
        return(timeStamp);
    }catch(Exception e){
        return("");
    }
}
 
Example 58
Project: OSCAR-ConCert   File: DefaultGenericHandler.java   Source Code and License 5 votes vote down vote up
protected String getOBXField(int i, int j, int field, int rep, int comp){
    ArrayList<Segment> obxSegs = obrGroups.get(i);

    try{
        Segment obxSeg = obxSegs.get(j);
        return (getString(Terser.get(obxSeg, field, rep, comp, 1 )));
    }catch(Exception e){
        return("");
    }
}
 
Example 59
Project: OSCAR-ConCert   File: IHAHandler.java   Source Code and License 5 votes vote down vote up
protected String getOBXField(int i, int j, int field, int rep, int comp){
    ArrayList<Segment> obxSegs = obrGroups.get(i);
    
    try{
        Segment obxSeg = obxSegs.get(j);
        return (getString(Terser.get(obxSeg, field, rep, comp, 1 )));
    }catch(Exception e){
        return("");
    }
}
 
Example 60
Project: OSCAR-ConCert   File: HHSEmrDownloadHandler.java   Source Code and License 5 votes vote down vote up
private void findOBX(Group group,ArrayList<Structure> list) throws Exception{
    String[] noms = group.getNames();
    for (String nom:noms){
        Structure[] obxS = group.getAll(nom);
        for(Structure ss : obxS){
            if (ss instanceof Segment){
                if ("OBX".equals(ss.getName())){
                    list.add(ss);
                }
            }else{
                findOBX((Group) ss,list);
            }
        }
    }
}