Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bmule committed Mar 27, 2012
1 parent 6928fec commit 5af4727
Show file tree
Hide file tree
Showing 11 changed files with 208 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ public class MenuController extends FaceCommon {
home = new DefaultTreeNode(new DocumentReference("Error", "/jsf/home.xhtml", PhrsConstants.TYPE_ITEM_NODE_HEADER_LINK, codedLabel, root), root)//TYPE_ITEM_NODE_HOME
WebUtil.addFacesMessageSeverityWarn("Status", "System failed to start")

} else if (!UserSessionService.loggedIn()) {
} else if ( ! UserSessionService.loggedIn()) {
//no side bar menu
//home = new DefaultTreeNode(new DocumentReference("Home","/jsf/home.xhtml", PhrsConstants.TYPE_ITEM_NODE_HEADER_LINK,codedLabel,root), root)//TYPE_ITEM_NODE_HOME

} else if (UserSessionService.sessionUserHasMedicalRole()) {
LOGGER.debug("menuController session user has medical role")
// one level, no tree nesting
home = new DefaultTreeNode(new DocumentReference("Home", "/jsf/home.xhtml", PhrsConstants.TYPE_ITEM_NODE_HEADER_LINK, codedLabel, root), root)//TYPE_ITEM_NODE_HOME
//consultation reports
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public String findUserPixPid() {
}
return null;
}

private List importSelectedTypes(Set<String> importTypes,boolean saveImports){
List transformedMsgs = new ArrayList();

Expand All @@ -102,6 +103,7 @@ private List importSelectedTypes(Set<String> importTypes,boolean saveImports){
getOwnerUri(),
phrClass,
saveImports);

if(temp!=null && !temp.isEmpty()){
transformedMsgs.addAll(temp);
}
Expand All @@ -127,7 +129,9 @@ private void initModelMain() {
if (count > 0) {
//ok
LOGGER.debug("transformedMsgs. OK found INTEROP MEDS found count=" + count);
modelMain = toolTransformer.tranformResource(transformedMsgs);


modelMain = toolTransformer.tranformResource(transformedMsgs,true);
} else {

LOGGER.debug("transformedMsgs. No interop meds found, create test data");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import at.srfg.kmt.ehealth.phrs.support.test.CoreTestData
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import at.srfg.kmt.ehealth.phrs.model.baseform.MedicationTreatment
import at.srfg.kmt.ehealth.phrs.Constants
import at.srfg.kmt.ehealth.phrs.model.baseform.ObsVitalsBodyWeight

/**
*
Expand Down Expand Up @@ -614,7 +616,13 @@ public class CommonDao {
return map;

}

/**
* Determines if medication already exists, especially for imported data from EHR
* @param ownerUri
* @param medName
* @param productCode
* @return
*/
public boolean hasMedication(String ownerUri, String medName, String productCode) {

//not blank or null
Expand All @@ -633,6 +641,34 @@ public class CommonDao {
}
return false;
}
/**
* Determines if Vital sign already imported for this effective time
*
* @param ownerUri
* @param hl7Code
* @param effectiveTime
* @return
*/
public boolean hasVitalSignImported(String ownerUri,String hl7Code,Date effectiveTime){
boolean flag=false;

if( ownerUri && hl7Code && effectiveTime){

if( hl7Code.equals(Constants.ICARDEA_INSTANCE_BODY_WEIGHT)){
try{
Map query = ['beginDate': effectiveTime]

def obj= getResourceByExampleToSingle(ObsVitalsBodyWeight.class,query,false,ownerUri)
//TODO can check if origin is EHR.... however effective time is very specific to time!
if(obj != null) return true;
} catch(Exception e) {
LOGGER.error("check hasVitalSignImported ",e)
}
}

}
return flag;
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class ReportToolTransformer {
private ReportTool reportTool;
Expand All @@ -23,30 +24,80 @@ public ReportToolTransformer() {
* @return
*/
public List<MonitorPhrItem> tranformResource(List phrResources) {
return tranformResource(phrResources,false);
}

public List<MonitorPhrItem> tranformResource(List phrResources, boolean filterOnTitle) {
List<MonitorPhrItem> list = new ArrayList<MonitorPhrItem>();

if (phrResources != null && !phrResources.isEmpty()) {
if (phrResources != null && ! phrResources.isEmpty()) {

for (Object obj : phrResources) {

MonitorPhrItem item = null;
if (obj instanceof MedicationTreatment) {
item = toMonitorPhrItem((MedicationTreatment) obj);

} else if(obj instanceof ObsRecord){
item= toMonitorPhrItem((ObsRecord) obj);

}

if (item != null){
if(filterOnTitle){
if( ! hasDuplicateTitle(list,item)) {
list.add(item);
}
} else {
list.add(item);
}
}
if (item != null) list.add(item);

}


}
// MonitorPhrItem item= new MonitorPhrItem();


return list;
}

/**
* Show only unique titles
* @param list
* @param monitorPhrItem
* @return
*/
public boolean hasDuplicateTitle( List<MonitorPhrItem> list,MonitorPhrItem monitorPhrItem){
if(list != null && monitorPhrItem != null){
String theLabel = monitorPhrItem.getLabel();
//Check label otherwise, show just one type, usually Vital signs
if(theLabel != null && ! theLabel.isEmpty()){
//
} else {
theLabel = monitorPhrItem.getDescriptionLabelCode();
}

if(theLabel != null){
for(MonitorPhrItem item:list){
String label = item.getLabel();
if(label != null && ! label.isEmpty()){
//
} else {
label = item.getDescriptionLabelCode();
}
if(theLabel.equals(label)) {
return true;
}
}
}else {

}
}

return false;

}

/**
* Medication transformation
*
Expand Down Expand Up @@ -119,4 +170,30 @@ public MonitorPhrItem toMonitorPhrItem(ObsRecord resource) {

return item;
}
// public String makeDescriptiveLabel(ObsRecord resource){
// String label=resource.getLabel();
//
// if(resource !=null){
// if(label != null && !label.isEmpty()){
// //
// } else {
//
// if(resource.getAttrs()!=null){
// Map<String,String> attrs= resource.getAttrs();
// StringBuffer sb= new StringBuffer();
// for(String prop:attrs.keySet()){
// if(prop!=null){
// String val= attrs.get(prop);
// if(sb.length() > 0){
// sb.append("/");
// }
// if(val != null) sb.append(val);
//
// }
//
// }
// }
// }
// return label;
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,8 @@ public List importNewMessages(String ownerUri, String phrsClass, boolean importM
//to determine a finer degreee of relationship. We are uncertain if the dates alone will help to group records imported.

String transactionId = UUID.randomUUID().toString();
//keep track of what


for (DynaBean dynaBean : results) {
String messageUri = null;
Expand Down Expand Up @@ -809,6 +811,7 @@ public Object transformInteropMessage(String phrOwnerUri, String phrsClass, Dyna
LOGGER.debug("Tries to transform this [{}] Dynamic Bean in to a HL7 V3 CD instance.", toString);
codeUri= startBean.getDynaClass().getName();
LOGGER.debug("codeUri = ", codeUri);

/*
//final String codePrefLabel = (String) DynaUtil.getStringProperty.get(dynabean,Constants.SKOS_PREFLABEL);
Expand Down Expand Up @@ -867,6 +870,7 @@ public static Double toDouble(String value, Double defaultValue) {
* @param transactionId
* @return
*/

public ObsRecord transformInteropMessageToObsRecord(
String phrOwnerUri,
String phrsClass,
Expand All @@ -877,11 +881,31 @@ public ObsRecord transformInteropMessageToObsRecord(

ObsRecord resource = null;
LOGGER.debug("transformInteropMessageToObsRecord code found code="+code);
String effectiveDateStr =null;
Date effectiveDate=null;
Date queryDate=null;

//need to check for duplicates from EHR and local phr. Vital sign (type) for user (phrOwnerUri) on effectiveTime
try {
effectiveDateStr = DynaUtil.getStringProperty(dynabean, Constants.EFFECTIVE_TIME);// Constants.HL7V3_DATE_START);
queryDate =transformDateFromMessage(effectiveDateStr, null);

boolean hasVitalSign= getCommonDao().hasVitalSignImported(phrOwnerUri, code, queryDate);
if(hasVitalSign){
//ignore this vital sign
return null;
}

} catch (Exception e) {
LOGGER.error("error extracting effectiveTime");
}

if (code.equals(Constants.ICARDEA_INSTANCE_BODY_WEIGHT)
//|| code.equals(Constants.ICARDEA_INSTANCE_BODY_HEIGHT)
//|| code.equals(Constants.ICARDEA_INSTANCE_SYSTOLIC_BLOOD_PRESSURE)
//|| code.equals(Constants.ICARDEA_INSTANCE_DIASTOLIC_BLOOD_PRERSSURE)
) {

LOGGER.debug("transformInteropMessageToObsRecord create object code="+code);
resource = new ObsRecord();
resource.setCode(code);
Expand All @@ -895,9 +919,9 @@ public ObsRecord transformInteropMessageToObsRecord(
String units = DynaUtil.getStringProperty(dynabean, Constants.HL7V3_UNIT);
resource.setUnits(units);

String effectiveDateStr = DynaUtil.getStringProperty(dynabean, Constants.EFFECTIVE_TIME);// Constants.HL7V3_DATE_START);
Date effectiveDate = transformDateFromMessage(effectiveDateStr, new Date()); //HealthyUtils.formatDate( dateBegin, (String)null, DATE_PATTERN_INTEROP_DATE_TIME)

//String effectiveDateStr = DynaUtil.getStringProperty(dynabean, Constants.EFFECTIVE_TIME);// Constants.HL7V3_DATE_START);
//Date effectiveDate = transformDateFromMessage(effectiveDateStr, new Date()); //HealthyUtils.formatDate( dateBegin, (String)null, DATE_PATTERN_INTEROP_DATE_TIME)
effectiveDate = transformDateFromMessage(effectiveDateStr, new Date());
resource.setBeginDate(effectiveDate);
resource.setEndDate(effectiveDate);

Expand Down Expand Up @@ -1145,19 +1169,23 @@ public MedicationTreatment transformInteropMedicationMessage(String phrOwnerUri,
//dates. always need a start date
String dateBegin = DynaUtil.getStringProperty(dynabean, Constants.HL7V3_DATE_START);
//set new date if not found

Date beginDate = transformDateFromMessage(dateBegin, new Date()); //HealthyUtils.formatDate( dateBegin, (String)null, DATE_PATTERN_INTEROP_DATE_TIME)

String dateEnd = DynaUtil.getStringProperty(dynabean, Constants.HL7V3_DATE_END, null);
Date endDate = transformDateFromMessage(dateEnd, (Date) null); //HealthyUtils.formatDate( dateEnd, (String)null, DATE_PATTERN_INTEROP_DATE_TIME)//transformDate(dateEnd)

med.setBeginDate(beginDate);
med.setEndDate(endDate);
LOGGER.debug("Dates: dateBegin Interop: "+dateBegin+ " local beginDate "+beginDate+" dateEnd Interop "+dateEnd+" local endDate "+endDate
+" med Begin: "+med.getBeginDate()+" med End: "+med.getEndDate());


med.setCreateDate(new Date());
med.setModifyDate(med.getCreateDate());
med.setType(MedicationTreatment.class.toString());

med.setReasonCode("https://www.icardea.at/phrs/instances/NoSpecialTreatment");
theObject = med;

if (med != null) {
Expand Down Expand Up @@ -1346,7 +1374,7 @@ public static Date transformDateFromMessage(String dateMessage, Date defaultDate
//throws nullexception on blank or null
theDate = DateUtil.getFormatedDate(dateMessage);
}
if (theDate != null) {
if (theDate == null) {
theDate = defaultDate != null ? defaultDate : new Date();
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public static PhrFederatedUser managePhrUserSessionByOpenIdUserLoginScenario(
phrUser.getOwnerUri());

String role = model.getRole() != null ? model.getRole() : phrUser.getRole();
LOGGER.debug("managePhrUserSessionByOpenIdUserLoginScenario setting session role "+role);
if (role != null && !role.isEmpty()) {
sess.setAttribute(PhrsConstants.SESSION_USER_AUTHORITY_ROLE,
role);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public boolean permitAccessByPID(String targetUser,
if (consentMgrService != null) {
if (isConsentMgrRole(subjectRole)) {

consentMgrService.isPermittedByPID(targetUser, subjectRole,
result = consentMgrService.isPermittedByPID(targetUser, subjectRole,
resourceCode, action);

} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,32 +173,34 @@ public boolean isPermittedByPID(String targetUserPID, String subjectCode,
+ " action=" + action );
try {
//This is the local setting
if (isAccessibleByThisRole(subjectCode)) {

flag = true;

} else if (isConsentMgrRole(subjectCode)) {
// if (isAccessibleByThisRole(subjectCode)) {
//
// flag = true;
//
// } else
if (isConsentMgrRole(subjectCode)) {
LOGGER.debug("isPermitted callGetDecision setup ssl");
//FIXXME
sslSetup();


LOGGER.debug("isPermitted callGetDecision ");
String result = callGetDecision(targetUserPID, ISSUERNAME,
subjectCode, resourceCode, action);
// try on protocol ID
flag = isPermitted(result);

LOGGER.debug("callGetDecision result " + " targetUserPID " + targetUserPID
LOGGER.debug("isPermitted callGetDecision result " + " targetUserPID " + targetUserPID
+ " subjectCode=" + subjectCode
+ " resourceCode=" + resourceCode
+ "action=" + action + " decision allow?=" + flag);


} else {
LOGGER.debug("isPermitted input param error, invalid consentMgr role code: "+subjectCode);
}
} catch (Exception e) {



e.printStackTrace();
LOGGER.error("isPermitted Error with ssl or callGetDecision",e);
}
this.sendAuditMessage(targetUserPID, subjectCode, resourceCode, action);

Expand Down Expand Up @@ -246,7 +248,6 @@ public static String getServiceEndpoint() {
}



public String callGetDecision(String patientId, String issuerName,
String subjectCode, String resourceCode, String action) {

Expand Down
Loading

0 comments on commit 5af4727

Please sign in to comment.