Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 15d75e66 authored by AAZIBOU EL GERRAB Nabila's avatar AAZIBOU EL GERRAB Nabila
Browse files

add script for xehealth project

parent db11684e
No related branches found
No related tags found
2 merge requests!52release 3.2.0,!51release 3.2.0
#!/bin/bash #!/bin/bash
#################################### ####################################
# SEQUOIA Generation & Adaptation Script # Xehealth Generation Script
# Created by Achraf Achkari - 09 Nov 2021 # Created by Nabila Aazibou - 03 Aout 2023
# Last revision - 09 Nov 2021 # Last revision - 03 Aout 2023
# Version 1.0.0 # Version 3.5.1
##################################### #####################################
#Colors definitions for terminal #Colors definitions for terminal
RED='\033[0;31m' RED='\033[0;31m'
GREEN='\033[0;32m' GREEN='\033[0;32m'
ORANGE='\033[0;33m' ORANGE='\033[0;33m'
NC='\033[0m' NC='\033[0m'
#SEQUOIA Validators
MU3="HL7 - C-CDA R2.1 - Meaningful Use Stage 3" ## FUNCTIONS DEFINITION
USCDI="HL7 - C-CDA R2.1 - USCDI"
CCDA_R_1="HL7 - C-CDA R1.1" function readBBR {
read -r bbrPath
isAbsPath=`echo "${bbrPath}" | grep ^/.* | wc -l`
if [ $isAbsPath -eq 0 ]; then
echo -e "${RED}[ ${bbrPath} ] is not an absolute path${NC}"
exit 1
fi
if [ ! -f $bbrPath ]; then
echo -e "${RED}[ ${bbrPath} ] is not a file or doesn't exist !${NC}"
exit 1
fi
}
#UNCOMENT THIS TO OVERRIDE DEFAULT JAVA VERSION USED BY SYSTEM #UNCOMENT THIS TO OVERRIDE DEFAULT JAVA VERSION USED BY SYSTEM
...@@ -37,20 +50,22 @@ if [ -z "$javaVersion" ]; then ...@@ -37,20 +50,22 @@ if [ -z "$javaVersion" ]; then
exit 1 exit 1
fi fi
## JAR DETECTION
# Try to get the jar of GOC automatically # Try to get the jar of GOC automatically
jarPath=$(ls -l | grep -oh -e "[^ ]*-jar-with-dependencies\.jar") jarPath=`ls -l | grep -oh -e "[^ ]*-jar-with-dependencies\.jar"`
if [ -z "$jarPath" ]; then if [ -z $jarPath ]; then
echo -e "${ORANGE}Could not detect the JAR of GOC, please provide the path manually${NC}" echo -e "${ORANGE}Could not detect the JAR of GOC, please provide the path manually${NC}"
read -r jarPath read -r jarPath
else else
absJarPath=$(realpath "$jarPath") absJarPath=`realpath $jarPath`
echo -e "${GREEN}A GOC JAR has been detected at: (${jarPath}) want you to use it?${NC}" echo -e "${GREEN}A GOC JAR has been detected at: (${jarPath}) want you to use it?${NC}"
printf "hit enter for yes, enter an other path to change it: " printf "hit enter for yes, provide an other path to change it: "
read -r newJarPath read -r newJarPath
if [ ! -z "$newJarPath" ]; then if [ ! -z $newJarPath ]; then
isAbsPath=$(echo "${newJarPath}" | grep -c "^/.*") isAbsPath=`echo "${newJarPath}" | grep ^/.* | wc -l`
if [ "$isAbsPath" -eq 0 ]; then if [ $isAbsPath -eq 0 ]; then
echo -e "${RED}[ ${newJarPath} ] is not an absolute path${NC}" echo -e "${RED}[ ${newJarPath} ] is not an absolute path${NC}"
exit 1 exit 1
fi fi
...@@ -58,10 +73,10 @@ else ...@@ -58,10 +73,10 @@ else
fi fi
fi fi
## MAVEN VERIFICATION
#Try to use maven wrapper #Try to use maven wrapper
if [ -f ./classes/maven-wrapper/mvnw ];then if [ -f ./classes/maven-wrapper/mvnw ];then
# base_dir=$(realpath ./classes/maven-wrapper)
mavenPath=$(realpath "./classes/maven-wrapper/mvnw") mavenPath=$(realpath "./classes/maven-wrapper/mvnw")
testMaven=$($mavenPath -v) testMaven=$($mavenPath -v)
if [ ! -z "$testMaven" ]; then if [ ! -z "$testMaven" ]; then
...@@ -121,109 +136,65 @@ fi; ...@@ -121,109 +136,65 @@ fi;
echo -e "${GREEN}Using maven at: ${mavenPath}${NC}" echo -e "${GREEN}Using maven at: ${mavenPath}${NC}"
## BBR READING
printf "Please enter a path to your BBR (Absolute Path) : " printf "Please enter a path to your BBR (Absolute Path) : "
read -r bbrPath readBBR
isAbsPath=$(echo "${bbrPath}" | grep ^/.* | wc -l) validator="xehealth"
if [ "$isAbsPath" -eq 0 ]; then
echo -e "${RED}[ ${bbrPath} ] is not an absolute path${NC}"
exit 1
fi
if [ ! -f "$bbrPath" ]; then
echo -e "${RED}[ ${bbrPath} ] is not a file or doesn't exist !${NC}"
exit 1
fi
printf "Please choose the kind of validator you want to generate: \n"
printf "\t 1- $MU3\n"
printf "\t 2- $USCDI\n"
printf "\t 3- $CCDA_R_1\n"
printf "your choice: "
read -r choice
if [ "$choice" -gt 3 -o "$choice" -lt 1 ]; then
echo "${RED}Wrong choice, please repeat and choose between 1 and 3${NC}"
exit 1
fi
versionLabel=""
case $choice in
1)
echo -e "${GREEN}generating ${MU3// /}${NC}"
validator=${MU3// /}
versionLabel="2.1"
;;
esac
printf "Please enter workspace path (where you want to generate the validator): " printf "Please enter workspace path (where you want to generate the validator): "
read -r workspaceDir read -r workspaceDir
if [ ! -d "$workspaceDir" ]; then if [ ! -d $workspaceDir ]; then
echo "${RED}The provided workspace is not a valid directory" echo "${RED}The provided workspace is not a valid directory"
exit 1 exit 0
fi fi
isAbsPath=$(echo "${workspaceDir}" | grep -c "^/.*") isAbsPath=`echo "${workspaceDir}" | grep ^/.* | wc -l`
if [ "$isAbsPath" -eq 0 ]; then if [ $isAbsPath -eq 0 ]; then
echo -e "${RED}[ ${workspaceDir} ] is not an absolute path" echo -e "${RED}[ ${workspaceDir} ] is not an absolute path"
exit 1 exit 0
fi fi
_currDate=$(date +%Y-%m-%d-%H-%M-%S) _currDate=`date +%Y-%m-%d-%H-%M-%S`
printf "Please enter the folder name of your validator: (output-${validator}-${_currDate})?: " printf "Please enter the folder name of your validator: (output-${validator}-${_currDate})?"
read -r folderName read -r folderName
if [ -z "$folderName" ]; then if [ -z $folderName ]; then
folderName="output-${validator}-${_currDate}" folderName="output-${validator}-${_currDate}"
fi; fi;
echo -e "${GREEN}your validator will be generated in: ${workspaceDir}/${folderName}${NC}" echo -e "${GREEN}your validator will be generated in: ${workspaceDir}/${folderName}${NC}"
######## GENERATION COMMAND ######## ######## GENERATION COMMAND ########
$JAVA_HOME/bin/java -jar "$absJarPath" -bbr "$bbrPath" -out "${workspaceDir}/${folderName}" -mvn "$mavenPath" -serviceName "$validator" -versionLabel "$versionLabel" -ignoreTemplateIdRequirements -ignoreCdaBasicRequirements $JAVA_HOME/bin/java -jar $jarPath -bbr $bbrPath -out "${workspaceDir}/${folderName}" -mvn $mavenPath -serviceName $validator -HL7TEMP_CDACONFFOLDERNAME cdaxehealth -ignoreCdaBasicRequirements
#################################### ####################################
if [ $? != 0 ]; then #Replacing XSD
echo "${RED}Generation Failed${NC}" pathToResources=""
exit 1 if [ -d ./classes/xehealth-resources/xsd ]; then
fi pathToResources=$(realpath "./classes/xehealth-resources/xsd")
echo -e "${GREEN}XSD Resources found at $pathToResources${NC}"
echo -e "${GREEN}Validator generated successfully${NC}" else
echo -e "${ORANGE}Could not find resources, please provide the path to the XSD folder manually${NC}"
echo -e "${NC}Start SVS Adaptations..." echo -e "${ORANGE}be careful, the directory should contain correct XSD files for the validator to run. This is not checked by the script!${NC}"
read -r pathToResources
if [ ! -f ./xehealthGeneration.sh ]; then if [ ! -d $pathToResources ]; then
echo -e "${RED}Could not find the xehealthGeneration script, please recompile GOC and rerun this script" echo -e "${RED} invalid path to directory"
exit 1; exit 1;
fi;
# adapt only if version is higher than 1.1
if [ "$versionLabel" != "1.1" ]; then
pathToResources=''
if [ ! -d ./classes/xehealth-resources.xsd ]; then
echo -e "${RED}Resources for adaptations not found, please provide a path manually"
read -r $pathToResources
else
pathToResources=$(realpath ./classes/xehealth-resources.xsd)
fi
if [ ! -x ./xehealthGeneration.sh ]; then
chmod +x xehealthGeneration.sh
fi; fi;
fi;
env JAVA_HOME=$JAVA_HOME M2_BIN=$mavenPath ./xehealthGeneration.sh "$workspaceDir/$folderName" $pathToResources pathToXSD=$(realpath $(find "${workspaceDir}/${folderName}" -type d -name "xsd" | grep -e ".*-app/.*"))
echo "$pathToXSD"
XSDDirname=$(dirname "$pathToXSD")
echo "$XSDDirname"
rm -r "$pathToXSD"
cp -r "$pathToResources" "$XSDDirname"
if [ $? != 0 ]; then
echo "${RED}Adaptations failed"
exit 1
fi
fi;
#Zip validator #Zip validator
#move to bin path #move to app path
appassemblerPath=$(realpath $(find $workspaceDir/$folderName -type d -wholename */appassembler)) appPath=$(realpath $(find $workspaceDir/$folderName -type d -wholename *validator-app))
cd $appassemblerPath cd $appPath
#Create bbr folder #Create bbr folder
mkdir "bbr" || echo "File already exist, that won't affect next steps" mkdir "bbr" || echo "File already exist, that won't affect next steps"
...@@ -231,7 +202,7 @@ cp $bbrPath bbr ...@@ -231,7 +202,7 @@ cp $bbrPath bbr
#create documentation folder #create documentation folder
documentationPath=$(realpath $(find $workspaceDir/$folderName -type d -wholename "*/documentation")) documentationPath=$(realpath $(find $workspaceDir/$folderName -type d -wholename "*/documentation"))
cp -r $documentationPath $appassemblerPath cp -r $documentationPath $appPath
#Zipping #Zipping
zip -r "validator-$_currDate.zip" bbr/ documentation/ repo/ bin/ zip -r "validator-$_currDate.zip" bbr/ documentation/ repo/ bin/
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment