Pārlūkot izejas kodu

new:1.chis module,2. GetAgeFromIdCard

QiuSW 1 gadu atpakaļ
vecāks
revīzija
0d979228bc
5 mainītis faili ar 46 papildinājumiem un 4 dzēšanām
  1. 3 0
      chis/chis'.go
  2. 39 0
      chis/record.go
  3. 1 0
      go.mod
  4. 2 0
      go.sum
  5. 1 4
      win/shortcut.go

+ 3 - 0
chis/chis'.go

@@ -0,0 +1,3 @@
+package chis
+
+//中国医院信息系统(China Hospital Information System)

+ 39 - 0
chis/record.go

@@ -0,0 +1,39 @@
+package chis
+
+import (
+	"fmt"
+	"time"
+
+	"gbase/glog"
+)
+
+func GetAgeFromIdCard(idCard string) (age int) {
+	age = 0
+	if len(idCard) != 18 {
+		return age
+	}
+	birthdayStr := idCard[6:14]
+
+	// 解析出生日期
+	birthday, err := time.Parse("20060102", birthdayStr)
+	if err != nil {
+		glog.XWarning(fmt.Sprint("time.Parse error : %v\n", err))
+		return
+	}
+	// 计算年龄,几年
+
+	today := time.Now()
+	age = today.Year() - birthday.Year()
+
+	firstDayOfNextYear := time.Date(today.Year()+1, 1, 1, 0, 0, 0, 0, time.UTC)
+	lastDayOfYear := firstDayOfNextYear.AddDate(0, 0, -1)
+	if lastDayOfYear.Month() > birthday.Month() {
+		age += 1
+	} else if lastDayOfYear.Month() == birthday.Month() && lastDayOfYear.Day() > birthday.Day() {
+		age += 1
+	} else {
+		age += 0
+	}
+
+	return age
+}

+ 1 - 0
go.mod

@@ -24,6 +24,7 @@ require (
 	github.com/godbus/dbus/v5 v5.1.0 // indirect
 	github.com/gonuts/binary v0.2.0 // indirect
 	github.com/google/uuid v1.5.0 // indirect
+	github.com/jxeng/shortcut v1.0.2 // indirect
 	github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6 // indirect
 	github.com/moul/http2curl v1.0.0 // indirect
 	github.com/patrickmn/go-cache v2.1.0+incompatible // indirect

+ 2 - 0
go.sum

@@ -68,6 +68,8 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
 github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
 github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
 github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
+github.com/jxeng/shortcut v1.0.2 h1:nYVmn22NjzfJewPX9uC8zwHoc4gZotpfX+7HgLRDaKQ=
+github.com/jxeng/shortcut v1.0.2/go.mod h1:3J/BiW+ER+vTzzg1anfOoYyMKXQH3R5xzlnjaaGH7qs=
 github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6 h1:IsMZxCuZqKuao2vNdfD82fjjgPLfyHLpR41Z88viRWs=
 github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6/go.mod h1:3VeWNIJaW+O5xpRQbPp0Ybqu1vJd/pm7s2F473HRrkw=
 github.com/koltyakov/gosip v0.0.0-20240227190045-46a1ea645a98 h1:GlFv1fFG3H3NsCPcAJrV2t4FPhcIy0AezygW+qky+as=

+ 1 - 4
win/shortcut.go

@@ -10,9 +10,6 @@ import (
 )
 
 func CreateShortCut(softPath, shortcutName string) (err error) {
-	_, name1 := filepath.Split(softPath)
-	ext := filepath.Ext(name1)
-	filename := name1[:len(name1)-len(ext)]
 	startUpFlag := false
 	userHomeDir, _ := os.UserConfigDir()
 	startUpList := []string{
@@ -25,7 +22,7 @@ func CreateShortCut(softPath, shortcutName string) (err error) {
 			if handle.IsDir() {
 				continue
 			}
-			if strings.Contains(handle.Name(), filename) == true && strings.Contains(handle.Name(), ".lnk") == true {
+			if strings.Contains(handle.Name(), shortcutName) == true && strings.Contains(handle.Name(), ".lnk") == true {
 				startUpFlag = true
 			}
 		}